diff options
author | David Walter Seikel | 2016-11-03 21:44:39 +1000 |
---|---|---|
committer | David Walter Seikel | 2016-11-03 21:44:39 +1000 |
commit | 134f86e8d5c414409631b25b8c6f0ee45fbd8631 (patch) | |
tree | 216b89d3fb89acfb81be1e440c25c41ab09fa96d /OpenSim/Region/CoreModules/World/Estate/XEstateModule.cs | |
parent | More changing to production grid. Double oops. (diff) | |
download | opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.zip opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.gz opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.bz2 opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.xz |
Initial update to OpenSim 0.8.2.1 source code.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/CoreModules/World/Estate/XEstateModule.cs | 255 |
1 files changed, 255 insertions, 0 deletions
diff --git a/OpenSim/Region/CoreModules/World/Estate/XEstateModule.cs b/OpenSim/Region/CoreModules/World/Estate/XEstateModule.cs new file mode 100644 index 0000000..4bb3799 --- /dev/null +++ b/OpenSim/Region/CoreModules/World/Estate/XEstateModule.cs | |||
@@ -0,0 +1,255 @@ | |||
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 | |||
28 | using System; | ||
29 | using System.Collections; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Reflection; | ||
32 | using log4net; | ||
33 | using Nini.Config; | ||
34 | using Nwc.XmlRpc; | ||
35 | using OpenMetaverse; | ||
36 | using OpenSim.Framework; | ||
37 | using OpenSim.Region.Framework.Interfaces; | ||
38 | using OpenSim.Region.Framework.Scenes; | ||
39 | using OpenSim.Services.Interfaces; | ||
40 | using OpenSim.Server.Base; | ||
41 | using OpenSim.Framework.Servers; | ||
42 | using OpenSim.Framework.Servers.HttpServer; | ||
43 | using Mono.Addins; | ||
44 | |||
45 | namespace OpenSim.Region.CoreModules.World.Estate | ||
46 | { | ||
47 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "XEstate")] | ||
48 | public class XEstateModule : ISharedRegionModule | ||
49 | { | ||
50 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
51 | |||
52 | protected List<Scene> m_Scenes = new List<Scene>(); | ||
53 | protected bool m_InInfoUpdate = false; | ||
54 | |||
55 | public bool InInfoUpdate | ||
56 | { | ||
57 | get { return m_InInfoUpdate; } | ||
58 | set { m_InInfoUpdate = value; } | ||
59 | } | ||
60 | |||
61 | public List<Scene> Scenes | ||
62 | { | ||
63 | get { return m_Scenes; } | ||
64 | } | ||
65 | |||
66 | protected EstateConnector m_EstateConnector; | ||
67 | |||
68 | public void Initialise(IConfigSource config) | ||
69 | { | ||
70 | int port = 0; | ||
71 | |||
72 | IConfig estateConfig = config.Configs["Estate"]; | ||
73 | if (estateConfig != null) | ||
74 | { | ||
75 | port = estateConfig.GetInt("Port", 0); | ||
76 | } | ||
77 | |||
78 | m_EstateConnector = new EstateConnector(this); | ||
79 | |||
80 | // Instantiate the request handler | ||
81 | IHttpServer server = MainServer.GetHttpServer((uint)port); | ||
82 | server.AddStreamHandler(new EstateRequestHandler(this)); | ||
83 | } | ||
84 | |||
85 | public void PostInitialise() | ||
86 | { | ||
87 | } | ||
88 | |||
89 | public void Close() | ||
90 | { | ||
91 | } | ||
92 | |||
93 | public void AddRegion(Scene scene) | ||
94 | { | ||
95 | lock (m_Scenes) | ||
96 | m_Scenes.Add(scene); | ||
97 | |||
98 | scene.EventManager.OnNewClient += OnNewClient; | ||
99 | } | ||
100 | |||
101 | public void RegionLoaded(Scene scene) | ||
102 | { | ||
103 | IEstateModule em = scene.RequestModuleInterface<IEstateModule>(); | ||
104 | |||
105 | em.OnRegionInfoChange += OnRegionInfoChange; | ||
106 | em.OnEstateInfoChange += OnEstateInfoChange; | ||
107 | em.OnEstateMessage += OnEstateMessage; | ||
108 | } | ||
109 | |||
110 | public void RemoveRegion(Scene scene) | ||
111 | { | ||
112 | scene.EventManager.OnNewClient -= OnNewClient; | ||
113 | |||
114 | lock (m_Scenes) | ||
115 | m_Scenes.Remove(scene); | ||
116 | } | ||
117 | |||
118 | public string Name | ||
119 | { | ||
120 | get { return "EstateModule"; } | ||
121 | } | ||
122 | |||
123 | public Type ReplaceableInterface | ||
124 | { | ||
125 | get { return null; } | ||
126 | } | ||
127 | |||
128 | private Scene FindScene(UUID RegionID) | ||
129 | { | ||
130 | foreach (Scene s in Scenes) | ||
131 | { | ||
132 | if (s.RegionInfo.RegionID == RegionID) | ||
133 | return s; | ||
134 | } | ||
135 | |||
136 | return null; | ||
137 | } | ||
138 | |||
139 | private void OnRegionInfoChange(UUID RegionID) | ||
140 | { | ||
141 | Scene s = FindScene(RegionID); | ||
142 | if (s == null) | ||
143 | return; | ||
144 | |||
145 | if (!m_InInfoUpdate) | ||
146 | m_EstateConnector.SendUpdateCovenant(s.RegionInfo.EstateSettings.EstateID, s.RegionInfo.RegionSettings.Covenant); | ||
147 | } | ||
148 | |||
149 | private void OnEstateInfoChange(UUID RegionID) | ||
150 | { | ||
151 | Scene s = FindScene(RegionID); | ||
152 | if (s == null) | ||
153 | return; | ||
154 | |||
155 | if (!m_InInfoUpdate) | ||
156 | m_EstateConnector.SendUpdateEstate(s.RegionInfo.EstateSettings.EstateID); | ||
157 | } | ||
158 | |||
159 | private void OnEstateMessage(UUID RegionID, UUID FromID, string FromName, string Message) | ||
160 | { | ||
161 | Scene senderScenes = FindScene(RegionID); | ||
162 | if (senderScenes == null) | ||
163 | return; | ||
164 | |||
165 | uint estateID = senderScenes.RegionInfo.EstateSettings.EstateID; | ||
166 | |||
167 | foreach (Scene s in Scenes) | ||
168 | { | ||
169 | if (s.RegionInfo.EstateSettings.EstateID == estateID) | ||
170 | { | ||
171 | IDialogModule dm = s.RequestModuleInterface<IDialogModule>(); | ||
172 | |||
173 | if (dm != null) | ||
174 | { | ||
175 | dm.SendNotificationToUsersInRegion(FromID, FromName, | ||
176 | Message); | ||
177 | } | ||
178 | } | ||
179 | } | ||
180 | if (!m_InInfoUpdate) | ||
181 | m_EstateConnector.SendEstateMessage(estateID, FromID, FromName, Message); | ||
182 | } | ||
183 | |||
184 | private void OnNewClient(IClientAPI client) | ||
185 | { | ||
186 | client.OnEstateTeleportOneUserHomeRequest += OnEstateTeleportOneUserHomeRequest; | ||
187 | client.OnEstateTeleportAllUsersHomeRequest += OnEstateTeleportAllUsersHomeRequest; | ||
188 | |||
189 | } | ||
190 | |||
191 | private void OnEstateTeleportOneUserHomeRequest(IClientAPI client, UUID invoice, UUID senderID, UUID prey) | ||
192 | { | ||
193 | if (prey == UUID.Zero) | ||
194 | return; | ||
195 | |||
196 | if (!(client.Scene is Scene)) | ||
197 | return; | ||
198 | |||
199 | Scene scene = (Scene)client.Scene; | ||
200 | |||
201 | uint estateID = scene.RegionInfo.EstateSettings.EstateID; | ||
202 | |||
203 | if (!scene.Permissions.CanIssueEstateCommand(client.AgentId, false)) | ||
204 | return; | ||
205 | |||
206 | foreach (Scene s in Scenes) | ||
207 | { | ||
208 | if (s == scene) | ||
209 | continue; // Already handles by estate module | ||
210 | if (s.RegionInfo.EstateSettings.EstateID != estateID) | ||
211 | continue; | ||
212 | |||
213 | ScenePresence p = scene.GetScenePresence(prey); | ||
214 | if (p != null && !p.IsChildAgent) | ||
215 | { | ||
216 | p.ControllingClient.SendTeleportStart(16); | ||
217 | scene.TeleportClientHome(prey, p.ControllingClient); | ||
218 | } | ||
219 | } | ||
220 | |||
221 | m_EstateConnector.SendTeleportHomeOneUser(estateID, prey); | ||
222 | } | ||
223 | |||
224 | private void OnEstateTeleportAllUsersHomeRequest(IClientAPI client, UUID invoice, UUID senderID) | ||
225 | { | ||
226 | if (!(client.Scene is Scene)) | ||
227 | return; | ||
228 | |||
229 | Scene scene = (Scene)client.Scene; | ||
230 | |||
231 | uint estateID = scene.RegionInfo.EstateSettings.EstateID; | ||
232 | |||
233 | if (!scene.Permissions.CanIssueEstateCommand(client.AgentId, false)) | ||
234 | return; | ||
235 | |||
236 | foreach (Scene s in Scenes) | ||
237 | { | ||
238 | if (s == scene) | ||
239 | continue; // Already handles by estate module | ||
240 | if (s.RegionInfo.EstateSettings.EstateID != estateID) | ||
241 | continue; | ||
242 | |||
243 | scene.ForEachScenePresence(delegate(ScenePresence p) { | ||
244 | if (p != null && !p.IsChildAgent) | ||
245 | { | ||
246 | p.ControllingClient.SendTeleportStart(16); | ||
247 | scene.TeleportClientHome(p.ControllingClient.AgentId, p.ControllingClient); | ||
248 | } | ||
249 | }); | ||
250 | } | ||
251 | |||
252 | m_EstateConnector.SendTeleportHomeAllUsers(estateID); | ||
253 | } | ||
254 | } | ||
255 | } | ||