diff options
author | Teravus Ovares | 2008-06-12 20:19:42 +0000 |
---|---|---|
committer | Teravus Ovares | 2008-06-12 20:19:42 +0000 |
commit | 5219eb74209d83f1a240a75528fad9d302b84f0e (patch) | |
tree | b9cd1712b30bb348998482ef39d51c777c4e854e /OpenSim/Region/Environment | |
parent | Fix mysql migrations. This is tested with an existing up to date schema, (diff) | |
download | opensim-SC-5219eb74209d83f1a240a75528fad9d302b84f0e.zip opensim-SC-5219eb74209d83f1a240a75528fad9d302b84f0e.tar.gz opensim-SC-5219eb74209d83f1a240a75528fad9d302b84f0e.tar.bz2 opensim-SC-5219eb74209d83f1a240a75528fad9d302b84f0e.tar.xz |
* Split the World Map code into a module.
* Implemented a hack so regions beyond the 10,000m range will show the map without having to click on the map before they'll start to show. The hack shows regions around the one you're in, but it won't show the one you're in.. you still need to click on the map to get that (not sure why yet). Additionally, the map still only shows pictures for regions that are hosted on the same instance (no change).
Diffstat (limited to 'OpenSim/Region/Environment')
-rw-r--r-- | OpenSim/Region/Environment/Modules/World/WorldMap/WorldMapModule.cs | 239 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Scenes/Scene.cs | 5 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Scenes/ScenePresence.cs | 2 |
3 files changed, 243 insertions, 3 deletions
diff --git a/OpenSim/Region/Environment/Modules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/Environment/Modules/World/WorldMap/WorldMapModule.cs new file mode 100644 index 0000000..041af2b --- /dev/null +++ b/OpenSim/Region/Environment/Modules/World/WorldMap/WorldMapModule.cs | |||
@@ -0,0 +1,239 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSim Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Reflection; | ||
32 | using libsecondlife; | ||
33 | using log4net; | ||
34 | using Nini.Config; | ||
35 | using OpenSim.Framework; | ||
36 | using OpenSim.Framework.Communications.Cache; | ||
37 | using OpenSim.Framework.Communications.Capabilities; | ||
38 | using OpenSim.Framework.Servers; | ||
39 | using OpenSim.Region.Environment.Interfaces; | ||
40 | using OpenSim.Region.Environment.Scenes; | ||
41 | using OpenSim.Region.Environment.Types; | ||
42 | using Caps = OpenSim.Framework.Communications.Capabilities.Caps; | ||
43 | |||
44 | |||
45 | namespace OpenSim.Region.Environment.Modules.World.WorldMap | ||
46 | { | ||
47 | public class WorldMapModule : IRegionModule | ||
48 | { | ||
49 | private static readonly ILog m_log = | ||
50 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
51 | |||
52 | private static readonly string m_mapLayerPath = "0001/"; | ||
53 | |||
54 | //private IConfig m_config; | ||
55 | private Scene m_scene; | ||
56 | private List<MapBlockData> cachedMapBlocks = new List<MapBlockData>(); | ||
57 | private int cachedTime = 0; | ||
58 | |||
59 | //private int CacheRegionsDistance = 256; | ||
60 | |||
61 | #region IRegionModule Members | ||
62 | |||
63 | public void Initialise(Scene scene, IConfigSource config) | ||
64 | { | ||
65 | m_scene = scene; | ||
66 | |||
67 | //QuadTree.Subdivide(); | ||
68 | //QuadTree.Subdivide(); | ||
69 | |||
70 | scene.EventManager.OnRegisterCaps += OnRegisterCaps; | ||
71 | scene.EventManager.OnNewClient += OnNewClient; | ||
72 | scene.EventManager.OnClientClosed += ClientLoggedOut; | ||
73 | } | ||
74 | public void PostInitialise() | ||
75 | { | ||
76 | |||
77 | } | ||
78 | |||
79 | public void Close() | ||
80 | { | ||
81 | } | ||
82 | public string Name | ||
83 | { | ||
84 | get { return "WorldMapModule"; } | ||
85 | } | ||
86 | |||
87 | public bool IsSharedModule | ||
88 | { | ||
89 | get { return false; } | ||
90 | } | ||
91 | |||
92 | #endregion | ||
93 | |||
94 | |||
95 | |||
96 | |||
97 | |||
98 | public void OnRegisterCaps(LLUUID agentID, Caps caps) | ||
99 | { | ||
100 | m_log.DebugFormat("[VOICE] OnRegisterCaps: agentID {0} caps {1}", agentID, caps); | ||
101 | string capsBase = "/CAPS/" + caps.CapsObjectPath; | ||
102 | caps.RegisterHandler("MapLayer", | ||
103 | new RestStreamHandler("POST", capsBase + m_mapLayerPath, | ||
104 | delegate(string request, string path, string param, | ||
105 | OSHttpRequest httpRequest, OSHttpResponse httpResponse) | ||
106 | { | ||
107 | return MapLayerRequest(request, path, param, | ||
108 | agentID, caps); | ||
109 | })); | ||
110 | |||
111 | } | ||
112 | |||
113 | /// <summary> | ||
114 | /// Callback for a map layer request | ||
115 | /// </summary> | ||
116 | /// <param name="request"></param> | ||
117 | /// <param name="path"></param> | ||
118 | /// <param name="param"></param> | ||
119 | /// <param name="agentID"></param> | ||
120 | /// <param name="caps"></param> | ||
121 | /// <returns></returns> | ||
122 | public string MapLayerRequest(string request, string path, string param, | ||
123 | LLUUID agentID, Caps caps) | ||
124 | { | ||
125 | //try | ||
126 | //{ | ||
127 | //m_log.DebugFormat("[MAPLAYER]: request: {0}, path: {1}, param: {2}, agent:{3}", | ||
128 | //request, path, param,agentID.ToString()); | ||
129 | |||
130 | // this is here because CAPS map requests work even beyond the 10,000 limit. | ||
131 | ScenePresence avatarPresence = null; | ||
132 | |||
133 | m_scene.TryGetAvatar(agentID, out avatarPresence); | ||
134 | |||
135 | if (avatarPresence != null) | ||
136 | { | ||
137 | bool lookup = false; | ||
138 | |||
139 | lock(cachedMapBlocks) | ||
140 | { | ||
141 | if (cachedMapBlocks.Count > 0 && ((cachedTime + 1800) > Util.UnixTimeSinceEpoch())) | ||
142 | { | ||
143 | List<MapBlockData> mapBlocks; | ||
144 | |||
145 | mapBlocks = cachedMapBlocks; | ||
146 | avatarPresence.ControllingClient.SendMapBlock(mapBlocks); | ||
147 | } | ||
148 | else | ||
149 | { | ||
150 | lookup = true; | ||
151 | } | ||
152 | } | ||
153 | if (lookup) | ||
154 | { | ||
155 | List<MapBlockData> mapBlocks; | ||
156 | |||
157 | mapBlocks = m_scene.CommsManager.GridService.RequestNeighbourMapBlocks((int)m_scene.RegionInfo.RegionLocX - 8, (int)m_scene.RegionInfo.RegionLocY - 8, (int)m_scene.RegionInfo.RegionLocX + 8, (int)m_scene.RegionInfo.RegionLocY + 8); | ||
158 | avatarPresence.ControllingClient.SendMapBlock(mapBlocks); | ||
159 | |||
160 | lock(cachedMapBlocks) | ||
161 | cachedMapBlocks = mapBlocks; | ||
162 | |||
163 | cachedTime = Util.UnixTimeSinceEpoch(); | ||
164 | } | ||
165 | } | ||
166 | LLSDMapLayerResponse mapResponse = new LLSDMapLayerResponse(); | ||
167 | mapResponse.LayerData.Array.Add(GetLLSDMapLayerResponse()); | ||
168 | return mapResponse.ToString(); | ||
169 | } | ||
170 | |||
171 | /// <summary> | ||
172 | /// | ||
173 | /// </summary> | ||
174 | /// <param name="mapReq"></param> | ||
175 | /// <returns></returns> | ||
176 | public LLSDMapLayerResponse GetMapLayer(LLSDMapRequest mapReq) | ||
177 | { | ||
178 | m_log.Debug("[CAPS]: MapLayer Request in region: " + m_scene.RegionInfo.RegionName); | ||
179 | LLSDMapLayerResponse mapResponse = new LLSDMapLayerResponse(); | ||
180 | mapResponse.LayerData.Array.Add(GetLLSDMapLayerResponse()); | ||
181 | return mapResponse; | ||
182 | } | ||
183 | |||
184 | /// <summary> | ||
185 | /// | ||
186 | /// </summary> | ||
187 | /// <returns></returns> | ||
188 | protected static LLSDMapLayer GetLLSDMapLayerResponse() | ||
189 | { | ||
190 | LLSDMapLayer mapLayer = new LLSDMapLayer(); | ||
191 | mapLayer.Right = 5000; | ||
192 | mapLayer.Top = 5000; | ||
193 | mapLayer.ImageID = new LLUUID("00000000-0000-1111-9999-000000000006"); | ||
194 | |||
195 | return mapLayer; | ||
196 | } | ||
197 | #region EventHandlers | ||
198 | |||
199 | |||
200 | private void OnNewClient(IClientAPI client) | ||
201 | { | ||
202 | // All friends establishment protocol goes over instant message | ||
203 | // There's no way to send a message from the sim | ||
204 | // to a user to 'add a friend' without causing dialog box spam | ||
205 | // | ||
206 | // The base set of friends are added when the user signs on in their XMLRPC response | ||
207 | // Generated by LoginService. The friends are retreived from the database by the UserManager | ||
208 | |||
209 | // Subscribe to instant messages | ||
210 | |||
211 | //client.OnInstantMessage += OnInstantMessage; | ||
212 | //client.OnApproveFriendRequest += OnApprovedFriendRequest; | ||
213 | //client.OnDenyFriendRequest += OnDenyFriendRequest; | ||
214 | //client.OnTerminateFriendship += OnTerminateFriendship; | ||
215 | |||
216 | //doFriendListUpdateOnline(client.AgentId); | ||
217 | client.OnRequestMapBlocks += RequestMapBlocks; | ||
218 | } | ||
219 | private void ClientLoggedOut(LLUUID AgentId) | ||
220 | { | ||
221 | |||
222 | } | ||
223 | #endregion | ||
224 | |||
225 | /// <summary> | ||
226 | /// Requests map blocks in area of minX, maxX, minY, MaxY in world cordinates | ||
227 | /// </summary> | ||
228 | /// <param name="minX"></param> | ||
229 | /// <param name="minY"></param> | ||
230 | /// <param name="maxX"></param> | ||
231 | /// <param name="maxY"></param> | ||
232 | public virtual void RequestMapBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY) | ||
233 | { | ||
234 | List<MapBlockData> mapBlocks; | ||
235 | mapBlocks = m_scene.CommsManager.GridService.RequestNeighbourMapBlocks(minX - 4, minY - 4, minX + 4, minY + 4); | ||
236 | remoteClient.SendMapBlock(mapBlocks); | ||
237 | } | ||
238 | } | ||
239 | } \ No newline at end of file | ||
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index 43bb709..95d6f1f 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs | |||
@@ -1867,7 +1867,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
1867 | client.OnUpdatePrimGroupScale += m_innerScene.UpdatePrimGroupScale; | 1867 | client.OnUpdatePrimGroupScale += m_innerScene.UpdatePrimGroupScale; |
1868 | client.OnUpdateExtraParams += m_innerScene.UpdateExtraParam; | 1868 | client.OnUpdateExtraParams += m_innerScene.UpdateExtraParam; |
1869 | client.OnUpdatePrimShape += m_innerScene.UpdatePrimShape; | 1869 | client.OnUpdatePrimShape += m_innerScene.UpdatePrimShape; |
1870 | client.OnRequestMapBlocks += RequestMapBlocks; | 1870 | //client.OnRequestMapBlocks += RequestMapBlocks; // handled in a module now. |
1871 | client.OnUpdatePrimTexture += m_innerScene.UpdatePrimTexture; | 1871 | client.OnUpdatePrimTexture += m_innerScene.UpdatePrimTexture; |
1872 | client.OnTeleportLocationRequest += RequestTeleportLocation; | 1872 | client.OnTeleportLocationRequest += RequestTeleportLocation; |
1873 | client.OnTeleportLandmarkRequest += RequestTeleportLandmark; | 1873 | client.OnTeleportLandmarkRequest += RequestTeleportLandmark; |
@@ -2487,7 +2487,8 @@ namespace OpenSim.Region.Environment.Scenes | |||
2487 | /// <param name="maxY"></param> | 2487 | /// <param name="maxY"></param> |
2488 | public void RequestMapBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY) | 2488 | public void RequestMapBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY) |
2489 | { | 2489 | { |
2490 | m_sceneGridService.RequestMapBlocks(remoteClient, minX, minY, maxX, maxX); | 2490 | m_log.InfoFormat("[MAPBLOCK]: {0}-{1}, {2}-{3}", minX, minY, maxX, maxY); |
2491 | m_sceneGridService.RequestMapBlocks(remoteClient, minX, minY, maxX, maxY); | ||
2491 | } | 2492 | } |
2492 | 2493 | ||
2493 | /// <summary> | 2494 | /// <summary> |
diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs index 300a363..2774a45 100644 --- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs | |||
@@ -81,7 +81,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
81 | private ScriptControlled IgnoredControls = ScriptControlled.CONTROL_ZERO; | 81 | private ScriptControlled IgnoredControls = ScriptControlled.CONTROL_ZERO; |
82 | private ScriptControlled LastCommands = ScriptControlled.CONTROL_ZERO; | 82 | private ScriptControlled LastCommands = ScriptControlled.CONTROL_ZERO; |
83 | private SceneObjectGroup proxyObjectGroup = null; | 83 | private SceneObjectGroup proxyObjectGroup = null; |
84 | private SceneObjectPart proxyObjectPart = null; | 84 | //private SceneObjectPart proxyObjectPart = null; |
85 | 85 | ||
86 | public Vector3 lastKnownAllowedPosition = new Vector3(); | 86 | public Vector3 lastKnownAllowedPosition = new Vector3(); |
87 | public bool sentMessageAboutRestrictedParcelFlyingDown = false; | 87 | public bool sentMessageAboutRestrictedParcelFlyingDown = false; |