diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Environment/Modules/World/WorldMap/MapSearchModule.cs | 119 |
1 files changed, 119 insertions, 0 deletions
diff --git a/OpenSim/Region/Environment/Modules/World/WorldMap/MapSearchModule.cs b/OpenSim/Region/Environment/Modules/World/WorldMap/MapSearchModule.cs new file mode 100644 index 0000000..9a522ff --- /dev/null +++ b/OpenSim/Region/Environment/Modules/World/WorldMap/MapSearchModule.cs | |||
@@ -0,0 +1,119 @@ | |||
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 | using System; | ||
28 | using System.Reflection; | ||
29 | using System.Collections.Generic; | ||
30 | using OpenSim.Framework; | ||
31 | using OpenSim.Region.Environment.Interfaces; | ||
32 | using OpenSim.Region.Environment.Scenes; | ||
33 | using OpenMetaverse; | ||
34 | using log4net; | ||
35 | using Nini.Config; | ||
36 | |||
37 | namespace OpenSim.Region.Environment.Modules.World.WorldMap | ||
38 | { | ||
39 | public class MapSearchModule : IRegionModule | ||
40 | { | ||
41 | private static readonly ILog m_log = | ||
42 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
43 | |||
44 | Scene m_scene = null; // only need one for communication with GridService | ||
45 | |||
46 | #region IRegionModule Members | ||
47 | public void Initialise(Scene scene, IConfigSource source) | ||
48 | { | ||
49 | if (m_scene == null) m_scene = scene; | ||
50 | scene.EventManager.OnNewClient += OnNewClient; | ||
51 | } | ||
52 | |||
53 | public void PostInitialise() | ||
54 | { | ||
55 | } | ||
56 | |||
57 | public void Close() | ||
58 | { | ||
59 | m_scene = null; | ||
60 | } | ||
61 | |||
62 | public string Name | ||
63 | { | ||
64 | get { return "MapSearchModule"; } | ||
65 | } | ||
66 | |||
67 | public bool IsSharedModule | ||
68 | { | ||
69 | get { return true; } | ||
70 | } | ||
71 | |||
72 | #endregion | ||
73 | |||
74 | private void OnNewClient(IClientAPI client) | ||
75 | { | ||
76 | client.OnMapNameRequest += OnMapNameRequest; | ||
77 | } | ||
78 | |||
79 | private void OnMapNameRequest(IClientAPI remoteClient, string mapName) | ||
80 | { | ||
81 | m_log.DebugFormat("[MAPSEARCH]: looking for region {0}", mapName); | ||
82 | |||
83 | // TODO currently, this only returns one region per name. LL servers will return all starting with the provided name. | ||
84 | RegionInfo info = m_scene.SceneGridService.RequestClosestRegion(mapName); | ||
85 | // fetch the mapblock of the named sim. We need this anyway (we have the map open, and just jumped to the sim), | ||
86 | // so there shouldn't be any penalty for that. | ||
87 | List<MapBlockData> mapBlocks = m_scene.SceneGridService.RequestNeighbourMapBlocks((int)info.RegionLocX, | ||
88 | (int)info.RegionLocY, | ||
89 | (int)info.RegionLocX, | ||
90 | (int)info.RegionLocY); | ||
91 | |||
92 | List<MapBlockData> blocks = new List<MapBlockData>(); | ||
93 | |||
94 | MapBlockData data = new MapBlockData(); | ||
95 | data.Agents = 3; // TODO set to number of agents in region | ||
96 | data.Access = 21; // TODO what's this? | ||
97 | data.MapImageId = mapBlocks.Count == 0 ? UUID.Zero : mapBlocks[0].MapImageId; | ||
98 | data.Name = info.RegionName; | ||
99 | data.RegionFlags = 0; // TODO fix this | ||
100 | data.WaterHeight = 0; // not used | ||
101 | data.X = (ushort)info.RegionLocX; | ||
102 | data.Y = (ushort)info.RegionLocY; | ||
103 | blocks.Add(data); | ||
104 | |||
105 | data = new MapBlockData(); | ||
106 | data.Agents = 0; | ||
107 | data.Access = 255; | ||
108 | data.MapImageId = UUID.Zero; | ||
109 | data.Name = mapName; | ||
110 | data.RegionFlags = 0; | ||
111 | data.WaterHeight = 0; // not used | ||
112 | data.X = 0; | ||
113 | data.Y = 0; | ||
114 | blocks.Add(data); | ||
115 | |||
116 | remoteClient.SendMapBlock(blocks, 0); | ||
117 | } | ||
118 | } | ||
119 | } | ||