aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorTeravus Ovares2008-06-12 20:19:42 +0000
committerTeravus Ovares2008-06-12 20:19:42 +0000
commit5219eb74209d83f1a240a75528fad9d302b84f0e (patch)
treeb9cd1712b30bb348998482ef39d51c777c4e854e /OpenSim
parentFix mysql migrations. This is tested with an existing up to date schema, (diff)
downloadopensim-SC_OLD-5219eb74209d83f1a240a75528fad9d302b84f0e.zip
opensim-SC_OLD-5219eb74209d83f1a240a75528fad9d302b84f0e.tar.gz
opensim-SC_OLD-5219eb74209d83f1a240a75528fad9d302b84f0e.tar.bz2
opensim-SC_OLD-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')
-rw-r--r--OpenSim/Framework/Communications/Capabilities/Caps.cs9
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs47
-rw-r--r--OpenSim/Region/Environment/Modules/World/WorldMap/WorldMapModule.cs239
-rw-r--r--OpenSim/Region/Environment/Scenes/Scene.cs5
-rw-r--r--OpenSim/Region/Environment/Scenes/ScenePresence.cs2
5 files changed, 284 insertions, 18 deletions
diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs
index c2b0046..2bfcaca 100644
--- a/OpenSim/Framework/Communications/Capabilities/Caps.cs
+++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs
@@ -135,10 +135,10 @@ namespace OpenSim.Framework.Communications.Capabilities
135 { 135 {
136 // the root of all evil 136 // the root of all evil
137 m_capsHandlers["SEED"] = new RestStreamHandler("POST", capsBase + m_requestPath, CapsRequest); 137 m_capsHandlers["SEED"] = new RestStreamHandler("POST", capsBase + m_requestPath, CapsRequest);
138 m_capsHandlers["MapLayer"] = 138 //m_capsHandlers["MapLayer"] =
139 new LLSDStreamhandler<LLSDMapRequest, LLSDMapLayerResponse>("POST", 139 // new LLSDStreamhandler<LLSDMapRequest, LLSDMapLayerResponse>("POST",
140 capsBase + m_mapLayerPath, 140 // capsBase + m_mapLayerPath,
141 GetMapLayer); 141 // GetMapLayer);
142 m_capsHandlers["NewFileAgentInventory"] = 142 m_capsHandlers["NewFileAgentInventory"] =
143 new LLSDStreamhandler<LLSDAssetUploadRequest, LLSDAssetUploadResponse>("POST", 143 new LLSDStreamhandler<LLSDAssetUploadRequest, LLSDAssetUploadResponse>("POST",
144 capsBase + m_newInventory, 144 capsBase + m_newInventory,
@@ -420,6 +420,7 @@ namespace OpenSim.Framework.Communications.Capabilities
420 mapLayer.Right = 5000; 420 mapLayer.Right = 5000;
421 mapLayer.Top = 5000; 421 mapLayer.Top = 5000;
422 mapLayer.ImageID = new LLUUID("00000000-0000-1111-9999-000000000006"); 422 mapLayer.ImageID = new LLUUID("00000000-0000-1111-9999-000000000006");
423
423 return mapLayer; 424 return mapLayer;
424 } 425 }
425 426
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
index 47a9f53..5cbe04e 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
@@ -1209,29 +1209,54 @@ namespace OpenSim.Region.ClientStack.LindenUDP
1209 OutPacket(newSimPack, ThrottleOutPacketType.Unknown); 1209 OutPacket(newSimPack, ThrottleOutPacketType.Unknown);
1210 } 1210 }
1211 1211
1212 public void SendMapBlock(List<MapBlockData> mapBlocks) 1212 internal void SendMapBlockSplit(List<MapBlockData> mapBlocks)
1213 { 1213 {
1214 MapBlockReplyPacket mapReply = (MapBlockReplyPacket)PacketPool.Instance.GetPacket(PacketType.MapBlockReply); 1214 MapBlockReplyPacket mapReply = (MapBlockReplyPacket)PacketPool.Instance.GetPacket(PacketType.MapBlockReply);
1215 // TODO: don't create new blocks if recycling an old packet 1215 // TODO: don't create new blocks if recycling an old packet
1216
1217 MapBlockData[] mapBlocks2 = mapBlocks.ToArray();
1218
1216 mapReply.AgentData.AgentID = AgentId; 1219 mapReply.AgentData.AgentID = AgentId;
1217 mapReply.Data = new MapBlockReplyPacket.DataBlock[mapBlocks.Count]; 1220 mapReply.Data = new MapBlockReplyPacket.DataBlock[mapBlocks2.Length];
1218 mapReply.AgentData.Flags = 0; 1221 mapReply.AgentData.Flags = 0;
1219 1222
1220 for (int i = 0; i < mapBlocks.Count; i++) 1223 for (int i = 0; i < mapBlocks2.Length; i++)
1221 { 1224 {
1222 mapReply.Data[i] = new MapBlockReplyPacket.DataBlock(); 1225 mapReply.Data[i] = new MapBlockReplyPacket.DataBlock();
1223 mapReply.Data[i].MapImageID = mapBlocks[i].MapImageId; 1226 mapReply.Data[i].MapImageID = mapBlocks2[i].MapImageId;
1224 mapReply.Data[i].X = mapBlocks[i].X; 1227 mapReply.Data[i].X = mapBlocks2[i].X;
1225 mapReply.Data[i].Y = mapBlocks[i].Y; 1228 mapReply.Data[i].Y = mapBlocks2[i].Y;
1226 mapReply.Data[i].WaterHeight = mapBlocks[i].WaterHeight; 1229 mapReply.Data[i].WaterHeight = mapBlocks2[i].WaterHeight;
1227 mapReply.Data[i].Name = Helpers.StringToField(mapBlocks[i].Name); 1230 mapReply.Data[i].Name = Helpers.StringToField(mapBlocks2[i].Name);
1228 mapReply.Data[i].RegionFlags = mapBlocks[i].RegionFlags; 1231 mapReply.Data[i].RegionFlags = mapBlocks2[i].RegionFlags;
1229 mapReply.Data[i].Access = mapBlocks[i].Access; 1232 mapReply.Data[i].Access = mapBlocks2[i].Access;
1230 mapReply.Data[i].Agents = mapBlocks[i].Agents; 1233 mapReply.Data[i].Agents = mapBlocks2[i].Agents;
1231 } 1234 }
1232 OutPacket(mapReply, ThrottleOutPacketType.Land); 1235 OutPacket(mapReply, ThrottleOutPacketType.Land);
1233 } 1236 }
1234 1237
1238 public void SendMapBlock(List<MapBlockData> mapBlocks)
1239 {
1240
1241 MapBlockData[] mapBlocks2 = mapBlocks.ToArray();
1242
1243 int maxsend = 10;
1244
1245 //int packets = Math.Ceiling(mapBlocks2.Length / maxsend);
1246
1247 List<MapBlockData> sendingBlocks = new List<MapBlockData>();
1248
1249 for (int i = 0; i < mapBlocks2.Length; i++)
1250 {
1251 sendingBlocks.Add(mapBlocks2[i]);
1252 if (((i + 1) == mapBlocks2.Length) || ((i % maxsend) == 0))
1253 {
1254 SendMapBlockSplit(sendingBlocks);
1255 sendingBlocks = new List<MapBlockData>();
1256 }
1257 }
1258 }
1259
1235 public void SendLocalTeleport(LLVector3 position, LLVector3 lookAt, uint flags) 1260 public void SendLocalTeleport(LLVector3 position, LLVector3 lookAt, uint flags)
1236 { 1261 {
1237 TeleportLocalPacket tpLocal = (TeleportLocalPacket)PacketPool.Instance.GetPacket(PacketType.TeleportLocal); 1262 TeleportLocalPacket tpLocal = (TeleportLocalPacket)PacketPool.Instance.GetPacket(PacketType.TeleportLocal);
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
28using System;
29using System.Collections;
30using System.Collections.Generic;
31using System.Reflection;
32using libsecondlife;
33using log4net;
34using Nini.Config;
35using OpenSim.Framework;
36using OpenSim.Framework.Communications.Cache;
37using OpenSim.Framework.Communications.Capabilities;
38using OpenSim.Framework.Servers;
39using OpenSim.Region.Environment.Interfaces;
40using OpenSim.Region.Environment.Scenes;
41using OpenSim.Region.Environment.Types;
42using Caps = OpenSim.Framework.Communications.Capabilities.Caps;
43
44
45namespace 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;