diff options
author | Jeff Ames | 2008-11-25 16:00:55 +0000 |
---|---|---|
committer | Jeff Ames | 2008-11-25 16:00:55 +0000 |
commit | 518a8b9f2ac09a5060e2e59c913dfbe7faf397ef (patch) | |
tree | 8b3e39fbd54452e031873d31ff099e7db064cdee /OpenSim/Region/Environment | |
parent | * minor: eliminate mono compiler warnings (diff) | |
download | opensim-SC_OLD-518a8b9f2ac09a5060e2e59c913dfbe7faf397ef.zip opensim-SC_OLD-518a8b9f2ac09a5060e2e59c913dfbe7faf397ef.tar.gz opensim-SC_OLD-518a8b9f2ac09a5060e2e59c913dfbe7faf397ef.tar.bz2 opensim-SC_OLD-518a8b9f2ac09a5060e2e59c913dfbe7faf397ef.tar.xz |
Update svn properties.
Diffstat (limited to 'OpenSim/Region/Environment')
8 files changed, 1744 insertions, 1744 deletions
diff --git a/OpenSim/Region/Environment/Modules/Hypergrid/HGStandaloneAssetService.cs b/OpenSim/Region/Environment/Modules/Hypergrid/HGStandaloneAssetService.cs index 192904c..d090052 100644 --- a/OpenSim/Region/Environment/Modules/Hypergrid/HGStandaloneAssetService.cs +++ b/OpenSim/Region/Environment/Modules/Hypergrid/HGStandaloneAssetService.cs | |||
@@ -1,200 +1,200 @@ | |||
1 | /** | 1 | /** |
2 | * Copyright (c) 2008, Contributors. All rights reserved. | 2 | * Copyright (c) 2008, Contributors. All rights reserved. |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without modification, | 5 | * Redistribution and use in source and binary forms, with or without modification, |
6 | * are permitted provided that the following conditions are met: | 6 | * are permitted provided that the following conditions are met: |
7 | * | 7 | * |
8 | * * Redistributions of source code must retain the above copyright notice, | 8 | * * Redistributions of source code must retain the above copyright notice, |
9 | * this list of conditions and the following disclaimer. | 9 | * this list of conditions and the following disclaimer. |
10 | * * Redistributions in binary form must reproduce the above copyright notice, | 10 | * * Redistributions in binary form must reproduce the above copyright notice, |
11 | * this list of conditions and the following disclaimer in the documentation | 11 | * this list of conditions and the following disclaimer in the documentation |
12 | * and/or other materials provided with the distribution. | 12 | * and/or other materials provided with the distribution. |
13 | * * Neither the name of the Organizations nor the names of Individual | 13 | * * Neither the name of the Organizations nor the names of Individual |
14 | * Contributors may be used to endorse or promote products derived from | 14 | * Contributors may be used to endorse or promote products derived from |
15 | * this software without specific prior written permission. | 15 | * this software without specific prior written permission. |
16 | * | 16 | * |
17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL | 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL |
20 | * THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 20 | * THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
21 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE | 21 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE |
22 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED | 22 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED |
23 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | 23 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
24 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | 24 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED |
25 | * OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | 28 | ||
29 | using System; | 29 | using System; |
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using System.Net; | 31 | using System.Net; |
32 | using System.Reflection; | 32 | using System.Reflection; |
33 | 33 | ||
34 | using log4net; | 34 | using log4net; |
35 | using Nini.Config; | 35 | using Nini.Config; |
36 | 36 | ||
37 | using OpenMetaverse; | 37 | using OpenMetaverse; |
38 | 38 | ||
39 | using OpenSim.Framework; | 39 | using OpenSim.Framework; |
40 | using OpenSim.Framework.Communications; | 40 | using OpenSim.Framework.Communications; |
41 | using OpenSim.Framework.Communications.Cache; | 41 | using OpenSim.Framework.Communications.Cache; |
42 | using OpenSim.Framework.Servers; | 42 | using OpenSim.Framework.Servers; |
43 | using OpenSim.Region.Environment.Interfaces; | 43 | using OpenSim.Region.Environment.Interfaces; |
44 | using OpenSim.Region.Environment.Scenes; | 44 | using OpenSim.Region.Environment.Scenes; |
45 | using OpenSim.Grid.AssetServer; | 45 | using OpenSim.Grid.AssetServer; |
46 | 46 | ||
47 | namespace OpenSim.Region.Environment.Modules.Hypergrid | 47 | namespace OpenSim.Region.Environment.Modules.Hypergrid |
48 | { | 48 | { |
49 | public class HGStandaloneAssetService : IRegionModule | 49 | public class HGStandaloneAssetService : IRegionModule |
50 | { | 50 | { |
51 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 51 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
52 | private static bool initialized = false; | 52 | private static bool initialized = false; |
53 | private static bool enabled = false; | 53 | private static bool enabled = false; |
54 | 54 | ||
55 | Scene m_scene; | 55 | Scene m_scene; |
56 | //AssetService m_assetService; | 56 | //AssetService m_assetService; |
57 | 57 | ||
58 | #region IRegionModule interface | 58 | #region IRegionModule interface |
59 | 59 | ||
60 | public void Initialise(Scene scene, IConfigSource config) | 60 | public void Initialise(Scene scene, IConfigSource config) |
61 | { | 61 | { |
62 | if (!initialized) | 62 | if (!initialized) |
63 | { | 63 | { |
64 | initialized = true; | 64 | initialized = true; |
65 | m_scene = scene; | 65 | m_scene = scene; |
66 | 66 | ||
67 | // This module is only on for standalones in hypergrid mode | 67 | // This module is only on for standalones in hypergrid mode |
68 | enabled = !config.Configs["Startup"].GetBoolean("gridmode", true) && config.Configs["Startup"].GetBoolean("hypergrid", false); | 68 | enabled = !config.Configs["Startup"].GetBoolean("gridmode", true) && config.Configs["Startup"].GetBoolean("hypergrid", false); |
69 | } | 69 | } |
70 | } | 70 | } |
71 | 71 | ||
72 | public void PostInitialise() | 72 | public void PostInitialise() |
73 | { | 73 | { |
74 | if (enabled) | 74 | if (enabled) |
75 | { | 75 | { |
76 | m_log.Info("[HGStandaloneAssetService]: Starting..."); | 76 | m_log.Info("[HGStandaloneAssetService]: Starting..."); |
77 | 77 | ||
78 | //m_assetService = new AssetService(m_scene); | 78 | //m_assetService = new AssetService(m_scene); |
79 | new AssetService(m_scene); | 79 | new AssetService(m_scene); |
80 | } | 80 | } |
81 | } | 81 | } |
82 | 82 | ||
83 | public void Close() | 83 | public void Close() |
84 | { | 84 | { |
85 | } | 85 | } |
86 | 86 | ||
87 | public string Name | 87 | public string Name |
88 | { | 88 | { |
89 | get { return "HGStandaloneAssetService"; } | 89 | get { return "HGStandaloneAssetService"; } |
90 | } | 90 | } |
91 | 91 | ||
92 | public bool IsSharedModule | 92 | public bool IsSharedModule |
93 | { | 93 | { |
94 | get { return true; } | 94 | get { return true; } |
95 | } | 95 | } |
96 | 96 | ||
97 | #endregion | 97 | #endregion |
98 | 98 | ||
99 | } | 99 | } |
100 | 100 | ||
101 | public class AssetService | 101 | public class AssetService |
102 | { | 102 | { |
103 | private IUserService m_userService; | 103 | private IUserService m_userService; |
104 | private bool m_doLookup = false; | 104 | private bool m_doLookup = false; |
105 | 105 | ||
106 | public bool DoLookup | 106 | public bool DoLookup |
107 | { | 107 | { |
108 | get { return m_doLookup; } | 108 | get { return m_doLookup; } |
109 | set { m_doLookup = value; } | 109 | set { m_doLookup = value; } |
110 | } | 110 | } |
111 | private static readonly ILog m_log | 111 | private static readonly ILog m_log |
112 | = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 112 | = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
113 | 113 | ||
114 | public AssetService(Scene m_scene) | 114 | public AssetService(Scene m_scene) |
115 | { | 115 | { |
116 | AddHttpHandlers(m_scene); | 116 | AddHttpHandlers(m_scene); |
117 | m_userService = m_scene.CommsManager.UserService; | 117 | m_userService = m_scene.CommsManager.UserService; |
118 | } | 118 | } |
119 | 119 | ||
120 | protected void AddHttpHandlers(Scene m_scene) | 120 | protected void AddHttpHandlers(Scene m_scene) |
121 | { | 121 | { |
122 | IAssetProviderPlugin m_assetProvider = ((AssetServerBase)m_scene.AssetCache.AssetServer).AssetProviderPlugin; | 122 | IAssetProviderPlugin m_assetProvider = ((AssetServerBase)m_scene.AssetCache.AssetServer).AssetProviderPlugin; |
123 | 123 | ||
124 | m_scene.AddStreamHandler(new GetAssetStreamHandler(m_assetProvider)); | 124 | m_scene.AddStreamHandler(new GetAssetStreamHandler(m_assetProvider)); |
125 | m_scene.AddStreamHandler(new PostAssetStreamHandler(m_assetProvider)); | 125 | m_scene.AddStreamHandler(new PostAssetStreamHandler(m_assetProvider)); |
126 | 126 | ||
127 | } | 127 | } |
128 | 128 | ||
129 | 129 | ||
130 | ///// <summary> | 130 | ///// <summary> |
131 | ///// Check that the source of an inventory request is one that we trust. | 131 | ///// Check that the source of an inventory request is one that we trust. |
132 | ///// </summary> | 132 | ///// </summary> |
133 | ///// <param name="peer"></param> | 133 | ///// <param name="peer"></param> |
134 | ///// <returns></returns> | 134 | ///// <returns></returns> |
135 | //public bool CheckTrustSource(IPEndPoint peer) | 135 | //public bool CheckTrustSource(IPEndPoint peer) |
136 | //{ | 136 | //{ |
137 | // if (m_doLookup) | 137 | // if (m_doLookup) |
138 | // { | 138 | // { |
139 | // m_log.InfoFormat("[GRID AGENT INVENTORY]: Checking trusted source {0}", peer); | 139 | // m_log.InfoFormat("[GRID AGENT INVENTORY]: Checking trusted source {0}", peer); |
140 | // UriBuilder ub = new UriBuilder(m_userserver_url); | 140 | // UriBuilder ub = new UriBuilder(m_userserver_url); |
141 | // IPAddress[] uaddrs = Dns.GetHostAddresses(ub.Host); | 141 | // IPAddress[] uaddrs = Dns.GetHostAddresses(ub.Host); |
142 | // foreach (IPAddress uaddr in uaddrs) | 142 | // foreach (IPAddress uaddr in uaddrs) |
143 | // { | 143 | // { |
144 | // if (uaddr.Equals(peer.Address)) | 144 | // if (uaddr.Equals(peer.Address)) |
145 | // { | 145 | // { |
146 | // return true; | 146 | // return true; |
147 | // } | 147 | // } |
148 | // } | 148 | // } |
149 | 149 | ||
150 | // m_log.WarnFormat( | 150 | // m_log.WarnFormat( |
151 | // "[GRID AGENT INVENTORY]: Rejecting request since source {0} was not in the list of trusted sources", | 151 | // "[GRID AGENT INVENTORY]: Rejecting request since source {0} was not in the list of trusted sources", |
152 | // peer); | 152 | // peer); |
153 | 153 | ||
154 | // return false; | 154 | // return false; |
155 | // } | 155 | // } |
156 | // else | 156 | // else |
157 | // { | 157 | // { |
158 | // return true; | 158 | // return true; |
159 | // } | 159 | // } |
160 | //} | 160 | //} |
161 | 161 | ||
162 | /// <summary> | 162 | /// <summary> |
163 | /// Check that the source of an inventory request for a particular agent is a current session belonging to | 163 | /// Check that the source of an inventory request for a particular agent is a current session belonging to |
164 | /// that agent. | 164 | /// that agent. |
165 | /// </summary> | 165 | /// </summary> |
166 | /// <param name="session_id"></param> | 166 | /// <param name="session_id"></param> |
167 | /// <param name="avatar_id"></param> | 167 | /// <param name="avatar_id"></param> |
168 | /// <returns></returns> | 168 | /// <returns></returns> |
169 | public bool CheckAuthSession(string session_id, string avatar_id) | 169 | public bool CheckAuthSession(string session_id, string avatar_id) |
170 | { | 170 | { |
171 | if (m_doLookup) | 171 | if (m_doLookup) |
172 | { | 172 | { |
173 | m_log.InfoFormat("[HGStandaloneInvService]: checking authed session {0} {1}", session_id, avatar_id); | 173 | m_log.InfoFormat("[HGStandaloneInvService]: checking authed session {0} {1}", session_id, avatar_id); |
174 | UUID userID = UUID.Zero; | 174 | UUID userID = UUID.Zero; |
175 | UUID sessionID = UUID.Zero; | 175 | UUID sessionID = UUID.Zero; |
176 | UUID.TryParse(avatar_id, out userID); | 176 | UUID.TryParse(avatar_id, out userID); |
177 | UUID.TryParse(session_id, out sessionID); | 177 | UUID.TryParse(session_id, out sessionID); |
178 | if (userID.Equals(UUID.Zero) || sessionID.Equals(UUID.Zero)) | 178 | if (userID.Equals(UUID.Zero) || sessionID.Equals(UUID.Zero)) |
179 | { | 179 | { |
180 | m_log.Info("[HGStandaloneInvService]: Invalid user or session id " + avatar_id + "; " + session_id); | 180 | m_log.Info("[HGStandaloneInvService]: Invalid user or session id " + avatar_id + "; " + session_id); |
181 | return false; | 181 | return false; |
182 | } | 182 | } |
183 | UserProfileData userProfile = m_userService.GetUserProfile(userID); | 183 | UserProfileData userProfile = m_userService.GetUserProfile(userID); |
184 | if (userProfile != null && userProfile.CurrentAgent != null && | 184 | if (userProfile != null && userProfile.CurrentAgent != null && |
185 | userProfile.CurrentAgent.SessionID == sessionID) | 185 | userProfile.CurrentAgent.SessionID == sessionID) |
186 | { | 186 | { |
187 | m_log.Info("[HGStandaloneInvService]: user is logged in and session is valid. Authorizing access."); | 187 | m_log.Info("[HGStandaloneInvService]: user is logged in and session is valid. Authorizing access."); |
188 | return true; | 188 | return true; |
189 | } | 189 | } |
190 | 190 | ||
191 | m_log.Warn("[HGStandaloneInvService]: unknown user or session_id, request rejected"); | 191 | m_log.Warn("[HGStandaloneInvService]: unknown user or session_id, request rejected"); |
192 | return false; | 192 | return false; |
193 | } | 193 | } |
194 | else | 194 | else |
195 | { | 195 | { |
196 | return true; | 196 | return true; |
197 | } | 197 | } |
198 | } | 198 | } |
199 | } | 199 | } |
200 | } | 200 | } |
diff --git a/OpenSim/Region/Environment/Modules/Hypergrid/HGStandaloneInventoryService.cs b/OpenSim/Region/Environment/Modules/Hypergrid/HGStandaloneInventoryService.cs index 7eeece9..bfdbcfc 100644 --- a/OpenSim/Region/Environment/Modules/Hypergrid/HGStandaloneInventoryService.cs +++ b/OpenSim/Region/Environment/Modules/Hypergrid/HGStandaloneInventoryService.cs | |||
@@ -1,316 +1,316 @@ | |||
1 | /** | 1 | /** |
2 | * Copyright (c) 2008, Contributors. All rights reserved. | 2 | * Copyright (c) 2008, Contributors. All rights reserved. |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without modification, | 5 | * Redistribution and use in source and binary forms, with or without modification, |
6 | * are permitted provided that the following conditions are met: | 6 | * are permitted provided that the following conditions are met: |
7 | * | 7 | * |
8 | * * Redistributions of source code must retain the above copyright notice, | 8 | * * Redistributions of source code must retain the above copyright notice, |
9 | * this list of conditions and the following disclaimer. | 9 | * this list of conditions and the following disclaimer. |
10 | * * Redistributions in binary form must reproduce the above copyright notice, | 10 | * * Redistributions in binary form must reproduce the above copyright notice, |
11 | * this list of conditions and the following disclaimer in the documentation | 11 | * this list of conditions and the following disclaimer in the documentation |
12 | * and/or other materials provided with the distribution. | 12 | * and/or other materials provided with the distribution. |
13 | * * Neither the name of the Organizations nor the names of Individual | 13 | * * Neither the name of the Organizations nor the names of Individual |
14 | * Contributors may be used to endorse or promote products derived from | 14 | * Contributors may be used to endorse or promote products derived from |
15 | * this software without specific prior written permission. | 15 | * this software without specific prior written permission. |
16 | * | 16 | * |
17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL | 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL |
20 | * THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 20 | * THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
21 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE | 21 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE |
22 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED | 22 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED |
23 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | 23 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
24 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | 24 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED |
25 | * OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | 28 | ||
29 | using System; | 29 | using System; |
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using System.Net; | 31 | using System.Net; |
32 | using System.Reflection; | 32 | using System.Reflection; |
33 | 33 | ||
34 | using log4net; | 34 | using log4net; |
35 | using Nini.Config; | 35 | using Nini.Config; |
36 | 36 | ||
37 | using OpenMetaverse; | 37 | using OpenMetaverse; |
38 | 38 | ||
39 | using OpenSim.Framework; | 39 | using OpenSim.Framework; |
40 | using OpenSim.Framework.Communications; | 40 | using OpenSim.Framework.Communications; |
41 | using OpenSim.Framework.Communications.Cache; | 41 | using OpenSim.Framework.Communications.Cache; |
42 | using OpenSim.Framework.Servers; | 42 | using OpenSim.Framework.Servers; |
43 | using OpenSim.Region.Environment.Interfaces; | 43 | using OpenSim.Region.Environment.Interfaces; |
44 | using OpenSim.Region.Environment.Scenes; | 44 | using OpenSim.Region.Environment.Scenes; |
45 | 45 | ||
46 | namespace OpenSim.Region.Environment.Modules.Hypergrid | 46 | namespace OpenSim.Region.Environment.Modules.Hypergrid |
47 | { | 47 | { |
48 | public class HGStandaloneInventoryService : IRegionModule | 48 | public class HGStandaloneInventoryService : IRegionModule |
49 | { | 49 | { |
50 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 50 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
51 | private static bool initialized = false; | 51 | private static bool initialized = false; |
52 | private static bool enabled = false; | 52 | private static bool enabled = false; |
53 | 53 | ||
54 | Scene m_scene; | 54 | Scene m_scene; |
55 | //InventoryService m_inventoryService; | 55 | //InventoryService m_inventoryService; |
56 | 56 | ||
57 | #region IRegionModule interface | 57 | #region IRegionModule interface |
58 | 58 | ||
59 | public void Initialise(Scene scene, IConfigSource config) | 59 | public void Initialise(Scene scene, IConfigSource config) |
60 | { | 60 | { |
61 | if (!initialized) | 61 | if (!initialized) |
62 | { | 62 | { |
63 | initialized = true; | 63 | initialized = true; |
64 | m_scene = scene; | 64 | m_scene = scene; |
65 | 65 | ||
66 | // This module is only on for standalones | 66 | // This module is only on for standalones |
67 | enabled = !config.Configs["Startup"].GetBoolean("gridmode", true) && config.Configs["Startup"].GetBoolean("hypergrid", false); | 67 | enabled = !config.Configs["Startup"].GetBoolean("gridmode", true) && config.Configs["Startup"].GetBoolean("hypergrid", false); |
68 | } | 68 | } |
69 | } | 69 | } |
70 | 70 | ||
71 | public void PostInitialise() | 71 | public void PostInitialise() |
72 | { | 72 | { |
73 | if (enabled) | 73 | if (enabled) |
74 | { | 74 | { |
75 | m_log.Info("[HGStandaloneInvService]: Starting..."); | 75 | m_log.Info("[HGStandaloneInvService]: Starting..."); |
76 | //m_inventoryService = new InventoryService(m_scene); | 76 | //m_inventoryService = new InventoryService(m_scene); |
77 | new InventoryService(m_scene); | 77 | new InventoryService(m_scene); |
78 | } | 78 | } |
79 | } | 79 | } |
80 | 80 | ||
81 | public void Close() | 81 | public void Close() |
82 | { | 82 | { |
83 | } | 83 | } |
84 | 84 | ||
85 | public string Name | 85 | public string Name |
86 | { | 86 | { |
87 | get { return "HGStandaloneInventoryService"; } | 87 | get { return "HGStandaloneInventoryService"; } |
88 | } | 88 | } |
89 | 89 | ||
90 | public bool IsSharedModule | 90 | public bool IsSharedModule |
91 | { | 91 | { |
92 | get { return true; } | 92 | get { return true; } |
93 | } | 93 | } |
94 | 94 | ||
95 | #endregion | 95 | #endregion |
96 | 96 | ||
97 | } | 97 | } |
98 | 98 | ||
99 | public class InventoryService | 99 | public class InventoryService |
100 | { | 100 | { |
101 | private InventoryServiceBase m_inventoryService; | 101 | private InventoryServiceBase m_inventoryService; |
102 | private IUserService m_userService; | 102 | private IUserService m_userService; |
103 | private bool m_doLookup = false; | 103 | private bool m_doLookup = false; |
104 | 104 | ||
105 | public bool DoLookup | 105 | public bool DoLookup |
106 | { | 106 | { |
107 | get { return m_doLookup; } | 107 | get { return m_doLookup; } |
108 | set { m_doLookup = value; } | 108 | set { m_doLookup = value; } |
109 | } | 109 | } |
110 | private static readonly ILog m_log | 110 | private static readonly ILog m_log |
111 | = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 111 | = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
112 | 112 | ||
113 | public InventoryService(Scene m_scene) | 113 | public InventoryService(Scene m_scene) |
114 | { | 114 | { |
115 | m_inventoryService = (InventoryServiceBase)m_scene.CommsManager.SecureInventoryService; | 115 | m_inventoryService = (InventoryServiceBase)m_scene.CommsManager.SecureInventoryService; |
116 | m_userService = m_scene.CommsManager.UserService; | 116 | m_userService = m_scene.CommsManager.UserService; |
117 | AddHttpHandlers(m_scene); | 117 | AddHttpHandlers(m_scene); |
118 | 118 | ||
119 | } | 119 | } |
120 | 120 | ||
121 | protected void AddHttpHandlers(Scene m_scene) | 121 | protected void AddHttpHandlers(Scene m_scene) |
122 | { | 122 | { |
123 | m_scene.AddStreamHandler( | 123 | m_scene.AddStreamHandler( |
124 | new RestDeserialiseSecureHandler<Guid, InventoryCollection>( | 124 | new RestDeserialiseSecureHandler<Guid, InventoryCollection>( |
125 | "POST", "/GetInventory/", GetUserInventory, CheckAuthSession)); | 125 | "POST", "/GetInventory/", GetUserInventory, CheckAuthSession)); |
126 | 126 | ||
127 | m_scene.AddStreamHandler( | 127 | m_scene.AddStreamHandler( |
128 | new RestDeserialiseSecureHandler<InventoryFolderBase, bool>( | 128 | new RestDeserialiseSecureHandler<InventoryFolderBase, bool>( |
129 | "POST", "/NewFolder/", m_inventoryService.AddFolder, CheckAuthSession)); | 129 | "POST", "/NewFolder/", m_inventoryService.AddFolder, CheckAuthSession)); |
130 | 130 | ||
131 | m_scene.AddStreamHandler( | 131 | m_scene.AddStreamHandler( |
132 | new RestDeserialiseSecureHandler<InventoryFolderBase, bool>( | 132 | new RestDeserialiseSecureHandler<InventoryFolderBase, bool>( |
133 | "POST", "/UpdateFolder/", m_inventoryService.UpdateFolder, CheckAuthSession)); | 133 | "POST", "/UpdateFolder/", m_inventoryService.UpdateFolder, CheckAuthSession)); |
134 | 134 | ||
135 | m_scene.AddStreamHandler( | 135 | m_scene.AddStreamHandler( |
136 | new RestDeserialiseSecureHandler<InventoryFolderBase, bool>( | 136 | new RestDeserialiseSecureHandler<InventoryFolderBase, bool>( |
137 | "POST", "/MoveFolder/", m_inventoryService.MoveFolder, CheckAuthSession)); | 137 | "POST", "/MoveFolder/", m_inventoryService.MoveFolder, CheckAuthSession)); |
138 | 138 | ||
139 | m_scene.AddStreamHandler( | 139 | m_scene.AddStreamHandler( |
140 | new RestDeserialiseSecureHandler<InventoryFolderBase, bool>( | 140 | new RestDeserialiseSecureHandler<InventoryFolderBase, bool>( |
141 | "POST", "/PurgeFolder/", m_inventoryService.PurgeFolder, CheckAuthSession)); | 141 | "POST", "/PurgeFolder/", m_inventoryService.PurgeFolder, CheckAuthSession)); |
142 | 142 | ||
143 | m_scene.AddStreamHandler( | 143 | m_scene.AddStreamHandler( |
144 | new RestDeserialiseSecureHandler<InventoryItemBase, bool>( | 144 | new RestDeserialiseSecureHandler<InventoryItemBase, bool>( |
145 | "POST", "/NewItem/", m_inventoryService.AddItem, CheckAuthSession)); | 145 | "POST", "/NewItem/", m_inventoryService.AddItem, CheckAuthSession)); |
146 | 146 | ||
147 | m_scene.AddStreamHandler( | 147 | m_scene.AddStreamHandler( |
148 | new RestDeserialiseSecureHandler<InventoryItemBase, bool>( | 148 | new RestDeserialiseSecureHandler<InventoryItemBase, bool>( |
149 | "POST", "/DeleteItem/", m_inventoryService.DeleteItem, CheckAuthSession)); | 149 | "POST", "/DeleteItem/", m_inventoryService.DeleteItem, CheckAuthSession)); |
150 | 150 | ||
151 | //// WARNING: Root folders no longer just delivers the root and immediate child folders (e.g | 151 | //// WARNING: Root folders no longer just delivers the root and immediate child folders (e.g |
152 | //// system folders such as Objects, Textures), but it now returns the entire inventory skeleton. | 152 | //// system folders such as Objects, Textures), but it now returns the entire inventory skeleton. |
153 | //// It would have been better to rename this request, but complexities in the BaseHttpServer | 153 | //// It would have been better to rename this request, but complexities in the BaseHttpServer |
154 | //// (e.g. any http request not found is automatically treated as an xmlrpc request) make it easier | 154 | //// (e.g. any http request not found is automatically treated as an xmlrpc request) make it easier |
155 | //// to do this for now. | 155 | //// to do this for now. |
156 | //m_scene.AddStreamHandler( | 156 | //m_scene.AddStreamHandler( |
157 | // new RestDeserialiseTrustedHandler<Guid, List<InventoryFolderBase>> | 157 | // new RestDeserialiseTrustedHandler<Guid, List<InventoryFolderBase>> |
158 | // ("POST", "/RootFolders/", GetInventorySkeleton, CheckTrustSource)); | 158 | // ("POST", "/RootFolders/", GetInventorySkeleton, CheckTrustSource)); |
159 | 159 | ||
160 | //// for persistent active gestures | 160 | //// for persistent active gestures |
161 | //m_scene.AddStreamHandler( | 161 | //m_scene.AddStreamHandler( |
162 | // new RestDeserialiseTrustedHandler<Guid, List<InventoryItemBase>> | 162 | // new RestDeserialiseTrustedHandler<Guid, List<InventoryItemBase>> |
163 | // ("POST", "/ActiveGestures/", GetActiveGestures, CheckTrustSource)); | 163 | // ("POST", "/ActiveGestures/", GetActiveGestures, CheckTrustSource)); |
164 | } | 164 | } |
165 | 165 | ||
166 | 166 | ||
167 | ///// <summary> | 167 | ///// <summary> |
168 | ///// Check that the source of an inventory request is one that we trust. | 168 | ///// Check that the source of an inventory request is one that we trust. |
169 | ///// </summary> | 169 | ///// </summary> |
170 | ///// <param name="peer"></param> | 170 | ///// <param name="peer"></param> |
171 | ///// <returns></returns> | 171 | ///// <returns></returns> |
172 | //public bool CheckTrustSource(IPEndPoint peer) | 172 | //public bool CheckTrustSource(IPEndPoint peer) |
173 | //{ | 173 | //{ |
174 | // if (m_doLookup) | 174 | // if (m_doLookup) |
175 | // { | 175 | // { |
176 | // m_log.InfoFormat("[GRID AGENT INVENTORY]: Checking trusted source {0}", peer); | 176 | // m_log.InfoFormat("[GRID AGENT INVENTORY]: Checking trusted source {0}", peer); |
177 | // UriBuilder ub = new UriBuilder(m_userserver_url); | 177 | // UriBuilder ub = new UriBuilder(m_userserver_url); |
178 | // IPAddress[] uaddrs = Dns.GetHostAddresses(ub.Host); | 178 | // IPAddress[] uaddrs = Dns.GetHostAddresses(ub.Host); |
179 | // foreach (IPAddress uaddr in uaddrs) | 179 | // foreach (IPAddress uaddr in uaddrs) |
180 | // { | 180 | // { |
181 | // if (uaddr.Equals(peer.Address)) | 181 | // if (uaddr.Equals(peer.Address)) |
182 | // { | 182 | // { |
183 | // return true; | 183 | // return true; |
184 | // } | 184 | // } |
185 | // } | 185 | // } |
186 | 186 | ||
187 | // m_log.WarnFormat( | 187 | // m_log.WarnFormat( |
188 | // "[GRID AGENT INVENTORY]: Rejecting request since source {0} was not in the list of trusted sources", | 188 | // "[GRID AGENT INVENTORY]: Rejecting request since source {0} was not in the list of trusted sources", |
189 | // peer); | 189 | // peer); |
190 | 190 | ||
191 | // return false; | 191 | // return false; |
192 | // } | 192 | // } |
193 | // else | 193 | // else |
194 | // { | 194 | // { |
195 | // return true; | 195 | // return true; |
196 | // } | 196 | // } |
197 | //} | 197 | //} |
198 | 198 | ||
199 | /// <summary> | 199 | /// <summary> |
200 | /// Check that the source of an inventory request for a particular agent is a current session belonging to | 200 | /// Check that the source of an inventory request for a particular agent is a current session belonging to |
201 | /// that agent. | 201 | /// that agent. |
202 | /// </summary> | 202 | /// </summary> |
203 | /// <param name="session_id"></param> | 203 | /// <param name="session_id"></param> |
204 | /// <param name="avatar_id"></param> | 204 | /// <param name="avatar_id"></param> |
205 | /// <returns></returns> | 205 | /// <returns></returns> |
206 | public bool CheckAuthSession(string session_id, string avatar_id) | 206 | public bool CheckAuthSession(string session_id, string avatar_id) |
207 | { | 207 | { |
208 | if (m_doLookup) | 208 | if (m_doLookup) |
209 | { | 209 | { |
210 | m_log.InfoFormat("[HGStandaloneInvService]: checking authed session {0} {1}", session_id, avatar_id); | 210 | m_log.InfoFormat("[HGStandaloneInvService]: checking authed session {0} {1}", session_id, avatar_id); |
211 | UUID userID = UUID.Zero; | 211 | UUID userID = UUID.Zero; |
212 | UUID sessionID = UUID.Zero; | 212 | UUID sessionID = UUID.Zero; |
213 | UUID.TryParse(avatar_id, out userID); | 213 | UUID.TryParse(avatar_id, out userID); |
214 | UUID.TryParse(session_id, out sessionID); | 214 | UUID.TryParse(session_id, out sessionID); |
215 | if (userID.Equals(UUID.Zero) || sessionID.Equals(UUID.Zero)) | 215 | if (userID.Equals(UUID.Zero) || sessionID.Equals(UUID.Zero)) |
216 | { | 216 | { |
217 | m_log.Info("[HGStandaloneInvService]: Invalid user or session id " + avatar_id + "; " + session_id); | 217 | m_log.Info("[HGStandaloneInvService]: Invalid user or session id " + avatar_id + "; " + session_id); |
218 | return false; | 218 | return false; |
219 | } | 219 | } |
220 | UserProfileData userProfile = m_userService.GetUserProfile(userID); | 220 | UserProfileData userProfile = m_userService.GetUserProfile(userID); |
221 | if (userProfile != null && userProfile.CurrentAgent != null && | 221 | if (userProfile != null && userProfile.CurrentAgent != null && |
222 | userProfile.CurrentAgent.SessionID == sessionID) | 222 | userProfile.CurrentAgent.SessionID == sessionID) |
223 | { | 223 | { |
224 | m_log.Info("[HGStandaloneInvService]: user is logged in and session is valid. Authorizing access."); | 224 | m_log.Info("[HGStandaloneInvService]: user is logged in and session is valid. Authorizing access."); |
225 | return true; | 225 | return true; |
226 | } | 226 | } |
227 | 227 | ||
228 | m_log.Warn("[HGStandaloneInvService]: unknown user or session_id, request rejected"); | 228 | m_log.Warn("[HGStandaloneInvService]: unknown user or session_id, request rejected"); |
229 | return false; | 229 | return false; |
230 | } | 230 | } |
231 | else | 231 | else |
232 | { | 232 | { |
233 | return true; | 233 | return true; |
234 | } | 234 | } |
235 | } | 235 | } |
236 | 236 | ||
237 | 237 | ||
238 | /// <summary> | 238 | /// <summary> |
239 | /// Return a user's entire inventory | 239 | /// Return a user's entire inventory |
240 | /// </summary> | 240 | /// </summary> |
241 | /// <param name="rawUserID"></param> | 241 | /// <param name="rawUserID"></param> |
242 | /// <returns>The user's inventory. If an inventory cannot be found then an empty collection is returned.</returns> | 242 | /// <returns>The user's inventory. If an inventory cannot be found then an empty collection is returned.</returns> |
243 | public InventoryCollection GetUserInventory(Guid rawUserID) | 243 | public InventoryCollection GetUserInventory(Guid rawUserID) |
244 | { | 244 | { |
245 | UUID userID = new UUID(rawUserID); | 245 | UUID userID = new UUID(rawUserID); |
246 | 246 | ||
247 | m_log.Info("[HGStandaloneInvService]: Processing request for inventory of " + userID); | 247 | m_log.Info("[HGStandaloneInvService]: Processing request for inventory of " + userID); |
248 | 248 | ||
249 | // Uncomment me to simulate a slow responding inventory server | 249 | // Uncomment me to simulate a slow responding inventory server |
250 | //Thread.Sleep(16000); | 250 | //Thread.Sleep(16000); |
251 | 251 | ||
252 | InventoryCollection invCollection = new InventoryCollection(); | 252 | InventoryCollection invCollection = new InventoryCollection(); |
253 | 253 | ||
254 | List<InventoryFolderBase> allFolders = ((InventoryServiceBase)m_inventoryService).GetInventorySkeleton(userID); | 254 | List<InventoryFolderBase> allFolders = ((InventoryServiceBase)m_inventoryService).GetInventorySkeleton(userID); |
255 | 255 | ||
256 | if (null == allFolders) | 256 | if (null == allFolders) |
257 | { | 257 | { |
258 | m_log.WarnFormat("[HGStandaloneInvService]: No inventory found for user {0}", rawUserID); | 258 | m_log.WarnFormat("[HGStandaloneInvService]: No inventory found for user {0}", rawUserID); |
259 | 259 | ||
260 | return invCollection; | 260 | return invCollection; |
261 | } | 261 | } |
262 | 262 | ||
263 | List<InventoryItemBase> allItems = new List<InventoryItemBase>(); | 263 | List<InventoryItemBase> allItems = new List<InventoryItemBase>(); |
264 | 264 | ||
265 | foreach (InventoryFolderBase folder in allFolders) | 265 | foreach (InventoryFolderBase folder in allFolders) |
266 | { | 266 | { |
267 | List<InventoryItemBase> items = ((InventoryServiceBase)m_inventoryService).RequestFolderItems(folder.ID); | 267 | List<InventoryItemBase> items = ((InventoryServiceBase)m_inventoryService).RequestFolderItems(folder.ID); |
268 | 268 | ||
269 | if (items != null) | 269 | if (items != null) |
270 | { | 270 | { |
271 | allItems.InsertRange(0, items); | 271 | allItems.InsertRange(0, items); |
272 | } | 272 | } |
273 | } | 273 | } |
274 | 274 | ||
275 | invCollection.UserID = userID; | 275 | invCollection.UserID = userID; |
276 | invCollection.Folders = allFolders; | 276 | invCollection.Folders = allFolders; |
277 | invCollection.Items = allItems; | 277 | invCollection.Items = allItems; |
278 | 278 | ||
279 | // foreach (InventoryFolderBase folder in invCollection.Folders) | 279 | // foreach (InventoryFolderBase folder in invCollection.Folders) |
280 | // { | 280 | // { |
281 | // m_log.DebugFormat("[GRID AGENT INVENTORY]: Sending back folder {0} {1}", folder.Name, folder.ID); | 281 | // m_log.DebugFormat("[GRID AGENT INVENTORY]: Sending back folder {0} {1}", folder.Name, folder.ID); |
282 | // } | 282 | // } |
283 | // | 283 | // |
284 | // foreach (InventoryItemBase item in invCollection.Items) | 284 | // foreach (InventoryItemBase item in invCollection.Items) |
285 | // { | 285 | // { |
286 | // m_log.DebugFormat("[GRID AGENT INVENTORY]: Sending back item {0} {1}, folder {2}", item.Name, item.ID, item.Folder); | 286 | // m_log.DebugFormat("[GRID AGENT INVENTORY]: Sending back item {0} {1}, folder {2}", item.Name, item.ID, item.Folder); |
287 | // } | 287 | // } |
288 | 288 | ||
289 | m_log.InfoFormat( | 289 | m_log.InfoFormat( |
290 | "[HGStandaloneInvService]: Sending back inventory response to user {0} containing {1} folders and {2} items", | 290 | "[HGStandaloneInvService]: Sending back inventory response to user {0} containing {1} folders and {2} items", |
291 | invCollection.UserID, invCollection.Folders.Count, invCollection.Items.Count); | 291 | invCollection.UserID, invCollection.Folders.Count, invCollection.Items.Count); |
292 | 292 | ||
293 | return invCollection; | 293 | return invCollection; |
294 | } | 294 | } |
295 | 295 | ||
296 | /// <summary> | 296 | /// <summary> |
297 | /// Guid to UUID wrapper for same name IInventoryServices method | 297 | /// Guid to UUID wrapper for same name IInventoryServices method |
298 | /// </summary> | 298 | /// </summary> |
299 | /// <param name="rawUserID"></param> | 299 | /// <param name="rawUserID"></param> |
300 | /// <returns></returns> | 300 | /// <returns></returns> |
301 | public List<InventoryFolderBase> GetInventorySkeleton(Guid rawUserID) | 301 | public List<InventoryFolderBase> GetInventorySkeleton(Guid rawUserID) |
302 | { | 302 | { |
303 | UUID userID = new UUID(rawUserID); | 303 | UUID userID = new UUID(rawUserID); |
304 | return ((InventoryServiceBase)m_inventoryService).GetInventorySkeleton(userID); | 304 | return ((InventoryServiceBase)m_inventoryService).GetInventorySkeleton(userID); |
305 | } | 305 | } |
306 | 306 | ||
307 | public List<InventoryItemBase> GetActiveGestures(Guid rawUserID) | 307 | public List<InventoryItemBase> GetActiveGestures(Guid rawUserID) |
308 | { | 308 | { |
309 | UUID userID = new UUID(rawUserID); | 309 | UUID userID = new UUID(rawUserID); |
310 | 310 | ||
311 | m_log.InfoFormat("[HGStandaloneInvService]: fetching active gestures for user {0}", userID); | 311 | m_log.InfoFormat("[HGStandaloneInvService]: fetching active gestures for user {0}", userID); |
312 | 312 | ||
313 | return ((InventoryServiceBase)m_inventoryService).GetActiveGestures(userID); | 313 | return ((InventoryServiceBase)m_inventoryService).GetActiveGestures(userID); |
314 | } | 314 | } |
315 | } | 315 | } |
316 | } | 316 | } |
diff --git a/OpenSim/Region/Environment/Modules/Hypergrid/HGWorldMapModule.cs b/OpenSim/Region/Environment/Modules/Hypergrid/HGWorldMapModule.cs index 7f8f285..e642b7f 100644 --- a/OpenSim/Region/Environment/Modules/Hypergrid/HGWorldMapModule.cs +++ b/OpenSim/Region/Environment/Modules/Hypergrid/HGWorldMapModule.cs | |||
@@ -1,178 +1,178 @@ | |||
1 | /** | 1 | /** |
2 | * Copyright (c) 2008, Contributors. All rights reserved. | 2 | * Copyright (c) 2008, Contributors. All rights reserved. |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without modification, | 5 | * Redistribution and use in source and binary forms, with or without modification, |
6 | * are permitted provided that the following conditions are met: | 6 | * are permitted provided that the following conditions are met: |
7 | * | 7 | * |
8 | * * Redistributions of source code must retain the above copyright notice, | 8 | * * Redistributions of source code must retain the above copyright notice, |
9 | * this list of conditions and the following disclaimer. | 9 | * this list of conditions and the following disclaimer. |
10 | * * Redistributions in binary form must reproduce the above copyright notice, | 10 | * * Redistributions in binary form must reproduce the above copyright notice, |
11 | * this list of conditions and the following disclaimer in the documentation | 11 | * this list of conditions and the following disclaimer in the documentation |
12 | * and/or other materials provided with the distribution. | 12 | * and/or other materials provided with the distribution. |
13 | * * Neither the name of the Organizations nor the names of Individual | 13 | * * Neither the name of the Organizations nor the names of Individual |
14 | * Contributors may be used to endorse or promote products derived from | 14 | * Contributors may be used to endorse or promote products derived from |
15 | * this software without specific prior written permission. | 15 | * this software without specific prior written permission. |
16 | * | 16 | * |
17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL | 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL |
20 | * THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 20 | * THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
21 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE | 21 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE |
22 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED | 22 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED |
23 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | 23 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
24 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | 24 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED |
25 | * OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | 28 | ||
29 | 29 | ||
30 | using System; | 30 | using System; |
31 | using System.Collections; | 31 | using System.Collections; |
32 | using System.Collections.Generic; | 32 | using System.Collections.Generic; |
33 | using System.Drawing; | 33 | using System.Drawing; |
34 | using System.Drawing.Imaging; | 34 | using System.Drawing.Imaging; |
35 | using System.IO; | 35 | using System.IO; |
36 | using System.Net; | 36 | using System.Net; |
37 | using System.Reflection; | 37 | using System.Reflection; |
38 | using System.Threading; | 38 | using System.Threading; |
39 | using OpenMetaverse; | 39 | using OpenMetaverse; |
40 | using OpenMetaverse.Imaging; | 40 | using OpenMetaverse.Imaging; |
41 | using OpenMetaverse.StructuredData; | 41 | using OpenMetaverse.StructuredData; |
42 | using log4net; | 42 | using log4net; |
43 | using Nini.Config; | 43 | using Nini.Config; |
44 | using Nwc.XmlRpc; | 44 | using Nwc.XmlRpc; |
45 | 45 | ||
46 | using OpenSim.Framework; | 46 | using OpenSim.Framework; |
47 | using OpenSim.Framework.Communications.Cache; | 47 | using OpenSim.Framework.Communications.Cache; |
48 | using OpenSim.Framework.Communications.Capabilities; | 48 | using OpenSim.Framework.Communications.Capabilities; |
49 | using OpenSim.Framework.Servers; | 49 | using OpenSim.Framework.Servers; |
50 | using OpenSim.Region.Environment.Interfaces; | 50 | using OpenSim.Region.Environment.Interfaces; |
51 | using OpenSim.Region.Environment.Modules.World.WorldMap; | 51 | using OpenSim.Region.Environment.Modules.World.WorldMap; |
52 | using OpenSim.Region.Environment.Scenes; | 52 | using OpenSim.Region.Environment.Scenes; |
53 | using OpenSim.Region.Environment.Types; | 53 | using OpenSim.Region.Environment.Types; |
54 | using Caps = OpenSim.Framework.Communications.Capabilities.Caps; | 54 | using Caps = OpenSim.Framework.Communications.Capabilities.Caps; |
55 | 55 | ||
56 | using OSD = OpenMetaverse.StructuredData.OSD; | 56 | using OSD = OpenMetaverse.StructuredData.OSD; |
57 | using OSDMap = OpenMetaverse.StructuredData.OSDMap; | 57 | using OSDMap = OpenMetaverse.StructuredData.OSDMap; |
58 | using OSDArray = OpenMetaverse.StructuredData.OSDArray; | 58 | using OSDArray = OpenMetaverse.StructuredData.OSDArray; |
59 | 59 | ||
60 | namespace OpenSim.Region.Environment.Modules.Hypergrid | 60 | namespace OpenSim.Region.Environment.Modules.Hypergrid |
61 | { | 61 | { |
62 | public class HGWorldMapModule : WorldMapModule, IRegionModule | 62 | public class HGWorldMapModule : WorldMapModule, IRegionModule |
63 | { | 63 | { |
64 | private static readonly ILog m_log = | 64 | private static readonly ILog m_log = |
65 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 65 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
66 | 66 | ||
67 | #region IRegionModule Members | 67 | #region IRegionModule Members |
68 | 68 | ||
69 | public override void Initialise(Scene scene, IConfigSource config) | 69 | public override void Initialise(Scene scene, IConfigSource config) |
70 | { | 70 | { |
71 | IConfig startupConfig = config.Configs["Startup"]; | 71 | IConfig startupConfig = config.Configs["Startup"]; |
72 | if (startupConfig.GetString("WorldMapModule", "WorldMap") == "HGWorldMap") | 72 | if (startupConfig.GetString("WorldMapModule", "WorldMap") == "HGWorldMap") |
73 | m_Enabled = true; | 73 | m_Enabled = true; |
74 | 74 | ||
75 | if (!m_Enabled) | 75 | if (!m_Enabled) |
76 | return; | 76 | return; |
77 | m_log.Info("[HGMap] Initializing..."); | 77 | m_log.Info("[HGMap] Initializing..."); |
78 | m_scene = scene; | 78 | m_scene = scene; |
79 | } | 79 | } |
80 | 80 | ||
81 | 81 | ||
82 | public override string Name | 82 | public override string Name |
83 | { | 83 | { |
84 | get { return "HGWorldMap"; } | 84 | get { return "HGWorldMap"; } |
85 | } | 85 | } |
86 | 86 | ||
87 | 87 | ||
88 | #endregion | 88 | #endregion |
89 | 89 | ||
90 | /// <summary> | 90 | /// <summary> |
91 | /// Requests map blocks in area of minX, maxX, minY, MaxY in world cordinates | 91 | /// Requests map blocks in area of minX, maxX, minY, MaxY in world cordinates |
92 | /// </summary> | 92 | /// </summary> |
93 | /// <param name="minX"></param> | 93 | /// <param name="minX"></param> |
94 | /// <param name="minY"></param> | 94 | /// <param name="minY"></param> |
95 | /// <param name="maxX"></param> | 95 | /// <param name="maxX"></param> |
96 | /// <param name="maxY"></param> | 96 | /// <param name="maxY"></param> |
97 | public override void RequestMapBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY, uint flag) | 97 | public override void RequestMapBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY, uint flag) |
98 | { | 98 | { |
99 | // | 99 | // |
100 | // WARNING!!! COPY & PASTE FROM SUPERCLASS | 100 | // WARNING!!! COPY & PASTE FROM SUPERCLASS |
101 | // The only difference is at the very end | 101 | // The only difference is at the very end |
102 | // | 102 | // |
103 | 103 | ||
104 | m_log.Info("[HGMap]: Request map blocks " + minX + "-" + maxX + " " + minY + "-" + maxY); | 104 | m_log.Info("[HGMap]: Request map blocks " + minX + "-" + maxX + " " + minY + "-" + maxY); |
105 | 105 | ||
106 | //m_scene.ForEachScenePresence(delegate (ScenePresence sp) { | 106 | //m_scene.ForEachScenePresence(delegate (ScenePresence sp) { |
107 | // if (!sp.IsChildAgent && sp.UUID == remoteClient.AgentId) | 107 | // if (!sp.IsChildAgent && sp.UUID == remoteClient.AgentId) |
108 | // { | 108 | // { |
109 | // Console.WriteLine("XXX Root agent"); | 109 | // Console.WriteLine("XXX Root agent"); |
110 | // DoRequestMapBlocks(remoteClient, minX, minY, maxX, maxY, flag); | 110 | // DoRequestMapBlocks(remoteClient, minX, minY, maxX, maxY, flag); |
111 | // } | 111 | // } |
112 | //}; | 112 | //}; |
113 | 113 | ||
114 | List<MapBlockData> mapBlocks; | 114 | List<MapBlockData> mapBlocks; |
115 | if ((flag & 0x10000) != 0) // user clicked on the map a tile that isn't visible | 115 | if ((flag & 0x10000) != 0) // user clicked on the map a tile that isn't visible |
116 | { | 116 | { |
117 | List<MapBlockData> response = new List<MapBlockData>(); | 117 | List<MapBlockData> response = new List<MapBlockData>(); |
118 | 118 | ||
119 | // this should return one mapblock at most. But make sure: Look whether the one we requested is in there | 119 | // this should return one mapblock at most. But make sure: Look whether the one we requested is in there |
120 | mapBlocks = m_scene.SceneGridService.RequestNeighbourMapBlocks(minX, minY, maxX, maxY); | 120 | mapBlocks = m_scene.SceneGridService.RequestNeighbourMapBlocks(minX, minY, maxX, maxY); |
121 | if (mapBlocks != null) | 121 | if (mapBlocks != null) |
122 | { | 122 | { |
123 | foreach (MapBlockData block in mapBlocks) | 123 | foreach (MapBlockData block in mapBlocks) |
124 | { | 124 | { |
125 | if (block.X == minX && block.Y == minY) | 125 | if (block.X == minX && block.Y == minY) |
126 | { | 126 | { |
127 | // found it => add it to response | 127 | // found it => add it to response |
128 | response.Add(block); | 128 | response.Add(block); |
129 | break; | 129 | break; |
130 | } | 130 | } |
131 | } | 131 | } |
132 | } | 132 | } |
133 | response = mapBlocks; | 133 | response = mapBlocks; |
134 | if (response.Count == 0) | 134 | if (response.Count == 0) |
135 | { | 135 | { |
136 | // response still empty => couldn't find the map-tile the user clicked on => tell the client | 136 | // response still empty => couldn't find the map-tile the user clicked on => tell the client |
137 | MapBlockData block = new MapBlockData(); | 137 | MapBlockData block = new MapBlockData(); |
138 | block.X = (ushort)minX; | 138 | block.X = (ushort)minX; |
139 | block.Y = (ushort)minY; | 139 | block.Y = (ushort)minY; |
140 | block.Access = 254; // == not there | 140 | block.Access = 254; // == not there |
141 | response.Add(block); | 141 | response.Add(block); |
142 | } | 142 | } |
143 | remoteClient.SendMapBlock(response, 0); | 143 | remoteClient.SendMapBlock(response, 0); |
144 | } | 144 | } |
145 | else | 145 | else |
146 | { | 146 | { |
147 | // normal mapblock request. Use the provided values | 147 | // normal mapblock request. Use the provided values |
148 | mapBlocks = m_scene.SceneGridService.RequestNeighbourMapBlocks(minX - 4, minY - 4, maxX + 4, maxY + 4); | 148 | mapBlocks = m_scene.SceneGridService.RequestNeighbourMapBlocks(minX - 4, minY - 4, maxX + 4, maxY + 4); |
149 | 149 | ||
150 | // Different from super | 150 | // Different from super |
151 | FillInMap(mapBlocks, minX, minY, maxX, maxY); | 151 | FillInMap(mapBlocks, minX, minY, maxX, maxY); |
152 | // | 152 | // |
153 | 153 | ||
154 | remoteClient.SendMapBlock(mapBlocks, flag); | 154 | remoteClient.SendMapBlock(mapBlocks, flag); |
155 | } | 155 | } |
156 | } | 156 | } |
157 | 157 | ||
158 | 158 | ||
159 | private void FillInMap(List<MapBlockData> mapBlocks, int minX, int minY, int maxX, int maxY) | 159 | private void FillInMap(List<MapBlockData> mapBlocks, int minX, int minY, int maxX, int maxY) |
160 | { | 160 | { |
161 | for (int x = minX; x <= maxX; x++) | 161 | for (int x = minX; x <= maxX; x++) |
162 | for (int y = minY; y <= maxY; y++) | 162 | for (int y = minY; y <= maxY; y++) |
163 | { | 163 | { |
164 | MapBlockData mblock = mapBlocks.Find(delegate(MapBlockData mb) { return ((mb.X == x) && (mb.Y == y)); }); | 164 | MapBlockData mblock = mapBlocks.Find(delegate(MapBlockData mb) { return ((mb.X == x) && (mb.Y == y)); }); |
165 | if (mblock == null) | 165 | if (mblock == null) |
166 | { | 166 | { |
167 | mblock = new MapBlockData(); | 167 | mblock = new MapBlockData(); |
168 | mblock.X = (ushort)x; | 168 | mblock.X = (ushort)x; |
169 | mblock.Y = (ushort)y; | 169 | mblock.Y = (ushort)y; |
170 | mblock.Name = ""; | 170 | mblock.Name = ""; |
171 | mblock.Access = 254; // not here??? | 171 | mblock.Access = 254; // not here??? |
172 | mblock.MapImageId = UUID.Zero; | 172 | mblock.MapImageId = UUID.Zero; |
173 | mapBlocks.Add(mblock); | 173 | mapBlocks.Add(mblock); |
174 | } | 174 | } |
175 | } | 175 | } |
176 | } | 176 | } |
177 | } | 177 | } |
178 | } | 178 | } |
diff --git a/OpenSim/Region/Environment/Scenes/EntityManager.cs b/OpenSim/Region/Environment/Scenes/EntityManager.cs index be39878..eb29ead 100644 --- a/OpenSim/Region/Environment/Scenes/EntityManager.cs +++ b/OpenSim/Region/Environment/Scenes/EntityManager.cs | |||
@@ -1,182 +1,182 @@ | |||
1 | using System; | 1 | using System; |
2 | using System.Collections; | 2 | using System.Collections; |
3 | using System.Collections.Generic; | 3 | using System.Collections.Generic; |
4 | using OpenMetaverse; | 4 | using OpenMetaverse; |
5 | 5 | ||
6 | namespace OpenSim.Region.Environment.Scenes | 6 | namespace OpenSim.Region.Environment.Scenes |
7 | { | 7 | { |
8 | public class EntityManager : IEnumerable<EntityBase> | 8 | public class EntityManager : IEnumerable<EntityBase> |
9 | { | 9 | { |
10 | private readonly Dictionary<UUID,EntityBase> m_eb_uuid = new Dictionary<UUID, EntityBase>(); | 10 | private readonly Dictionary<UUID,EntityBase> m_eb_uuid = new Dictionary<UUID, EntityBase>(); |
11 | private readonly Dictionary<uint, EntityBase> m_eb_localID = new Dictionary<uint, EntityBase>(); | 11 | private readonly Dictionary<uint, EntityBase> m_eb_localID = new Dictionary<uint, EntityBase>(); |
12 | private readonly Object m_lock = new Object(); | 12 | private readonly Object m_lock = new Object(); |
13 | 13 | ||
14 | [Obsolete("Use Add() instead.")] | 14 | [Obsolete("Use Add() instead.")] |
15 | public void Add(UUID id, EntityBase eb) | 15 | public void Add(UUID id, EntityBase eb) |
16 | { | 16 | { |
17 | Add(eb); | 17 | Add(eb); |
18 | } | 18 | } |
19 | 19 | ||
20 | public void Add(EntityBase entity) | 20 | public void Add(EntityBase entity) |
21 | { | 21 | { |
22 | lock(m_lock) | 22 | lock(m_lock) |
23 | { | 23 | { |
24 | m_eb_uuid.Add(entity.UUID, entity); | 24 | m_eb_uuid.Add(entity.UUID, entity); |
25 | m_eb_localID.Add(entity.LocalId, entity); | 25 | m_eb_localID.Add(entity.LocalId, entity); |
26 | } | 26 | } |
27 | } | 27 | } |
28 | 28 | ||
29 | public void InsertOrReplace(EntityBase entity) | 29 | public void InsertOrReplace(EntityBase entity) |
30 | { | 30 | { |
31 | lock(m_lock) | 31 | lock(m_lock) |
32 | { | 32 | { |
33 | m_eb_uuid[entity.UUID] = entity; | 33 | m_eb_uuid[entity.UUID] = entity; |
34 | m_eb_localID[entity.LocalId] = entity; | 34 | m_eb_localID[entity.LocalId] = entity; |
35 | } | 35 | } |
36 | } | 36 | } |
37 | 37 | ||
38 | public void Clear() | 38 | public void Clear() |
39 | { | 39 | { |
40 | lock (m_lock) | 40 | lock (m_lock) |
41 | { | 41 | { |
42 | m_eb_uuid.Clear(); | 42 | m_eb_uuid.Clear(); |
43 | m_eb_localID.Clear(); | 43 | m_eb_localID.Clear(); |
44 | } | 44 | } |
45 | } | 45 | } |
46 | 46 | ||
47 | public int Count | 47 | public int Count |
48 | { | 48 | { |
49 | get | 49 | get |
50 | { | 50 | { |
51 | lock (m_lock) | 51 | lock (m_lock) |
52 | { | 52 | { |
53 | return m_eb_uuid.Count; | 53 | return m_eb_uuid.Count; |
54 | } | 54 | } |
55 | } | 55 | } |
56 | } | 56 | } |
57 | 57 | ||
58 | public bool ContainsKey(UUID id) | 58 | public bool ContainsKey(UUID id) |
59 | { | 59 | { |
60 | lock(m_lock) | 60 | lock(m_lock) |
61 | { | 61 | { |
62 | return m_eb_uuid.ContainsKey(id); | 62 | return m_eb_uuid.ContainsKey(id); |
63 | } | 63 | } |
64 | } | 64 | } |
65 | 65 | ||
66 | public bool ContainsKey(uint localID) | 66 | public bool ContainsKey(uint localID) |
67 | { | 67 | { |
68 | lock (m_lock) | 68 | lock (m_lock) |
69 | { | 69 | { |
70 | return m_eb_localID.ContainsKey(localID); | 70 | return m_eb_localID.ContainsKey(localID); |
71 | } | 71 | } |
72 | } | 72 | } |
73 | 73 | ||
74 | public bool Remove(uint localID) | 74 | public bool Remove(uint localID) |
75 | { | 75 | { |
76 | lock(m_lock) | 76 | lock(m_lock) |
77 | { | 77 | { |
78 | bool a = m_eb_uuid.Remove(m_eb_localID[localID].UUID); | 78 | bool a = m_eb_uuid.Remove(m_eb_localID[localID].UUID); |
79 | bool b = m_eb_localID.Remove(localID); | 79 | bool b = m_eb_localID.Remove(localID); |
80 | 80 | ||
81 | return a && b; | 81 | return a && b; |
82 | } | 82 | } |
83 | } | 83 | } |
84 | 84 | ||
85 | public bool Remove(UUID id) | 85 | public bool Remove(UUID id) |
86 | { | 86 | { |
87 | lock(m_lock) | 87 | lock(m_lock) |
88 | { | 88 | { |
89 | bool a = m_eb_localID.Remove(m_eb_uuid[id].LocalId); | 89 | bool a = m_eb_localID.Remove(m_eb_uuid[id].LocalId); |
90 | bool b = m_eb_uuid.Remove(id); | 90 | bool b = m_eb_uuid.Remove(id); |
91 | 91 | ||
92 | return a && b; | 92 | return a && b; |
93 | } | 93 | } |
94 | } | 94 | } |
95 | 95 | ||
96 | public List<EntityBase> GetAllByType<T>() | 96 | public List<EntityBase> GetAllByType<T>() |
97 | { | 97 | { |
98 | List<EntityBase> tmp = new List<EntityBase>(); | 98 | List<EntityBase> tmp = new List<EntityBase>(); |
99 | 99 | ||
100 | lock(m_lock) | 100 | lock(m_lock) |
101 | { | 101 | { |
102 | foreach (KeyValuePair<UUID, EntityBase> pair in m_eb_uuid) | 102 | foreach (KeyValuePair<UUID, EntityBase> pair in m_eb_uuid) |
103 | { | 103 | { |
104 | if(pair.Value is T) | 104 | if(pair.Value is T) |
105 | { | 105 | { |
106 | tmp.Add(pair.Value); | 106 | tmp.Add(pair.Value); |
107 | } | 107 | } |
108 | } | 108 | } |
109 | } | 109 | } |
110 | 110 | ||
111 | return tmp; | 111 | return tmp; |
112 | } | 112 | } |
113 | 113 | ||
114 | public List<EntityBase> GetEntities() | 114 | public List<EntityBase> GetEntities() |
115 | { | 115 | { |
116 | lock (m_lock) | 116 | lock (m_lock) |
117 | { | 117 | { |
118 | return new List<EntityBase>(m_eb_uuid.Values); | 118 | return new List<EntityBase>(m_eb_uuid.Values); |
119 | } | 119 | } |
120 | } | 120 | } |
121 | 121 | ||
122 | public EntityBase this[UUID id] | 122 | public EntityBase this[UUID id] |
123 | { | 123 | { |
124 | get | 124 | get |
125 | { | 125 | { |
126 | lock (m_lock) | 126 | lock (m_lock) |
127 | { | 127 | { |
128 | return m_eb_uuid[id]; | 128 | return m_eb_uuid[id]; |
129 | } | 129 | } |
130 | } | 130 | } |
131 | set | 131 | set |
132 | { | 132 | { |
133 | InsertOrReplace(value); | 133 | InsertOrReplace(value); |
134 | } | 134 | } |
135 | } | 135 | } |
136 | 136 | ||
137 | public EntityBase this[uint localID] | 137 | public EntityBase this[uint localID] |
138 | { | 138 | { |
139 | get | 139 | get |
140 | { | 140 | { |
141 | lock (m_lock) | 141 | lock (m_lock) |
142 | { | 142 | { |
143 | return m_eb_localID[localID]; | 143 | return m_eb_localID[localID]; |
144 | } | 144 | } |
145 | } | 145 | } |
146 | set | 146 | set |
147 | { | 147 | { |
148 | InsertOrReplace(value); | 148 | InsertOrReplace(value); |
149 | } | 149 | } |
150 | } | 150 | } |
151 | 151 | ||
152 | public bool TryGetValue(UUID key, out EntityBase obj) | 152 | public bool TryGetValue(UUID key, out EntityBase obj) |
153 | { | 153 | { |
154 | lock(m_lock) | 154 | lock(m_lock) |
155 | { | 155 | { |
156 | return m_eb_uuid.TryGetValue(key, out obj); | 156 | return m_eb_uuid.TryGetValue(key, out obj); |
157 | } | 157 | } |
158 | } | 158 | } |
159 | 159 | ||
160 | public bool TryGetValue(uint key, out EntityBase obj) | 160 | public bool TryGetValue(uint key, out EntityBase obj) |
161 | { | 161 | { |
162 | lock (m_lock) | 162 | lock (m_lock) |
163 | { | 163 | { |
164 | return m_eb_localID.TryGetValue(key, out obj); | 164 | return m_eb_localID.TryGetValue(key, out obj); |
165 | } | 165 | } |
166 | } | 166 | } |
167 | 167 | ||
168 | /// <summary> | 168 | /// <summary> |
169 | /// This could be optimised to work on the list 'live' rather than making a safe copy and iterating that. | 169 | /// This could be optimised to work on the list 'live' rather than making a safe copy and iterating that. |
170 | /// </summary> | 170 | /// </summary> |
171 | /// <returns></returns> | 171 | /// <returns></returns> |
172 | public IEnumerator<EntityBase> GetEnumerator() | 172 | public IEnumerator<EntityBase> GetEnumerator() |
173 | { | 173 | { |
174 | return GetEntities().GetEnumerator(); | 174 | return GetEntities().GetEnumerator(); |
175 | } | 175 | } |
176 | 176 | ||
177 | IEnumerator IEnumerable.GetEnumerator() | 177 | IEnumerator IEnumerable.GetEnumerator() |
178 | { | 178 | { |
179 | return GetEnumerator(); | 179 | return GetEnumerator(); |
180 | } | 180 | } |
181 | } | 181 | } |
182 | } | 182 | } |
diff --git a/OpenSim/Region/Environment/Scenes/Hypergrid/HGAssetMapper.cs b/OpenSim/Region/Environment/Scenes/Hypergrid/HGAssetMapper.cs index 1715ffe..889c77e 100644 --- a/OpenSim/Region/Environment/Scenes/Hypergrid/HGAssetMapper.cs +++ b/OpenSim/Region/Environment/Scenes/Hypergrid/HGAssetMapper.cs | |||
@@ -1,377 +1,377 @@ | |||
1 | /** | 1 | /** |
2 | * Copyright (c) 2008, Contributors. All rights reserved. | 2 | * Copyright (c) 2008, Contributors. All rights reserved. |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without modification, | 5 | * Redistribution and use in source and binary forms, with or without modification, |
6 | * are permitted provided that the following conditions are met: | 6 | * are permitted provided that the following conditions are met: |
7 | * | 7 | * |
8 | * * Redistributions of source code must retain the above copyright notice, | 8 | * * Redistributions of source code must retain the above copyright notice, |
9 | * this list of conditions and the following disclaimer. | 9 | * this list of conditions and the following disclaimer. |
10 | * * Redistributions in binary form must reproduce the above copyright notice, | 10 | * * Redistributions in binary form must reproduce the above copyright notice, |
11 | * this list of conditions and the following disclaimer in the documentation | 11 | * this list of conditions and the following disclaimer in the documentation |
12 | * and/or other materials provided with the distribution. | 12 | * and/or other materials provided with the distribution. |
13 | * * Neither the name of the Organizations nor the names of Individual | 13 | * * Neither the name of the Organizations nor the names of Individual |
14 | * Contributors may be used to endorse or promote products derived from | 14 | * Contributors may be used to endorse or promote products derived from |
15 | * this software without specific prior written permission. | 15 | * this software without specific prior written permission. |
16 | * | 16 | * |
17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL | 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL |
20 | * THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 20 | * THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
21 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE | 21 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE |
22 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED | 22 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED |
23 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | 23 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
24 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | 24 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED |
25 | * OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | 28 | ||
29 | using System; | 29 | using System; |
30 | using System.Collections; | 30 | using System.Collections; |
31 | using System.Collections.Generic; | 31 | using System.Collections.Generic; |
32 | using System.Reflection; | 32 | using System.Reflection; |
33 | using System.Threading; | 33 | using System.Threading; |
34 | 34 | ||
35 | using log4net; | 35 | using log4net; |
36 | using Nini.Config; | 36 | using Nini.Config; |
37 | using OpenMetaverse; | 37 | using OpenMetaverse; |
38 | 38 | ||
39 | using OpenSim.Framework; | 39 | using OpenSim.Framework; |
40 | using OpenSim.Framework.Communications; | 40 | using OpenSim.Framework.Communications; |
41 | using OpenSim.Framework.Communications.Cache; | 41 | using OpenSim.Framework.Communications.Cache; |
42 | using OpenSim.Framework.Servers; | 42 | using OpenSim.Framework.Servers; |
43 | using OpenSim.Region.Environment; | 43 | using OpenSim.Region.Environment; |
44 | using OpenSim.Region.Environment.Scenes; | 44 | using OpenSim.Region.Environment.Scenes; |
45 | 45 | ||
46 | //using HyperGrid.Framework; | 46 | //using HyperGrid.Framework; |
47 | //using OpenSim.Region.Communications.Hypergrid; | 47 | //using OpenSim.Region.Communications.Hypergrid; |
48 | 48 | ||
49 | namespace OpenSim.Region.Environment.Scenes.Hypergrid | 49 | namespace OpenSim.Region.Environment.Scenes.Hypergrid |
50 | { | 50 | { |
51 | public class HGAssetMapper | 51 | public class HGAssetMapper |
52 | { | 52 | { |
53 | #region Fields | 53 | #region Fields |
54 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 54 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
55 | 55 | ||
56 | // This maps between asset server URLs and asset server clients | 56 | // This maps between asset server URLs and asset server clients |
57 | private Dictionary<string, GridAssetClient> m_assetServers = new Dictionary<string, GridAssetClient>(); | 57 | private Dictionary<string, GridAssetClient> m_assetServers = new Dictionary<string, GridAssetClient>(); |
58 | 58 | ||
59 | // This maps between asset UUIDs and asset servers | 59 | // This maps between asset UUIDs and asset servers |
60 | private Dictionary<UUID, GridAssetClient> m_assetMap = new Dictionary<UUID, GridAssetClient>(); | 60 | private Dictionary<UUID, GridAssetClient> m_assetMap = new Dictionary<UUID, GridAssetClient>(); |
61 | 61 | ||
62 | private Scene m_scene; | 62 | private Scene m_scene; |
63 | #endregion | 63 | #endregion |
64 | 64 | ||
65 | #region Constructor | 65 | #region Constructor |
66 | 66 | ||
67 | public HGAssetMapper(Scene scene) | 67 | public HGAssetMapper(Scene scene) |
68 | { | 68 | { |
69 | m_scene = scene; | 69 | m_scene = scene; |
70 | } | 70 | } |
71 | 71 | ||
72 | #endregion | 72 | #endregion |
73 | 73 | ||
74 | #region Internal functions | 74 | #region Internal functions |
75 | 75 | ||
76 | private string UserAssetURL(UUID userID) | 76 | private string UserAssetURL(UUID userID) |
77 | { | 77 | { |
78 | CachedUserInfo uinfo = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(userID); | 78 | CachedUserInfo uinfo = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(userID); |
79 | if (uinfo != null) | 79 | if (uinfo != null) |
80 | return (uinfo.UserProfile.UserAssetURI == "") ? null : uinfo.UserProfile.UserAssetURI; | 80 | return (uinfo.UserProfile.UserAssetURI == "") ? null : uinfo.UserProfile.UserAssetURI; |
81 | return null; | 81 | return null; |
82 | } | 82 | } |
83 | 83 | ||
84 | private bool IsHomeUser(UUID userID) | 84 | private bool IsHomeUser(UUID userID) |
85 | { | 85 | { |
86 | CachedUserInfo uinfo = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(userID); | 86 | CachedUserInfo uinfo = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(userID); |
87 | 87 | ||
88 | if (uinfo != null) | 88 | if (uinfo != null) |
89 | { | 89 | { |
90 | //if ((uinfo.UserProfile.UserAssetURI == null) || (uinfo.UserProfile.UserAssetURI == "") || | 90 | //if ((uinfo.UserProfile.UserAssetURI == null) || (uinfo.UserProfile.UserAssetURI == "") || |
91 | // uinfo.UserProfile.UserAssetURI.Equals(m_scene.CommsManager.NetworkServersInfo.AssetURL)) | 91 | // uinfo.UserProfile.UserAssetURI.Equals(m_scene.CommsManager.NetworkServersInfo.AssetURL)) |
92 | if (HGNetworkServersInfo.Singleton.IsLocalUser(uinfo.UserProfile.UserAssetURI)) | 92 | if (HGNetworkServersInfo.Singleton.IsLocalUser(uinfo.UserProfile.UserAssetURI)) |
93 | { | 93 | { |
94 | m_log.Debug("[HGScene]: Home user " + uinfo.UserProfile.FirstName + " " + uinfo.UserProfile.SurName); | 94 | m_log.Debug("[HGScene]: Home user " + uinfo.UserProfile.FirstName + " " + uinfo.UserProfile.SurName); |
95 | return true; | 95 | return true; |
96 | } | 96 | } |
97 | } | 97 | } |
98 | 98 | ||
99 | m_log.Debug("[HGScene]: Foreign user " + uinfo.UserProfile.FirstName + " " + uinfo.UserProfile.SurName); | 99 | m_log.Debug("[HGScene]: Foreign user " + uinfo.UserProfile.FirstName + " " + uinfo.UserProfile.SurName); |
100 | return false; | 100 | return false; |
101 | } | 101 | } |
102 | 102 | ||
103 | private bool IsInAssetMap(UUID uuid) | 103 | private bool IsInAssetMap(UUID uuid) |
104 | { | 104 | { |
105 | return m_assetMap.ContainsKey(uuid); | 105 | return m_assetMap.ContainsKey(uuid); |
106 | } | 106 | } |
107 | 107 | ||
108 | private bool FetchAsset(GridAssetClient asscli, UUID assetID, bool isTexture) | 108 | private bool FetchAsset(GridAssetClient asscli, UUID assetID, bool isTexture) |
109 | { | 109 | { |
110 | // I'm not going over 3 seconds since this will be blocking processing of all the other inbound | 110 | // I'm not going over 3 seconds since this will be blocking processing of all the other inbound |
111 | // packets from the client. | 111 | // packets from the client. |
112 | int pollPeriod = 200; | 112 | int pollPeriod = 200; |
113 | int maxPolls = 15; | 113 | int maxPolls = 15; |
114 | 114 | ||
115 | AssetBase asset; | 115 | AssetBase asset; |
116 | 116 | ||
117 | // Maybe it came late, and it's already here. Check first. | 117 | // Maybe it came late, and it's already here. Check first. |
118 | if (m_scene.CommsManager.AssetCache.TryGetCachedAsset(assetID, out asset)) | 118 | if (m_scene.CommsManager.AssetCache.TryGetCachedAsset(assetID, out asset)) |
119 | { | 119 | { |
120 | m_log.Debug("[HGScene]: Asset already in asset cache. " + assetID); | 120 | m_log.Debug("[HGScene]: Asset already in asset cache. " + assetID); |
121 | return true; | 121 | return true; |
122 | } | 122 | } |
123 | 123 | ||
124 | 124 | ||
125 | asscli.RequestAsset(assetID, isTexture); | 125 | asscli.RequestAsset(assetID, isTexture); |
126 | 126 | ||
127 | do | 127 | do |
128 | { | 128 | { |
129 | Thread.Sleep(pollPeriod); | 129 | Thread.Sleep(pollPeriod); |
130 | 130 | ||
131 | if (m_scene.CommsManager.AssetCache.TryGetCachedAsset(assetID, out asset) && (asset != null)) | 131 | if (m_scene.CommsManager.AssetCache.TryGetCachedAsset(assetID, out asset) && (asset != null)) |
132 | { | 132 | { |
133 | m_log.Debug("[HGScene]: Asset made it to asset cache. " + asset.Name + " " + assetID); | 133 | m_log.Debug("[HGScene]: Asset made it to asset cache. " + asset.Name + " " + assetID); |
134 | // I think I need to store it in the asset DB too. | 134 | // I think I need to store it in the asset DB too. |
135 | // For now, let me just do it for textures and scripts | 135 | // For now, let me just do it for textures and scripts |
136 | if (((AssetType)asset.Type == AssetType.Texture) || | 136 | if (((AssetType)asset.Type == AssetType.Texture) || |
137 | ((AssetType)asset.Type == AssetType.LSLBytecode) || | 137 | ((AssetType)asset.Type == AssetType.LSLBytecode) || |
138 | ((AssetType)asset.Type == AssetType.LSLText)) | 138 | ((AssetType)asset.Type == AssetType.LSLText)) |
139 | { | 139 | { |
140 | AssetBase asset1 = new AssetBase(); | 140 | AssetBase asset1 = new AssetBase(); |
141 | Copy(asset, asset1); | 141 | Copy(asset, asset1); |
142 | m_scene.AssetCache.AssetServer.StoreAsset(asset1); | 142 | m_scene.AssetCache.AssetServer.StoreAsset(asset1); |
143 | } | 143 | } |
144 | return true; | 144 | return true; |
145 | } | 145 | } |
146 | } while (--maxPolls > 0); | 146 | } while (--maxPolls > 0); |
147 | 147 | ||
148 | m_log.WarnFormat("[HGScene]: {0} {1} was not received before the retrieval timeout was reached", | 148 | m_log.WarnFormat("[HGScene]: {0} {1} was not received before the retrieval timeout was reached", |
149 | isTexture ? "texture" : "asset", assetID.ToString()); | 149 | isTexture ? "texture" : "asset", assetID.ToString()); |
150 | 150 | ||
151 | return false; | 151 | return false; |
152 | } | 152 | } |
153 | 153 | ||
154 | private bool PostAsset(GridAssetClient asscli, UUID assetID) | 154 | private bool PostAsset(GridAssetClient asscli, UUID assetID) |
155 | { | 155 | { |
156 | AssetBase asset1; | 156 | AssetBase asset1; |
157 | m_scene.CommsManager.AssetCache.TryGetCachedAsset(assetID, out asset1); | 157 | m_scene.CommsManager.AssetCache.TryGetCachedAsset(assetID, out asset1); |
158 | 158 | ||
159 | if (asset1 != null) | 159 | if (asset1 != null) |
160 | { | 160 | { |
161 | // See long comment in AssetCache.AddAsset | 161 | // See long comment in AssetCache.AddAsset |
162 | if (!asset1.Temporary || asset1.Local) | 162 | if (!asset1.Temporary || asset1.Local) |
163 | { | 163 | { |
164 | // The asset cache returns instances of subclasses of AssetBase: | 164 | // The asset cache returns instances of subclasses of AssetBase: |
165 | // TextureImage or AssetInfo. So in passing them to the remote | 165 | // TextureImage or AssetInfo. So in passing them to the remote |
166 | // server we first need to convert this to instances of AssetBase, | 166 | // server we first need to convert this to instances of AssetBase, |
167 | // which is the serializable class for assets. | 167 | // which is the serializable class for assets. |
168 | AssetBase asset = new AssetBase(); | 168 | AssetBase asset = new AssetBase(); |
169 | Copy(asset1, asset); | 169 | Copy(asset1, asset); |
170 | 170 | ||
171 | asscli.StoreAsset(asset); | 171 | asscli.StoreAsset(asset); |
172 | } | 172 | } |
173 | return true; | 173 | return true; |
174 | } | 174 | } |
175 | else | 175 | else |
176 | m_log.Warn("[HGScene]: Tried to post asset to remote server, but asset not in local cache."); | 176 | m_log.Warn("[HGScene]: Tried to post asset to remote server, but asset not in local cache."); |
177 | 177 | ||
178 | return false; | 178 | return false; |
179 | } | 179 | } |
180 | 180 | ||
181 | private void Copy(AssetBase from, AssetBase to) | 181 | private void Copy(AssetBase from, AssetBase to) |
182 | { | 182 | { |
183 | to.Data = from.Data; | 183 | to.Data = from.Data; |
184 | to.Description = from.Description; | 184 | to.Description = from.Description; |
185 | to.FullID = from.FullID; | 185 | to.FullID = from.FullID; |
186 | to.ID = from.ID; | 186 | to.ID = from.ID; |
187 | to.Local = from.Local; | 187 | to.Local = from.Local; |
188 | to.Name = from.Name; | 188 | to.Name = from.Name; |
189 | to.Temporary = from.Temporary; | 189 | to.Temporary = from.Temporary; |
190 | to.Type = from.Type; | 190 | to.Type = from.Type; |
191 | 191 | ||
192 | } | 192 | } |
193 | 193 | ||
194 | private void _guardedAdd(Dictionary<UUID, bool> lst, UUID obj, bool val) | 194 | private void _guardedAdd(Dictionary<UUID, bool> lst, UUID obj, bool val) |
195 | { | 195 | { |
196 | if (!lst.ContainsKey(obj)) | 196 | if (!lst.ContainsKey(obj)) |
197 | lst.Add(obj, val); | 197 | lst.Add(obj, val); |
198 | } | 198 | } |
199 | 199 | ||
200 | private void SniffTextureUUIDs(Dictionary<UUID, bool> uuids, SceneObjectGroup sog) | 200 | private void SniffTextureUUIDs(Dictionary<UUID, bool> uuids, SceneObjectGroup sog) |
201 | { | 201 | { |
202 | try | 202 | try |
203 | { | 203 | { |
204 | _guardedAdd(uuids, sog.RootPart.Shape.Textures.DefaultTexture.TextureID, true); | 204 | _guardedAdd(uuids, sog.RootPart.Shape.Textures.DefaultTexture.TextureID, true); |
205 | } | 205 | } |
206 | catch (Exception) { } | 206 | catch (Exception) { } |
207 | 207 | ||
208 | foreach (Primitive.TextureEntryFace tface in sog.RootPart.Shape.Textures.FaceTextures) | 208 | foreach (Primitive.TextureEntryFace tface in sog.RootPart.Shape.Textures.FaceTextures) |
209 | { | 209 | { |
210 | try | 210 | try |
211 | { | 211 | { |
212 | _guardedAdd(uuids, tface.TextureID, true); | 212 | _guardedAdd(uuids, tface.TextureID, true); |
213 | } | 213 | } |
214 | catch (Exception) { } | 214 | catch (Exception) { } |
215 | } | 215 | } |
216 | 216 | ||
217 | foreach (SceneObjectPart sop in sog.Children.Values) | 217 | foreach (SceneObjectPart sop in sog.Children.Values) |
218 | { | 218 | { |
219 | try | 219 | try |
220 | { | 220 | { |
221 | _guardedAdd(uuids, sop.Shape.Textures.DefaultTexture.TextureID, true); | 221 | _guardedAdd(uuids, sop.Shape.Textures.DefaultTexture.TextureID, true); |
222 | } | 222 | } |
223 | catch (Exception) { } | 223 | catch (Exception) { } |
224 | foreach (Primitive.TextureEntryFace tface in sop.Shape.Textures.FaceTextures) | 224 | foreach (Primitive.TextureEntryFace tface in sop.Shape.Textures.FaceTextures) |
225 | { | 225 | { |
226 | try | 226 | try |
227 | { | 227 | { |
228 | _guardedAdd(uuids, tface.TextureID, true); | 228 | _guardedAdd(uuids, tface.TextureID, true); |
229 | } | 229 | } |
230 | catch (Exception) { } | 230 | catch (Exception) { } |
231 | } | 231 | } |
232 | } | 232 | } |
233 | } | 233 | } |
234 | 234 | ||
235 | private void SniffTaskInventoryUUIDs(Dictionary<UUID, bool> uuids, SceneObjectGroup sog) | 235 | private void SniffTaskInventoryUUIDs(Dictionary<UUID, bool> uuids, SceneObjectGroup sog) |
236 | { | 236 | { |
237 | TaskInventoryDictionary tinv = sog.RootPart.TaskInventory; | 237 | TaskInventoryDictionary tinv = sog.RootPart.TaskInventory; |
238 | 238 | ||
239 | foreach (TaskInventoryItem titem in tinv.Values) | 239 | foreach (TaskInventoryItem titem in tinv.Values) |
240 | { | 240 | { |
241 | uuids.Add(titem.AssetID, (InventoryType)titem.Type == InventoryType.Texture); | 241 | uuids.Add(titem.AssetID, (InventoryType)titem.Type == InventoryType.Texture); |
242 | } | 242 | } |
243 | } | 243 | } |
244 | 244 | ||
245 | private Dictionary<UUID, bool> SniffUUIDs(AssetBase asset) | 245 | private Dictionary<UUID, bool> SniffUUIDs(AssetBase asset) |
246 | { | 246 | { |
247 | Dictionary<UUID, bool> uuids = new Dictionary<UUID, bool>(); | 247 | Dictionary<UUID, bool> uuids = new Dictionary<UUID, bool>(); |
248 | if ((asset != null) && ((AssetType)asset.Type == AssetType.Object)) | 248 | if ((asset != null) && ((AssetType)asset.Type == AssetType.Object)) |
249 | { | 249 | { |
250 | string ass_str = Utils.BytesToString(asset.Data); | 250 | string ass_str = Utils.BytesToString(asset.Data); |
251 | SceneObjectGroup sog = new SceneObjectGroup(ass_str, true); | 251 | SceneObjectGroup sog = new SceneObjectGroup(ass_str, true); |
252 | 252 | ||
253 | SniffTextureUUIDs(uuids, sog); | 253 | SniffTextureUUIDs(uuids, sog); |
254 | 254 | ||
255 | // We need to sniff further... | 255 | // We need to sniff further... |
256 | SniffTaskInventoryUUIDs(uuids, sog); | 256 | SniffTaskInventoryUUIDs(uuids, sog); |
257 | 257 | ||
258 | } | 258 | } |
259 | 259 | ||
260 | return uuids; | 260 | return uuids; |
261 | } | 261 | } |
262 | 262 | ||
263 | private Dictionary<UUID, bool> SniffUUIDs(UUID assetID) | 263 | private Dictionary<UUID, bool> SniffUUIDs(UUID assetID) |
264 | { | 264 | { |
265 | //Dictionary<UUID, bool> uuids = new Dictionary<UUID, bool>(); | 265 | //Dictionary<UUID, bool> uuids = new Dictionary<UUID, bool>(); |
266 | 266 | ||
267 | AssetBase asset; | 267 | AssetBase asset; |
268 | m_scene.CommsManager.AssetCache.TryGetCachedAsset(assetID, out asset); | 268 | m_scene.CommsManager.AssetCache.TryGetCachedAsset(assetID, out asset); |
269 | 269 | ||
270 | return SniffUUIDs(asset); | 270 | return SniffUUIDs(asset); |
271 | } | 271 | } |
272 | 272 | ||
273 | private void Dump(Dictionary<UUID, bool> lst) | 273 | private void Dump(Dictionary<UUID, bool> lst) |
274 | { | 274 | { |
275 | m_log.Debug("XXX -------- UUID DUMP ------- XXX"); | 275 | m_log.Debug("XXX -------- UUID DUMP ------- XXX"); |
276 | foreach (KeyValuePair<UUID, bool> kvp in lst) | 276 | foreach (KeyValuePair<UUID, bool> kvp in lst) |
277 | m_log.Debug(" >> " + kvp.Key + " (texture? " + kvp.Value + ")"); | 277 | m_log.Debug(" >> " + kvp.Key + " (texture? " + kvp.Value + ")"); |
278 | m_log.Debug("XXX -------- UUID DUMP ------- XXX"); | 278 | m_log.Debug("XXX -------- UUID DUMP ------- XXX"); |
279 | } | 279 | } |
280 | 280 | ||
281 | #endregion | 281 | #endregion |
282 | 282 | ||
283 | 283 | ||
284 | #region Public interface | 284 | #region Public interface |
285 | 285 | ||
286 | public void Get(UUID itemID, UUID ownerID) | 286 | public void Get(UUID itemID, UUID ownerID) |
287 | { | 287 | { |
288 | if (!IsInAssetMap(itemID) && !IsHomeUser(ownerID)) | 288 | if (!IsInAssetMap(itemID) && !IsHomeUser(ownerID)) |
289 | { | 289 | { |
290 | // Get the item from the remote asset server onto the local AssetCache | 290 | // Get the item from the remote asset server onto the local AssetCache |
291 | // and place an entry in m_assetMap | 291 | // and place an entry in m_assetMap |
292 | 292 | ||
293 | GridAssetClient asscli = null; | 293 | GridAssetClient asscli = null; |
294 | string userAssetURL = UserAssetURL(ownerID); | 294 | string userAssetURL = UserAssetURL(ownerID); |
295 | if (userAssetURL != null) | 295 | if (userAssetURL != null) |
296 | { | 296 | { |
297 | m_assetServers.TryGetValue(userAssetURL, out asscli); | 297 | m_assetServers.TryGetValue(userAssetURL, out asscli); |
298 | if (asscli == null) | 298 | if (asscli == null) |
299 | { | 299 | { |
300 | m_log.Debug("[HGScene]: Starting new GridAssetClient for " + userAssetURL); | 300 | m_log.Debug("[HGScene]: Starting new GridAssetClient for " + userAssetURL); |
301 | asscli = new GridAssetClient(userAssetURL); | 301 | asscli = new GridAssetClient(userAssetURL); |
302 | asscli.SetReceiver(m_scene.CommsManager.AssetCache); // Straight to the asset cache! | 302 | asscli.SetReceiver(m_scene.CommsManager.AssetCache); // Straight to the asset cache! |
303 | m_assetServers.Add(userAssetURL, asscli); | 303 | m_assetServers.Add(userAssetURL, asscli); |
304 | } | 304 | } |
305 | 305 | ||
306 | m_log.Debug("[HGScene]: Fetching object " + itemID + " to asset server " + userAssetURL); | 306 | m_log.Debug("[HGScene]: Fetching object " + itemID + " to asset server " + userAssetURL); |
307 | bool success = FetchAsset(asscli, itemID, false); // asscli.RequestAsset(item.ItemID, false); | 307 | bool success = FetchAsset(asscli, itemID, false); // asscli.RequestAsset(item.ItemID, false); |
308 | 308 | ||
309 | // OK, now fetch the inside. | 309 | // OK, now fetch the inside. |
310 | Dictionary<UUID, bool> ids = SniffUUIDs(itemID); | 310 | Dictionary<UUID, bool> ids = SniffUUIDs(itemID); |
311 | Dump(ids); | 311 | Dump(ids); |
312 | foreach (KeyValuePair<UUID, bool> kvp in ids) | 312 | foreach (KeyValuePair<UUID, bool> kvp in ids) |
313 | FetchAsset(asscli, kvp.Key, kvp.Value); | 313 | FetchAsset(asscli, kvp.Key, kvp.Value); |
314 | 314 | ||
315 | 315 | ||
316 | if (success) | 316 | if (success) |
317 | { | 317 | { |
318 | m_log.Debug("[HGScene]: Successfully fetched item from remote asset server " + userAssetURL); | 318 | m_log.Debug("[HGScene]: Successfully fetched item from remote asset server " + userAssetURL); |
319 | m_assetMap.Add(itemID, asscli); | 319 | m_assetMap.Add(itemID, asscli); |
320 | } | 320 | } |
321 | else | 321 | else |
322 | m_log.Warn("[HGScene]: Could not fetch asset from remote asset server " + userAssetURL); | 322 | m_log.Warn("[HGScene]: Could not fetch asset from remote asset server " + userAssetURL); |
323 | } | 323 | } |
324 | else | 324 | else |
325 | m_log.Warn("[HGScene]: Unable to locate foreign user's asset server"); | 325 | m_log.Warn("[HGScene]: Unable to locate foreign user's asset server"); |
326 | } | 326 | } |
327 | } | 327 | } |
328 | 328 | ||
329 | public void Post(UUID itemID, UUID ownerID) | 329 | public void Post(UUID itemID, UUID ownerID) |
330 | { | 330 | { |
331 | if (!IsHomeUser(ownerID)) | 331 | if (!IsHomeUser(ownerID)) |
332 | { | 332 | { |
333 | // Post the item from the local AssetCache ontp the remote asset server | 333 | // Post the item from the local AssetCache ontp the remote asset server |
334 | // and place an entry in m_assetMap | 334 | // and place an entry in m_assetMap |
335 | 335 | ||
336 | GridAssetClient asscli = null; | 336 | GridAssetClient asscli = null; |
337 | string userAssetURL = UserAssetURL(ownerID); | 337 | string userAssetURL = UserAssetURL(ownerID); |
338 | if (userAssetURL != null) | 338 | if (userAssetURL != null) |
339 | { | 339 | { |
340 | m_assetServers.TryGetValue(userAssetURL, out asscli); | 340 | m_assetServers.TryGetValue(userAssetURL, out asscli); |
341 | if (asscli == null) | 341 | if (asscli == null) |
342 | { | 342 | { |
343 | m_log.Debug("[HGScene]: Starting new GridAssetClient for " + userAssetURL); | 343 | m_log.Debug("[HGScene]: Starting new GridAssetClient for " + userAssetURL); |
344 | asscli = new GridAssetClient(userAssetURL); | 344 | asscli = new GridAssetClient(userAssetURL); |
345 | asscli.SetReceiver(m_scene.CommsManager.AssetCache); // Straight to the asset cache! | 345 | asscli.SetReceiver(m_scene.CommsManager.AssetCache); // Straight to the asset cache! |
346 | m_assetServers.Add(userAssetURL, asscli); | 346 | m_assetServers.Add(userAssetURL, asscli); |
347 | } | 347 | } |
348 | m_log.Debug("[HGScene]: Posting object " + itemID + " to asset server " + userAssetURL); | 348 | m_log.Debug("[HGScene]: Posting object " + itemID + " to asset server " + userAssetURL); |
349 | bool success = PostAsset(asscli, itemID); | 349 | bool success = PostAsset(asscli, itemID); |
350 | 350 | ||
351 | // Now the inside | 351 | // Now the inside |
352 | Dictionary<UUID, bool> ids = SniffUUIDs(itemID); | 352 | Dictionary<UUID, bool> ids = SniffUUIDs(itemID); |
353 | Dump(ids); | 353 | Dump(ids); |
354 | foreach (KeyValuePair<UUID, bool> kvp in ids) | 354 | foreach (KeyValuePair<UUID, bool> kvp in ids) |
355 | PostAsset(asscli, kvp.Key); | 355 | PostAsset(asscli, kvp.Key); |
356 | 356 | ||
357 | if (success) | 357 | if (success) |
358 | { | 358 | { |
359 | m_log.Debug("[HGScene]: Successfully posted item to remote asset server " + userAssetURL); | 359 | m_log.Debug("[HGScene]: Successfully posted item to remote asset server " + userAssetURL); |
360 | m_assetMap.Add(itemID, asscli); | 360 | m_assetMap.Add(itemID, asscli); |
361 | } | 361 | } |
362 | else | 362 | else |
363 | m_log.Warn("[HGScene]: Could not post asset to remote asset server " + userAssetURL); | 363 | m_log.Warn("[HGScene]: Could not post asset to remote asset server " + userAssetURL); |
364 | 364 | ||
365 | //if (!m_assetMap.ContainsKey(itemID)) | 365 | //if (!m_assetMap.ContainsKey(itemID)) |
366 | // m_assetMap.Add(itemID, asscli); | 366 | // m_assetMap.Add(itemID, asscli); |
367 | } | 367 | } |
368 | else | 368 | else |
369 | m_log.Warn("[HGScene]: Unable to locate foreign user's asset server"); | 369 | m_log.Warn("[HGScene]: Unable to locate foreign user's asset server"); |
370 | 370 | ||
371 | } | 371 | } |
372 | } | 372 | } |
373 | 373 | ||
374 | #endregion | 374 | #endregion |
375 | 375 | ||
376 | } | 376 | } |
377 | } | 377 | } |
diff --git a/OpenSim/Region/Environment/Scenes/Hypergrid/HGScene.Inventory.cs b/OpenSim/Region/Environment/Scenes/Hypergrid/HGScene.Inventory.cs index af3c04f..92627d1 100644 --- a/OpenSim/Region/Environment/Scenes/Hypergrid/HGScene.Inventory.cs +++ b/OpenSim/Region/Environment/Scenes/Hypergrid/HGScene.Inventory.cs | |||
@@ -1,152 +1,152 @@ | |||
1 | /** | 1 | /** |
2 | * Copyright (c) 2008, Contributors. All rights reserved. | 2 | * Copyright (c) 2008, Contributors. All rights reserved. |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without modification, | 5 | * Redistribution and use in source and binary forms, with or without modification, |
6 | * are permitted provided that the following conditions are met: | 6 | * are permitted provided that the following conditions are met: |
7 | * | 7 | * |
8 | * * Redistributions of source code must retain the above copyright notice, | 8 | * * Redistributions of source code must retain the above copyright notice, |
9 | * this list of conditions and the following disclaimer. | 9 | * this list of conditions and the following disclaimer. |
10 | * * Redistributions in binary form must reproduce the above copyright notice, | 10 | * * Redistributions in binary form must reproduce the above copyright notice, |
11 | * this list of conditions and the following disclaimer in the documentation | 11 | * this list of conditions and the following disclaimer in the documentation |
12 | * and/or other materials provided with the distribution. | 12 | * and/or other materials provided with the distribution. |
13 | * * Neither the name of the Organizations nor the names of Individual | 13 | * * Neither the name of the Organizations nor the names of Individual |
14 | * Contributors may be used to endorse or promote products derived from | 14 | * Contributors may be used to endorse or promote products derived from |
15 | * this software without specific prior written permission. | 15 | * this software without specific prior written permission. |
16 | * | 16 | * |
17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL | 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL |
20 | * THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 20 | * THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
21 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE | 21 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE |
22 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED | 22 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED |
23 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | 23 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
24 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | 24 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED |
25 | * OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | 28 | ||
29 | using System; | 29 | using System; |
30 | using System.Collections; | 30 | using System.Collections; |
31 | using System.Collections.Generic; | 31 | using System.Collections.Generic; |
32 | using System.Reflection; | 32 | using System.Reflection; |
33 | using System.Threading; | 33 | using System.Threading; |
34 | 34 | ||
35 | using log4net; | 35 | using log4net; |
36 | using Nini.Config; | 36 | using Nini.Config; |
37 | using OpenMetaverse; | 37 | using OpenMetaverse; |
38 | 38 | ||
39 | using OpenSim.Framework; | 39 | using OpenSim.Framework; |
40 | using OpenSim.Framework.Communications; | 40 | using OpenSim.Framework.Communications; |
41 | using OpenSim.Framework.Communications.Cache; | 41 | using OpenSim.Framework.Communications.Cache; |
42 | using OpenSim.Framework.Servers; | 42 | using OpenSim.Framework.Servers; |
43 | using OpenSim.Region.Environment; | 43 | using OpenSim.Region.Environment; |
44 | using OpenSim.Region.Environment.Scenes; | 44 | using OpenSim.Region.Environment.Scenes; |
45 | 45 | ||
46 | namespace OpenSim.Region.Environment.Scenes.Hypergrid | 46 | namespace OpenSim.Region.Environment.Scenes.Hypergrid |
47 | { | 47 | { |
48 | public partial class HGScene : Scene | 48 | public partial class HGScene : Scene |
49 | { | 49 | { |
50 | #region Fields | 50 | #region Fields |
51 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 51 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
52 | 52 | ||
53 | private HGAssetMapper m_assMapper; | 53 | private HGAssetMapper m_assMapper; |
54 | 54 | ||
55 | #endregion | 55 | #endregion |
56 | 56 | ||
57 | #region Constructors | 57 | #region Constructors |
58 | 58 | ||
59 | public HGScene(RegionInfo regInfo, AgentCircuitManager authen, | 59 | public HGScene(RegionInfo regInfo, AgentCircuitManager authen, |
60 | CommunicationsManager commsMan, SceneCommunicationService sceneGridService, | 60 | CommunicationsManager commsMan, SceneCommunicationService sceneGridService, |
61 | AssetCache assetCach, StorageManager storeManager, BaseHttpServer httpServer, | 61 | AssetCache assetCach, StorageManager storeManager, BaseHttpServer httpServer, |
62 | ModuleLoader moduleLoader, bool dumpAssetsToFile, bool physicalPrim, | 62 | ModuleLoader moduleLoader, bool dumpAssetsToFile, bool physicalPrim, |
63 | bool SeeIntoRegionFromNeighbor, IConfigSource config, string simulatorVersion) | 63 | bool SeeIntoRegionFromNeighbor, IConfigSource config, string simulatorVersion) |
64 | : base(regInfo, authen, commsMan, sceneGridService, assetCach, storeManager, httpServer, moduleLoader, | 64 | : base(regInfo, authen, commsMan, sceneGridService, assetCach, storeManager, httpServer, moduleLoader, |
65 | dumpAssetsToFile, physicalPrim, SeeIntoRegionFromNeighbor, config, simulatorVersion) | 65 | dumpAssetsToFile, physicalPrim, SeeIntoRegionFromNeighbor, config, simulatorVersion) |
66 | { | 66 | { |
67 | m_log.Info("[HGScene]: Starting HGScene."); | 67 | m_log.Info("[HGScene]: Starting HGScene."); |
68 | m_assMapper = new HGAssetMapper(this); | 68 | m_assMapper = new HGAssetMapper(this); |
69 | 69 | ||
70 | EventManager.OnNewInventoryItemUploadComplete += UploadInventoryItem; | 70 | EventManager.OnNewInventoryItemUploadComplete += UploadInventoryItem; |
71 | } | 71 | } |
72 | 72 | ||
73 | #endregion | 73 | #endregion |
74 | 74 | ||
75 | #region Event handlers | 75 | #region Event handlers |
76 | 76 | ||
77 | public void UploadInventoryItem(UUID avatarID, UUID assetID, string name, int userlevel) | 77 | public void UploadInventoryItem(UUID avatarID, UUID assetID, string name, int userlevel) |
78 | { | 78 | { |
79 | CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(avatarID); | 79 | CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(avatarID); |
80 | if (userInfo != null) | 80 | if (userInfo != null) |
81 | { | 81 | { |
82 | m_assMapper.Post(assetID, avatarID); | 82 | m_assMapper.Post(assetID, avatarID); |
83 | } | 83 | } |
84 | } | 84 | } |
85 | 85 | ||
86 | #endregion | 86 | #endregion |
87 | 87 | ||
88 | #region Overrides of Scene.Inventory methods | 88 | #region Overrides of Scene.Inventory methods |
89 | 89 | ||
90 | /// | 90 | /// |
91 | /// CapsUpdateInventoryItemAsset | 91 | /// CapsUpdateInventoryItemAsset |
92 | /// | 92 | /// |
93 | public override UUID CapsUpdateInventoryItemAsset(IClientAPI remoteClient, UUID itemID, byte[] data) | 93 | public override UUID CapsUpdateInventoryItemAsset(IClientAPI remoteClient, UUID itemID, byte[] data) |
94 | { | 94 | { |
95 | UUID newAssetID = base.CapsUpdateInventoryItemAsset(remoteClient, itemID, data); | 95 | UUID newAssetID = base.CapsUpdateInventoryItemAsset(remoteClient, itemID, data); |
96 | 96 | ||
97 | UploadInventoryItem(remoteClient.AgentId, newAssetID, "", 0); | 97 | UploadInventoryItem(remoteClient.AgentId, newAssetID, "", 0); |
98 | 98 | ||
99 | return newAssetID; | 99 | return newAssetID; |
100 | } | 100 | } |
101 | 101 | ||
102 | /// | 102 | /// |
103 | /// DeleteToInventory | 103 | /// DeleteToInventory |
104 | /// | 104 | /// |
105 | public override UUID DeleteToInventory(int destination, UUID folderID, SceneObjectGroup objectGroup, IClientAPI remoteClient) | 105 | public override UUID DeleteToInventory(int destination, UUID folderID, SceneObjectGroup objectGroup, IClientAPI remoteClient) |
106 | { | 106 | { |
107 | UUID assetID = base.DeleteToInventory(destination, folderID, objectGroup, remoteClient); | 107 | UUID assetID = base.DeleteToInventory(destination, folderID, objectGroup, remoteClient); |
108 | 108 | ||
109 | if (!assetID.Equals(UUID.Zero)) | 109 | if (!assetID.Equals(UUID.Zero)) |
110 | { | 110 | { |
111 | UploadInventoryItem(remoteClient.AgentId, assetID, "", 0); | 111 | UploadInventoryItem(remoteClient.AgentId, assetID, "", 0); |
112 | } | 112 | } |
113 | else | 113 | else |
114 | m_log.Debug("[HGScene]: Scene.Inventory did not create asset"); | 114 | m_log.Debug("[HGScene]: Scene.Inventory did not create asset"); |
115 | 115 | ||
116 | return assetID; | 116 | return assetID; |
117 | } | 117 | } |
118 | 118 | ||
119 | /// | 119 | /// |
120 | /// RezObject | 120 | /// RezObject |
121 | /// | 121 | /// |
122 | public override SceneObjectGroup RezObject(IClientAPI remoteClient, UUID itemID, Vector3 RayEnd, Vector3 RayStart, | 122 | public override SceneObjectGroup RezObject(IClientAPI remoteClient, UUID itemID, Vector3 RayEnd, Vector3 RayStart, |
123 | UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection, | 123 | UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection, |
124 | bool RezSelected, bool RemoveItem, UUID fromTaskID, bool attachment) | 124 | bool RezSelected, bool RemoveItem, UUID fromTaskID, bool attachment) |
125 | { | 125 | { |
126 | CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId); | 126 | CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId); |
127 | if (userInfo != null) | 127 | if (userInfo != null) |
128 | { | 128 | { |
129 | if (userInfo.RootFolder != null) | 129 | if (userInfo.RootFolder != null) |
130 | { | 130 | { |
131 | InventoryItemBase item = userInfo.RootFolder.FindItem(itemID); | 131 | InventoryItemBase item = userInfo.RootFolder.FindItem(itemID); |
132 | 132 | ||
133 | if (item != null) | 133 | if (item != null) |
134 | { | 134 | { |
135 | m_assMapper.Get(item.AssetID, remoteClient.AgentId); | 135 | m_assMapper.Get(item.AssetID, remoteClient.AgentId); |
136 | 136 | ||
137 | } | 137 | } |
138 | } | 138 | } |
139 | } | 139 | } |
140 | 140 | ||
141 | // OK, we're done fetching. Pass it up to the default RezObject | 141 | // OK, we're done fetching. Pass it up to the default RezObject |
142 | return base.RezObject(remoteClient, itemID, RayEnd, RayStart, RayTargetID, BypassRayCast, RayEndIsIntersection, | 142 | return base.RezObject(remoteClient, itemID, RayEnd, RayStart, RayTargetID, BypassRayCast, RayEndIsIntersection, |
143 | RezSelected, RemoveItem, fromTaskID, attachment); | 143 | RezSelected, RemoveItem, fromTaskID, attachment); |
144 | 144 | ||
145 | } | 145 | } |
146 | 146 | ||
147 | 147 | ||
148 | #endregion | 148 | #endregion |
149 | 149 | ||
150 | } | 150 | } |
151 | 151 | ||
152 | } | 152 | } |
diff --git a/OpenSim/Region/Environment/Scenes/Hypergrid/HGScene.cs b/OpenSim/Region/Environment/Scenes/Hypergrid/HGScene.cs index a1a6173..da1d3a7 100644 --- a/OpenSim/Region/Environment/Scenes/Hypergrid/HGScene.cs +++ b/OpenSim/Region/Environment/Scenes/Hypergrid/HGScene.cs | |||
@@ -1,78 +1,78 @@ | |||
1 | /** | 1 | /** |
2 | * Copyright (c) 2008, Contributors. All rights reserved. | 2 | * Copyright (c) 2008, Contributors. All rights reserved. |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without modification, | 5 | * Redistribution and use in source and binary forms, with or without modification, |
6 | * are permitted provided that the following conditions are met: | 6 | * are permitted provided that the following conditions are met: |
7 | * | 7 | * |
8 | * * Redistributions of source code must retain the above copyright notice, | 8 | * * Redistributions of source code must retain the above copyright notice, |
9 | * this list of conditions and the following disclaimer. | 9 | * this list of conditions and the following disclaimer. |
10 | * * Redistributions in binary form must reproduce the above copyright notice, | 10 | * * Redistributions in binary form must reproduce the above copyright notice, |
11 | * this list of conditions and the following disclaimer in the documentation | 11 | * this list of conditions and the following disclaimer in the documentation |
12 | * and/or other materials provided with the distribution. | 12 | * and/or other materials provided with the distribution. |
13 | * * Neither the name of the Organizations nor the names of Individual | 13 | * * Neither the name of the Organizations nor the names of Individual |
14 | * Contributors may be used to endorse or promote products derived from | 14 | * Contributors may be used to endorse or promote products derived from |
15 | * this software without specific prior written permission. | 15 | * this software without specific prior written permission. |
16 | * | 16 | * |
17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL | 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL |
20 | * THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 20 | * THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
21 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE | 21 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE |
22 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED | 22 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED |
23 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | 23 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
24 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | 24 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED |
25 | * OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | 28 | ||
29 | using System; | 29 | using System; |
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | 31 | ||
32 | using OpenMetaverse; | 32 | using OpenMetaverse; |
33 | 33 | ||
34 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
35 | 35 | ||
36 | using OpenSim.Framework.Communications.Cache; | 36 | using OpenSim.Framework.Communications.Cache; |
37 | using OpenSim.Region.Environment; | 37 | using OpenSim.Region.Environment; |
38 | using OpenSim.Region.Environment.Scenes; | 38 | using OpenSim.Region.Environment.Scenes; |
39 | using TPFlags = OpenSim.Framework.Constants.TeleportFlags; | 39 | using TPFlags = OpenSim.Framework.Constants.TeleportFlags; |
40 | 40 | ||
41 | namespace OpenSim.Region.Environment.Scenes.Hypergrid | 41 | namespace OpenSim.Region.Environment.Scenes.Hypergrid |
42 | { | 42 | { |
43 | public partial class HGScene : Scene | 43 | public partial class HGScene : Scene |
44 | { | 44 | { |
45 | /// <summary> | 45 | /// <summary> |
46 | /// Teleport an avatar to their home region | 46 | /// Teleport an avatar to their home region |
47 | /// </summary> | 47 | /// </summary> |
48 | /// <param name="agentId"></param> | 48 | /// <param name="agentId"></param> |
49 | /// <param name="client"></param> | 49 | /// <param name="client"></param> |
50 | public override void TeleportClientHome(UUID agentId, IClientAPI client) | 50 | public override void TeleportClientHome(UUID agentId, IClientAPI client) |
51 | { | 51 | { |
52 | m_log.Debug("[HGScene]: TeleportClientHome " + client.FirstName + " " + client.LastName); | 52 | m_log.Debug("[HGScene]: TeleportClientHome " + client.FirstName + " " + client.LastName); |
53 | 53 | ||
54 | CachedUserInfo uinfo = CommsManager.UserProfileCacheService.GetUserDetails(agentId); | 54 | CachedUserInfo uinfo = CommsManager.UserProfileCacheService.GetUserDetails(agentId); |
55 | UserProfileData UserProfile = uinfo.UserProfile; | 55 | UserProfileData UserProfile = uinfo.UserProfile; |
56 | 56 | ||
57 | if (UserProfile != null) | 57 | if (UserProfile != null) |
58 | { | 58 | { |
59 | RegionInfo regionInfo = CommsManager.GridService.RequestNeighbourInfo(UserProfile.HomeRegion); | 59 | RegionInfo regionInfo = CommsManager.GridService.RequestNeighbourInfo(UserProfile.HomeRegion); |
60 | //if (regionInfo != null) | 60 | //if (regionInfo != null) |
61 | //{ | 61 | //{ |
62 | // UserProfile.HomeRegionID = regionInfo.RegionID; | 62 | // UserProfile.HomeRegionID = regionInfo.RegionID; |
63 | // //CommsManager.UserService.UpdateUserProfile(UserProfile); | 63 | // //CommsManager.UserService.UpdateUserProfile(UserProfile); |
64 | //} | 64 | //} |
65 | if (regionInfo == null) | 65 | if (regionInfo == null) |
66 | { | 66 | { |
67 | // can't find the Home region: Tell viewer and abort | 67 | // can't find the Home region: Tell viewer and abort |
68 | client.SendTeleportFailed("Your home-region could not be found."); | 68 | client.SendTeleportFailed("Your home-region could not be found."); |
69 | return; | 69 | return; |
70 | } | 70 | } |
71 | RequestTeleportLocation( | 71 | RequestTeleportLocation( |
72 | client, regionInfo.RegionHandle, UserProfile.HomeLocation, UserProfile.HomeLookAt, | 72 | client, regionInfo.RegionHandle, UserProfile.HomeLocation, UserProfile.HomeLookAt, |
73 | (uint)(TPFlags.SetLastToTarget | TPFlags.ViaHome)); | 73 | (uint)(TPFlags.SetLastToTarget | TPFlags.ViaHome)); |
74 | } | 74 | } |
75 | } | 75 | } |
76 | 76 | ||
77 | } | 77 | } |
78 | } | 78 | } |
diff --git a/OpenSim/Region/Environment/Scenes/Hypergrid/HGSceneCommunicationService.cs b/OpenSim/Region/Environment/Scenes/Hypergrid/HGSceneCommunicationService.cs index 501584a..9eb331a 100644 --- a/OpenSim/Region/Environment/Scenes/Hypergrid/HGSceneCommunicationService.cs +++ b/OpenSim/Region/Environment/Scenes/Hypergrid/HGSceneCommunicationService.cs | |||
@@ -1,263 +1,263 @@ | |||
1 | /** | 1 | /** |
2 | * Copyright (c) 2008, Contributors. All rights reserved. | 2 | * Copyright (c) 2008, Contributors. All rights reserved. |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without modification, | 5 | * Redistribution and use in source and binary forms, with or without modification, |
6 | * are permitted provided that the following conditions are met: | 6 | * are permitted provided that the following conditions are met: |
7 | * | 7 | * |
8 | * * Redistributions of source code must retain the above copyright notice, | 8 | * * Redistributions of source code must retain the above copyright notice, |
9 | * this list of conditions and the following disclaimer. | 9 | * this list of conditions and the following disclaimer. |
10 | * * Redistributions in binary form must reproduce the above copyright notice, | 10 | * * Redistributions in binary form must reproduce the above copyright notice, |
11 | * this list of conditions and the following disclaimer in the documentation | 11 | * this list of conditions and the following disclaimer in the documentation |
12 | * and/or other materials provided with the distribution. | 12 | * and/or other materials provided with the distribution. |
13 | * * Neither the name of the Organizations nor the names of Individual | 13 | * * Neither the name of the Organizations nor the names of Individual |
14 | * Contributors may be used to endorse or promote products derived from | 14 | * Contributors may be used to endorse or promote products derived from |
15 | * this software without specific prior written permission. | 15 | * this software without specific prior written permission. |
16 | * | 16 | * |
17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL | 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL |
20 | * THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 20 | * THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
21 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE | 21 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE |
22 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED | 22 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED |
23 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | 23 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
24 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | 24 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED |
25 | * OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | 28 | ||
29 | using System; | 29 | using System; |
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using System.Reflection; | 31 | using System.Reflection; |
32 | using System.Threading; | 32 | using System.Threading; |
33 | 33 | ||
34 | using OpenMetaverse; | 34 | using OpenMetaverse; |
35 | 35 | ||
36 | using log4net; | 36 | using log4net; |
37 | using OpenSim.Framework; | 37 | using OpenSim.Framework; |
38 | using OpenSim.Framework.Communications; | 38 | using OpenSim.Framework.Communications; |
39 | using OpenSim.Framework.Communications.Cache; | 39 | using OpenSim.Framework.Communications.Cache; |
40 | using OpenSim.Region.Environment.Scenes; | 40 | using OpenSim.Region.Environment.Scenes; |
41 | using OpenSim.Region.Environment; | 41 | using OpenSim.Region.Environment; |
42 | using OpenSim.Region.Interfaces; | 42 | using OpenSim.Region.Interfaces; |
43 | using OSD = OpenMetaverse.StructuredData.OSD; | 43 | using OSD = OpenMetaverse.StructuredData.OSD; |
44 | 44 | ||
45 | namespace OpenSim.Region.Environment.Scenes.Hypergrid | 45 | namespace OpenSim.Region.Environment.Scenes.Hypergrid |
46 | { | 46 | { |
47 | public class HGSceneCommunicationService : SceneCommunicationService | 47 | public class HGSceneCommunicationService : SceneCommunicationService |
48 | { | 48 | { |
49 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 49 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
50 | 50 | ||
51 | private IHyperlink m_hg; | 51 | private IHyperlink m_hg; |
52 | 52 | ||
53 | public HGSceneCommunicationService(CommunicationsManager commsMan, IHyperlink hg) : base(commsMan) | 53 | public HGSceneCommunicationService(CommunicationsManager commsMan, IHyperlink hg) : base(commsMan) |
54 | { | 54 | { |
55 | m_hg = hg; | 55 | m_hg = hg; |
56 | } | 56 | } |
57 | 57 | ||
58 | 58 | ||
59 | /// <summary> | 59 | /// <summary> |
60 | /// Try to teleport an agent to a new region. | 60 | /// Try to teleport an agent to a new region. |
61 | /// </summary> | 61 | /// </summary> |
62 | /// <param name="remoteClient"></param> | 62 | /// <param name="remoteClient"></param> |
63 | /// <param name="RegionHandle"></param> | 63 | /// <param name="RegionHandle"></param> |
64 | /// <param name="position"></param> | 64 | /// <param name="position"></param> |
65 | /// <param name="lookAt"></param> | 65 | /// <param name="lookAt"></param> |
66 | /// <param name="flags"></param> | 66 | /// <param name="flags"></param> |
67 | public override void RequestTeleportToLocation(ScenePresence avatar, ulong regionHandle, Vector3 position, | 67 | public override void RequestTeleportToLocation(ScenePresence avatar, ulong regionHandle, Vector3 position, |
68 | Vector3 lookAt, uint teleportFlags) | 68 | Vector3 lookAt, uint teleportFlags) |
69 | { | 69 | { |
70 | if (!avatar.Scene.Permissions.CanTeleport(avatar.UUID)) | 70 | if (!avatar.Scene.Permissions.CanTeleport(avatar.UUID)) |
71 | return; | 71 | return; |
72 | 72 | ||
73 | bool destRegionUp = false; | 73 | bool destRegionUp = false; |
74 | 74 | ||
75 | IEventQueue eq = avatar.Scene.RequestModuleInterface<IEventQueue>(); | 75 | IEventQueue eq = avatar.Scene.RequestModuleInterface<IEventQueue>(); |
76 | 76 | ||
77 | if (regionHandle == m_regionInfo.RegionHandle) | 77 | if (regionHandle == m_regionInfo.RegionHandle) |
78 | { | 78 | { |
79 | // Teleport within the same region | 79 | // Teleport within the same region |
80 | if (position.X < 0 || position.X > Constants.RegionSize || position.Y < 0 || position.Y > Constants.RegionSize || position.Z < 0) | 80 | if (position.X < 0 || position.X > Constants.RegionSize || position.Y < 0 || position.Y > Constants.RegionSize || position.Z < 0) |
81 | { | 81 | { |
82 | Vector3 emergencyPos = new Vector3(128, 128, 128); | 82 | Vector3 emergencyPos = new Vector3(128, 128, 128); |
83 | 83 | ||
84 | m_log.WarnFormat( | 84 | m_log.WarnFormat( |
85 | "[HGSceneCommService]: RequestTeleportToLocation() was given an illegal position of {0} for avatar {1}, {2}. Substituting {3}", | 85 | "[HGSceneCommService]: RequestTeleportToLocation() was given an illegal position of {0} for avatar {1}, {2}. Substituting {3}", |
86 | position, avatar.Name, avatar.UUID, emergencyPos); | 86 | position, avatar.Name, avatar.UUID, emergencyPos); |
87 | position = emergencyPos; | 87 | position = emergencyPos; |
88 | } | 88 | } |
89 | // TODO: Get proper AVG Height | 89 | // TODO: Get proper AVG Height |
90 | float localAVHeight = 1.56f; | 90 | float localAVHeight = 1.56f; |
91 | float posZLimit = (float)avatar.Scene.GetLandHeight((int)position.X, (int)position.Y); | 91 | float posZLimit = (float)avatar.Scene.GetLandHeight((int)position.X, (int)position.Y); |
92 | float newPosZ = posZLimit + localAVHeight; | 92 | float newPosZ = posZLimit + localAVHeight; |
93 | if (posZLimit >= (position.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ))) | 93 | if (posZLimit >= (position.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ))) |
94 | { | 94 | { |
95 | position.Z = newPosZ; | 95 | position.Z = newPosZ; |
96 | } | 96 | } |
97 | 97 | ||
98 | // Only send this if the event queue is null | 98 | // Only send this if the event queue is null |
99 | if (eq == null) | 99 | if (eq == null) |
100 | avatar.ControllingClient.SendTeleportLocationStart(); | 100 | avatar.ControllingClient.SendTeleportLocationStart(); |
101 | 101 | ||
102 | 102 | ||
103 | avatar.ControllingClient.SendLocalTeleport(position, lookAt, teleportFlags); | 103 | avatar.ControllingClient.SendLocalTeleport(position, lookAt, teleportFlags); |
104 | avatar.Teleport(position); | 104 | avatar.Teleport(position); |
105 | } | 105 | } |
106 | else | 106 | else |
107 | { | 107 | { |
108 | RegionInfo reg = RequestNeighbouringRegionInfo(regionHandle); | 108 | RegionInfo reg = RequestNeighbouringRegionInfo(regionHandle); |
109 | if (reg != null) | 109 | if (reg != null) |
110 | { | 110 | { |
111 | /// | 111 | /// |
112 | /// Hypergrid mod start | 112 | /// Hypergrid mod start |
113 | /// | 113 | /// |
114 | /// | 114 | /// |
115 | bool isHyperLink = m_hg.IsHyperlinkRegion(reg.RegionHandle); | 115 | bool isHyperLink = m_hg.IsHyperlinkRegion(reg.RegionHandle); |
116 | bool isHomeUser = true; | 116 | bool isHomeUser = true; |
117 | ulong realHandle = regionHandle; | 117 | ulong realHandle = regionHandle; |
118 | CachedUserInfo uinfo = m_commsProvider.UserProfileCacheService.GetUserDetails(avatar.UUID); | 118 | CachedUserInfo uinfo = m_commsProvider.UserProfileCacheService.GetUserDetails(avatar.UUID); |
119 | if (uinfo != null) | 119 | if (uinfo != null) |
120 | { | 120 | { |
121 | isHomeUser = HGNetworkServersInfo.Singleton.IsLocalUser(uinfo.UserProfile.UserAssetURI); | 121 | isHomeUser = HGNetworkServersInfo.Singleton.IsLocalUser(uinfo.UserProfile.UserAssetURI); |
122 | realHandle = m_hg.FindRegionHandle(regionHandle); | 122 | realHandle = m_hg.FindRegionHandle(regionHandle); |
123 | Console.WriteLine("XXX ---- home user? " + isHomeUser + " --- hyperlink? " + isHyperLink + " --- real handle: " + realHandle.ToString()); | 123 | Console.WriteLine("XXX ---- home user? " + isHomeUser + " --- hyperlink? " + isHyperLink + " --- real handle: " + realHandle.ToString()); |
124 | } | 124 | } |
125 | /// | 125 | /// |
126 | /// Hypergrid mod stop | 126 | /// Hypergrid mod stop |
127 | /// | 127 | /// |
128 | /// | 128 | /// |
129 | 129 | ||
130 | if (eq == null) | 130 | if (eq == null) |
131 | avatar.ControllingClient.SendTeleportLocationStart(); | 131 | avatar.ControllingClient.SendTeleportLocationStart(); |
132 | 132 | ||
133 | AgentCircuitData agent = avatar.ControllingClient.RequestClientInfo(); | 133 | AgentCircuitData agent = avatar.ControllingClient.RequestClientInfo(); |
134 | agent.BaseFolder = UUID.Zero; | 134 | agent.BaseFolder = UUID.Zero; |
135 | agent.InventoryFolder = UUID.Zero; | 135 | agent.InventoryFolder = UUID.Zero; |
136 | agent.startpos = position; | 136 | agent.startpos = position; |
137 | agent.child = true; | 137 | agent.child = true; |
138 | 138 | ||
139 | if (reg.RemotingAddress != "" && reg.RemotingPort != 0) | 139 | if (reg.RemotingAddress != "" && reg.RemotingPort != 0) |
140 | { | 140 | { |
141 | // region is remote. see if it is up | 141 | // region is remote. see if it is up |
142 | destRegionUp = m_commsProvider.InterRegion.CheckRegion(reg.RemotingAddress, reg.RemotingPort); | 142 | destRegionUp = m_commsProvider.InterRegion.CheckRegion(reg.RemotingAddress, reg.RemotingPort); |
143 | } | 143 | } |
144 | else | 144 | else |
145 | { | 145 | { |
146 | // assume local regions are always up | 146 | // assume local regions are always up |
147 | destRegionUp = true; | 147 | destRegionUp = true; |
148 | } | 148 | } |
149 | 149 | ||
150 | if (destRegionUp) | 150 | if (destRegionUp) |
151 | { | 151 | { |
152 | // Fixing a bug where teleporting while sitting results in the avatar ending up removed from | 152 | // Fixing a bug where teleporting while sitting results in the avatar ending up removed from |
153 | // both regions | 153 | // both regions |
154 | if (avatar.ParentID != (uint)0) | 154 | if (avatar.ParentID != (uint)0) |
155 | avatar.StandUp(); | 155 | avatar.StandUp(); |
156 | if (!avatar.ValidateAttachments()) | 156 | if (!avatar.ValidateAttachments()) |
157 | { | 157 | { |
158 | avatar.ControllingClient.SendTeleportFailed("Inconsistent attachment state"); | 158 | avatar.ControllingClient.SendTeleportFailed("Inconsistent attachment state"); |
159 | return; | 159 | return; |
160 | } | 160 | } |
161 | 161 | ||
162 | // the avatar.Close below will clear the child region list. We need this below for (possibly) | 162 | // the avatar.Close below will clear the child region list. We need this below for (possibly) |
163 | // closing the child agents, so save it here (we need a copy as it is Clear()-ed). | 163 | // closing the child agents, so save it here (we need a copy as it is Clear()-ed). |
164 | List<ulong> childRegions = new List<ulong>(avatar.GetKnownRegionList()); | 164 | List<ulong> childRegions = new List<ulong>(avatar.GetKnownRegionList()); |
165 | // Compared to ScenePresence.CrossToNewRegion(), there's no obvious code to handle a teleport | 165 | // Compared to ScenePresence.CrossToNewRegion(), there's no obvious code to handle a teleport |
166 | // failure at this point (unlike a border crossing failure). So perhaps this can never fail | 166 | // failure at this point (unlike a border crossing failure). So perhaps this can never fail |
167 | // once we reach here... | 167 | // once we reach here... |
168 | avatar.Scene.RemoveCapsHandler(avatar.UUID); | 168 | avatar.Scene.RemoveCapsHandler(avatar.UUID); |
169 | agent.child = false; | 169 | agent.child = false; |
170 | m_commsProvider.InterRegion.InformRegionOfChildAgent(reg.RegionHandle, agent); | 170 | m_commsProvider.InterRegion.InformRegionOfChildAgent(reg.RegionHandle, agent); |
171 | 171 | ||
172 | m_commsProvider.InterRegion.ExpectAvatarCrossing(reg.RegionHandle, avatar.ControllingClient.AgentId, | 172 | m_commsProvider.InterRegion.ExpectAvatarCrossing(reg.RegionHandle, avatar.ControllingClient.AgentId, |
173 | position, false); | 173 | position, false); |
174 | Thread.Sleep(2000); | 174 | Thread.Sleep(2000); |
175 | AgentCircuitData circuitdata = avatar.ControllingClient.RequestClientInfo(); | 175 | AgentCircuitData circuitdata = avatar.ControllingClient.RequestClientInfo(); |
176 | 176 | ||
177 | // TODO Should construct this behind a method | 177 | // TODO Should construct this behind a method |
178 | string capsPath = | 178 | string capsPath = |
179 | "http://" + reg.ExternalHostName + ":" + reg.HttpPort | 179 | "http://" + reg.ExternalHostName + ":" + reg.HttpPort |
180 | + "/CAPS/" + circuitdata.CapsPath + "0000/"; | 180 | + "/CAPS/" + circuitdata.CapsPath + "0000/"; |
181 | 181 | ||
182 | m_log.DebugFormat( | 182 | m_log.DebugFormat( |
183 | "[CAPS]: Sending new CAPS seed url {0} to client {1}", capsPath, avatar.UUID); | 183 | "[CAPS]: Sending new CAPS seed url {0} to client {1}", capsPath, avatar.UUID); |
184 | 184 | ||
185 | 185 | ||
186 | /// | 186 | /// |
187 | /// Hypergrid mod: realHandle instead of reg.RegionHandle | 187 | /// Hypergrid mod: realHandle instead of reg.RegionHandle |
188 | /// | 188 | /// |
189 | /// | 189 | /// |
190 | if (eq != null) | 190 | if (eq != null) |
191 | { | 191 | { |
192 | OSD Item = EventQueueHelper.TeleportFinishEvent(realHandle, 13, reg.ExternalEndPoint, | 192 | OSD Item = EventQueueHelper.TeleportFinishEvent(realHandle, 13, reg.ExternalEndPoint, |
193 | 4, teleportFlags, capsPath, avatar.UUID); | 193 | 4, teleportFlags, capsPath, avatar.UUID); |
194 | eq.Enqueue(Item, avatar.UUID); | 194 | eq.Enqueue(Item, avatar.UUID); |
195 | } | 195 | } |
196 | else | 196 | else |
197 | { | 197 | { |
198 | avatar.ControllingClient.SendRegionTeleport(realHandle, 13, reg.ExternalEndPoint, 4, | 198 | avatar.ControllingClient.SendRegionTeleport(realHandle, 13, reg.ExternalEndPoint, 4, |
199 | teleportFlags, capsPath); | 199 | teleportFlags, capsPath); |
200 | } | 200 | } |
201 | /// | 201 | /// |
202 | /// Hypergrid mod stop | 202 | /// Hypergrid mod stop |
203 | /// | 203 | /// |
204 | 204 | ||
205 | avatar.MakeChildAgent(); | 205 | avatar.MakeChildAgent(); |
206 | Thread.Sleep(7000); | 206 | Thread.Sleep(7000); |
207 | avatar.CrossAttachmentsIntoNewRegion(reg.RegionHandle, true); | 207 | avatar.CrossAttachmentsIntoNewRegion(reg.RegionHandle, true); |
208 | if (KiPrimitive != null) | 208 | if (KiPrimitive != null) |
209 | { | 209 | { |
210 | KiPrimitive(avatar.LocalId); | 210 | KiPrimitive(avatar.LocalId); |
211 | } | 211 | } |
212 | 212 | ||
213 | avatar.Close(); | 213 | avatar.Close(); |
214 | 214 | ||
215 | uint newRegionX = (uint)(reg.RegionHandle >> 40); | 215 | uint newRegionX = (uint)(reg.RegionHandle >> 40); |
216 | uint newRegionY = (((uint)(reg.RegionHandle)) >> 8); | 216 | uint newRegionY = (((uint)(reg.RegionHandle)) >> 8); |
217 | uint oldRegionX = (uint)(m_regionInfo.RegionHandle >> 40); | 217 | uint oldRegionX = (uint)(m_regionInfo.RegionHandle >> 40); |
218 | uint oldRegionY = (((uint)(m_regionInfo.RegionHandle)) >> 8); | 218 | uint oldRegionY = (((uint)(m_regionInfo.RegionHandle)) >> 8); |
219 | /// | 219 | /// |
220 | /// Hypergrid mod: extra check for isHyperLink | 220 | /// Hypergrid mod: extra check for isHyperLink |
221 | /// | 221 | /// |
222 | if ((Util.fast_distance2d((int)(newRegionX - oldRegionX), (int)(newRegionY - oldRegionY)) > 3) || isHyperLink) | 222 | if ((Util.fast_distance2d((int)(newRegionX - oldRegionX), (int)(newRegionY - oldRegionY)) > 3) || isHyperLink) |
223 | { | 223 | { |
224 | //SendCloseChildAgentConnections(avatar.UUID, avatar.GetKnownRegionList()); | 224 | //SendCloseChildAgentConnections(avatar.UUID, avatar.GetKnownRegionList()); |
225 | SendCloseChildAgentConnections(avatar.UUID, childRegions); | 225 | SendCloseChildAgentConnections(avatar.UUID, childRegions); |
226 | CloseConnection(avatar.UUID); | 226 | CloseConnection(avatar.UUID); |
227 | } | 227 | } |
228 | // if (teleport success) // seems to be always success here | 228 | // if (teleport success) // seems to be always success here |
229 | // the user may change their profile information in other region, | 229 | // the user may change their profile information in other region, |
230 | // so the userinfo in UserProfileCache is not reliable any more, delete it | 230 | // so the userinfo in UserProfileCache is not reliable any more, delete it |
231 | if (avatar.Scene.NeedSceneCacheClear(avatar.UUID)) | 231 | if (avatar.Scene.NeedSceneCacheClear(avatar.UUID)) |
232 | m_commsProvider.UserProfileCacheService.RemoveUser(avatar.UUID); | 232 | m_commsProvider.UserProfileCacheService.RemoveUser(avatar.UUID); |
233 | m_log.InfoFormat("[HGSceneCommService]: User {0} is going to another region, profile cache removed", avatar.UUID); | 233 | m_log.InfoFormat("[HGSceneCommService]: User {0} is going to another region, profile cache removed", avatar.UUID); |
234 | } | 234 | } |
235 | else | 235 | else |
236 | { | 236 | { |
237 | avatar.ControllingClient.SendTeleportFailed("Remote Region appears to be down"); | 237 | avatar.ControllingClient.SendTeleportFailed("Remote Region appears to be down"); |
238 | } | 238 | } |
239 | } | 239 | } |
240 | else | 240 | else |
241 | { | 241 | { |
242 | // TP to a place that doesn't exist (anymore) | 242 | // TP to a place that doesn't exist (anymore) |
243 | // Inform the viewer about that | 243 | // Inform the viewer about that |
244 | avatar.ControllingClient.SendTeleportFailed("The region you tried to teleport to doesn't exist anymore"); | 244 | avatar.ControllingClient.SendTeleportFailed("The region you tried to teleport to doesn't exist anymore"); |
245 | 245 | ||
246 | // and set the map-tile to '(Offline)' | 246 | // and set the map-tile to '(Offline)' |
247 | uint regX, regY; | 247 | uint regX, regY; |
248 | Utils.LongToUInts(regionHandle, out regX, out regY); | 248 | Utils.LongToUInts(regionHandle, out regX, out regY); |
249 | 249 | ||
250 | MapBlockData block = new MapBlockData(); | 250 | MapBlockData block = new MapBlockData(); |
251 | block.X = (ushort)(regX / Constants.RegionSize); | 251 | block.X = (ushort)(regX / Constants.RegionSize); |
252 | block.Y = (ushort)(regY / Constants.RegionSize); | 252 | block.Y = (ushort)(regY / Constants.RegionSize); |
253 | block.Access = 254; // == not there | 253 | block.Access = 254; // == not there |
254 | 254 | ||
255 | List<MapBlockData> blocks = new List<MapBlockData>(); | 255 | List<MapBlockData> blocks = new List<MapBlockData>(); |
256 | blocks.Add(block); | 256 | blocks.Add(block); |
257 | avatar.ControllingClient.SendMapBlock(blocks, 0); | 257 | avatar.ControllingClient.SendMapBlock(blocks, 0); |
258 | } | 258 | } |
259 | } | 259 | } |
260 | } | 260 | } |
261 | 261 | ||
262 | } | 262 | } |
263 | } | 263 | } |