aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Scenes/InnerScene.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Environment/Scenes/InnerScene.cs')
-rw-r--r--OpenSim/Region/Environment/Scenes/InnerScene.cs1310
1 files changed, 655 insertions, 655 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 @@
1using System; 1using System;
2using System.Collections.Generic; 2using System.Collections.Generic;
3using System.Text; 3using System.Text;
4using libsecondlife; 4using libsecondlife;
5using libsecondlife.Packets; 5using libsecondlife.Packets;
6using OpenSim.Framework; 6using OpenSim.Framework;
7using OpenSim.Framework.Console; 7using OpenSim.Framework.Console;
8using OpenSim.Region.Environment.Types; 8using OpenSim.Region.Environment.Types;
9using OpenSim.Region.Physics.Manager; 9using OpenSim.Region.Physics.Manager;
10 10
11namespace OpenSim.Region.Environment.Scenes 11namespace 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}