aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Environment/Modules')
-rw-r--r--OpenSim/Region/Environment/Modules/Hypergrid/HGStandaloneAssetService.cs398
-rw-r--r--OpenSim/Region/Environment/Modules/Hypergrid/HGStandaloneInventoryService.cs630
-rw-r--r--OpenSim/Region/Environment/Modules/Hypergrid/HGWorldMapModule.cs356
3 files changed, 692 insertions, 692 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
29using System; 29using System;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Net; 31using System.Net;
32using System.Reflection; 32using System.Reflection;
33 33
34using log4net; 34using log4net;
35using Nini.Config; 35using Nini.Config;
36 36
37using OpenMetaverse; 37using OpenMetaverse;
38 38
39using OpenSim.Framework; 39using OpenSim.Framework;
40using OpenSim.Framework.Communications; 40using OpenSim.Framework.Communications;
41using OpenSim.Framework.Communications.Cache; 41using OpenSim.Framework.Communications.Cache;
42using OpenSim.Framework.Servers; 42using OpenSim.Framework.Servers;
43using OpenSim.Region.Environment.Interfaces; 43using OpenSim.Region.Environment.Interfaces;
44using OpenSim.Region.Environment.Scenes; 44using OpenSim.Region.Environment.Scenes;
45using OpenSim.Grid.AssetServer; 45using OpenSim.Grid.AssetServer;
46 46
47namespace OpenSim.Region.Environment.Modules.Hypergrid 47namespace 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
29using System; 29using System;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Net; 31using System.Net;
32using System.Reflection; 32using System.Reflection;
33 33
34using log4net; 34using log4net;
35using Nini.Config; 35using Nini.Config;
36 36
37using OpenMetaverse; 37using OpenMetaverse;
38 38
39using OpenSim.Framework; 39using OpenSim.Framework;
40using OpenSim.Framework.Communications; 40using OpenSim.Framework.Communications;
41using OpenSim.Framework.Communications.Cache; 41using OpenSim.Framework.Communications.Cache;
42using OpenSim.Framework.Servers; 42using OpenSim.Framework.Servers;
43using OpenSim.Region.Environment.Interfaces; 43using OpenSim.Region.Environment.Interfaces;
44using OpenSim.Region.Environment.Scenes; 44using OpenSim.Region.Environment.Scenes;
45 45
46namespace OpenSim.Region.Environment.Modules.Hypergrid 46namespace 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
30using System; 30using System;
31using System.Collections; 31using System.Collections;
32using System.Collections.Generic; 32using System.Collections.Generic;
33using System.Drawing; 33using System.Drawing;
34using System.Drawing.Imaging; 34using System.Drawing.Imaging;
35using System.IO; 35using System.IO;
36using System.Net; 36using System.Net;
37using System.Reflection; 37using System.Reflection;
38using System.Threading; 38using System.Threading;
39using OpenMetaverse; 39using OpenMetaverse;
40using OpenMetaverse.Imaging; 40using OpenMetaverse.Imaging;
41using OpenMetaverse.StructuredData; 41using OpenMetaverse.StructuredData;
42using log4net; 42using log4net;
43using Nini.Config; 43using Nini.Config;
44using Nwc.XmlRpc; 44using Nwc.XmlRpc;
45 45
46using OpenSim.Framework; 46using OpenSim.Framework;
47using OpenSim.Framework.Communications.Cache; 47using OpenSim.Framework.Communications.Cache;
48using OpenSim.Framework.Communications.Capabilities; 48using OpenSim.Framework.Communications.Capabilities;
49using OpenSim.Framework.Servers; 49using OpenSim.Framework.Servers;
50using OpenSim.Region.Environment.Interfaces; 50using OpenSim.Region.Environment.Interfaces;
51using OpenSim.Region.Environment.Modules.World.WorldMap; 51using OpenSim.Region.Environment.Modules.World.WorldMap;
52using OpenSim.Region.Environment.Scenes; 52using OpenSim.Region.Environment.Scenes;
53using OpenSim.Region.Environment.Types; 53using OpenSim.Region.Environment.Types;
54using Caps = OpenSim.Framework.Communications.Capabilities.Caps; 54using Caps = OpenSim.Framework.Communications.Capabilities.Caps;
55 55
56using OSD = OpenMetaverse.StructuredData.OSD; 56using OSD = OpenMetaverse.StructuredData.OSD;
57using OSDMap = OpenMetaverse.StructuredData.OSDMap; 57using OSDMap = OpenMetaverse.StructuredData.OSDMap;
58using OSDArray = OpenMetaverse.StructuredData.OSDArray; 58using OSDArray = OpenMetaverse.StructuredData.OSDArray;
59 59
60namespace OpenSim.Region.Environment.Modules.Hypergrid 60namespace 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}