diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/Lure/HGLureModule.cs | 163 |
1 files changed, 71 insertions, 92 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Lure/HGLureModule.cs b/OpenSim/Region/CoreModules/Avatar/Lure/HGLureModule.cs index 24286a4..3dc9bf5 100644 --- a/OpenSim/Region/CoreModules/Avatar/Lure/HGLureModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Lure/HGLureModule.cs | |||
@@ -29,10 +29,9 @@ using System; | |||
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Reflection; | 30 | using System.Reflection; |
31 | using log4net; | 31 | using log4net; |
32 | using Mono.Addins; | ||
32 | using Nini.Config; | 33 | using Nini.Config; |
33 | using OpenMetaverse; | 34 | using OpenMetaverse; |
34 | using Mono.Addins; | ||
35 | |||
36 | using OpenSim.Framework; | 35 | using OpenSim.Framework; |
37 | using OpenSim.Region.Framework.Interfaces; | 36 | using OpenSim.Region.Framework.Interfaces; |
38 | using OpenSim.Region.Framework.Scenes; | 37 | using OpenSim.Region.Framework.Scenes; |
@@ -45,13 +44,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Lure | |||
45 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "HGLureModule")] | 44 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "HGLureModule")] |
46 | public class HGLureModule : ISharedRegionModule | 45 | public class HGLureModule : ISharedRegionModule |
47 | { | 46 | { |
48 | private static readonly ILog m_log = LogManager.GetLogger( | 47 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
49 | MethodBase.GetCurrentMethod().DeclaringType); | ||
50 | 48 | ||
51 | private readonly List<Scene> m_scenes = new List<Scene>(); | 49 | private readonly List<Scene> m_scenes = new List<Scene>(); |
52 | 50 | ||
53 | private IMessageTransferModule m_TransferModule = null; | 51 | private IMessageTransferModule m_TransferModule = null; |
54 | private bool m_Enabled = false; | ||
55 | 52 | ||
56 | private string m_ThisGridURL; | 53 | private string m_ThisGridURL; |
57 | 54 | ||
@@ -61,24 +58,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Lure | |||
61 | { | 58 | { |
62 | if (config.Configs["Messaging"] != null) | 59 | if (config.Configs["Messaging"] != null) |
63 | { | 60 | { |
64 | if (config.Configs["Messaging"].GetString("LureModule", string.Empty) == "HGLureModule") | 61 | m_ThisGridURL = Util.GetConfigVarFromSections<string>(config, "GatekeeperURI", new string[] { "Startup", "Hypergrid", "Messaging" }, String.Empty); |
65 | { | 62 | // Legacy. Remove soon! |
66 | m_Enabled = true; | 63 | //// m_ThisGridURL = config.Configs["Messaging"].GetString("Gatekeeper", m_ThisGridURL); |
67 | 64 | m_log.DebugFormat("[HG LURE MODULE]: {0} enabled", Name); | |
68 | m_ThisGridURL = Util.GetConfigVarFromSections<string>(config, "GatekeeperURI", | ||
69 | new string[] { "Startup", "Hypergrid", "Messaging" }, String.Empty); | ||
70 | // Legacy. Remove soon! | ||
71 | m_ThisGridURL = config.Configs["Messaging"].GetString("Gatekeeper", m_ThisGridURL); | ||
72 | m_log.DebugFormat("[LURE MODULE]: {0} enabled", Name); | ||
73 | } | ||
74 | } | 65 | } |
75 | } | 66 | } |
76 | 67 | ||
77 | public void AddRegion(Scene scene) | 68 | public void AddRegion(Scene scene) |
78 | { | 69 | { |
79 | if (!m_Enabled) | ||
80 | return; | ||
81 | |||
82 | lock (m_scenes) | 70 | lock (m_scenes) |
83 | { | 71 | { |
84 | m_scenes.Add(scene); | 72 | m_scenes.Add(scene); |
@@ -89,9 +77,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Lure | |||
89 | 77 | ||
90 | public void RegionLoaded(Scene scene) | 78 | public void RegionLoaded(Scene scene) |
91 | { | 79 | { |
92 | if (!m_Enabled) | ||
93 | return; | ||
94 | |||
95 | if (m_TransferModule == null) | 80 | if (m_TransferModule == null) |
96 | { | 81 | { |
97 | m_TransferModule = | 82 | m_TransferModule = |
@@ -99,9 +84,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Lure | |||
99 | 84 | ||
100 | if (m_TransferModule == null) | 85 | if (m_TransferModule == null) |
101 | { | 86 | { |
102 | m_log.Error("[LURE MODULE]: No message transfer module, lures will not work!"); | 87 | m_log.Error("[HG LURE MODULE]: No message transfer module, lures will not work!"); |
103 | |||
104 | m_Enabled = false; | ||
105 | m_scenes.Clear(); | 88 | m_scenes.Clear(); |
106 | scene.EventManager.OnNewClient -= OnNewClient; | 89 | scene.EventManager.OnNewClient -= OnNewClient; |
107 | scene.EventManager.OnIncomingInstantMessage -= OnIncomingInstantMessage; | 90 | scene.EventManager.OnIncomingInstantMessage -= OnIncomingInstantMessage; |
@@ -112,9 +95,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Lure | |||
112 | 95 | ||
113 | public void RemoveRegion(Scene scene) | 96 | public void RemoveRegion(Scene scene) |
114 | { | 97 | { |
115 | if (!m_Enabled) | ||
116 | return; | ||
117 | |||
118 | lock (m_scenes) | 98 | lock (m_scenes) |
119 | { | 99 | { |
120 | m_scenes.Remove(scene); | 100 | m_scenes.Remove(scene); |
@@ -154,19 +134,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Lure | |||
154 | 134 | ||
155 | void OnIncomingInstantMessage(GridInstantMessage im) | 135 | void OnIncomingInstantMessage(GridInstantMessage im) |
156 | { | 136 | { |
157 | if (im.dialog == (byte)InstantMessageDialog.RequestTeleport | 137 | if (im.dialog == (byte)InstantMessageDialog.RequestTeleport || im.dialog == (byte)InstantMessageDialog.GodLikeRequestTeleport) |
158 | || im.dialog == (byte)InstantMessageDialog.GodLikeRequestTeleport) | ||
159 | { | 138 | { |
160 | UUID sessionID = new UUID(im.imSessionID); | 139 | UUID sessionID = new UUID(im.imSessionID); |
161 | |||
162 | if (!m_PendingLures.Contains(sessionID)) | 140 | if (!m_PendingLures.Contains(sessionID)) |
163 | { | 141 | { |
164 | m_log.DebugFormat("[HG LURE MODULE]: RequestTeleport sessionID={0}, regionID={1}, message={2}", im.imSessionID, im.RegionID, im.message); | 142 | m_log.DebugFormat("[HG LURE MODULE]: RequestTeleport sessionID={0}, regionID={1}, message={2}", im.imSessionID, im.RegionID, im.message); |
165 | m_PendingLures.Add(sessionID, im, 7200); // 2 hours | 143 | m_PendingLures.Add(sessionID, im, 7200); // 2 hours |
166 | } | 144 | } |
167 | 145 | // Forward. We do this, because the IM module explicitly rejects IMs of this type | |
168 | // Forward. We do this, because the IM module explicitly rejects | ||
169 | // IMs of this type | ||
170 | if (m_TransferModule != null) | 146 | if (m_TransferModule != null) |
171 | m_TransferModule.SendInstantMessage(im, delegate(bool success) { }); | 147 | m_TransferModule.SendInstantMessage(im, delegate(bool success) { }); |
172 | } | 148 | } |
@@ -179,23 +155,34 @@ namespace OpenSim.Region.CoreModules.Avatar.Lure | |||
179 | 155 | ||
180 | Scene scene = (Scene)(client.Scene); | 156 | Scene scene = (Scene)(client.Scene); |
181 | ScenePresence presence = scene.GetScenePresence(client.AgentId); | 157 | ScenePresence presence = scene.GetScenePresence(client.AgentId); |
158 | ScenePresence target = scene.GetScenePresence(targetid); | ||
159 | Guid start = client.Scene.RegionInfo.RegionID.Guid; | ||
160 | UUID dest = UUID.Random(); | ||
161 | byte reqType = (byte)InstantMessageDialog.RequestTeleport; | ||
162 | GridInstantMessage m; | ||
182 | 163 | ||
183 | message += "@" + m_ThisGridURL; | 164 | GridRegion region = scene.GridService.GetRegionByUUID(scene.RegionInfo.ScopeID, new UUID(start)); |
184 | 165 | if (region != null) | |
185 | m_log.DebugFormat("[HG LURE MODULE]: TP invite with message {0}", message); | 166 | { |
186 | 167 | if (scene.Permissions.IsAdministrator(client.AgentId) && presence.IsViewerUIGod && (!scene.Permissions.IsAdministrator(targetid))) | |
187 | UUID sessionID = UUID.Random(); | 168 | { |
169 | reqType = (byte)InstantMessageDialog.GodLikeRequestTeleport; | ||
170 | m_log.DebugFormat("[HG LURE MODULE]: TP FORCE GOD LURE with message {0}, type {1}", message, lureType); | ||
171 | } | ||
172 | else | ||
173 | m_log.DebugFormat("[HG LURE MODULE]: TP lure with message {0}, type {1}", message, lureType); | ||
174 | } | ||
175 | else | ||
176 | { | ||
177 | m_log.DebugFormat("[HG LURE MODULE]: hypergrid TP lure with message {0}, type {1}", message, lureType); | ||
178 | message += "@" + m_ThisGridURL; | ||
179 | } | ||
188 | 180 | ||
189 | GridInstantMessage m = new GridInstantMessage(scene, client.AgentId, | 181 | m = new GridInstantMessage(scene, client.AgentId, client.FirstName+" "+client.LastName, targetid, |
190 | client.FirstName+" "+client.LastName, targetid, | 182 | reqType, false, message, dest, false, presence.AbsolutePosition, new Byte[0], true); |
191 | (byte)InstantMessageDialog.RequestTeleport, false, | 183 | m.RegionID = start; |
192 | message, sessionID, false, presence.AbsolutePosition, | 184 | m_PendingLures.Add(dest, m, 7200); // 2 hours |
193 | new Byte[0], true); | ||
194 | m.RegionID = client.Scene.RegionInfo.RegionID.Guid; | ||
195 | 185 | ||
196 | m_log.DebugFormat("[HG LURE MODULE]: RequestTeleport sessionID={0}, regionID={1}, message={2}", m.imSessionID, m.RegionID, m.message); | ||
197 | m_PendingLures.Add(sessionID, m, 7200); // 2 hours | ||
198 | |||
199 | if (m_TransferModule != null) | 186 | if (m_TransferModule != null) |
200 | { | 187 | { |
201 | m_TransferModule.SendInstantMessage(m, | 188 | m_TransferModule.SendInstantMessage(m, |
@@ -208,64 +195,56 @@ namespace OpenSim.Region.CoreModules.Avatar.Lure | |||
208 | if (!(client.Scene is Scene)) | 195 | if (!(client.Scene is Scene)) |
209 | return; | 196 | return; |
210 | 197 | ||
211 | // Scene scene = (Scene)(client.Scene); | 198 | Scene scene = (Scene)(client.Scene); |
212 | |||
213 | GridInstantMessage im = null; | 199 | GridInstantMessage im = null; |
200 | |||
214 | if (m_PendingLures.TryGetValue(lureID, out im)) | 201 | if (m_PendingLures.TryGetValue(lureID, out im)) |
215 | { | 202 | { |
203 | im.Position = im.Position + new Vector3(0.5f, 0.5f, 2f); | ||
216 | m_PendingLures.Remove(lureID); | 204 | m_PendingLures.Remove(lureID); |
217 | Lure(client, teleportFlags, im); | 205 | GridRegion region = scene.GridService.GetRegionByUUID(scene.RegionInfo.ScopeID, new UUID(im.RegionID)); |
218 | } | 206 | if (region != null) |
219 | else | 207 | scene.RequestTeleportLocation(client, region.RegionHandle, im.Position, Vector3.UnitX, teleportFlags); |
220 | m_log.DebugFormat("[HG LURE MODULE]: pending lure {0} not found", lureID); | 208 | else // we don't have that region here. Check if it's HG |
221 | |||
222 | } | ||
223 | |||
224 | private void Lure(IClientAPI client, uint teleportflags, GridInstantMessage im) | ||
225 | { | ||
226 | Scene scene = (Scene)(client.Scene); | ||
227 | GridRegion region = scene.GridService.GetRegionByUUID(scene.RegionInfo.ScopeID, new UUID(im.RegionID)); | ||
228 | if (region != null) | ||
229 | scene.RequestTeleportLocation(client, region.RegionHandle, im.Position + new Vector3(0.5f, 0.5f, 0f), Vector3.UnitX, teleportflags); | ||
230 | else // we don't have that region here. Check if it's HG | ||
231 | { | ||
232 | string[] parts = im.message.Split(new char[] { '@' }); | ||
233 | if (parts.Length > 1) | ||
234 | { | 209 | { |
235 | string url = parts[parts.Length - 1]; // the last part | 210 | string[] parts = im.message.Split(new char[] { '@' }); |
236 | if (url.Trim(new char[] {'/'}) != m_ThisGridURL.Trim(new char[] {'/'})) | 211 | if (parts.Length > 1) |
237 | { | 212 | { |
238 | m_log.DebugFormat("[HG LURE MODULE]: Luring agent to grid {0} region {1} position {2}", url, im.RegionID, im.Position); | 213 | string url = parts[parts.Length - 1]; // the last part |
239 | GatekeeperServiceConnector gConn = new GatekeeperServiceConnector(); | 214 | if (url.Trim(new char[] {'/'}) != m_ThisGridURL.Trim(new char[] {'/'})) |
240 | GridRegion gatekeeper = new GridRegion(); | ||
241 | gatekeeper.ServerURI = url; | ||
242 | string homeURI = scene.GetAgentHomeURI(client.AgentId); | ||
243 | |||
244 | string message; | ||
245 | GridRegion finalDestination = gConn.GetHyperlinkRegion(gatekeeper, new UUID(im.RegionID), client.AgentId, homeURI, out message); | ||
246 | if (finalDestination != null) | ||
247 | { | 215 | { |
248 | ScenePresence sp = scene.GetScenePresence(client.AgentId); | 216 | m_log.DebugFormat("[HG LURE MODULE]: Luring agent to remote grid {0} region {1} position {2}", url, im.RegionID, im.Position); |
249 | IEntityTransferModule transferMod = scene.RequestModuleInterface<IEntityTransferModule>(); | 217 | GatekeeperServiceConnector gConn = new GatekeeperServiceConnector(); |
250 | 218 | GridRegion gatekeeper = new GridRegion(); | |
251 | if (transferMod != null && sp != null) | 219 | gatekeeper.ServerURI = url; |
220 | string homeURI = scene.GetAgentHomeURI(client.AgentId); | ||
221 | |||
222 | string message; | ||
223 | GridRegion finalDestination = gConn.GetHyperlinkRegion(gatekeeper, new UUID(im.RegionID), client.AgentId, homeURI, out message); | ||
224 | if (finalDestination != null) | ||
252 | { | 225 | { |
253 | if (message != null) | 226 | ScenePresence sp = scene.GetScenePresence(client.AgentId); |
254 | sp.ControllingClient.SendAgentAlertMessage(message, true); | 227 | IEntityTransferModule transferMod = scene.RequestModuleInterface<IEntityTransferModule>(); |
228 | |||
229 | if (transferMod != null && sp != null) | ||
230 | { | ||
231 | if (message != null) | ||
232 | sp.ControllingClient.SendAgentAlertMessage(message, true); | ||
255 | 233 | ||
256 | transferMod.DoTeleport( | 234 | transferMod.DoTeleport(sp, gatekeeper, finalDestination, im.Position, Vector3.UnitX, teleportFlags); |
257 | sp, gatekeeper, finalDestination, im.Position + new Vector3(0.5f, 0.5f, 0f), | 235 | } |
258 | Vector3.UnitX, teleportflags); | 236 | } |
237 | else | ||
238 | { | ||
239 | m_log.InfoFormat("[HG LURE MODULE]: Lure failed: {0}", message); | ||
240 | client.SendAgentAlertMessage(message, true); | ||
259 | } | 241 | } |
260 | } | ||
261 | else | ||
262 | { | ||
263 | m_log.InfoFormat("[HG LURE MODULE]: Lure failed: {0}", message); | ||
264 | client.SendAgentAlertMessage(message, true); | ||
265 | } | 242 | } |
266 | } | 243 | } |
267 | } | 244 | } |
268 | } | 245 | } |
246 | else | ||
247 | m_log.DebugFormat("[HG LURE MODULE]: pending lure {0} not found", lureID); | ||
269 | } | 248 | } |
270 | } | 249 | } |
271 | } \ No newline at end of file | 250 | } |