aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs234
1 files changed, 0 insertions, 234 deletions
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}