aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authoronefang2019-07-25 20:20:21 +1000
committeronefang2019-07-25 20:20:21 +1000
commit0a38585d4a15100183acb293edcb9c69190c61db (patch)
tree8fbad76e2c7b275d4af90f034e7e5a637132ea7d /OpenSim
parentGatekeeper -> GatekeeperURI (diff)
downloadopensim-SC_OLD-0a38585d4a15100183acb293edcb9c69190c61db.zip
opensim-SC_OLD-0a38585d4a15100183acb293edcb9c69190c61db.tar.gz
opensim-SC_OLD-0a38585d4a15100183acb293edcb9c69190c61db.tar.bz2
opensim-SC_OLD-0a38585d4a15100183acb293edcb9c69190c61db.tar.xz
Merge LureModule into HGLureModule.
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Lure/HGLureModule.cs88
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs234
2 files changed, 18 insertions, 304 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Lure/HGLureModule.cs b/OpenSim/Region/CoreModules/Avatar/Lure/HGLureModule.cs
index dfcf925..3dc9bf5 100644
--- a/OpenSim/Region/CoreModules/Avatar/Lure/HGLureModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Lure/HGLureModule.cs
@@ -49,7 +49,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Lure
49 private readonly List<Scene> m_scenes = new List<Scene>(); 49 private readonly List<Scene> m_scenes = new List<Scene>();
50 50
51 private IMessageTransferModule m_TransferModule = null; 51 private IMessageTransferModule m_TransferModule = null;
52 private bool m_Enabled = false;
53 52
54 private string m_ThisGridURL; 53 private string m_ThisGridURL;
55 54
@@ -59,24 +58,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Lure
59 { 58 {
60 if (config.Configs["Messaging"] != null) 59 if (config.Configs["Messaging"] != null)
61 { 60 {
62 if (config.Configs["Messaging"].GetString("LureModule", string.Empty) == "HGLureModule") 61 m_ThisGridURL = Util.GetConfigVarFromSections<string>(config, "GatekeeperURI", new string[] { "Startup", "Hypergrid", "Messaging" }, String.Empty);
63 {
64 m_Enabled = true;
65
66 m_ThisGridURL = Util.GetConfigVarFromSections<string>(config, "GatekeeperURI",
67 new string[] { "Startup", "Hypergrid", "Messaging" }, String.Empty);
68 m_log.DebugFormat("[LURE MODULE]: {0} enabled", Name);
69 }
70 // Legacy. Remove soon! 62 // Legacy. Remove soon!
71//// m_ThisGridURL = config.Configs["Messaging"].GetString("Gatekeeper", m_ThisGridURL); 63//// m_ThisGridURL = config.Configs["Messaging"].GetString("Gatekeeper", m_ThisGridURL);
64 m_log.DebugFormat("[HG LURE MODULE]: {0} enabled", Name);
72 } 65 }
73 } 66 }
74 67
75 public void AddRegion(Scene scene) 68 public void AddRegion(Scene scene)
76 { 69 {
77 if (!m_Enabled)
78 return;
79
80 lock (m_scenes) 70 lock (m_scenes)
81 { 71 {
82 m_scenes.Add(scene); 72 m_scenes.Add(scene);
@@ -87,9 +77,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Lure
87 77
88 public void RegionLoaded(Scene scene) 78 public void RegionLoaded(Scene scene)
89 { 79 {
90 if (!m_Enabled)
91 return;
92
93 if (m_TransferModule == null) 80 if (m_TransferModule == null)
94 { 81 {
95 m_TransferModule = 82 m_TransferModule =
@@ -97,9 +84,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Lure
97 84
98 if (m_TransferModule == null) 85 if (m_TransferModule == null)
99 { 86 {
100 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!");
101
102 m_Enabled = false;
103 m_scenes.Clear(); 88 m_scenes.Clear();
104 scene.EventManager.OnNewClient -= OnNewClient; 89 scene.EventManager.OnNewClient -= OnNewClient;
105 scene.EventManager.OnIncomingInstantMessage -= OnIncomingInstantMessage; 90 scene.EventManager.OnIncomingInstantMessage -= OnIncomingInstantMessage;
@@ -110,9 +95,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Lure
110 95
111 public void RemoveRegion(Scene scene) 96 public void RemoveRegion(Scene scene)
112 { 97 {
113 if (!m_Enabled)
114 return;
115
116 lock (m_scenes) 98 lock (m_scenes)
117 { 99 {
118 m_scenes.Remove(scene); 100 m_scenes.Remove(scene);
@@ -154,17 +136,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Lure
154 { 136 {
155 if (im.dialog == (byte)InstantMessageDialog.RequestTeleport || im.dialog == (byte)InstantMessageDialog.GodLikeRequestTeleport) 137 if (im.dialog == (byte)InstantMessageDialog.RequestTeleport || im.dialog == (byte)InstantMessageDialog.GodLikeRequestTeleport)
156 { 138 {
157 if (1 == im.binaryBucket[0]) 139 UUID sessionID = new UUID(im.imSessionID);
140 if (!m_PendingLures.Contains(sessionID))
158 { 141 {
159 UUID sessionID = new UUID(im.imSessionID); 142 m_log.DebugFormat("[HG LURE MODULE]: RequestTeleport sessionID={0}, regionID={1}, message={2}", im.imSessionID, im.RegionID, im.message);
160 143 m_PendingLures.Add(sessionID, im, 7200); // 2 hours
161 if (!m_PendingLures.Contains(sessionID))
162 {
163 m_log.DebugFormat("[HG LURE MODULE]: RequestTeleport sessionID={0}, regionID={1}, message={2}", im.imSessionID, im.RegionID, im.message);
164 m_PendingLures.Add(sessionID, im, 7200); // 2 hours
165 }
166 } 144 }
167
168 // Forward. We do this, because the IM module explicitly rejects IMs of this type 145 // Forward. We do this, because the IM module explicitly rejects IMs of this type
169 if (m_TransferModule != null) 146 if (m_TransferModule != null)
170 m_TransferModule.SendInstantMessage(im, delegate(bool success) { }); 147 m_TransferModule.SendInstantMessage(im, delegate(bool success) { });
@@ -180,45 +157,31 @@ namespace OpenSim.Region.CoreModules.Avatar.Lure
180 ScenePresence presence = scene.GetScenePresence(client.AgentId); 157 ScenePresence presence = scene.GetScenePresence(client.AgentId);
181 ScenePresence target = scene.GetScenePresence(targetid); 158 ScenePresence target = scene.GetScenePresence(targetid);
182 Guid start = client.Scene.RegionInfo.RegionID.Guid; 159 Guid start = client.Scene.RegionInfo.RegionID.Guid;
183 UUID dest; 160 UUID dest = UUID.Random();
184 byte reqType = (byte)InstantMessageDialog.RequestTeleport; 161 byte reqType = (byte)InstantMessageDialog.RequestTeleport;
185 byte[] bucket = new Byte[1];
186
187 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)));
188
189 GridInstantMessage m; 162 GridInstantMessage m;
190 163
191 GridRegion region = scene.GridService.GetRegionByUUID(scene.RegionInfo.ScopeID, new UUID(start)); 164 GridRegion region = scene.GridService.GetRegionByUUID(scene.RegionInfo.ScopeID, new UUID(start));
192 if (region != null) 165 if (region != null)
193 { 166 {
194 bucket[0] = 0;
195 dest = Util.BuildFakeParcelID(scene.RegionInfo.RegionHandle,
196 (uint)presence.AbsolutePosition.X, (uint)presence.AbsolutePosition.Y, (uint)presence.AbsolutePosition.Z);
197 if (scene.Permissions.IsAdministrator(client.AgentId) && presence.IsViewerUIGod && (!scene.Permissions.IsAdministrator(targetid))) 167 if (scene.Permissions.IsAdministrator(client.AgentId) && presence.IsViewerUIGod && (!scene.Permissions.IsAdministrator(targetid)))
198 { 168 {
199 reqType = (byte)InstantMessageDialog.GodLikeRequestTeleport; 169 reqType = (byte)InstantMessageDialog.GodLikeRequestTeleport;
200 m_log.DebugFormat("[LURE MODULE]: TP FORCE GOD LURE with message {0}, type {1}", message, lureType); 170 m_log.DebugFormat("[HG LURE MODULE]: TP FORCE GOD LURE with message {0}, type {1}", message, lureType);
201 } 171 }
202 else 172 else
203 m_log.DebugFormat("[LURE MODULE]: TP lure with message {0}, type {1}", message, lureType); 173 m_log.DebugFormat("[HG LURE MODULE]: TP lure with message {0}, type {1}", message, lureType);
204 } 174 }
205 else 175 else
206 { 176 {
207 m_log.DebugFormat("[LURE MODULE]: HG lure with message {0}, type {1}", message, lureType); 177 m_log.DebugFormat("[HG LURE MODULE]: hypergrid TP lure with message {0}, type {1}", message, lureType);
208 bucket[0] = 1;
209 message += "@" + m_ThisGridURL; 178 message += "@" + m_ThisGridURL;
210 dest = UUID.Random();
211 } 179 }
212 180
213 m = new GridInstantMessage(scene, client.AgentId, client.FirstName+" "+client.LastName, targetid, 181 m = new GridInstantMessage(scene, client.AgentId, client.FirstName+" "+client.LastName, targetid,
214 reqType, false, message, dest, false, presence.AbsolutePosition, bucket, true); 182 reqType, false, message, dest, false, presence.AbsolutePosition, new Byte[0], true);
215 183 m.RegionID = start;
216 if (region == null) 184 m_PendingLures.Add(dest, m, 7200); // 2 hours
217 {
218 m.RegionID = start;
219 m_log.DebugFormat("[LURE MODULE]: Hypergrid RequestTeleport sessionID={0}, regionID={1}, message={2}", m.imSessionID, m.RegionID, m.message);
220 m_PendingLures.Add(dest, m, 7200); // 2 hours
221 }
222 185
223 if (m_TransferModule != null) 186 if (m_TransferModule != null)
224 { 187 {
@@ -237,10 +200,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Lure
237 200
238 if (m_PendingLures.TryGetValue(lureID, out im)) 201 if (m_PendingLures.TryGetValue(lureID, out im))
239 { 202 {
203 im.Position = im.Position + new Vector3(0.5f, 0.5f, 2f);
240 m_PendingLures.Remove(lureID); 204 m_PendingLures.Remove(lureID);
241 GridRegion region = scene.GridService.GetRegionByUUID(scene.RegionInfo.ScopeID, new UUID(im.RegionID)); 205 GridRegion region = scene.GridService.GetRegionByUUID(scene.RegionInfo.ScopeID, new UUID(im.RegionID));
242 if (region != null) 206 if (region != null)
243 scene.RequestTeleportLocation(client, region.RegionHandle, im.Position + new Vector3(0.5f, 0.5f, 2f), Vector3.UnitX, teleportFlags); 207 scene.RequestTeleportLocation(client, region.RegionHandle, im.Position, Vector3.UnitX, teleportFlags);
244 else // we don't have that region here. Check if it's HG 208 else // we don't have that region here. Check if it's HG
245 { 209 {
246 string[] parts = im.message.Split(new char[] { '@' }); 210 string[] parts = im.message.Split(new char[] { '@' });
@@ -267,7 +231,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Lure
267 if (message != null) 231 if (message != null)
268 sp.ControllingClient.SendAgentAlertMessage(message, true); 232 sp.ControllingClient.SendAgentAlertMessage(message, true);
269 233
270 transferMod.DoTeleport(sp, gatekeeper, finalDestination, im.Position + new Vector3(0.5f, 0.5f, 2f), Vector3.UnitX, teleportFlags); 234 transferMod.DoTeleport(sp, gatekeeper, finalDestination, im.Position, Vector3.UnitX, teleportFlags);
271 } 235 }
272 } 236 }
273 else 237 else
@@ -280,23 +244,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Lure
280 } 244 }
281 } 245 }
282 else 246 else
283 { 247 m_log.DebugFormat("[HG LURE MODULE]: pending lure {0} not found", lureID);
284 ulong handle = 0;
285 uint x = 128;
286 uint y = 128;
287 uint z = 70;
288
289 Util.ParseFakeParcelID(lureID, out handle, out x, out y, out z);
290
291 Vector3 position = new Vector3();
292 position.X = (float)x;
293 position.Y = (float)y;
294 position.Z = (float)z;
295
296 m_log.DebugFormat("[LURE MODULE]: Luring agent to local region {0}, position {1}", scene.Name, position);
297 scene.RequestTeleportLocation(client, handle, position + new Vector3(0.5f, 0.5f, 2f), Vector3.Zero, teleportFlags);
298 }
299
300 } 248 }
301 } 249 }
302} 250}
diff --git a/OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs b/OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs
deleted file mode 100644
index 6f79676..0000000
--- a/OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs
+++ /dev/null
@@ -1,234 +0,0 @@
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 OpenSimulator 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.Generic;
30using System.Reflection;
31using log4net;
32using Mono.Addins;
33using Nini.Config;
34using OpenMetaverse;
35using OpenSim.Framework;
36using OpenSim.Region.Framework.Interfaces;
37using OpenSim.Region.Framework.Scenes;
38
39namespace OpenSim.Region.CoreModules.Avatar.Lure
40{
41 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "LureModule")]
42 public class LureModule : ISharedRegionModule
43 {
44 private static readonly ILog m_log = LogManager.GetLogger(
45 MethodBase.GetCurrentMethod().DeclaringType);
46
47 private readonly List<Scene> m_scenes = new List<Scene>();
48
49 private IMessageTransferModule m_TransferModule = null;
50 private bool m_Enabled = false;
51
52 public void Initialise(IConfigSource config)
53 {
54 if (config.Configs["Messaging"] != null)
55 {
56 if (config.Configs["Messaging"].GetString(
57 "LureModule", "LureModule") ==
58 "LureModule")
59 {
60 m_Enabled = true;
61 m_log.DebugFormat("[LURE MODULE]: {0} enabled", Name);
62 }
63 }
64 }
65
66 public void AddRegion(Scene scene)
67 {
68 if (!m_Enabled)
69 return;
70
71 lock (m_scenes)
72 {
73 m_scenes.Add(scene);
74 scene.EventManager.OnNewClient += OnNewClient;
75 scene.EventManager.OnIncomingInstantMessage +=
76 OnGridInstantMessage;
77 }
78 }
79
80 public void RegionLoaded(Scene scene)
81 {
82 if (!m_Enabled)
83 return;
84
85 if (m_TransferModule == null)
86 {
87 m_TransferModule =
88 scene.RequestModuleInterface<IMessageTransferModule>();
89
90 if (m_TransferModule == null)
91 {
92 m_log.Error("[INSTANT MESSAGE]: No message transfer module, "+
93 "lures will not work!");
94
95 m_Enabled = false;
96 m_scenes.Clear();
97 scene.EventManager.OnNewClient -= OnNewClient;
98 scene.EventManager.OnIncomingInstantMessage -=
99 OnGridInstantMessage;
100 }
101 }
102
103 }
104
105 public void RemoveRegion(Scene scene)
106 {
107 if (!m_Enabled)
108 return;
109
110 lock (m_scenes)
111 {
112 m_scenes.Remove(scene);
113 scene.EventManager.OnNewClient -= OnNewClient;
114 scene.EventManager.OnIncomingInstantMessage -=
115 OnGridInstantMessage;
116 }
117 }
118
119 void OnNewClient(IClientAPI client)
120 {
121 client.OnInstantMessage += OnInstantMessage;
122 client.OnStartLure += OnStartLure;
123 client.OnTeleportLureRequest += OnTeleportLureRequest;
124 }
125
126 public void PostInitialise()
127 {
128 }
129
130 public void Close()
131 {
132 }
133
134 public string Name
135 {
136 get { return "LureModule"; }
137 }
138
139 public Type ReplaceableInterface
140 {
141 get { return null; }
142 }
143
144 public void OnInstantMessage(IClientAPI client, GridInstantMessage im)
145 {
146 }
147
148 public void OnStartLure(byte lureType, string message, UUID targetid, IClientAPI client)
149 {
150 if (!(client.Scene is Scene))
151 return;
152
153 Scene scene = (Scene)(client.Scene);
154 ScenePresence presence = scene.GetScenePresence(client.AgentId);
155
156 // Round up Z co-ordinate rather than round-down by casting. This stops tall avatars from being given
157 // a teleport Z co-ordinate by short avatars that drops them through or embeds them in thin floors on
158 // arrival.
159 //
160 // Ideally we would give the exact float position adjusting for the relative height of the two avatars
161 // but it looks like a float component isn't possible with a parcel ID.
162 UUID dest = Util.BuildFakeParcelID(
163 scene.RegionInfo.RegionHandle,
164 (uint)presence.AbsolutePosition.X,
165 (uint)presence.AbsolutePosition.Y,
166 (uint)presence.AbsolutePosition.Z + 2);
167
168 m_log.DebugFormat("[LURE MODULE]: TP invite with message {0}, type {1}", message, lureType);
169
170 GridInstantMessage m;
171
172 if (scene.Permissions.IsAdministrator(client.AgentId) && presence.IsViewerUIGod && (!scene.Permissions.IsAdministrator(targetid)))
173 {
174 m = new GridInstantMessage(scene, client.AgentId,
175 client.FirstName+" "+client.LastName, targetid,
176 (byte)InstantMessageDialog.GodLikeRequestTeleport, false,
177 message, dest, false, presence.AbsolutePosition,
178 new Byte[0], true);
179 }
180 else
181 {
182 m = new GridInstantMessage(scene, client.AgentId,
183 client.FirstName+" "+client.LastName, targetid,
184 (byte)InstantMessageDialog.RequestTeleport, false,
185 message, dest, false, presence.AbsolutePosition,
186 new Byte[0], true);
187 }
188
189 if (m_TransferModule != null)
190 {
191 m_TransferModule.SendInstantMessage(m,
192 delegate(bool success) { });
193 }
194 }
195
196 public void OnTeleportLureRequest(UUID lureID, uint teleportFlags, IClientAPI client)
197 {
198 if (!(client.Scene is Scene))
199 return;
200
201 Scene scene = (Scene)(client.Scene);
202
203 ulong handle = 0;
204 uint x = 128;
205 uint y = 128;
206 uint z = 70;
207
208 Util.ParseFakeParcelID(lureID, out handle, out x, out y, out z);
209
210 Vector3 position = new Vector3();
211 position.X = (float)x;
212 position.Y = (float)y;
213 position.Z = (float)z;
214
215 scene.RequestTeleportLocation(client, handle, position,
216 Vector3.Zero, teleportFlags);
217 }
218
219 private void OnGridInstantMessage(GridInstantMessage msg)
220 {
221 // Forward remote teleport requests
222 //
223 if (msg.dialog != (byte)InstantMessageDialog.RequestTeleport &&
224 msg.dialog != (byte)InstantMessageDialog.GodLikeRequestTeleport)
225 return;
226
227 if (m_TransferModule != null)
228 {
229 m_TransferModule.SendInstantMessage(msg,
230 delegate(bool success) { });
231 }
232 }
233 }
234}