diff options
Diffstat (limited to 'OpenSim/Region')
-rw-r--r-- | OpenSim/Region/Environment/Scenes/InnerScene.cs | 1310 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs | 424 |
2 files changed, 867 insertions, 867 deletions
diff --git a/OpenSim/Region/Environment/Scenes/InnerScene.cs b/OpenSim/Region/Environment/Scenes/InnerScene.cs index 5d85c1d..3195991 100644 --- a/OpenSim/Region/Environment/Scenes/InnerScene.cs +++ b/OpenSim/Region/Environment/Scenes/InnerScene.cs | |||
@@ -1,655 +1,655 @@ | |||
1 | using System; | 1 | using System; |
2 | using System.Collections.Generic; | 2 | using System.Collections.Generic; |
3 | using System.Text; | 3 | using System.Text; |
4 | using libsecondlife; | 4 | using libsecondlife; |
5 | using libsecondlife.Packets; | 5 | using libsecondlife.Packets; |
6 | using OpenSim.Framework; | 6 | using OpenSim.Framework; |
7 | using OpenSim.Framework.Console; | 7 | using OpenSim.Framework.Console; |
8 | using OpenSim.Region.Environment.Types; | 8 | using OpenSim.Region.Environment.Types; |
9 | using OpenSim.Region.Physics.Manager; | 9 | using OpenSim.Region.Physics.Manager; |
10 | 10 | ||
11 | namespace OpenSim.Region.Environment.Scenes | 11 | namespace OpenSim.Region.Environment.Scenes |
12 | { | 12 | { |
13 | public class InnerScene | 13 | public class InnerScene |
14 | { | 14 | { |
15 | public Dictionary<LLUUID, ScenePresence> ScenePresences; | 15 | public Dictionary<LLUUID, ScenePresence> ScenePresences; |
16 | public Dictionary<LLUUID, SceneObjectGroup> SceneObjects; | 16 | public Dictionary<LLUUID, SceneObjectGroup> SceneObjects; |
17 | public Dictionary<LLUUID, EntityBase> Entities; | 17 | public Dictionary<LLUUID, EntityBase> Entities; |
18 | 18 | ||
19 | public BasicQuadTreeNode QuadTree; | 19 | public BasicQuadTreeNode QuadTree; |
20 | 20 | ||
21 | protected RegionInfo m_regInfo; | 21 | protected RegionInfo m_regInfo; |
22 | 22 | ||
23 | protected Scene m_parentScene; | 23 | protected Scene m_parentScene; |
24 | public PhysicsScene PhyScene; | 24 | public PhysicsScene PhyScene; |
25 | 25 | ||
26 | private PermissionManager PermissionsMngr; | 26 | private PermissionManager PermissionsMngr; |
27 | 27 | ||
28 | public InnerScene(Scene parent, RegionInfo regInfo, PermissionManager permissionsMngr) | 28 | public InnerScene(Scene parent, RegionInfo regInfo, PermissionManager permissionsMngr) |
29 | { | 29 | { |
30 | m_parentScene = parent; | 30 | m_parentScene = parent; |
31 | m_regInfo = regInfo; | 31 | m_regInfo = regInfo; |
32 | PermissionsMngr = permissionsMngr; | 32 | PermissionsMngr = permissionsMngr; |
33 | QuadTree = new BasicQuadTreeNode(null, "/0/", 0, 0, 256, 256); | 33 | QuadTree = new BasicQuadTreeNode(null, "/0/", 0, 0, 256, 256); |
34 | QuadTree.Subdivide(); | 34 | QuadTree.Subdivide(); |
35 | QuadTree.Subdivide(); | 35 | QuadTree.Subdivide(); |
36 | } | 36 | } |
37 | 37 | ||
38 | public void Close() | 38 | public void Close() |
39 | { | 39 | { |
40 | ScenePresences.Clear(); | 40 | ScenePresences.Clear(); |
41 | SceneObjects.Clear(); | 41 | SceneObjects.Clear(); |
42 | Entities.Clear(); | 42 | Entities.Clear(); |
43 | } | 43 | } |
44 | 44 | ||
45 | public void AddEntityFromStorage(SceneObjectGroup sceneObject) | 45 | public void AddEntityFromStorage(SceneObjectGroup sceneObject) |
46 | { | 46 | { |
47 | sceneObject.RegionHandle = m_regInfo.RegionHandle; | 47 | sceneObject.RegionHandle = m_regInfo.RegionHandle; |
48 | sceneObject.SetScene(m_parentScene); | 48 | sceneObject.SetScene(m_parentScene); |
49 | foreach (SceneObjectPart part in sceneObject.Children.Values) | 49 | foreach (SceneObjectPart part in sceneObject.Children.Values) |
50 | { | 50 | { |
51 | part.LocalID = m_parentScene.PrimIDAllocate(); | 51 | part.LocalID = m_parentScene.PrimIDAllocate(); |
52 | } | 52 | } |
53 | sceneObject.UpdateParentIDs(); | 53 | sceneObject.UpdateParentIDs(); |
54 | AddEntity(sceneObject); | 54 | AddEntity(sceneObject); |
55 | } | 55 | } |
56 | 56 | ||
57 | public void AddEntity(SceneObjectGroup sceneObject) | 57 | public void AddEntity(SceneObjectGroup sceneObject) |
58 | { | 58 | { |
59 | if (!Entities.ContainsKey(sceneObject.UUID)) | 59 | if (!Entities.ContainsKey(sceneObject.UUID)) |
60 | { | 60 | { |
61 | // QuadTree.AddObject(sceneObject); | 61 | // QuadTree.AddObject(sceneObject); |
62 | Entities.Add(sceneObject.UUID, sceneObject); | 62 | Entities.Add(sceneObject.UUID, sceneObject); |
63 | } | 63 | } |
64 | } | 64 | } |
65 | 65 | ||
66 | public void RemovePrim(uint localID, LLUUID avatar_deleter) | 66 | public void RemovePrim(uint localID, LLUUID avatar_deleter) |
67 | { | 67 | { |
68 | foreach (EntityBase obj in Entities.Values) | 68 | foreach (EntityBase obj in Entities.Values) |
69 | { | 69 | { |
70 | if (obj is SceneObjectGroup) | 70 | if (obj is SceneObjectGroup) |
71 | { | 71 | { |
72 | if (((SceneObjectGroup)obj).LocalId == localID) | 72 | if (((SceneObjectGroup)obj).LocalId == localID) |
73 | { | 73 | { |
74 | m_parentScene.RemoveEntity((SceneObjectGroup)obj); | 74 | m_parentScene.RemoveEntity((SceneObjectGroup)obj); |
75 | return; | 75 | return; |
76 | } | 76 | } |
77 | } | 77 | } |
78 | } | 78 | } |
79 | } | 79 | } |
80 | 80 | ||
81 | public ScenePresence CreateAndAddScenePresence(IClientAPI client, bool child, AvatarWearable[] wearables, byte[] visualParams) | 81 | public ScenePresence CreateAndAddScenePresence(IClientAPI client, bool child, AvatarWearable[] wearables, byte[] visualParams) |
82 | { | 82 | { |
83 | ScenePresence newAvatar = null; | 83 | ScenePresence newAvatar = null; |
84 | 84 | ||
85 | newAvatar = new ScenePresence(client, m_parentScene, m_regInfo, visualParams, wearables); | 85 | newAvatar = new ScenePresence(client, m_parentScene, m_regInfo, visualParams, wearables); |
86 | newAvatar.IsChildAgent = child; | 86 | newAvatar.IsChildAgent = child; |
87 | 87 | ||
88 | if (child) | 88 | if (child) |
89 | { | 89 | { |
90 | MainLog.Instance.Verbose("SCENE", m_regInfo.RegionName + ": Creating new child agent."); | 90 | MainLog.Instance.Verbose("SCENE", m_regInfo.RegionName + ": Creating new child agent."); |
91 | } | 91 | } |
92 | else | 92 | else |
93 | { | 93 | { |
94 | MainLog.Instance.Verbose("SCENE", m_regInfo.RegionName + ": Creating new root agent."); | 94 | MainLog.Instance.Verbose("SCENE", m_regInfo.RegionName + ": Creating new root agent."); |
95 | MainLog.Instance.Verbose("SCENE", m_regInfo.RegionName + ": Adding Physical agent."); | 95 | MainLog.Instance.Verbose("SCENE", m_regInfo.RegionName + ": Adding Physical agent."); |
96 | 96 | ||
97 | newAvatar.AddToPhysicalScene(); | 97 | newAvatar.AddToPhysicalScene(); |
98 | } | 98 | } |
99 | 99 | ||
100 | lock (Entities) | 100 | lock (Entities) |
101 | { | 101 | { |
102 | if (!Entities.ContainsKey(client.AgentId)) | 102 | if (!Entities.ContainsKey(client.AgentId)) |
103 | { | 103 | { |
104 | Entities.Add(client.AgentId, newAvatar); | 104 | Entities.Add(client.AgentId, newAvatar); |
105 | } | 105 | } |
106 | else | 106 | else |
107 | { | 107 | { |
108 | Entities[client.AgentId] = newAvatar; | 108 | Entities[client.AgentId] = newAvatar; |
109 | } | 109 | } |
110 | } | 110 | } |
111 | lock (ScenePresences) | 111 | lock (ScenePresences) |
112 | { | 112 | { |
113 | if (ScenePresences.ContainsKey(client.AgentId)) | 113 | if (ScenePresences.ContainsKey(client.AgentId)) |
114 | { | 114 | { |
115 | ScenePresences[client.AgentId] = newAvatar; | 115 | ScenePresences[client.AgentId] = newAvatar; |
116 | } | 116 | } |
117 | else | 117 | else |
118 | { | 118 | { |
119 | ScenePresences.Add(client.AgentId, newAvatar); | 119 | ScenePresences.Add(client.AgentId, newAvatar); |
120 | } | 120 | } |
121 | } | 121 | } |
122 | 122 | ||
123 | return newAvatar; | 123 | return newAvatar; |
124 | } | 124 | } |
125 | 125 | ||
126 | /// <summary> | 126 | /// <summary> |
127 | /// Request a List of all m_scenePresences in this World | 127 | /// Request a List of all m_scenePresences in this World |
128 | /// </summary> | 128 | /// </summary> |
129 | /// <returns></returns> | 129 | /// <returns></returns> |
130 | public List<ScenePresence> GetScenePresences() | 130 | public List<ScenePresence> GetScenePresences() |
131 | { | 131 | { |
132 | List<ScenePresence> result = new List<ScenePresence>(ScenePresences.Values); | 132 | List<ScenePresence> result = new List<ScenePresence>(ScenePresences.Values); |
133 | 133 | ||
134 | return result; | 134 | return result; |
135 | } | 135 | } |
136 | 136 | ||
137 | public List<ScenePresence> GetAvatars() | 137 | public List<ScenePresence> GetAvatars() |
138 | { | 138 | { |
139 | List<ScenePresence> result = | 139 | List<ScenePresence> result = |
140 | GetScenePresences(delegate(ScenePresence scenePresence) { return !scenePresence.IsChildAgent; }); | 140 | GetScenePresences(delegate(ScenePresence scenePresence) { return !scenePresence.IsChildAgent; }); |
141 | 141 | ||
142 | return result; | 142 | return result; |
143 | } | 143 | } |
144 | 144 | ||
145 | /// <summary> | 145 | /// <summary> |
146 | /// Request a filtered list of m_scenePresences in this World | 146 | /// Request a filtered list of m_scenePresences in this World |
147 | /// </summary> | 147 | /// </summary> |
148 | /// <returns></returns> | 148 | /// <returns></returns> |
149 | public List<ScenePresence> GetScenePresences(FilterAvatarList filter) | 149 | public List<ScenePresence> GetScenePresences(FilterAvatarList filter) |
150 | { | 150 | { |
151 | List<ScenePresence> result = new List<ScenePresence>(); | 151 | List<ScenePresence> result = new List<ScenePresence>(); |
152 | 152 | ||
153 | foreach (ScenePresence avatar in ScenePresences.Values) | 153 | foreach (ScenePresence avatar in ScenePresences.Values) |
154 | { | 154 | { |
155 | if (filter(avatar)) | 155 | if (filter(avatar)) |
156 | { | 156 | { |
157 | result.Add(avatar); | 157 | result.Add(avatar); |
158 | } | 158 | } |
159 | } | 159 | } |
160 | 160 | ||
161 | return result; | 161 | return result; |
162 | } | 162 | } |
163 | 163 | ||
164 | /// <summary> | 164 | /// <summary> |
165 | /// Request a Avatar by UUID | 165 | /// Request a Avatar by UUID |
166 | /// </summary> | 166 | /// </summary> |
167 | /// <param name="avatarID"></param> | 167 | /// <param name="avatarID"></param> |
168 | /// <returns></returns> | 168 | /// <returns></returns> |
169 | public ScenePresence GetScenePresence(LLUUID avatarID) | 169 | public ScenePresence GetScenePresence(LLUUID avatarID) |
170 | { | 170 | { |
171 | if (ScenePresences.ContainsKey(avatarID)) | 171 | if (ScenePresences.ContainsKey(avatarID)) |
172 | { | 172 | { |
173 | return ScenePresences[avatarID]; | 173 | return ScenePresences[avatarID]; |
174 | } | 174 | } |
175 | return null; | 175 | return null; |
176 | } | 176 | } |
177 | 177 | ||
178 | 178 | ||
179 | public LLUUID ConvertLocalIDToFullID(uint localID) | 179 | public LLUUID ConvertLocalIDToFullID(uint localID) |
180 | { | 180 | { |
181 | bool hasPrim = false; | 181 | bool hasPrim = false; |
182 | foreach (EntityBase ent in Entities.Values) | 182 | foreach (EntityBase ent in Entities.Values) |
183 | { | 183 | { |
184 | if (ent is SceneObjectGroup) | 184 | if (ent is SceneObjectGroup) |
185 | { | 185 | { |
186 | hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID); | 186 | hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID); |
187 | if (hasPrim != false) | 187 | if (hasPrim != false) |
188 | { | 188 | { |
189 | return ((SceneObjectGroup)ent).GetPartsFullID(localID); | 189 | return ((SceneObjectGroup)ent).GetPartsFullID(localID); |
190 | } | 190 | } |
191 | } | 191 | } |
192 | } | 192 | } |
193 | return LLUUID.Zero; | 193 | return LLUUID.Zero; |
194 | } | 194 | } |
195 | 195 | ||
196 | public void SendAllSceneObjectsToClient(ScenePresence presence) | 196 | public void SendAllSceneObjectsToClient(ScenePresence presence) |
197 | { | 197 | { |
198 | foreach (EntityBase ent in Entities.Values) | 198 | foreach (EntityBase ent in Entities.Values) |
199 | { | 199 | { |
200 | if (ent is SceneObjectGroup) | 200 | if (ent is SceneObjectGroup) |
201 | { | 201 | { |
202 | ((SceneObjectGroup)ent).ScheduleFullUpdateToAvatar(presence); | 202 | ((SceneObjectGroup)ent).ScheduleFullUpdateToAvatar(presence); |
203 | } | 203 | } |
204 | } | 204 | } |
205 | } | 205 | } |
206 | 206 | ||
207 | public SceneObjectPart GetSceneObjectPart(uint localID) | 207 | public SceneObjectPart GetSceneObjectPart(uint localID) |
208 | { | 208 | { |
209 | bool hasPrim = false; | 209 | bool hasPrim = false; |
210 | foreach (EntityBase ent in Entities.Values) | 210 | foreach (EntityBase ent in Entities.Values) |
211 | { | 211 | { |
212 | if (ent is SceneObjectGroup) | 212 | if (ent is SceneObjectGroup) |
213 | { | 213 | { |
214 | hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID); | 214 | hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID); |
215 | if (hasPrim != false) | 215 | if (hasPrim != false) |
216 | { | 216 | { |
217 | return ((SceneObjectGroup)ent).GetChildPart(localID); | 217 | return ((SceneObjectGroup)ent).GetChildPart(localID); |
218 | } | 218 | } |
219 | } | 219 | } |
220 | } | 220 | } |
221 | return null; | 221 | return null; |
222 | } | 222 | } |
223 | 223 | ||
224 | public SceneObjectPart GetSceneObjectPart(LLUUID fullID) | 224 | public SceneObjectPart GetSceneObjectPart(LLUUID fullID) |
225 | { | 225 | { |
226 | bool hasPrim = false; | 226 | bool hasPrim = false; |
227 | foreach (EntityBase ent in Entities.Values) | 227 | foreach (EntityBase ent in Entities.Values) |
228 | { | 228 | { |
229 | if (ent is SceneObjectGroup) | 229 | if (ent is SceneObjectGroup) |
230 | { | 230 | { |
231 | hasPrim = ((SceneObjectGroup)ent).HasChildPrim(fullID); | 231 | hasPrim = ((SceneObjectGroup)ent).HasChildPrim(fullID); |
232 | if (hasPrim != false) | 232 | if (hasPrim != false) |
233 | { | 233 | { |
234 | return ((SceneObjectGroup)ent).GetChildPart(fullID); | 234 | return ((SceneObjectGroup)ent).GetChildPart(fullID); |
235 | } | 235 | } |
236 | } | 236 | } |
237 | } | 237 | } |
238 | return null; | 238 | return null; |
239 | } | 239 | } |
240 | 240 | ||
241 | internal bool TryGetAvatar(LLUUID avatarId, out ScenePresence avatar) | 241 | internal bool TryGetAvatar(LLUUID avatarId, out ScenePresence avatar) |
242 | { | 242 | { |
243 | ScenePresence presence; | 243 | ScenePresence presence; |
244 | if (ScenePresences.TryGetValue(avatarId, out presence)) | 244 | if (ScenePresences.TryGetValue(avatarId, out presence)) |
245 | { | 245 | { |
246 | if (!presence.IsChildAgent) | 246 | if (!presence.IsChildAgent) |
247 | { | 247 | { |
248 | avatar = presence; | 248 | avatar = presence; |
249 | return true; | 249 | return true; |
250 | } | 250 | } |
251 | } | 251 | } |
252 | 252 | ||
253 | avatar = null; | 253 | avatar = null; |
254 | return false; | 254 | return false; |
255 | } | 255 | } |
256 | 256 | ||
257 | internal bool TryGetAvatarByName(string avatarName, out ScenePresence avatar) | 257 | internal bool TryGetAvatarByName(string avatarName, out ScenePresence avatar) |
258 | { | 258 | { |
259 | foreach (ScenePresence presence in ScenePresences.Values) | 259 | foreach (ScenePresence presence in ScenePresences.Values) |
260 | { | 260 | { |
261 | if (!presence.IsChildAgent) | 261 | if (!presence.IsChildAgent) |
262 | { | 262 | { |
263 | string name = presence.ControllingClient.FirstName + " " + presence.ControllingClient.LastName; | 263 | string name = presence.ControllingClient.FirstName + " " + presence.ControllingClient.LastName; |
264 | 264 | ||
265 | if (String.Compare(avatarName, name, true) == 0) | 265 | if (String.Compare(avatarName, name, true) == 0) |
266 | { | 266 | { |
267 | avatar = presence; | 267 | avatar = presence; |
268 | return true; | 268 | return true; |
269 | } | 269 | } |
270 | } | 270 | } |
271 | } | 271 | } |
272 | 272 | ||
273 | avatar = null; | 273 | avatar = null; |
274 | return false; | 274 | return false; |
275 | } | 275 | } |
276 | 276 | ||
277 | 277 | ||
278 | internal void ForEachClient(Action<IClientAPI> action) | 278 | internal void ForEachClient(Action<IClientAPI> action) |
279 | { | 279 | { |
280 | foreach (ScenePresence presence in ScenePresences.Values) | 280 | foreach (ScenePresence presence in ScenePresences.Values) |
281 | { | 281 | { |
282 | action(presence.ControllingClient); | 282 | action(presence.ControllingClient); |
283 | } | 283 | } |
284 | } | 284 | } |
285 | 285 | ||
286 | #region Client Event handlers | 286 | #region Client Event handlers |
287 | /// <summary> | 287 | /// <summary> |
288 | /// | 288 | /// |
289 | /// </summary> | 289 | /// </summary> |
290 | /// <param name="localID"></param> | 290 | /// <param name="localID"></param> |
291 | /// <param name="scale"></param> | 291 | /// <param name="scale"></param> |
292 | /// <param name="remoteClient"></param> | 292 | /// <param name="remoteClient"></param> |
293 | public void UpdatePrimScale(uint localID, LLVector3 scale, IClientAPI remoteClient) | 293 | public void UpdatePrimScale(uint localID, LLVector3 scale, IClientAPI remoteClient) |
294 | { | 294 | { |
295 | bool hasPrim = false; | 295 | bool hasPrim = false; |
296 | foreach (EntityBase ent in Entities.Values) | 296 | foreach (EntityBase ent in Entities.Values) |
297 | { | 297 | { |
298 | if (ent is SceneObjectGroup) | 298 | if (ent is SceneObjectGroup) |
299 | { | 299 | { |
300 | hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID); | 300 | hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID); |
301 | if (hasPrim != false) | 301 | if (hasPrim != false) |
302 | { | 302 | { |
303 | ((SceneObjectGroup)ent).Resize(scale, localID); | 303 | ((SceneObjectGroup)ent).Resize(scale, localID); |
304 | break; | 304 | break; |
305 | } | 305 | } |
306 | } | 306 | } |
307 | } | 307 | } |
308 | } | 308 | } |
309 | 309 | ||
310 | 310 | ||
311 | /// <summary> | 311 | /// <summary> |
312 | /// | 312 | /// |
313 | /// </summary> | 313 | /// </summary> |
314 | /// <param name="localID"></param> | 314 | /// <param name="localID"></param> |
315 | /// <param name="rot"></param> | 315 | /// <param name="rot"></param> |
316 | /// <param name="remoteClient"></param> | 316 | /// <param name="remoteClient"></param> |
317 | public void UpdatePrimSingleRotation(uint localID, LLQuaternion rot, IClientAPI remoteClient) | 317 | public void UpdatePrimSingleRotation(uint localID, LLQuaternion rot, IClientAPI remoteClient) |
318 | { | 318 | { |
319 | bool hasPrim = false; | 319 | bool hasPrim = false; |
320 | foreach (EntityBase ent in Entities.Values) | 320 | foreach (EntityBase ent in Entities.Values) |
321 | { | 321 | { |
322 | if (ent is SceneObjectGroup) | 322 | if (ent is SceneObjectGroup) |
323 | { | 323 | { |
324 | hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID); | 324 | hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID); |
325 | if (hasPrim != false) | 325 | if (hasPrim != false) |
326 | { | 326 | { |
327 | ((SceneObjectGroup)ent).UpdateSingleRotation(rot, localID); | 327 | ((SceneObjectGroup)ent).UpdateSingleRotation(rot, localID); |
328 | break; | 328 | break; |
329 | } | 329 | } |
330 | } | 330 | } |
331 | } | 331 | } |
332 | } | 332 | } |
333 | 333 | ||
334 | /// <summary> | 334 | /// <summary> |
335 | /// | 335 | /// |
336 | /// </summary> | 336 | /// </summary> |
337 | /// <param name="localID"></param> | 337 | /// <param name="localID"></param> |
338 | /// <param name="rot"></param> | 338 | /// <param name="rot"></param> |
339 | /// <param name="remoteClient"></param> | 339 | /// <param name="remoteClient"></param> |
340 | public void UpdatePrimRotation(uint localID, LLQuaternion rot, IClientAPI remoteClient) | 340 | public void UpdatePrimRotation(uint localID, LLQuaternion rot, IClientAPI remoteClient) |
341 | { | 341 | { |
342 | bool hasPrim = false; | 342 | bool hasPrim = false; |
343 | foreach (EntityBase ent in Entities.Values) | 343 | foreach (EntityBase ent in Entities.Values) |
344 | { | 344 | { |
345 | if (ent is SceneObjectGroup) | 345 | if (ent is SceneObjectGroup) |
346 | { | 346 | { |
347 | hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID); | 347 | hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID); |
348 | if (hasPrim != false) | 348 | if (hasPrim != false) |
349 | { | 349 | { |
350 | ((SceneObjectGroup)ent).UpdateGroupRotation(rot); | 350 | ((SceneObjectGroup)ent).UpdateGroupRotation(rot); |
351 | break; | 351 | break; |
352 | } | 352 | } |
353 | } | 353 | } |
354 | } | 354 | } |
355 | } | 355 | } |
356 | 356 | ||
357 | /// <summary> | 357 | /// <summary> |
358 | /// | 358 | /// |
359 | /// </summary> | 359 | /// </summary> |
360 | /// <param name="localID"></param> | 360 | /// <param name="localID"></param> |
361 | /// <param name="pos"></param> | 361 | /// <param name="pos"></param> |
362 | /// <param name="rot"></param> | 362 | /// <param name="rot"></param> |
363 | /// <param name="remoteClient"></param> | 363 | /// <param name="remoteClient"></param> |
364 | public void UpdatePrimRotation(uint localID, LLVector3 pos, LLQuaternion rot, IClientAPI remoteClient) | 364 | public void UpdatePrimRotation(uint localID, LLVector3 pos, LLQuaternion rot, IClientAPI remoteClient) |
365 | { | 365 | { |
366 | bool hasPrim = false; | 366 | bool hasPrim = false; |
367 | foreach (EntityBase ent in Entities.Values) | 367 | foreach (EntityBase ent in Entities.Values) |
368 | { | 368 | { |
369 | if (ent is SceneObjectGroup) | 369 | if (ent is SceneObjectGroup) |
370 | { | 370 | { |
371 | hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID); | 371 | hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID); |
372 | if (hasPrim != false) | 372 | if (hasPrim != false) |
373 | { | 373 | { |
374 | ((SceneObjectGroup)ent).UpdateGroupRotation(pos, rot); | 374 | ((SceneObjectGroup)ent).UpdateGroupRotation(pos, rot); |
375 | break; | 375 | break; |
376 | } | 376 | } |
377 | } | 377 | } |
378 | } | 378 | } |
379 | } | 379 | } |
380 | 380 | ||
381 | public void UpdatePrimSinglePosition(uint localID, LLVector3 pos, IClientAPI remoteClient) | 381 | public void UpdatePrimSinglePosition(uint localID, LLVector3 pos, IClientAPI remoteClient) |
382 | { | 382 | { |
383 | bool hasPrim = false; | 383 | bool hasPrim = false; |
384 | foreach (EntityBase ent in Entities.Values) | 384 | foreach (EntityBase ent in Entities.Values) |
385 | { | 385 | { |
386 | if (ent is SceneObjectGroup) | 386 | if (ent is SceneObjectGroup) |
387 | { | 387 | { |
388 | hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID); | 388 | hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID); |
389 | if (hasPrim != false) | 389 | if (hasPrim != false) |
390 | { | 390 | { |
391 | ((SceneObjectGroup)ent).UpdateSinglePosition(pos, localID); | 391 | ((SceneObjectGroup)ent).UpdateSinglePosition(pos, localID); |
392 | break; | 392 | break; |
393 | } | 393 | } |
394 | } | 394 | } |
395 | } | 395 | } |
396 | } | 396 | } |
397 | 397 | ||
398 | 398 | ||
399 | /// <summary> | 399 | /// <summary> |
400 | /// | 400 | /// |
401 | /// </summary> | 401 | /// </summary> |
402 | /// <param name="localID"></param> | 402 | /// <param name="localID"></param> |
403 | /// <param name="pos"></param> | 403 | /// <param name="pos"></param> |
404 | /// <param name="remoteClient"></param> | 404 | /// <param name="remoteClient"></param> |
405 | public void UpdatePrimPosition(uint localID, LLVector3 pos, IClientAPI remoteClient) | 405 | public void UpdatePrimPosition(uint localID, LLVector3 pos, IClientAPI remoteClient) |
406 | { | 406 | { |
407 | bool hasPrim = false; | 407 | bool hasPrim = false; |
408 | foreach (EntityBase ent in Entities.Values) | 408 | foreach (EntityBase ent in Entities.Values) |
409 | { | 409 | { |
410 | if (ent is SceneObjectGroup) | 410 | if (ent is SceneObjectGroup) |
411 | { | 411 | { |
412 | hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID); | 412 | hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID); |
413 | if (hasPrim != false) | 413 | if (hasPrim != false) |
414 | { | 414 | { |
415 | ((SceneObjectGroup)ent).UpdateGroupPosition(pos); | 415 | ((SceneObjectGroup)ent).UpdateGroupPosition(pos); |
416 | break; | 416 | break; |
417 | } | 417 | } |
418 | } | 418 | } |
419 | } | 419 | } |
420 | } | 420 | } |
421 | 421 | ||
422 | /// <summary> | 422 | /// <summary> |
423 | /// | 423 | /// |
424 | /// </summary> | 424 | /// </summary> |
425 | /// <param name="localID"></param> | 425 | /// <param name="localID"></param> |
426 | /// <param name="texture"></param> | 426 | /// <param name="texture"></param> |
427 | /// <param name="remoteClient"></param> | 427 | /// <param name="remoteClient"></param> |
428 | public void UpdatePrimTexture(uint localID, byte[] texture, IClientAPI remoteClient) | 428 | public void UpdatePrimTexture(uint localID, byte[] texture, IClientAPI remoteClient) |
429 | { | 429 | { |
430 | bool hasPrim = false; | 430 | bool hasPrim = false; |
431 | foreach (EntityBase ent in Entities.Values) | 431 | foreach (EntityBase ent in Entities.Values) |
432 | { | 432 | { |
433 | if (ent is SceneObjectGroup) | 433 | if (ent is SceneObjectGroup) |
434 | { | 434 | { |
435 | hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID); | 435 | hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID); |
436 | if (hasPrim != false) | 436 | if (hasPrim != false) |
437 | { | 437 | { |
438 | ((SceneObjectGroup)ent).UpdateTextureEntry(localID, texture); | 438 | ((SceneObjectGroup)ent).UpdateTextureEntry(localID, texture); |
439 | break; | 439 | break; |
440 | } | 440 | } |
441 | } | 441 | } |
442 | } | 442 | } |
443 | } | 443 | } |
444 | 444 | ||
445 | /// <summary> | 445 | /// <summary> |
446 | /// | 446 | /// |
447 | /// </summary> | 447 | /// </summary> |
448 | /// <param name="localID"></param> | 448 | /// <param name="localID"></param> |
449 | /// <param name="packet"></param> | 449 | /// <param name="packet"></param> |
450 | /// <param name="remoteClient"></param> | 450 | /// <param name="remoteClient"></param> |
451 | public void UpdatePrimFlags(uint localID, Packet packet, IClientAPI remoteClient) | 451 | public void UpdatePrimFlags(uint localID, Packet packet, IClientAPI remoteClient) |
452 | { | 452 | { |
453 | bool hasprim = false; | 453 | bool hasprim = false; |
454 | foreach (EntityBase ent in Entities.Values) | 454 | foreach (EntityBase ent in Entities.Values) |
455 | { | 455 | { |
456 | if (ent is SceneObjectGroup) | 456 | if (ent is SceneObjectGroup) |
457 | { | 457 | { |
458 | hasprim = ((SceneObjectGroup)ent).HasChildPrim(localID); | 458 | hasprim = ((SceneObjectGroup)ent).HasChildPrim(localID); |
459 | if (hasprim != false) | 459 | if (hasprim != false) |
460 | { | 460 | { |
461 | ((SceneObjectGroup)ent).UpdatePrimFlags(localID, (ushort)packet.Type, true, packet.ToBytes()); | 461 | ((SceneObjectGroup)ent).UpdatePrimFlags(localID, (ushort)packet.Type, true, packet.ToBytes()); |
462 | } | 462 | } |
463 | } | 463 | } |
464 | } | 464 | } |
465 | 465 | ||
466 | //System.Console.WriteLine("Got primupdate packet: " + packet.UsePhysics.ToString()); | 466 | //System.Console.WriteLine("Got primupdate packet: " + packet.UsePhysics.ToString()); |
467 | } | 467 | } |
468 | 468 | ||
469 | public void MoveObject(LLUUID objectID, LLVector3 offset, LLVector3 pos, IClientAPI remoteClient) | 469 | public void MoveObject(LLUUID objectID, LLVector3 offset, LLVector3 pos, IClientAPI remoteClient) |
470 | { | 470 | { |
471 | if (PermissionsMngr.CanEditObject(remoteClient.AgentId, objectID)) | 471 | if (PermissionsMngr.CanEditObject(remoteClient.AgentId, objectID)) |
472 | { | 472 | { |
473 | bool hasPrim = false; | 473 | bool hasPrim = false; |
474 | foreach (EntityBase ent in Entities.Values) | 474 | foreach (EntityBase ent in Entities.Values) |
475 | { | 475 | { |
476 | if (ent is SceneObjectGroup) | 476 | if (ent is SceneObjectGroup) |
477 | { | 477 | { |
478 | hasPrim = ((SceneObjectGroup)ent).HasChildPrim(objectID); | 478 | hasPrim = ((SceneObjectGroup)ent).HasChildPrim(objectID); |
479 | if (hasPrim != false) | 479 | if (hasPrim != false) |
480 | { | 480 | { |
481 | ((SceneObjectGroup)ent).GrabMovement(offset, pos, remoteClient); | 481 | ((SceneObjectGroup)ent).GrabMovement(offset, pos, remoteClient); |
482 | break; | 482 | break; |
483 | } | 483 | } |
484 | } | 484 | } |
485 | } | 485 | } |
486 | } | 486 | } |
487 | } | 487 | } |
488 | 488 | ||
489 | /// <summary> | 489 | /// <summary> |
490 | /// | 490 | /// |
491 | /// </summary> | 491 | /// </summary> |
492 | /// <param name="primLocalID"></param> | 492 | /// <param name="primLocalID"></param> |
493 | /// <param name="description"></param> | 493 | /// <param name="description"></param> |
494 | public void PrimName(uint primLocalID, string name) | 494 | public void PrimName(uint primLocalID, string name) |
495 | { | 495 | { |
496 | bool hasPrim = false; | 496 | bool hasPrim = false; |
497 | foreach (EntityBase ent in Entities.Values) | 497 | foreach (EntityBase ent in Entities.Values) |
498 | { | 498 | { |
499 | if (ent is SceneObjectGroup) | 499 | if (ent is SceneObjectGroup) |
500 | { | 500 | { |
501 | hasPrim = ((SceneObjectGroup)ent).HasChildPrim(primLocalID); | 501 | hasPrim = ((SceneObjectGroup)ent).HasChildPrim(primLocalID); |
502 | if (hasPrim != false) | 502 | if (hasPrim != false) |
503 | { | 503 | { |
504 | ((SceneObjectGroup)ent).SetPartName(name, primLocalID); | 504 | ((SceneObjectGroup)ent).SetPartName(name, primLocalID); |
505 | break; | 505 | break; |
506 | } | 506 | } |
507 | } | 507 | } |
508 | } | 508 | } |
509 | } | 509 | } |
510 | 510 | ||
511 | /// <summary> | 511 | /// <summary> |
512 | /// | 512 | /// |
513 | /// </summary> | 513 | /// </summary> |
514 | /// <param name="primLocalID"></param> | 514 | /// <param name="primLocalID"></param> |
515 | /// <param name="description"></param> | 515 | /// <param name="description"></param> |
516 | public void PrimDescription(uint primLocalID, string description) | 516 | public void PrimDescription(uint primLocalID, string description) |
517 | { | 517 | { |
518 | bool hasPrim = false; | 518 | bool hasPrim = false; |
519 | foreach (EntityBase ent in Entities.Values) | 519 | foreach (EntityBase ent in Entities.Values) |
520 | { | 520 | { |
521 | if (ent is SceneObjectGroup) | 521 | if (ent is SceneObjectGroup) |
522 | { | 522 | { |
523 | hasPrim = ((SceneObjectGroup)ent).HasChildPrim(primLocalID); | 523 | hasPrim = ((SceneObjectGroup)ent).HasChildPrim(primLocalID); |
524 | if (hasPrim != false) | 524 | if (hasPrim != false) |
525 | { | 525 | { |
526 | ((SceneObjectGroup)ent).SetPartDescription(description, primLocalID); | 526 | ((SceneObjectGroup)ent).SetPartDescription(description, primLocalID); |
527 | break; | 527 | break; |
528 | } | 528 | } |
529 | } | 529 | } |
530 | } | 530 | } |
531 | } | 531 | } |
532 | 532 | ||
533 | public void UpdateExtraParam(uint primLocalID, ushort type, bool inUse, byte[] data) | 533 | public void UpdateExtraParam(uint primLocalID, ushort type, bool inUse, byte[] data) |
534 | { | 534 | { |
535 | bool hasPrim = false; | 535 | bool hasPrim = false; |
536 | foreach (EntityBase ent in Entities.Values) | 536 | foreach (EntityBase ent in Entities.Values) |
537 | { | 537 | { |
538 | if (ent is SceneObjectGroup) | 538 | if (ent is SceneObjectGroup) |
539 | { | 539 | { |
540 | hasPrim = ((SceneObjectGroup)ent).HasChildPrim(primLocalID); | 540 | hasPrim = ((SceneObjectGroup)ent).HasChildPrim(primLocalID); |
541 | if (hasPrim != false) | 541 | if (hasPrim != false) |
542 | { | 542 | { |
543 | ((SceneObjectGroup)ent).UpdateExtraParam(primLocalID, type, inUse, data); | 543 | ((SceneObjectGroup)ent).UpdateExtraParam(primLocalID, type, inUse, data); |
544 | break; | 544 | break; |
545 | } | 545 | } |
546 | } | 546 | } |
547 | } | 547 | } |
548 | } | 548 | } |
549 | 549 | ||
550 | /// <summary> | 550 | /// <summary> |
551 | /// | 551 | /// |
552 | /// </summary> | 552 | /// </summary> |
553 | /// <param name="primLocalID"></param> | 553 | /// <param name="primLocalID"></param> |
554 | /// <param name="shapeBlock"></param> | 554 | /// <param name="shapeBlock"></param> |
555 | public void UpdatePrimShape(uint primLocalID, ObjectShapePacket.ObjectDataBlock shapeBlock) | 555 | public void UpdatePrimShape(uint primLocalID, ObjectShapePacket.ObjectDataBlock shapeBlock) |
556 | { | 556 | { |
557 | bool hasPrim = false; | 557 | bool hasPrim = false; |
558 | foreach (EntityBase ent in Entities.Values) | 558 | foreach (EntityBase ent in Entities.Values) |
559 | { | 559 | { |
560 | if (ent is SceneObjectGroup) | 560 | if (ent is SceneObjectGroup) |
561 | { | 561 | { |
562 | hasPrim = ((SceneObjectGroup)ent).HasChildPrim(primLocalID); | 562 | hasPrim = ((SceneObjectGroup)ent).HasChildPrim(primLocalID); |
563 | if (hasPrim != false) | 563 | if (hasPrim != false) |
564 | { | 564 | { |
565 | ((SceneObjectGroup)ent).UpdateShape(shapeBlock, primLocalID); | 565 | ((SceneObjectGroup)ent).UpdateShape(shapeBlock, primLocalID); |
566 | break; | 566 | break; |
567 | } | 567 | } |
568 | } | 568 | } |
569 | } | 569 | } |
570 | } | 570 | } |
571 | 571 | ||
572 | /// <summary> | 572 | /// <summary> |
573 | /// | 573 | /// |
574 | /// </summary> | 574 | /// </summary> |
575 | /// <param name="parentPrim"></param> | 575 | /// <param name="parentPrim"></param> |
576 | /// <param name="childPrims"></param> | 576 | /// <param name="childPrims"></param> |
577 | public void LinkObjects(uint parentPrim, List<uint> childPrims) | 577 | public void LinkObjects(uint parentPrim, List<uint> childPrims) |
578 | { | 578 | { |
579 | SceneObjectGroup parenPrim = null; | 579 | SceneObjectGroup parenPrim = null; |
580 | foreach (EntityBase ent in Entities.Values) | 580 | foreach (EntityBase ent in Entities.Values) |
581 | { | 581 | { |
582 | if (ent is SceneObjectGroup) | 582 | if (ent is SceneObjectGroup) |
583 | { | 583 | { |
584 | if (((SceneObjectGroup)ent).LocalId == parentPrim) | 584 | if (((SceneObjectGroup)ent).LocalId == parentPrim) |
585 | { | 585 | { |
586 | parenPrim = (SceneObjectGroup)ent; | 586 | parenPrim = (SceneObjectGroup)ent; |
587 | break; | 587 | break; |
588 | } | 588 | } |
589 | } | 589 | } |
590 | } | 590 | } |
591 | 591 | ||
592 | List<SceneObjectGroup> children = new List<SceneObjectGroup>(); | 592 | List<SceneObjectGroup> children = new List<SceneObjectGroup>(); |
593 | if (parenPrim != null) | 593 | if (parenPrim != null) |
594 | { | 594 | { |
595 | for (int i = 0; i < childPrims.Count; i++) | 595 | for (int i = 0; i < childPrims.Count; i++) |
596 | { | 596 | { |
597 | foreach (EntityBase ent in Entities.Values) | 597 | foreach (EntityBase ent in Entities.Values) |
598 | { | 598 | { |
599 | if (ent is SceneObjectGroup) | 599 | if (ent is SceneObjectGroup) |
600 | { | 600 | { |
601 | if (((SceneObjectGroup)ent).LocalId == childPrims[i]) | 601 | if (((SceneObjectGroup)ent).LocalId == childPrims[i]) |
602 | { | 602 | { |
603 | children.Add((SceneObjectGroup)ent); | 603 | children.Add((SceneObjectGroup)ent); |
604 | } | 604 | } |
605 | } | 605 | } |
606 | } | 606 | } |
607 | } | 607 | } |
608 | } | 608 | } |
609 | 609 | ||
610 | foreach (SceneObjectGroup sceneObj in children) | 610 | foreach (SceneObjectGroup sceneObj in children) |
611 | { | 611 | { |
612 | parenPrim.LinkToGroup(sceneObj); | 612 | parenPrim.LinkToGroup(sceneObj); |
613 | } | 613 | } |
614 | } | 614 | } |
615 | 615 | ||
616 | /// <summary> | 616 | /// <summary> |
617 | /// | 617 | /// |
618 | /// </summary> | 618 | /// </summary> |
619 | /// <param name="originalPrim"></param> | 619 | /// <param name="originalPrim"></param> |
620 | /// <param name="offset"></param> | 620 | /// <param name="offset"></param> |
621 | /// <param name="flags"></param> | 621 | /// <param name="flags"></param> |
622 | public void DuplicateObject(uint originalPrim, LLVector3 offset, uint flags) | 622 | public void DuplicateObject(uint originalPrim, LLVector3 offset, uint flags) |
623 | { | 623 | { |
624 | SceneObjectGroup originPrim = null; | 624 | SceneObjectGroup originPrim = null; |
625 | foreach (EntityBase ent in Entities.Values) | 625 | foreach (EntityBase ent in Entities.Values) |
626 | { | 626 | { |
627 | if (ent is SceneObjectGroup) | 627 | if (ent is SceneObjectGroup) |
628 | { | 628 | { |
629 | if (((SceneObjectGroup)ent).LocalId == originalPrim) | 629 | if (((SceneObjectGroup)ent).LocalId == originalPrim) |
630 | { | 630 | { |
631 | originPrim = (SceneObjectGroup)ent; | 631 | originPrim = (SceneObjectGroup)ent; |
632 | break; | 632 | break; |
633 | } | 633 | } |
634 | } | 634 | } |
635 | } | 635 | } |
636 | 636 | ||
637 | if (originPrim != null) | 637 | if (originPrim != null) |
638 | { | 638 | { |
639 | SceneObjectGroup copy = originPrim.Copy(); | 639 | SceneObjectGroup copy = originPrim.Copy(); |
640 | copy.AbsolutePosition = copy.AbsolutePosition + offset; | 640 | copy.AbsolutePosition = copy.AbsolutePosition + offset; |
641 | Entities.Add(copy.UUID, copy); | 641 | Entities.Add(copy.UUID, copy); |
642 | 642 | ||
643 | copy.ScheduleGroupForFullUpdate(); | 643 | copy.ScheduleGroupForFullUpdate(); |
644 | 644 | ||
645 | } | 645 | } |
646 | else | 646 | else |
647 | { | 647 | { |
648 | MainLog.Instance.Warn("client", "Attempted to duplicate nonexistant prim"); | 648 | MainLog.Instance.Warn("client", "Attempted to duplicate nonexistant prim"); |
649 | } | 649 | } |
650 | } | 650 | } |
651 | 651 | ||
652 | 652 | ||
653 | #endregion | 653 | #endregion |
654 | } | 654 | } |
655 | } | 655 | } |
diff --git a/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs index 2ade989..e67d413 100644 --- a/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs +++ b/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs | |||
@@ -1,212 +1,212 @@ | |||
1 | using System; | 1 | using System; |
2 | using System.Collections.Generic; | 2 | using System.Collections.Generic; |
3 | using System.Net; | 3 | using System.Net; |
4 | using System.Text; | 4 | using System.Text; |
5 | using libsecondlife; | 5 | using libsecondlife; |
6 | using OpenSim.Framework; | 6 | using OpenSim.Framework; |
7 | using OpenSim.Framework.Console; | 7 | using OpenSim.Framework.Console; |
8 | using OpenSim.Framework.Communications; | 8 | using OpenSim.Framework.Communications; |
9 | 9 | ||
10 | 10 | ||
11 | namespace OpenSim.Region.Environment.Scenes | 11 | namespace OpenSim.Region.Environment.Scenes |
12 | { | 12 | { |
13 | public class SceneCommunicationService //one instance per region | 13 | public class SceneCommunicationService //one instance per region |
14 | { | 14 | { |
15 | protected CommunicationsManager m_commsProvider; | 15 | protected CommunicationsManager m_commsProvider; |
16 | protected RegionInfo m_regionInfo; | 16 | protected RegionInfo m_regionInfo; |
17 | 17 | ||
18 | protected RegionCommsListener regionCommsHost; | 18 | protected RegionCommsListener regionCommsHost; |
19 | 19 | ||
20 | public event AgentCrossing OnAvatarCrossingIntoRegion; | 20 | public event AgentCrossing OnAvatarCrossingIntoRegion; |
21 | public event ExpectUserDelegate OnExpectUser; | 21 | public event ExpectUserDelegate OnExpectUser; |
22 | 22 | ||
23 | 23 | ||
24 | public SceneCommunicationService(CommunicationsManager commsMan) | 24 | public SceneCommunicationService(CommunicationsManager commsMan) |
25 | { | 25 | { |
26 | m_commsProvider = commsMan; | 26 | m_commsProvider = commsMan; |
27 | } | 27 | } |
28 | 28 | ||
29 | public void RegisterRegion(RegionInfo regionInfos) | 29 | public void RegisterRegion(RegionInfo regionInfos) |
30 | { | 30 | { |
31 | m_regionInfo = regionInfos; | 31 | m_regionInfo = regionInfos; |
32 | regionCommsHost = m_commsProvider.GridService.RegisterRegion(m_regionInfo); | 32 | regionCommsHost = m_commsProvider.GridService.RegisterRegion(m_regionInfo); |
33 | if (regionCommsHost != null) | 33 | if (regionCommsHost != null) |
34 | { | 34 | { |
35 | regionCommsHost.OnExpectUser += NewUserConnection; | 35 | regionCommsHost.OnExpectUser += NewUserConnection; |
36 | regionCommsHost.OnAvatarCrossingIntoRegion += AgentCrossing; | 36 | regionCommsHost.OnAvatarCrossingIntoRegion += AgentCrossing; |
37 | } | 37 | } |
38 | } | 38 | } |
39 | 39 | ||
40 | public void Close() | 40 | public void Close() |
41 | { | 41 | { |
42 | regionCommsHost.OnExpectUser -= NewUserConnection; | 42 | regionCommsHost.OnExpectUser -= NewUserConnection; |
43 | regionCommsHost.OnAvatarCrossingIntoRegion -= AgentCrossing; | 43 | regionCommsHost.OnAvatarCrossingIntoRegion -= AgentCrossing; |
44 | //regionCommsHost.RemoveRegion(m_regionInfo); //TODO add to method to commsManager | 44 | //regionCommsHost.RemoveRegion(m_regionInfo); //TODO add to method to commsManager |
45 | regionCommsHost = null; | 45 | regionCommsHost = null; |
46 | } | 46 | } |
47 | 47 | ||
48 | #region CommsManager Event handlers | 48 | #region CommsManager Event handlers |
49 | /// <summary> | 49 | /// <summary> |
50 | /// | 50 | /// |
51 | /// </summary> | 51 | /// </summary> |
52 | /// <param name="regionHandle"></param> | 52 | /// <param name="regionHandle"></param> |
53 | /// <param name="agent"></param> | 53 | /// <param name="agent"></param> |
54 | public void NewUserConnection(ulong regionHandle, AgentCircuitData agent) | 54 | public void NewUserConnection(ulong regionHandle, AgentCircuitData agent) |
55 | { | 55 | { |
56 | if (OnExpectUser != null) | 56 | if (OnExpectUser != null) |
57 | { | 57 | { |
58 | OnExpectUser(regionHandle, agent); | 58 | OnExpectUser(regionHandle, agent); |
59 | } | 59 | } |
60 | } | 60 | } |
61 | 61 | ||
62 | public void AgentCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position, bool isFlying) | 62 | public void AgentCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position, bool isFlying) |
63 | { | 63 | { |
64 | if (OnAvatarCrossingIntoRegion != null) | 64 | if (OnAvatarCrossingIntoRegion != null) |
65 | { | 65 | { |
66 | OnAvatarCrossingIntoRegion(regionHandle, agentID, position, isFlying); | 66 | OnAvatarCrossingIntoRegion(regionHandle, agentID, position, isFlying); |
67 | } | 67 | } |
68 | } | 68 | } |
69 | #endregion | 69 | #endregion |
70 | 70 | ||
71 | #region Inform Client of Neighbours | 71 | #region Inform Client of Neighbours |
72 | private delegate void InformClientOfNeighbourDelegate( | 72 | private delegate void InformClientOfNeighbourDelegate( |
73 | ScenePresence avatar, AgentCircuitData a, ulong regionHandle, IPEndPoint endPoint); | 73 | ScenePresence avatar, AgentCircuitData a, ulong regionHandle, IPEndPoint endPoint); |
74 | 74 | ||
75 | private void InformClientOfNeighbourCompleted(IAsyncResult iar) | 75 | private void InformClientOfNeighbourCompleted(IAsyncResult iar) |
76 | { | 76 | { |
77 | InformClientOfNeighbourDelegate icon = (InformClientOfNeighbourDelegate)iar.AsyncState; | 77 | InformClientOfNeighbourDelegate icon = (InformClientOfNeighbourDelegate)iar.AsyncState; |
78 | icon.EndInvoke(iar); | 78 | icon.EndInvoke(iar); |
79 | } | 79 | } |
80 | 80 | ||
81 | /// <summary> | 81 | /// <summary> |
82 | /// Async compnent for informing client of which neighbours exists | 82 | /// Async compnent for informing client of which neighbours exists |
83 | /// </summary> | 83 | /// </summary> |
84 | /// <remarks> | 84 | /// <remarks> |
85 | /// This needs to run asynchronesously, as a network timeout may block the thread for a long while | 85 | /// This needs to run asynchronesously, as a network timeout may block the thread for a long while |
86 | /// </remarks> | 86 | /// </remarks> |
87 | /// <param name="remoteClient"></param> | 87 | /// <param name="remoteClient"></param> |
88 | /// <param name="a"></param> | 88 | /// <param name="a"></param> |
89 | /// <param name="regionHandle"></param> | 89 | /// <param name="regionHandle"></param> |
90 | /// <param name="endPoint"></param> | 90 | /// <param name="endPoint"></param> |
91 | private void InformClientOfNeighbourAsync(ScenePresence avatar, AgentCircuitData a, ulong regionHandle, | 91 | private void InformClientOfNeighbourAsync(ScenePresence avatar, AgentCircuitData a, ulong regionHandle, |
92 | IPEndPoint endPoint) | 92 | IPEndPoint endPoint) |
93 | { | 93 | { |
94 | MainLog.Instance.Notice("INTERGRID", "Starting to inform client about neighbours"); | 94 | MainLog.Instance.Notice("INTERGRID", "Starting to inform client about neighbours"); |
95 | bool regionAccepted = m_commsProvider.InterRegion.InformRegionOfChildAgent(regionHandle, a); | 95 | bool regionAccepted = m_commsProvider.InterRegion.InformRegionOfChildAgent(regionHandle, a); |
96 | 96 | ||
97 | if (regionAccepted) | 97 | if (regionAccepted) |
98 | { | 98 | { |
99 | avatar.ControllingClient.InformClientOfNeighbour(regionHandle, endPoint); | 99 | avatar.ControllingClient.InformClientOfNeighbour(regionHandle, endPoint); |
100 | avatar.AddNeighbourRegion(regionHandle); | 100 | avatar.AddNeighbourRegion(regionHandle); |
101 | MainLog.Instance.Notice("INTERGRID", "Completed inform client about neighbours"); | 101 | MainLog.Instance.Notice("INTERGRID", "Completed inform client about neighbours"); |
102 | } | 102 | } |
103 | } | 103 | } |
104 | 104 | ||
105 | /// <summary> | 105 | /// <summary> |
106 | /// | 106 | /// |
107 | /// </summary> | 107 | /// </summary> |
108 | public void InformClientOfNeighbours(ScenePresence avatar) | 108 | public void InformClientOfNeighbours(ScenePresence avatar) |
109 | { | 109 | { |
110 | List<SimpleRegionInfo> neighbours = | 110 | List<SimpleRegionInfo> neighbours = |
111 | m_commsProvider.GridService.RequestNeighbours(m_regionInfo.RegionLocX, m_regionInfo.RegionLocY); | 111 | m_commsProvider.GridService.RequestNeighbours(m_regionInfo.RegionLocX, m_regionInfo.RegionLocY); |
112 | if (neighbours != null) | 112 | if (neighbours != null) |
113 | { | 113 | { |
114 | for (int i = 0; i < neighbours.Count; i++) | 114 | for (int i = 0; i < neighbours.Count; i++) |
115 | { | 115 | { |
116 | AgentCircuitData agent = avatar.ControllingClient.RequestClientInfo(); | 116 | AgentCircuitData agent = avatar.ControllingClient.RequestClientInfo(); |
117 | agent.BaseFolder = LLUUID.Zero; | 117 | agent.BaseFolder = LLUUID.Zero; |
118 | agent.InventoryFolder = LLUUID.Zero; | 118 | agent.InventoryFolder = LLUUID.Zero; |
119 | agent.startpos = new LLVector3(128, 128, 70); | 119 | agent.startpos = new LLVector3(128, 128, 70); |
120 | agent.child = true; | 120 | agent.child = true; |
121 | 121 | ||
122 | InformClientOfNeighbourDelegate d = InformClientOfNeighbourAsync; | 122 | InformClientOfNeighbourDelegate d = InformClientOfNeighbourAsync; |
123 | d.BeginInvoke(avatar, agent, neighbours[i].RegionHandle, neighbours[i].ExternalEndPoint, | 123 | d.BeginInvoke(avatar, agent, neighbours[i].RegionHandle, neighbours[i].ExternalEndPoint, |
124 | InformClientOfNeighbourCompleted, | 124 | InformClientOfNeighbourCompleted, |
125 | d); | 125 | d); |
126 | } | 126 | } |
127 | } | 127 | } |
128 | } | 128 | } |
129 | #endregion | 129 | #endregion |
130 | 130 | ||
131 | /// <summary> | 131 | /// <summary> |
132 | /// | 132 | /// |
133 | /// </summary> | 133 | /// </summary> |
134 | /// <param name="regionHandle"></param> | 134 | /// <param name="regionHandle"></param> |
135 | /// <returns></returns> | 135 | /// <returns></returns> |
136 | public virtual RegionInfo RequestNeighbouringRegionInfo(ulong regionHandle) | 136 | public virtual RegionInfo RequestNeighbouringRegionInfo(ulong regionHandle) |
137 | { | 137 | { |
138 | return m_commsProvider.GridService.RequestNeighbourInfo(regionHandle); | 138 | return m_commsProvider.GridService.RequestNeighbourInfo(regionHandle); |
139 | } | 139 | } |
140 | 140 | ||
141 | /// <summary> | 141 | /// <summary> |
142 | /// | 142 | /// |
143 | /// </summary> | 143 | /// </summary> |
144 | /// <param name="minX"></param> | 144 | /// <param name="minX"></param> |
145 | /// <param name="minY"></param> | 145 | /// <param name="minY"></param> |
146 | /// <param name="maxX"></param> | 146 | /// <param name="maxX"></param> |
147 | /// <param name="maxY"></param> | 147 | /// <param name="maxY"></param> |
148 | public virtual void RequestMapBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY) | 148 | public virtual void RequestMapBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY) |
149 | { | 149 | { |
150 | List<MapBlockData> mapBlocks; | 150 | List<MapBlockData> mapBlocks; |
151 | mapBlocks = m_commsProvider.GridService.RequestNeighbourMapBlocks(minX, minY, maxX, maxY); | 151 | mapBlocks = m_commsProvider.GridService.RequestNeighbourMapBlocks(minX, minY, maxX, maxY); |
152 | remoteClient.SendMapBlock(mapBlocks); | 152 | remoteClient.SendMapBlock(mapBlocks); |
153 | } | 153 | } |
154 | 154 | ||
155 | /// <summary> | 155 | /// <summary> |
156 | /// | 156 | /// |
157 | /// </summary> | 157 | /// </summary> |
158 | /// <param name="remoteClient"></param> | 158 | /// <param name="remoteClient"></param> |
159 | /// <param name="RegionHandle"></param> | 159 | /// <param name="RegionHandle"></param> |
160 | /// <param name="position"></param> | 160 | /// <param name="position"></param> |
161 | /// <param name="lookAt"></param> | 161 | /// <param name="lookAt"></param> |
162 | /// <param name="flags"></param> | 162 | /// <param name="flags"></param> |
163 | public virtual void RequestTeleportLocation(ScenePresence avatar, ulong regionHandle, LLVector3 position, | 163 | public virtual void RequestTeleportLocation(ScenePresence avatar, ulong regionHandle, LLVector3 position, |
164 | LLVector3 lookAt, uint flags) | 164 | LLVector3 lookAt, uint flags) |
165 | { | 165 | { |
166 | if (regionHandle == m_regionInfo.RegionHandle) | 166 | if (regionHandle == m_regionInfo.RegionHandle) |
167 | { | 167 | { |
168 | 168 | ||
169 | avatar.ControllingClient.SendTeleportLocationStart(); | 169 | avatar.ControllingClient.SendTeleportLocationStart(); |
170 | avatar.ControllingClient.SendLocalTeleport(position, lookAt, flags); | 170 | avatar.ControllingClient.SendLocalTeleport(position, lookAt, flags); |
171 | avatar.Teleport(position); | 171 | avatar.Teleport(position); |
172 | 172 | ||
173 | } | 173 | } |
174 | else | 174 | else |
175 | { | 175 | { |
176 | RegionInfo reg = RequestNeighbouringRegionInfo(regionHandle); | 176 | RegionInfo reg = RequestNeighbouringRegionInfo(regionHandle); |
177 | if (reg != null) | 177 | if (reg != null) |
178 | { | 178 | { |
179 | avatar.ControllingClient.SendTeleportLocationStart(); | 179 | avatar.ControllingClient.SendTeleportLocationStart(); |
180 | AgentCircuitData agent = avatar.ControllingClient.RequestClientInfo(); | 180 | AgentCircuitData agent = avatar.ControllingClient.RequestClientInfo(); |
181 | agent.BaseFolder = LLUUID.Zero; | 181 | agent.BaseFolder = LLUUID.Zero; |
182 | agent.InventoryFolder = LLUUID.Zero; | 182 | agent.InventoryFolder = LLUUID.Zero; |
183 | agent.startpos = position; | 183 | agent.startpos = position; |
184 | agent.child = true; | 184 | agent.child = true; |
185 | avatar.Close(); | 185 | avatar.Close(); |
186 | m_commsProvider.InterRegion.InformRegionOfChildAgent(regionHandle, agent); | 186 | m_commsProvider.InterRegion.InformRegionOfChildAgent(regionHandle, agent); |
187 | m_commsProvider.InterRegion.ExpectAvatarCrossing(regionHandle, avatar.ControllingClient.AgentId, position, false); | 187 | m_commsProvider.InterRegion.ExpectAvatarCrossing(regionHandle, avatar.ControllingClient.AgentId, position, false); |
188 | AgentCircuitData circuitdata = avatar.ControllingClient.RequestClientInfo(); | 188 | AgentCircuitData circuitdata = avatar.ControllingClient.RequestClientInfo(); |
189 | string capsPath = Util.GetCapsURL(avatar.ControllingClient.AgentId); | 189 | string capsPath = Util.GetCapsURL(avatar.ControllingClient.AgentId); |
190 | avatar.ControllingClient.SendRegionTeleport(regionHandle, 13, reg.ExternalEndPoint, 4, (1 << 4), capsPath); | 190 | avatar.ControllingClient.SendRegionTeleport(regionHandle, 13, reg.ExternalEndPoint, 4, (1 << 4), capsPath); |
191 | avatar.MakeChildAgent(); | 191 | avatar.MakeChildAgent(); |
192 | } | 192 | } |
193 | } | 193 | } |
194 | } | 194 | } |
195 | 195 | ||
196 | /// <summary> | 196 | /// <summary> |
197 | /// | 197 | /// |
198 | /// </summary> | 198 | /// </summary> |
199 | /// <param name="regionhandle"></param> | 199 | /// <param name="regionhandle"></param> |
200 | /// <param name="agentID"></param> | 200 | /// <param name="agentID"></param> |
201 | /// <param name="position"></param> | 201 | /// <param name="position"></param> |
202 | public bool InformNeighbourOfCrossing(ulong regionhandle, LLUUID agentID, LLVector3 position, bool isFlying) | 202 | public bool InformNeighbourOfCrossing(ulong regionhandle, LLUUID agentID, LLVector3 position, bool isFlying) |
203 | { | 203 | { |
204 | return m_commsProvider.InterRegion.ExpectAvatarCrossing(regionhandle, agentID, position, isFlying); | 204 | return m_commsProvider.InterRegion.ExpectAvatarCrossing(regionhandle, agentID, position, isFlying); |
205 | } | 205 | } |
206 | 206 | ||
207 | public void CloseAgentConnection(ScenePresence presence) | 207 | public void CloseAgentConnection(ScenePresence presence) |
208 | { | 208 | { |
209 | throw new Exception("The method or operation is not implemented."); | 209 | throw new Exception("The method or operation is not implemented."); |
210 | } | 210 | } |
211 | } | 211 | } |
212 | } | 212 | } |