diff options
author | onefang | 2019-07-25 00:23:57 +1000 |
---|---|---|
committer | onefang | 2019-07-25 00:23:57 +1000 |
commit | 73934c7cae0d295bbe0fde8f8502b0ccece2ba15 (patch) | |
tree | f8ed54476dcd3afbd6ec60ae80404c70992ecf63 /OpenSim/Region | |
parent | Allow sitting on attachments, and attaching tings with people sitting on them. (diff) | |
download | opensim-SC_OLD-73934c7cae0d295bbe0fde8f8502b0ccece2ba15.zip opensim-SC_OLD-73934c7cae0d295bbe0fde8f8502b0ccece2ba15.tar.gz opensim-SC_OLD-73934c7cae0d295bbe0fde8f8502b0ccece2ba15.tar.bz2 opensim-SC_OLD-73934c7cae0d295bbe0fde8f8502b0ccece2ba15.tar.xz |
Combine LureModule and HGLureModule.
Still need to clean up after this, LureModule.cs isn't needed anymore.
Diffstat (limited to 'OpenSim/Region')
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/Lure/HGLureModule.cs | 170 |
1 files changed, 101 insertions, 69 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Lure/HGLureModule.cs b/OpenSim/Region/CoreModules/Avatar/Lure/HGLureModule.cs index 10781e9..381bb4d 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,8 +44,7 @@ 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 | ||
@@ -69,6 +67,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Lure | |||
69 | new string[] { "Startup", "Hypergrid", "Messaging" }, String.Empty); | 67 | new string[] { "Startup", "Hypergrid", "Messaging" }, String.Empty); |
70 | // Legacy. Remove soon! | 68 | // Legacy. Remove soon! |
71 | m_ThisGridURL = config.Configs["Messaging"].GetString("Gatekeeper", m_ThisGridURL); | 69 | m_ThisGridURL = config.Configs["Messaging"].GetString("Gatekeeper", m_ThisGridURL); |
70 | |||
72 | m_log.DebugFormat("[LURE MODULE]: {0} enabled", Name); | 71 | m_log.DebugFormat("[LURE MODULE]: {0} enabled", Name); |
73 | } | 72 | } |
74 | } | 73 | } |
@@ -154,19 +153,20 @@ namespace OpenSim.Region.CoreModules.Avatar.Lure | |||
154 | 153 | ||
155 | void OnIncomingInstantMessage(GridInstantMessage im) | 154 | void OnIncomingInstantMessage(GridInstantMessage im) |
156 | { | 155 | { |
157 | if (im.dialog == (byte)InstantMessageDialog.RequestTeleport | 156 | if (im.dialog == (byte)InstantMessageDialog.RequestTeleport || im.dialog == (byte)InstantMessageDialog.GodLikeRequestTeleport) |
158 | || im.dialog == (byte)InstantMessageDialog.GodLikeRequestTeleport) | ||
159 | { | 157 | { |
160 | UUID sessionID = new UUID(im.imSessionID); | 158 | if (1 == im.binaryBucket[0]) |
161 | |||
162 | if (!m_PendingLures.Contains(sessionID)) | ||
163 | { | 159 | { |
164 | m_log.DebugFormat("[HG LURE MODULE]: RequestTeleport sessionID={0}, regionID={1}, message={2}", im.imSessionID, im.RegionID, im.message); | 160 | UUID sessionID = new UUID(im.imSessionID); |
165 | m_PendingLures.Add(sessionID, im, 7200); // 2 hours | 161 | |
162 | if (!m_PendingLures.Contains(sessionID)) | ||
163 | { | ||
164 | 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 | ||
166 | } | ||
166 | } | 167 | } |
167 | 168 | ||
168 | // Forward. We do this, because the IM module explicitly rejects | 169 | // Forward. We do this, because the IM module explicitly rejects IMs of this type |
169 | // IMs of this type | ||
170 | if (m_TransferModule != null) | 170 | if (m_TransferModule != null) |
171 | m_TransferModule.SendInstantMessage(im, delegate(bool success) { }); | 171 | m_TransferModule.SendInstantMessage(im, delegate(bool success) { }); |
172 | } | 172 | } |
@@ -179,22 +179,47 @@ namespace OpenSim.Region.CoreModules.Avatar.Lure | |||
179 | 179 | ||
180 | Scene scene = (Scene)(client.Scene); | 180 | Scene scene = (Scene)(client.Scene); |
181 | ScenePresence presence = scene.GetScenePresence(client.AgentId); | 181 | ScenePresence presence = scene.GetScenePresence(client.AgentId); |
182 | ScenePresence target = scene.GetScenePresence(targetid); | ||
183 | Guid start = client.Scene.RegionInfo.RegionID.Guid; | ||
184 | UUID dest; | ||
185 | byte reqType = (byte)InstantMessageDialog.RequestTeleport; | ||
186 | byte[] bucket = new Byte[1]; | ||
182 | 187 | ||
183 | message += "@" + m_ThisGridURL; | 188 | m_log.DebugFormat("[LURE MODULE]: TP invite with message {0}, type {1} {2} {3} {4}", message, lureType, scene.Permissions.IsAdministrator(client.AgentId), presence.IsViewerUIGod, (!scene.Permissions.IsAdministrator(targetid))); |
184 | 189 | ||
185 | m_log.DebugFormat("[HG LURE MODULE]: TP invite with message {0}", message); | 190 | GridInstantMessage m; |
186 | 191 | ||
187 | UUID sessionID = UUID.Random(); | 192 | GridRegion region = scene.GridService.GetRegionByUUID(scene.RegionInfo.ScopeID, new UUID(start)); |
193 | if (region != null) | ||
194 | { | ||
195 | bucket[0] = 0; | ||
196 | dest = Util.BuildFakeParcelID(scene.RegionInfo.RegionHandle, | ||
197 | (uint)presence.AbsolutePosition.X, (uint)presence.AbsolutePosition.Y, (uint)presence.AbsolutePosition.Z); | ||
198 | if (scene.Permissions.IsAdministrator(client.AgentId) && presence.IsViewerUIGod && (!scene.Permissions.IsAdministrator(targetid))) | ||
199 | { | ||
200 | reqType = (byte)InstantMessageDialog.GodLikeRequestTeleport; | ||
201 | m_log.DebugFormat("[LURE MODULE]: TP FORCE GOD LURE with message {0}, type {1}", message, lureType); | ||
202 | } | ||
203 | else | ||
204 | m_log.DebugFormat("[LURE MODULE]: TP lure with message {0}, type {1}", message, lureType); | ||
205 | } | ||
206 | else | ||
207 | { | ||
208 | m_log.DebugFormat("[LURE MODULE]: HG lure with message {0}, type {1}", message, lureType); | ||
209 | bucket[0] = 1; | ||
210 | message += "@" + m_ThisGridURL; | ||
211 | dest = UUID.Random(); | ||
212 | } | ||
188 | 213 | ||
189 | GridInstantMessage m = new GridInstantMessage(scene, client.AgentId, | 214 | m = new GridInstantMessage(scene, client.AgentId, client.FirstName+" "+client.LastName, targetid, |
190 | client.FirstName+" "+client.LastName, targetid, | 215 | reqType, false, message, dest, false, presence.AbsolutePosition, bucket, true); |
191 | (byte)InstantMessageDialog.RequestTeleport, false, | ||
192 | message, sessionID, false, presence.AbsolutePosition, | ||
193 | new Byte[0], true); | ||
194 | m.RegionID = client.Scene.RegionInfo.RegionID.Guid; | ||
195 | 216 | ||
196 | m_log.DebugFormat("[HG LURE MODULE]: RequestTeleport sessionID={0}, regionID={1}, message={2}", m.imSessionID, m.RegionID, m.message); | 217 | if (region == null) |
197 | m_PendingLures.Add(sessionID, m, 7200); // 2 hours | 218 | { |
219 | m.RegionID = start; | ||
220 | m_log.DebugFormat("[LURE MODULE]: Hypergrid RequestTeleport sessionID={0}, regionID={1}, message={2}", m.imSessionID, m.RegionID, m.message); | ||
221 | m_PendingLures.Add(dest, m, 7200); // 2 hours | ||
222 | } | ||
198 | 223 | ||
199 | if (m_TransferModule != null) | 224 | if (m_TransferModule != null) |
200 | { | 225 | { |
@@ -208,64 +233,71 @@ namespace OpenSim.Region.CoreModules.Avatar.Lure | |||
208 | if (!(client.Scene is Scene)) | 233 | if (!(client.Scene is Scene)) |
209 | return; | 234 | return; |
210 | 235 | ||
211 | // Scene scene = (Scene)(client.Scene); | 236 | Scene scene = (Scene)(client.Scene); |
212 | |||
213 | GridInstantMessage im = null; | 237 | GridInstantMessage im = null; |
238 | |||
214 | if (m_PendingLures.TryGetValue(lureID, out im)) | 239 | if (m_PendingLures.TryGetValue(lureID, out im)) |
215 | { | 240 | { |
216 | m_PendingLures.Remove(lureID); | 241 | m_PendingLures.Remove(lureID); |
217 | Lure(client, teleportFlags, im); | 242 | GridRegion region = scene.GridService.GetRegionByUUID(scene.RegionInfo.ScopeID, new UUID(im.RegionID)); |
218 | } | 243 | if (region != null) |
219 | else | 244 | scene.RequestTeleportLocation(client, region.RegionHandle, im.Position + new Vector3(0.5f, 0.5f, 2f), Vector3.UnitX, teleportFlags); |
220 | m_log.DebugFormat("[HG LURE MODULE]: pending lure {0} not found", lureID); | 245 | 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 | { | 246 | { |
235 | string url = parts[parts.Length - 1]; // the last part | 247 | string[] parts = im.message.Split(new char[] { '@' }); |
236 | if (url.Trim(new char[] {'/'}) != m_ThisGridURL.Trim(new char[] {'/'})) | 248 | if (parts.Length > 1) |
237 | { | 249 | { |
238 | m_log.DebugFormat("[HG LURE MODULE]: Luring agent to grid {0} region {1} position {2}", url, im.RegionID, im.Position); | 250 | string url = parts[parts.Length - 1]; // the last part |
239 | GatekeeperServiceConnector gConn = new GatekeeperServiceConnector(); | 251 | 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 | { | 252 | { |
248 | ScenePresence sp = scene.GetScenePresence(client.AgentId); | 253 | 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>(); | 254 | GatekeeperServiceConnector gConn = new GatekeeperServiceConnector(); |
250 | 255 | GridRegion gatekeeper = new GridRegion(); | |
251 | if (transferMod != null && sp != null) | 256 | gatekeeper.ServerURI = url; |
257 | string homeURI = scene.GetAgentHomeURI(client.AgentId); | ||
258 | |||
259 | string message; | ||
260 | GridRegion finalDestination = gConn.GetHyperlinkRegion(gatekeeper, new UUID(im.RegionID), client.AgentId, homeURI, out message); | ||
261 | if (finalDestination != null) | ||
252 | { | 262 | { |
253 | if (message != null) | 263 | ScenePresence sp = scene.GetScenePresence(client.AgentId); |
254 | sp.ControllingClient.SendAgentAlertMessage(message, true); | 264 | IEntityTransferModule transferMod = scene.RequestModuleInterface<IEntityTransferModule>(); |
255 | 265 | ||
256 | transferMod.DoTeleport( | 266 | if (transferMod != null && sp != null) |
257 | sp, gatekeeper, finalDestination, im.Position + new Vector3(0.5f, 0.5f, 0f), | 267 | { |
258 | Vector3.UnitX, teleportflags); | 268 | if (message != null) |
269 | sp.ControllingClient.SendAgentAlertMessage(message, true); | ||
270 | |||
271 | transferMod.DoTeleport(sp, gatekeeper, finalDestination, im.Position + new Vector3(0.5f, 0.5f, 2f), Vector3.UnitX, teleportFlags); | ||
272 | } | ||
273 | } | ||
274 | else | ||
275 | { | ||
276 | m_log.InfoFormat("[HG LURE MODULE]: Lure failed: {0}", message); | ||
277 | client.SendAgentAlertMessage(message, true); | ||
259 | } | 278 | } |
260 | } | ||
261 | else | ||
262 | { | ||
263 | m_log.InfoFormat("[HG LURE MODULE]: Lure failed: {0}", message); | ||
264 | client.SendAgentAlertMessage(message, true); | ||
265 | } | 279 | } |
266 | } | 280 | } |
267 | } | 281 | } |
268 | } | 282 | } |
283 | else | ||
284 | { | ||
285 | ulong handle = 0; | ||
286 | uint x = 128; | ||
287 | uint y = 128; | ||
288 | uint z = 70; | ||
289 | |||
290 | Util.ParseFakeParcelID(lureID, out handle, out x, out y, out z); | ||
291 | |||
292 | Vector3 position = new Vector3(); | ||
293 | position.X = (float)x; | ||
294 | position.Y = (float)y; | ||
295 | position.Z = (float)z; | ||
296 | |||
297 | m_log.DebugFormat("[LURE MODULE]: Luring agent to local region {0}, position {1}", scene.Name, position); | ||
298 | scene.RequestTeleportLocation(client, handle, position + new Vector3(0.5f, 0.5f, 2f), Vector3.Zero, teleportFlags); | ||
299 | } | ||
300 | |||
269 | } | 301 | } |
270 | } | 302 | } |
271 | } \ No newline at end of file | 303 | } |