aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Environment')
-rw-r--r--OpenSim/Region/Environment/EstateManager.cs24
-rw-r--r--OpenSim/Region/Environment/Interfaces/IAvatarFactory.cs1
-rw-r--r--OpenSim/Region/Environment/Interfaces/IHttpRequests.cs2
-rw-r--r--OpenSim/Region/Environment/Interfaces/IRegionDataStore.cs7
-rw-r--r--OpenSim/Region/Environment/LandManagement/Land.cs61
-rw-r--r--OpenSim/Region/Environment/LandManagement/LandManager.cs95
-rw-r--r--OpenSim/Region/Environment/ModuleLoader.cs2
-rw-r--r--OpenSim/Region/Environment/Modules/AvatarFactoryModule.cs17
-rw-r--r--OpenSim/Region/Environment/Modules/ChatModule.cs10
-rw-r--r--OpenSim/Region/Environment/Modules/ScriptsHttpRequests.cs260
-rw-r--r--OpenSim/Region/Environment/Modules/SunModule.cs37
-rw-r--r--OpenSim/Region/Environment/Modules/TextureDownloadModule.cs42
-rw-r--r--OpenSim/Region/Environment/Modules/WorldCommModule.cs4
-rw-r--r--OpenSim/Region/Environment/Modules/XMLRPCModule.cs9
-rw-r--r--OpenSim/Region/Environment/PermissionManager.cs31
-rw-r--r--OpenSim/Region/Environment/Scenes/AvatarAnimations.cs17
-rw-r--r--OpenSim/Region/Environment/Scenes/AvatarAppearance.cs14
-rw-r--r--OpenSim/Region/Environment/Scenes/EntityBase.cs5
-rw-r--r--OpenSim/Region/Environment/Scenes/IScenePresenceBody.cs1
-rw-r--r--OpenSim/Region/Environment/Scenes/InnerScene.cs123
-rw-r--r--OpenSim/Region/Environment/Scenes/Scene.Inventory.cs189
-rw-r--r--OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs19
-rw-r--r--OpenSim/Region/Environment/Scenes/Scene.cs400
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneBase.cs11
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs72
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneEvents.cs12
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneManager.cs9
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs93
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneObjectPart.cs414
-rw-r--r--OpenSim/Region/Environment/Scenes/ScenePresence.cs132
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneXmlLoader.cs25
-rw-r--r--OpenSim/Region/Environment/Scenes/Scripting/ScriptEngineInterface.cs2
-rw-r--r--OpenSim/Region/Environment/Scenes/Scripting/ScriptEngineLoader.cs2
-rw-r--r--OpenSim/Region/Environment/Scenes/SimStatsReporter.cs69
34 files changed, 1119 insertions, 1092 deletions
diff --git a/OpenSim/Region/Environment/EstateManager.cs b/OpenSim/Region/Environment/EstateManager.cs
index 081a8cd..3ca9796 100644
--- a/OpenSim/Region/Environment/EstateManager.cs
+++ b/OpenSim/Region/Environment/EstateManager.cs
@@ -334,6 +334,7 @@ namespace OpenSim.Region.Environment
334 } 334 }
335 } 335 }
336 } 336 }
337
337 private void estateRestartSim(EstateOwnerMessagePacket packet) 338 private void estateRestartSim(EstateOwnerMessagePacket packet)
338 { 339 {
339 // There's only 1 block in the estateResetSim.. and that's the number of seconds till restart. 340 // There's only 1 block in the estateResetSim.. and that's the number of seconds till restart.
@@ -341,26 +342,25 @@ namespace OpenSim.Region.Environment
341 { 342 {
342 float timeSeconds = 0; 343 float timeSeconds = 0;
343 timeSeconds = BitConverter.ToInt16(block.Parameter, 1); 344 timeSeconds = BitConverter.ToInt16(block.Parameter, 1);
344 timeSeconds = (int)((timeSeconds / 100) - 3); 345 timeSeconds = (int) ((timeSeconds/100) - 3);
345 m_scene.Restart(timeSeconds); 346 m_scene.Restart(timeSeconds);
346
347 } 347 }
348 } 348 }
349
349 private void EstateChangeCovenant(EstateOwnerMessagePacket packet) 350 private void EstateChangeCovenant(EstateOwnerMessagePacket packet)
350 { 351 {
351 foreach (EstateOwnerMessagePacket.ParamListBlock block in packet.ParamList) 352 foreach (EstateOwnerMessagePacket.ParamListBlock block in packet.ParamList)
352 { 353 {
353 LLUUID newCovenantID = new LLUUID(Helpers.FieldToUTF8String(block.Parameter)); 354 LLUUID newCovenantID = new LLUUID(Helpers.FieldToUTF8String(block.Parameter));
354 m_regInfo.CovenantID = newCovenantID; 355 m_regInfo.CovenantID = newCovenantID;
355
356 } 356 }
357
358 } 357 }
358
359 public void HandleRegionInfoRequest(IClientAPI client, LLUUID sessionID) 359 public void HandleRegionInfoRequest(IClientAPI client, LLUUID sessionID)
360 { 360 {
361 RegionInfoPacket rinfopack = new RegionInfoPacket(); 361 RegionInfoPacket rinfopack = new RegionInfoPacket();
362 RegionInfoPacket.RegionInfoBlock rinfoblk = new RegionInfoPacket.RegionInfoBlock(); 362 RegionInfoPacket.RegionInfoBlock rinfoblk = new RegionInfoPacket.RegionInfoBlock();
363 363
364 rinfoblk.BillableFactor = 0; 364 rinfoblk.BillableFactor = 0;
365 rinfoblk.EstateID = 02; 365 rinfoblk.EstateID = 02;
366 rinfoblk.MaxAgents = 100; 366 rinfoblk.MaxAgents = 100;
@@ -369,20 +369,20 @@ namespace OpenSim.Region.Environment
369 rinfoblk.PricePerMeter = 0; 369 rinfoblk.PricePerMeter = 0;
370 rinfoblk.RedirectGridX = 0; 370 rinfoblk.RedirectGridX = 0;
371 rinfoblk.RedirectGridY = 0; 371 rinfoblk.RedirectGridY = 0;
372 rinfoblk.RegionFlags = (uint)m_regInfo.EstateSettings.regionFlags; 372 rinfoblk.RegionFlags = (uint) m_regInfo.EstateSettings.regionFlags;
373 rinfoblk.SimAccess = (byte)m_regInfo.EstateSettings.simAccess; 373 rinfoblk.SimAccess = (byte) m_regInfo.EstateSettings.simAccess;
374 rinfoblk.SunHour = m_regInfo.EstateSettings.sunHour; 374 rinfoblk.SunHour = m_regInfo.EstateSettings.sunHour;
375 rinfoblk.TerrainLowerLimit = 20; 375 rinfoblk.TerrainLowerLimit = 20;
376 rinfoblk.TerrainRaiseLimit = 20; 376 rinfoblk.TerrainRaiseLimit = 20;
377 rinfoblk.UseEstateSun = true; 377 rinfoblk.UseEstateSun = true;
378 rinfoblk.WaterHeight = m_regInfo.EstateSettings.waterHeight; 378 rinfoblk.WaterHeight = m_regInfo.EstateSettings.waterHeight;
379 rinfoblk.SimName = Helpers.StringToField(m_regInfo.RegionName); 379 rinfoblk.SimName = Helpers.StringToField(m_regInfo.RegionName);
380 380
381 rinfopack.RegionInfo = rinfoblk; 381 rinfopack.RegionInfo = rinfoblk;
382 382
383 client.OutPacket(rinfopack, ThrottleOutPacketType.Task); 383 client.OutPacket(rinfopack, ThrottleOutPacketType.Task);
384
385 } 384 }
385
386 public void HandleEstateCovenantRequest(IClientAPI client, LLUUID sessionID) 386 public void HandleEstateCovenantRequest(IClientAPI client, LLUUID sessionID)
387 { 387 {
388 EstateCovenantReplyPacket einfopack = new EstateCovenantReplyPacket(); 388 EstateCovenantReplyPacket einfopack = new EstateCovenantReplyPacket();
@@ -390,10 +390,12 @@ namespace OpenSim.Region.Environment
390 edata.CovenantID = m_regInfo.CovenantID; 390 edata.CovenantID = m_regInfo.CovenantID;
391 edata.CovenantTimestamp = 0; 391 edata.CovenantTimestamp = 0;
392 edata.EstateOwnerID = m_regInfo.MasterAvatarAssignedUUID; 392 edata.EstateOwnerID = m_regInfo.MasterAvatarAssignedUUID;
393 edata.EstateName = Helpers.StringToField(m_regInfo.MasterAvatarFirstName + " " + m_regInfo.MasterAvatarLastName); 393 edata.EstateName =
394 Helpers.StringToField(m_regInfo.MasterAvatarFirstName + " " + m_regInfo.MasterAvatarLastName);
394 einfopack.Data = edata; 395 einfopack.Data = edata;
395 client.OutPacket(einfopack, ThrottleOutPacketType.Task); 396 client.OutPacket(einfopack, ThrottleOutPacketType.Task);
396 } 397 }
398
397 #endregion 399 #endregion
398 400
399 #region Outgoing Packets 401 #region Outgoing Packets
@@ -451,4 +453,4 @@ namespace OpenSim.Region.Environment
451 453
452 #endregion 454 #endregion
453 } 455 }
454} 456} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Interfaces/IAvatarFactory.cs b/OpenSim/Region/Environment/Interfaces/IAvatarFactory.cs
index ee4d8bc..fb83150 100644
--- a/OpenSim/Region/Environment/Interfaces/IAvatarFactory.cs
+++ b/OpenSim/Region/Environment/Interfaces/IAvatarFactory.cs
@@ -27,7 +27,6 @@
27*/ 27*/
28 28
29using libsecondlife; 29using libsecondlife;
30using OpenSim.Framework;
31using OpenSim.Region.Environment.Scenes; 30using OpenSim.Region.Environment.Scenes;
32 31
33namespace OpenSim.Region.Environment.Interfaces 32namespace OpenSim.Region.Environment.Interfaces
diff --git a/OpenSim/Region/Environment/Interfaces/IHttpRequests.cs b/OpenSim/Region/Environment/Interfaces/IHttpRequests.cs
index c974616..6aa8f35 100644
--- a/OpenSim/Region/Environment/Interfaces/IHttpRequests.cs
+++ b/OpenSim/Region/Environment/Interfaces/IHttpRequests.cs
@@ -26,9 +26,9 @@
26* 26*
27*/ 27*/
28 28
29using System.Collections.Generic;
29using libsecondlife; 30using libsecondlife;
30using OpenSim.Region.Environment.Modules; 31using OpenSim.Region.Environment.Modules;
31using System.Collections.Generic;
32 32
33namespace OpenSim.Region.Environment.Interfaces 33namespace OpenSim.Region.Environment.Interfaces
34{ 34{
diff --git a/OpenSim/Region/Environment/Interfaces/IRegionDataStore.cs b/OpenSim/Region/Environment/Interfaces/IRegionDataStore.cs
index 91aa5ff..78ad428 100644
--- a/OpenSim/Region/Environment/Interfaces/IRegionDataStore.cs
+++ b/OpenSim/Region/Environment/Interfaces/IRegionDataStore.cs
@@ -28,6 +28,7 @@
28 28
29using System.Collections.Generic; 29using System.Collections.Generic;
30using libsecondlife; 30using libsecondlife;
31using OpenSim.Framework;
31using OpenSim.Region.Environment.LandManagement; 32using OpenSim.Region.Environment.LandManagement;
32using OpenSim.Region.Environment.Scenes; 33using OpenSim.Region.Environment.Scenes;
33 34
@@ -51,10 +52,10 @@ namespace OpenSim.Region.Environment.Interfaces
51 void StoreTerrain(double[,] terrain, LLUUID regionID); 52 void StoreTerrain(double[,] terrain, LLUUID regionID);
52 double[,] LoadTerrain(LLUUID regionID); 53 double[,] LoadTerrain(LLUUID regionID);
53 54
54 void StoreLandObject(Land Parcel,LLUUID regionUUID); 55 void StoreLandObject(Land Parcel, LLUUID regionUUID);
55 void RemoveLandObject(LLUUID globalID); 56 void RemoveLandObject(LLUUID globalID);
56 List<Framework.LandData> LoadLandObjects(LLUUID regionUUID); 57 List<LandData> LoadLandObjects(LLUUID regionUUID);
57 58
58 void Shutdown(); 59 void Shutdown();
59 } 60 }
60} 61} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/LandManagement/Land.cs b/OpenSim/Region/Environment/LandManagement/Land.cs
index 7977c78..ff16319 100644
--- a/OpenSim/Region/Environment/LandManagement/Land.cs
+++ b/OpenSim/Region/Environment/LandManagement/Land.cs
@@ -32,7 +32,6 @@ using libsecondlife;
32using libsecondlife.Packets; 32using libsecondlife.Packets;
33using OpenSim.Framework; 33using OpenSim.Framework;
34using OpenSim.Region.Environment.Scenes; 34using OpenSim.Region.Environment.Scenes;
35using OpenSim.Region.Environment.Interfaces;
36 35
37namespace OpenSim.Region.Environment.LandManagement 36namespace OpenSim.Region.Environment.LandManagement
38{ 37{
@@ -98,7 +97,6 @@ namespace OpenSim.Region.Environment.LandManagement
98 return newLand; 97 return newLand;
99 } 98 }
100 99
101
102 #endregion 100 #endregion
103 101
104 #region Packet Request Handling 102 #region Packet Request Handling
@@ -202,7 +200,7 @@ namespace OpenSim.Region.Environment.LandManagement
202 //Needs later group support 200 //Needs later group support
203 LandData newData = landData.Copy(); 201 LandData newData = landData.Copy();
204 newData.authBuyerID = packet.ParcelData.AuthBuyerID; 202 newData.authBuyerID = packet.ParcelData.AuthBuyerID;
205 newData.category = (Parcel.ParcelCategory)packet.ParcelData.Category; 203 newData.category = (Parcel.ParcelCategory) packet.ParcelData.Category;
206 newData.landDesc = Helpers.FieldToUTF8String(packet.ParcelData.Desc); 204 newData.landDesc = Helpers.FieldToUTF8String(packet.ParcelData.Desc);
207 newData.groupID = packet.ParcelData.GroupID; 205 newData.groupID = packet.ParcelData.GroupID;
208 newData.landingType = packet.ParcelData.LandingType; 206 newData.landingType = packet.ParcelData.LandingType;
@@ -222,8 +220,6 @@ namespace OpenSim.Region.Environment.LandManagement
222 m_scene.LandManager.updateLandObject(landData.localID, newData); 220 m_scene.LandManager.updateLandObject(landData.localID, newData);
223 221
224 sendLandUpdateToAvatarsOverMe(); 222 sendLandUpdateToAvatarsOverMe();
225
226
227 } 223 }
228 } 224 }
229 225
@@ -242,13 +238,13 @@ namespace OpenSim.Region.Environment.LandManagement
242 238
243 public bool isBannedFromLand(LLUUID avatar) 239 public bool isBannedFromLand(LLUUID avatar)
244 { 240 {
245 if ((this.landData.landFlags & (uint)Parcel.ParcelFlags.UseBanList) > 0) 241 if ((landData.landFlags & (uint) Parcel.ParcelFlags.UseBanList) > 0)
246 { 242 {
247 ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry(); 243 ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry();
248 entry.AgentID = avatar; 244 entry.AgentID = avatar;
249 entry.Flags = ParcelManager.AccessList.Ban; 245 entry.Flags = ParcelManager.AccessList.Ban;
250 entry.Time = new DateTime(); 246 entry.Time = new DateTime();
251 if (this.landData.parcelAccessList.Contains(entry)) 247 if (landData.parcelAccessList.Contains(entry))
252 { 248 {
253 //They are banned, so lets send them a notice about this parcel 249 //They are banned, so lets send them a notice about this parcel
254 return true; 250 return true;
@@ -259,13 +255,13 @@ namespace OpenSim.Region.Environment.LandManagement
259 255
260 public bool isRestrictedFromLand(LLUUID avatar) 256 public bool isRestrictedFromLand(LLUUID avatar)
261 { 257 {
262 if ((this.landData.landFlags & (uint)Parcel.ParcelFlags.UseAccessList) > 0) 258 if ((landData.landFlags & (uint) Parcel.ParcelFlags.UseAccessList) > 0)
263 { 259 {
264 ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry(); 260 ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry();
265 entry.AgentID = avatar; 261 entry.AgentID = avatar;
266 entry.Flags = ParcelManager.AccessList.Access; 262 entry.Flags = ParcelManager.AccessList.Access;
267 entry.Time = new DateTime(); 263 entry.Time = new DateTime();
268 if (!this.landData.parcelAccessList.Contains(entry)) 264 if (!landData.parcelAccessList.Contains(entry))
269 { 265 {
270 //They are not allowed in this parcel, but not banned, so lets send them a notice about this parcel 266 //They are not allowed in this parcel, but not banned, so lets send them a notice about this parcel
271 return true; 267 return true;
@@ -310,7 +306,7 @@ namespace OpenSim.Region.Environment.LandManagement
310 { 306 {
311 ParcelAccessListReplyPacket.ListBlock listBlock = new ParcelAccessListReplyPacket.ListBlock(); 307 ParcelAccessListReplyPacket.ListBlock listBlock = new ParcelAccessListReplyPacket.ListBlock();
312 308
313 listBlock.Flags = (uint)0; 309 listBlock.Flags = (uint) 0;
314 listBlock.ID = entry.AgentID; 310 listBlock.ID = entry.AgentID;
315 listBlock.Time = 0; 311 listBlock.Time = 0;
316 312
@@ -322,7 +318,7 @@ namespace OpenSim.Region.Environment.LandManagement
322 { 318 {
323 ParcelAccessListReplyPacket.ListBlock listBlock = new ParcelAccessListReplyPacket.ListBlock(); 319 ParcelAccessListReplyPacket.ListBlock listBlock = new ParcelAccessListReplyPacket.ListBlock();
324 320
325 listBlock.Flags = (uint)0; 321 listBlock.Flags = (uint) 0;
326 listBlock.ID = LLUUID.Zero; 322 listBlock.ID = LLUUID.Zero;
327 listBlock.Time = 0; 323 listBlock.Time = 0;
328 324
@@ -331,38 +327,37 @@ namespace OpenSim.Region.Environment.LandManagement
331 return list.ToArray(); 327 return list.ToArray();
332 } 328 }
333 329
334 public void sendAccessList(LLUUID agentID, LLUUID sessionID, uint flags, int sequenceID, IClientAPI remote_client) 330 public void sendAccessList(LLUUID agentID, LLUUID sessionID, uint flags, int sequenceID,
331 IClientAPI remote_client)
335 { 332 {
336
337 ParcelAccessListReplyPacket replyPacket; 333 ParcelAccessListReplyPacket replyPacket;
338 334
339 if (flags == (uint)ParcelManager.AccessList.Access || flags == (uint)ParcelManager.AccessList.Both) 335 if (flags == (uint) ParcelManager.AccessList.Access || flags == (uint) ParcelManager.AccessList.Both)
340 { 336 {
341 replyPacket = new ParcelAccessListReplyPacket(); 337 replyPacket = new ParcelAccessListReplyPacket();
342 replyPacket.Data.AgentID = agentID; 338 replyPacket.Data.AgentID = agentID;
343 replyPacket.Data.Flags = (uint)ParcelManager.AccessList.Access; 339 replyPacket.Data.Flags = (uint) ParcelManager.AccessList.Access;
344 replyPacket.Data.LocalID = this.landData.localID; 340 replyPacket.Data.LocalID = landData.localID;
345 replyPacket.Data.SequenceID = 0; 341 replyPacket.Data.SequenceID = 0;
346 342
347 replyPacket.List = createAccessListArrayByFlag(ParcelManager.AccessList.Access); 343 replyPacket.List = createAccessListArrayByFlag(ParcelManager.AccessList.Access);
348 remote_client.OutPacket((Packet)replyPacket, ThrottleOutPacketType.Task); 344 remote_client.OutPacket((Packet) replyPacket, ThrottleOutPacketType.Task);
349 } 345 }
350 346
351 if (flags == (uint)ParcelManager.AccessList.Ban || flags == (uint)ParcelManager.AccessList.Both) 347 if (flags == (uint) ParcelManager.AccessList.Ban || flags == (uint) ParcelManager.AccessList.Both)
352 { 348 {
353 replyPacket = new ParcelAccessListReplyPacket(); 349 replyPacket = new ParcelAccessListReplyPacket();
354 replyPacket.Data.AgentID = agentID; 350 replyPacket.Data.AgentID = agentID;
355 replyPacket.Data.Flags = (uint)ParcelManager.AccessList.Ban; 351 replyPacket.Data.Flags = (uint) ParcelManager.AccessList.Ban;
356 replyPacket.Data.LocalID = this.landData.localID; 352 replyPacket.Data.LocalID = landData.localID;
357 replyPacket.Data.SequenceID = 0; 353 replyPacket.Data.SequenceID = 0;
358 354
359 replyPacket.List = createAccessListArrayByFlag(ParcelManager.AccessList.Ban); 355 replyPacket.List = createAccessListArrayByFlag(ParcelManager.AccessList.Ban);
360 remote_client.OutPacket((Packet)replyPacket, ThrottleOutPacketType.Task); 356 remote_client.OutPacket((Packet) replyPacket, ThrottleOutPacketType.Task);
361 } 357 }
362
363 } 358 }
364 359
365 public void updateAccessList(uint flags, List<ParcelManager.ParcelAccessEntry> entries, IClientAPI remote_client) 360 public void updateAccessList(uint flags, List<ParcelManager.ParcelAccessEntry> entries, IClientAPI remote_client)
366 { 361 {
367 LandData newData = landData.Copy(); 362 LandData newData = landData.Copy();
368 363
@@ -370,11 +365,11 @@ namespace OpenSim.Region.Environment.LandManagement
370 { 365 {
371 entries.Clear(); 366 entries.Clear();
372 } 367 }
373 368
374 List<ParcelManager.ParcelAccessEntry> toRemove = new List<ParcelManager.ParcelAccessEntry>(); 369 List<ParcelManager.ParcelAccessEntry> toRemove = new List<ParcelManager.ParcelAccessEntry>();
375 foreach (ParcelManager.ParcelAccessEntry entry in newData.parcelAccessList) 370 foreach (ParcelManager.ParcelAccessEntry entry in newData.parcelAccessList)
376 { 371 {
377 if (entry.Flags == (ParcelManager.AccessList)flags) 372 if (entry.Flags == (ParcelManager.AccessList) flags)
378 { 373 {
379 toRemove.Add(entry); 374 toRemove.Add(entry);
380 } 375 }
@@ -388,8 +383,8 @@ namespace OpenSim.Region.Environment.LandManagement
388 { 383 {
389 ParcelManager.ParcelAccessEntry temp = new ParcelManager.ParcelAccessEntry(); 384 ParcelManager.ParcelAccessEntry temp = new ParcelManager.ParcelAccessEntry();
390 temp.AgentID = entry.AgentID; 385 temp.AgentID = entry.AgentID;
391 temp.Time = new DateTime() ; //Pointless? Yes. 386 temp.Time = new DateTime(); //Pointless? Yes.
392 temp.Flags = (ParcelManager.AccessList)flags; 387 temp.Flags = (ParcelManager.AccessList) flags;
393 388
394 if (!newData.parcelAccessList.Contains(temp)) 389 if (!newData.parcelAccessList.Contains(temp))
395 { 390 {
@@ -398,7 +393,6 @@ namespace OpenSim.Region.Environment.LandManagement
398 } 393 }
399 394
400 m_scene.LandManager.updateLandObject(landData.localID, newData); 395 m_scene.LandManager.updateLandObject(landData.localID, newData);
401
402 } 396 }
403 397
404 #endregion 398 #endregion
@@ -437,7 +431,6 @@ namespace OpenSim.Region.Environment.LandManagement
437 new LLVector3((float) (max_x*4), (float) (max_y*4), 431 new LLVector3((float) (max_x*4), (float) (max_y*4),
438 (float) m_scene.Terrain.GetHeight((max_x*4), (max_y*4))); 432 (float) m_scene.Terrain.GetHeight((max_x*4), (max_y*4)));
439 landData.area = tempArea; 433 landData.area = tempArea;
440
441 } 434 }
442 435
443 public void updateLandBitmapByteArray() 436 public void updateLandBitmapByteArray()
@@ -650,9 +643,9 @@ namespace OpenSim.Region.Environment.LandManagement
650 { 643 {
651 resultLocalIDs.Add(obj.LocalId); 644 resultLocalIDs.Add(obj.LocalId);
652 } 645 }
653 // else if (request_type == LandManager.LAND_SELECT_OBJECTS_GROUP && ...) // TODO: group support 646 // else if (request_type == LandManager.LAND_SELECT_OBJECTS_GROUP && ...) // TODO: group support
654 // { 647 // {
655 // } 648 // }
656 else if (request_type == LandManager.LAND_SELECT_OBJECTS_OTHER && 649 else if (request_type == LandManager.LAND_SELECT_OBJECTS_OTHER &&
657 obj.OwnerID != remote_client.AgentId) 650 obj.OwnerID != remote_client.AgentId)
658 { 651 {
@@ -732,10 +725,8 @@ namespace OpenSim.Region.Environment.LandManagement
732 725
733 num++; 726 num++;
734 } 727 }
735 728
736 pack.Data = dataBlock; 729 pack.Data = dataBlock;
737
738
739 } 730 }
740 remote_client.OutPacket(pack, ThrottleOutPacketType.Task); 731 remote_client.OutPacket(pack, ThrottleOutPacketType.Task);
741 } 732 }
diff --git a/OpenSim/Region/Environment/LandManagement/LandManager.cs b/OpenSim/Region/Environment/LandManagement/LandManager.cs
index ecd458d..772fe2e 100644
--- a/OpenSim/Region/Environment/LandManagement/LandManager.cs
+++ b/OpenSim/Region/Environment/LandManagement/LandManager.cs
@@ -27,11 +27,13 @@
27*/ 27*/
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using Axiom.Math;
30using libsecondlife; 31using libsecondlife;
31using libsecondlife.Packets; 32using libsecondlife.Packets;
32using OpenSim.Framework; 33using OpenSim.Framework;
34using OpenSim.Framework.Console;
33using OpenSim.Region.Environment.Scenes; 35using OpenSim.Region.Environment.Scenes;
34using OpenSim.Region.Environment.Interfaces; 36using OpenSim.Region.Physics.Manager;
35 37
36namespace OpenSim.Region.Environment.LandManagement 38namespace OpenSim.Region.Environment.LandManagement
37{ 39{
@@ -93,7 +95,7 @@ namespace OpenSim.Region.Environment.LandManagement
93 private readonly RegionInfo m_regInfo; 95 private readonly RegionInfo m_regInfo;
94 96
95 public bool allowedForcefulBans = true; 97 public bool allowedForcefulBans = true;
96 98
97 #endregion 99 #endregion
98 100
99 #region Constructors 101 #region Constructors
@@ -103,14 +105,13 @@ namespace OpenSim.Region.Environment.LandManagement
103 m_scene = scene; 105 m_scene = scene;
104 m_regInfo = reginfo; 106 m_regInfo = reginfo;
105 landIDList.Initialize(); 107 landIDList.Initialize();
106 scene.EventManager.OnAvatarEnteringNewParcel += new EventManager.AvatarEnteringNewParcel(handleAvatarChangingParcel); 108 scene.EventManager.OnAvatarEnteringNewParcel +=
107 scene.EventManager.OnClientMovement += new EventManager.ClientMovement(this.handleAnyClientMovement); 109 new EventManager.AvatarEnteringNewParcel(handleAvatarChangingParcel);
110 scene.EventManager.OnClientMovement += new EventManager.ClientMovement(handleAnyClientMovement);
108 } 111 }
109 112
110
111
112 #endregion 113 #endregion
113 114
114 #region Member Functions 115 #region Member Functions
115 116
116 #region Land Object From Storage Functions 117 #region Land Object From Storage Functions
@@ -147,7 +148,6 @@ namespace OpenSim.Region.Environment.LandManagement
147 /// <returns></returns> 148 /// <returns></returns>
148 public Land createBaseLand() 149 public Land createBaseLand()
149 { 150 {
150
151 return new Land(LLUUID.Zero, false, m_scene); 151 return new Land(LLUUID.Zero, false, m_scene);
152 } 152 }
153 153
@@ -175,7 +175,7 @@ namespace OpenSim.Region.Environment.LandManagement
175 } 175 }
176 } 176 }
177 landList[lastLandLocalID].forceUpdateLandInfo(); 177 landList[lastLandLocalID].forceUpdateLandInfo();
178 m_scene.EventManager.TriggerLandObjectAdded(new_land,m_scene.RegionInfo.RegionID); 178 m_scene.EventManager.TriggerLandObjectAdded(new_land, m_scene.RegionInfo.RegionID);
179 return new_land; 179 return new_land;
180 } 180 }
181 181
@@ -207,7 +207,7 @@ namespace OpenSim.Region.Environment.LandManagement
207 if (landList.ContainsKey(local_id)) 207 if (landList.ContainsKey(local_id))
208 { 208 {
209 landList[local_id].landData = newData.Copy(); 209 landList[local_id].landData = newData.Copy();
210 m_scene.EventManager.TriggerLandObjectUpdated((uint)local_id, landList[local_id]); 210 m_scene.EventManager.TriggerLandObjectUpdated((uint) local_id, landList[local_id]);
211 } 211 }
212 else 212 else
213 { 213 {
@@ -335,7 +335,7 @@ namespace OpenSim.Region.Environment.LandManagement
335 335
336 //Now add the new land object 336 //Now add the new land object
337 Land result = addLandObject(newLand); 337 Land result = addLandObject(newLand);
338 updateLandObject(startLandObject.landData.localID,startLandObject.landData); 338 updateLandObject(startLandObject.landData.localID, startLandObject.landData);
339 result.sendLandUpdateToAvatarsOverMe(); 339 result.sendLandUpdateToAvatarsOverMe();
340 340
341 341
@@ -463,11 +463,11 @@ namespace OpenSim.Region.Environment.LandManagement
463 Land southParcel = null; 463 Land southParcel = null;
464 if (x > 0) 464 if (x > 0)
465 { 465 {
466 westParcel = getLandObject((x - 1) * 4, y * 4); 466 westParcel = getLandObject((x - 1)*4, y*4);
467 } 467 }
468 if (y > 0) 468 if (y > 0)
469 { 469 {
470 southParcel = getLandObject(x * 4, (y - 1) * 4); 470 southParcel = getLandObject(x*4, (y - 1)*4);
471 } 471 }
472 472
473 if (x == 0) 473 if (x == 0)
@@ -496,14 +496,15 @@ namespace OpenSim.Region.Environment.LandManagement
496 packet = new ParcelOverlayPacket(); 496 packet = new ParcelOverlayPacket();
497 packet.ParcelData.Data = byteArray; 497 packet.ParcelData.Data = byteArray;
498 packet.ParcelData.SequenceID = sequenceID; 498 packet.ParcelData.SequenceID = sequenceID;
499 remote_client.OutPacket((Packet)packet, ThrottleOutPacketType.Task); 499 remote_client.OutPacket((Packet) packet, ThrottleOutPacketType.Task);
500 sequenceID++; 500 sequenceID++;
501 byteArray = new byte[LAND_BLOCKS_PER_PACKET]; 501 byteArray = new byte[LAND_BLOCKS_PER_PACKET];
502 } 502 }
503 } 503 }
504 catch (System.Exception e) 504 catch (Exception e)
505 { 505 {
506 OpenSim.Framework.Console.MainLog.Instance.Debug("LAND", "Skipped Land checks because avatar is out of bounds: " + e.Message); 506 MainLog.Instance.Debug("LAND",
507 "Skipped Land checks because avatar is out of bounds: " + e.Message);
507 } 508 }
508 } 509 }
509 } 510 }
@@ -599,7 +600,6 @@ namespace OpenSim.Region.Environment.LandManagement
599 600
600 public List<Land> parcelsNearPoint(LLVector3 position) 601 public List<Land> parcelsNearPoint(LLVector3 position)
601 { 602 {
602
603 List<Land> parcelsNear = new List<Land>(); 603 List<Land> parcelsNear = new List<Land>();
604 int x, y; 604 int x, y;
605 for (x = -4; x <= 4; x += 4) 605 for (x = -4; x <= 4; x += 4)
@@ -617,22 +617,25 @@ namespace OpenSim.Region.Environment.LandManagement
617 } 617 }
618 } 618 }
619 619
620 return parcelsNear; 620 return parcelsNear;
621
622 } 621 }
623 622
624 public void sendYouAreBannedNotice(ScenePresence avatar) 623 public void sendYouAreBannedNotice(ScenePresence avatar)
625 { 624 {
626 if (allowedForcefulBans) 625 if (allowedForcefulBans)
627 { 626 {
628 avatar.ControllingClient.SendAlertMessage("You are not allowed on this parcel because you are banned. Please go away. <3 OpenSim Developers"); 627 avatar.ControllingClient.SendAlertMessage(
628 "You are not allowed on this parcel because you are banned. Please go away. <3 OpenSim Developers");
629 629
630 avatar.PhysicsActor.Position = new OpenSim.Region.Physics.Manager.PhysicsVector(avatar.lastKnownAllowedPosition.x, avatar.lastKnownAllowedPosition.y, avatar.lastKnownAllowedPosition.z); 630 avatar.PhysicsActor.Position =
631 avatar.PhysicsActor.Velocity = new OpenSim.Region.Physics.Manager.PhysicsVector(0, 0, 0); 631 new PhysicsVector(avatar.lastKnownAllowedPosition.x, avatar.lastKnownAllowedPosition.y,
632 avatar.lastKnownAllowedPosition.z);
633 avatar.PhysicsActor.Velocity = new PhysicsVector(0, 0, 0);
632 } 634 }
633 else 635 else
634 { 636 {
635 avatar.ControllingClient.SendAlertMessage("You are not allowed on this parcel because you are banned; however, the grid administrator has disabled ban lines globally. Please obey the land owner's requests or you can be banned from the entire sim! <3 OpenSim Developers"); 637 avatar.ControllingClient.SendAlertMessage(
638 "You are not allowed on this parcel because you are banned; however, the grid administrator has disabled ban lines globally. Please obey the land owner's requests or you can be banned from the entire sim! <3 OpenSim Developers");
636 } 639 }
637 } 640 }
638 641
@@ -651,7 +654,8 @@ namespace OpenSim.Region.Environment.LandManagement
651 } 654 }
652 else if (parcelAvatarIsEntering.isRestrictedFromLand(avatar.UUID)) 655 else if (parcelAvatarIsEntering.isRestrictedFromLand(avatar.UUID))
653 { 656 {
654 avatar.ControllingClient.SendAlertMessage("You are not allowed on this parcel because the land owner has restricted access. For now, you can enter, but please respect the land owner's decisions (or he can ban you!). <3 OpenSim Developers"); 657 avatar.ControllingClient.SendAlertMessage(
658 "You are not allowed on this parcel because the land owner has restricted access. For now, you can enter, but please respect the land owner's decisions (or he can ban you!). <3 OpenSim Developers");
655 } 659 }
656 else 660 else
657 { 661 {
@@ -668,7 +672,6 @@ namespace OpenSim.Region.Environment.LandManagement
668 672
669 public void sendOutNearestBanLine(IClientAPI avatar) 673 public void sendOutNearestBanLine(IClientAPI avatar)
670 { 674 {
671
672 List<ScenePresence> avatars = m_scene.GetAvatars(); 675 List<ScenePresence> avatars = m_scene.GetAvatars();
673 foreach (ScenePresence presence in avatars) 676 foreach (ScenePresence presence in avatars)
674 { 677 {
@@ -679,15 +682,14 @@ namespace OpenSim.Region.Environment.LandManagement
679 { 682 {
680 if (checkBan.isBannedFromLand(avatar.AgentId)) 683 if (checkBan.isBannedFromLand(avatar.AgentId))
681 { 684 {
682 checkBan.sendLandProperties(-30000, false, (int)ParcelManager.ParcelResult.Single, avatar); 685 checkBan.sendLandProperties(-30000, false, (int) ParcelManager.ParcelResult.Single, avatar);
683 return; //Only send one 686 return; //Only send one
684 } 687 }
685 else if (checkBan.isRestrictedFromLand(avatar.AgentId)) 688 else if (checkBan.isRestrictedFromLand(avatar.AgentId))
686 { 689 {
687 checkBan.sendLandProperties(-40000, false, (int)ParcelManager.ParcelResult.Single, avatar); 690 checkBan.sendLandProperties(-40000, false, (int) ParcelManager.ParcelResult.Single, avatar);
688 return; //Only send one 691 return; //Only send one
689 } 692 }
690
691 } 693 }
692 return; 694 return;
693 } 695 }
@@ -696,8 +698,8 @@ namespace OpenSim.Region.Environment.LandManagement
696 698
697 public void sendLandUpdate(ScenePresence avatar) 699 public void sendLandUpdate(ScenePresence avatar)
698 { 700 {
699 Land over = getLandObject((int)Math.Min(255, Math.Max(0, Math.Round(avatar.AbsolutePosition.X))), 701 Land over = getLandObject((int) Math.Min(255, Math.Max(0, Math.Round(avatar.AbsolutePosition.X))),
700 (int)Math.Min(255, Math.Max(0, Math.Round(avatar.AbsolutePosition.Y)))); 702 (int) Math.Min(255, Math.Max(0, Math.Round(avatar.AbsolutePosition.Y))));
701 703
702 if (over != null) 704 if (over != null)
703 { 705 {
@@ -705,10 +707,10 @@ namespace OpenSim.Region.Environment.LandManagement
705 if (avatar.currentParcelUUID != over.landData.globalID) 707 if (avatar.currentParcelUUID != over.landData.globalID)
706 { 708 {
707 avatar.currentParcelUUID = over.landData.globalID; 709 avatar.currentParcelUUID = over.landData.globalID;
708 m_scene.EventManager.TriggerAvatarEnteringNewParcel(avatar, over.landData.localID, this.m_scene.RegionInfo.RegionID); 710 m_scene.EventManager.TriggerAvatarEnteringNewParcel(avatar, over.landData.localID,
711 m_scene.RegionInfo.RegionID);
709 } 712 }
710 } 713 }
711
712 } 714 }
713 715
714 public void handleSignificantClientMovement(IClientAPI remote_client) 716 public void handleSignificantClientMovement(IClientAPI remote_client)
@@ -722,16 +724,18 @@ namespace OpenSim.Region.Environment.LandManagement
722 Land parcel = getLandObject(clientAvatar.AbsolutePosition.X, clientAvatar.AbsolutePosition.Y); 724 Land parcel = getLandObject(clientAvatar.AbsolutePosition.X, clientAvatar.AbsolutePosition.Y);
723 if (parcel != null) 725 if (parcel != null)
724 { 726 {
725 if (clientAvatar.AbsolutePosition.Z < BAN_LINE_SAFETY_HIEGHT && clientAvatar.sentMessageAboutRestrictedParcelFlyingDown) 727 if (clientAvatar.AbsolutePosition.Z < BAN_LINE_SAFETY_HIEGHT &&
728 clientAvatar.sentMessageAboutRestrictedParcelFlyingDown)
726 { 729 {
727 730 handleAvatarChangingParcel(clientAvatar, parcel.landData.localID, m_scene.RegionInfo.RegionID);
728 handleAvatarChangingParcel(clientAvatar, parcel.landData.localID, m_scene.RegionInfo.RegionID); //They are going below the safety line! 731 //They are going below the safety line!
729 if (!parcel.isBannedFromLand(clientAvatar.UUID)) 732 if (!parcel.isBannedFromLand(clientAvatar.UUID))
730 { 733 {
731 clientAvatar.sentMessageAboutRestrictedParcelFlyingDown = false; 734 clientAvatar.sentMessageAboutRestrictedParcelFlyingDown = false;
732 } 735 }
733 } 736 }
734 else if (clientAvatar.AbsolutePosition.Z < BAN_LINE_SAFETY_HIEGHT && parcel.isBannedFromLand(clientAvatar.UUID)) 737 else if (clientAvatar.AbsolutePosition.Z < BAN_LINE_SAFETY_HIEGHT &&
738 parcel.isBannedFromLand(clientAvatar.UUID))
735 { 739 {
736 sendYouAreBannedNotice(clientAvatar); 740 sendYouAreBannedNotice(clientAvatar);
737 } 741 }
@@ -739,30 +743,33 @@ namespace OpenSim.Region.Environment.LandManagement
739 } 743 }
740 } 744 }
741 745
742 public void handleAnyClientMovement(ScenePresence avatar) //Like handleSignificantClientMovement, but called with an AgentUpdate regardless of distance. 746 public void handleAnyClientMovement(ScenePresence avatar)
747 //Like handleSignificantClientMovement, but called with an AgentUpdate regardless of distance.
743 { 748 {
744 Land over = getLandObject(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y); 749 Land over = getLandObject(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y);
745 if (over != null) 750 if (over != null)
746 { 751 {
747 if (!over.isBannedFromLand(avatar.UUID) || avatar.AbsolutePosition.Z >= BAN_LINE_SAFETY_HIEGHT) 752 if (!over.isBannedFromLand(avatar.UUID) || avatar.AbsolutePosition.Z >= BAN_LINE_SAFETY_HIEGHT)
748 { 753 {
749 avatar.lastKnownAllowedPosition = new Axiom.Math.Vector3(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y, avatar.AbsolutePosition.Z); 754 avatar.lastKnownAllowedPosition =
750 755 new Vector3(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y, avatar.AbsolutePosition.Z);
751
752 } 756 }
753 } 757 }
754 } 758 }
755 759
756 760
757 public void handleParcelAccessRequest(LLUUID agentID, LLUUID sessionID, uint flags, int sequenceID, int landLocalID, IClientAPI remote_client) 761 public void handleParcelAccessRequest(LLUUID agentID, LLUUID sessionID, uint flags, int sequenceID,
762 int landLocalID, IClientAPI remote_client)
758 { 763 {
759 if (landList.ContainsKey(landLocalID)) 764 if (landList.ContainsKey(landLocalID))
760 { 765 {
761 landList[landLocalID].sendAccessList(agentID, sessionID, flags, sequenceID,remote_client); 766 landList[landLocalID].sendAccessList(agentID, sessionID, flags, sequenceID, remote_client);
762 } 767 }
763 } 768 }
764 769
765 public void handleParcelAccessUpdateRequest(LLUUID agentID, LLUUID sessionID,uint flags, int landLocalID, List<libsecondlife.ParcelManager.ParcelAccessEntry> entries, IClientAPI remote_client) 770 public void handleParcelAccessUpdateRequest(LLUUID agentID, LLUUID sessionID, uint flags, int landLocalID,
771 List<ParcelManager.ParcelAccessEntry> entries,
772 IClientAPI remote_client)
766 { 773 {
767 if (landList.ContainsKey(landLocalID)) 774 if (landList.ContainsKey(landLocalID))
768 { 775 {
@@ -849,4 +856,4 @@ namespace OpenSim.Region.Environment.LandManagement
849 } 856 }
850 857
851 #endregion 858 #endregion
852} 859} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/ModuleLoader.cs b/OpenSim/Region/Environment/ModuleLoader.cs
index b1ab330..fcf0f72 100644
--- a/OpenSim/Region/Environment/ModuleLoader.cs
+++ b/OpenSim/Region/Environment/ModuleLoader.cs
@@ -220,7 +220,7 @@ namespace OpenSim.Region.Environment
220 { 220 {
221 if (pluginType.GetInterface("IRegionModule") != null) 221 if (pluginType.GetInterface("IRegionModule") != null)
222 { 222 {
223 modules.Add((IRegionModule)Activator.CreateInstance(pluginType)); 223 modules.Add((IRegionModule) Activator.CreateInstance(pluginType));
224 } 224 }
225 } 225 }
226 } 226 }
diff --git a/OpenSim/Region/Environment/Modules/AvatarFactoryModule.cs b/OpenSim/Region/Environment/Modules/AvatarFactoryModule.cs
index 0b95aee..c31a79b 100644
--- a/OpenSim/Region/Environment/Modules/AvatarFactoryModule.cs
+++ b/OpenSim/Region/Environment/Modules/AvatarFactoryModule.cs
@@ -27,11 +27,12 @@
27*/ 27*/
28 28
29using System; 29using System;
30using libsecondlife;
31using System.Collections.Generic; 30using System.Collections.Generic;
31using libsecondlife;
32using Nini.Config; 32using Nini.Config;
33using OpenSim.Framework; 33using OpenSim.Framework;
34using OpenSim.Framework.Communications.Cache; 34using OpenSim.Framework.Communications.Cache;
35using OpenSim.Framework.Console;
35using OpenSim.Region.Environment.Interfaces; 36using OpenSim.Region.Environment.Interfaces;
36using OpenSim.Region.Environment.Scenes; 37using OpenSim.Region.Environment.Scenes;
37 38
@@ -59,9 +60,9 @@ namespace OpenSim.Region.Environment.Modules
59 { 60 {
60 m_avatarsAppearance[avatarId] = appearance; 61 m_avatarsAppearance[avatarId] = appearance;
61 } 62 }
62 catch (System.NullReferenceException) 63 catch (NullReferenceException)
63 { 64 {
64 OpenSim.Framework.Console.MainLog.Instance.Error("AVATAR", "Unable to load appearance for uninitialized avatar"); 65 MainLog.Instance.Error("AVATAR", "Unable to load appearance for uninitialized avatar");
65 } 66 }
66 return true; 67 return true;
67 } 68 }
@@ -98,17 +99,17 @@ namespace OpenSim.Region.Environment.Modules
98 99
99 public void NewClient(IClientAPI client) 100 public void NewClient(IClientAPI client)
100 { 101 {
101 client.OnAvatarNowWearing += AvatarIsWearing; 102 client.OnAvatarNowWearing += AvatarIsWearing;
102 } 103 }
103 104
104 public void RemoveClient(IClientAPI client) 105 public void RemoveClient(IClientAPI client)
105 { 106 {
106 // client.OnAvatarNowWearing -= AvatarIsWearing; 107 // client.OnAvatarNowWearing -= AvatarIsWearing;
107 } 108 }
108 109
109 public void AvatarIsWearing(Object sender, AvatarWearingArgs e) 110 public void AvatarIsWearing(Object sender, AvatarWearingArgs e)
110 { 111 {
111 IClientAPI clientView = (IClientAPI)sender; 112 IClientAPI clientView = (IClientAPI) sender;
112 CachedUserInfo profile = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(clientView.AgentId); 113 CachedUserInfo profile = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(clientView.AgentId);
113 if (profile != null) 114 if (profile != null)
114 { 115 {
@@ -127,7 +128,7 @@ namespace OpenSim.Region.Environment.Modules
127 { 128 {
128 assetId = baseItem.assetID; 129 assetId = baseItem.assetID;
129 //temporary dictionary storage. This should be storing to a database 130 //temporary dictionary storage. This should be storing to a database
130 131
131 if (m_avatarsAppearance.ContainsKey(clientView.AgentId)) 132 if (m_avatarsAppearance.ContainsKey(clientView.AgentId))
132 { 133 {
133 AvatarAppearance avatAppearance = m_avatarsAppearance[clientView.AgentId]; 134 AvatarAppearance avatAppearance = m_avatarsAppearance[clientView.AgentId];
@@ -158,4 +159,4 @@ namespace OpenSim.Region.Environment.Modules
158 return visualParams; 159 return visualParams;
159 } 160 }
160 } 161 }
161} 162} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Modules/ChatModule.cs b/OpenSim/Region/Environment/Modules/ChatModule.cs
index 069eb3f..d6df978 100644
--- a/OpenSim/Region/Environment/Modules/ChatModule.cs
+++ b/OpenSim/Region/Environment/Modules/ChatModule.cs
@@ -176,10 +176,10 @@ namespace OpenSim.Region.Environment.Modules
176 foreach (Scene s in m_scenes) 176 foreach (Scene s in m_scenes)
177 { 177 {
178 s.ForEachScenePresence(delegate(ScenePresence presence) 178 s.ForEachScenePresence(delegate(ScenePresence presence)
179 { 179 {
180 TrySendChatMessage(presence, fromPos, regionPos, 180 TrySendChatMessage(presence, fromPos, regionPos,
181 fromAgentID, fromName, e.Type, message); 181 fromAgentID, fromName, e.Type, message);
182 }); 182 });
183 } 183 }
184 } 184 }
185 } 185 }
@@ -373,4 +373,4 @@ namespace OpenSim.Region.Environment.Modules
373 m_tcp.Close(); 373 m_tcp.Close();
374 } 374 }
375 } 375 }
376} 376} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Modules/ScriptsHttpRequests.cs b/OpenSim/Region/Environment/Modules/ScriptsHttpRequests.cs
index d47004b..f8798dc 100644
--- a/OpenSim/Region/Environment/Modules/ScriptsHttpRequests.cs
+++ b/OpenSim/Region/Environment/Modules/ScriptsHttpRequests.cs
@@ -27,18 +27,15 @@
27*/ 27*/
28 28
29using System; 29using System;
30using System.Collections.Generic;
30using System.IO; 31using System.IO;
31using System.Net; 32using System.Net;
32using System.Text; 33using System.Text;
33using OpenSim.Region.Environment.Interfaces;
34using OpenSim.Region.Environment.Scenes;
35using System.Collections;
36using System.Collections.Generic;
37using System.Threading; 34using System.Threading;
38using libsecondlife; 35using libsecondlife;
39using Nini.Config; 36using Nini.Config;
40using Nwc.XmlRpc; 37using OpenSim.Region.Environment.Interfaces;
41using OpenSim.Framework.Servers; 38using OpenSim.Region.Environment.Scenes;
42 39
43/***************************************************** 40/*****************************************************
44 * 41 *
@@ -85,120 +82,120 @@ using OpenSim.Framework.Servers;
85 82
86namespace OpenSim.Region.Environment.Modules 83namespace OpenSim.Region.Environment.Modules
87{ 84{
88 public class ScriptHTTPRequests : IRegionModule, IHttpRequests 85 public class ScriptHTTPRequests : IRegionModule, IHttpRequests
89 { 86 {
90 private Scene m_scene; 87 private Scene m_scene;
91 private Queue<HttpRequestClass> rpcQueue = new Queue<HttpRequestClass>(); 88 private Queue<HttpRequestClass> rpcQueue = new Queue<HttpRequestClass>();
92 private object HttpListLock = new object(); 89 private object HttpListLock = new object();
93 private string m_name = "HttpScriptRequests"; 90 private string m_name = "HttpScriptRequests";
94 private int httpTimeout = 300; 91 private int httpTimeout = 300;
95 92
96 // <request id, HttpRequestClass> 93 // <request id, HttpRequestClass>
97 private Dictionary<LLUUID, HttpRequestClass> m_pendingRequests; 94 private Dictionary<LLUUID, HttpRequestClass> m_pendingRequests;
98 95
99 public ScriptHTTPRequests() 96 public ScriptHTTPRequests()
100 { 97 {
101 } 98 }
102 99
103 public void Initialise(Scene scene, IConfigSource config) 100 public void Initialise(Scene scene, IConfigSource config)
104 { 101 {
105 m_scene = scene; 102 m_scene = scene;
106 103
107 m_scene.RegisterModuleInterface<IHttpRequests>(this); 104 m_scene.RegisterModuleInterface<IHttpRequests>(this);
108 105
109 m_pendingRequests = new Dictionary<LLUUID, HttpRequestClass>(); 106 m_pendingRequests = new Dictionary<LLUUID, HttpRequestClass>();
110 } 107 }
111 108
112 public void PostInitialise() 109 public void PostInitialise()
113 { 110 {
114 } 111 }
115 112
116 public void Close() 113 public void Close()
117 { 114 {
118 } 115 }
119 116
120 public string Name 117 public string Name
121 { 118 {
122 get { return m_name; } 119 get { return m_name; }
123 } 120 }
124 121
125 public bool IsSharedModule 122 public bool IsSharedModule
126 { 123 {
127 get { return true; } 124 get { return true; }
128 } 125 }
129 126
130 public LLUUID MakeHttpRequest(string url, string parameters, string body) { 127 public LLUUID MakeHttpRequest(string url, string parameters, string body)
131 return LLUUID.Zero; 128 {
132 } 129 return LLUUID.Zero;
133 130 }
134 public LLUUID StartHttpRequest(uint localID, LLUUID itemID, string url, List<string> parameters, string body) 131
135 { 132 public LLUUID StartHttpRequest(uint localID, LLUUID itemID, string url, List<string> parameters, string body)
136 LLUUID reqID = LLUUID.Random(); 133 {
137 HttpRequestClass htc = new HttpRequestClass(); 134 LLUUID reqID = LLUUID.Random();
138 135 HttpRequestClass htc = new HttpRequestClass();
139 // Parameters are expected in {key, value, ... , key, value} 136
140 if( parameters != null ) 137 // Parameters are expected in {key, value, ... , key, value}
141 { 138 if (parameters != null)
142 string[] parms = parameters.ToArray(); 139 {
143 for (int i = 0; i < parms.Length / 2; i += 2) 140 string[] parms = parameters.ToArray();
141 for (int i = 0; i < parms.Length/2; i += 2)
144 { 142 {
145 switch( Int32.Parse(parms[i]) ) 143 switch (Int32.Parse(parms[i]))
146 { 144 {
147 case HttpRequestClass.HTTP_METHOD: 145 case HttpRequestClass.HTTP_METHOD:
148 146
149 htc.httpMethod = parms[i + 1]; 147 htc.httpMethod = parms[i + 1];
150 break; 148 break;
151 149
152 case HttpRequestClass.HTTP_MIMETYPE: 150 case HttpRequestClass.HTTP_MIMETYPE:
153 151
154 htc.httpMIMEType = parms[i + 1]; 152 htc.httpMIMEType = parms[i + 1];
155 break; 153 break;
156 154
157 case HttpRequestClass.HTTP_BODY_MAXLENGTH: 155 case HttpRequestClass.HTTP_BODY_MAXLENGTH:
158 156
159 // TODO implement me 157 // TODO implement me
160 break; 158 break;
161 159
162 case HttpRequestClass.HTTP_VERIFY_CERT: 160 case HttpRequestClass.HTTP_VERIFY_CERT:
163 161
164 // TODO implement me 162 // TODO implement me
165 break; 163 break;
166 } 164 }
167 } 165 }
168 } 166 }
169 167
170 htc.localID = localID; 168 htc.localID = localID;
171 htc.itemID = itemID; 169 htc.itemID = itemID;
172 htc.url = url; 170 htc.url = url;
173 htc.reqID = reqID; 171 htc.reqID = reqID;
174 htc.httpTimeout = httpTimeout; 172 htc.httpTimeout = httpTimeout;
175 htc.outbound_body = body; 173 htc.outbound_body = body;
176 174
177 lock (HttpListLock) 175 lock (HttpListLock)
178 { 176 {
179 m_pendingRequests.Add(reqID, htc); 177 m_pendingRequests.Add(reqID, htc);
180 } 178 }
181 179
182 htc.process(); 180 htc.process();
183 181
184 return reqID; 182 return reqID;
185 } 183 }
186 184
187 public void StopHttpRequest(uint m_localID, LLUUID m_itemID) 185 public void StopHttpRequest(uint m_localID, LLUUID m_itemID)
188 { 186 {
189 lock (HttpListLock) 187 lock (HttpListLock)
190 { 188 {
191 189 HttpRequestClass tmpReq;
192 HttpRequestClass tmpReq; 190 if (m_pendingRequests.TryGetValue(m_itemID, out tmpReq))
193 if (m_pendingRequests.TryGetValue(m_itemID, out tmpReq)) 191 {
194 { 192 tmpReq.Stop();
195 tmpReq.Stop(); 193 m_pendingRequests.Remove(m_itemID);
196 m_pendingRequests.Remove(m_itemID); 194 }
197 } 195 }
198 } 196 }
199 } 197
200 198 /*
201 /*
202 * TODO 199 * TODO
203 * Not sure how important ordering is is here - the next first 200 * Not sure how important ordering is is here - the next first
204 * one completed in the list is returned, based soley on its list 201 * one completed in the list is returned, based soley on its list
@@ -206,10 +203,11 @@ namespace OpenSim.Region.Environment.Modules
206 * finsihed. I thought about setting up a queue for this, but 203 * finsihed. I thought about setting up a queue for this, but
207 * it will need some refactoring and this works 'enough' right now 204 * it will need some refactoring and this works 'enough' right now
208 */ 205 */
209 public HttpRequestClass GetNextCompletedRequest() 206
210 { 207 public HttpRequestClass GetNextCompletedRequest()
211 lock (HttpListLock) 208 {
212 { 209 lock (HttpListLock)
210 {
213 foreach (LLUUID luid in m_pendingRequests.Keys) 211 foreach (LLUUID luid in m_pendingRequests.Keys)
214 { 212 {
215 HttpRequestClass tmpReq; 213 HttpRequestClass tmpReq;
@@ -225,18 +223,16 @@ namespace OpenSim.Region.Environment.Modules
225 } 223 }
226 } 224 }
227 return null; 225 return null;
228 } 226 }
229 227 }
230
231 }
232 228
233 // 229 //
234 // HTTP REAQUEST 230 // HTTP REAQUEST
235 // This class was originally in LSLLongCmdHandler 231 // This class was originally in LSLLongCmdHandler
236 // 232 //
237 // TODO: setter/getter methods, maybe pass some in 233 // TODO: setter/getter methods, maybe pass some in
238 // constructor 234 // constructor
239 // 235 //
240 236
241 public class HttpRequestClass 237 public class HttpRequestClass
242 { 238 {
@@ -280,9 +276,9 @@ namespace OpenSim.Region.Environment.Modules
280 * TODO: More work on the response codes. Right now 276 * TODO: More work on the response codes. Right now
281 * returning 200 for success or 499 for exception 277 * returning 200 for success or 499 for exception
282 */ 278 */
279
283 public void SendRequest() 280 public void SendRequest()
284 { 281 {
285
286 HttpWebResponse response = null; 282 HttpWebResponse response = null;
287 StringBuilder sb = new StringBuilder(); 283 StringBuilder sb = new StringBuilder();
288 byte[] buf = new byte[8192]; 284 byte[] buf = new byte[8192];
@@ -292,14 +288,14 @@ namespace OpenSim.Region.Environment.Modules
292 try 288 try
293 { 289 {
294 request = (HttpWebRequest) 290 request = (HttpWebRequest)
295 WebRequest.Create(url); 291 WebRequest.Create(url);
296 request.Method = httpMethod; 292 request.Method = httpMethod;
297 request.ContentType = httpMIMEType; 293 request.ContentType = httpMIMEType;
298 294
299 request.Timeout = httpTimeout; 295 request.Timeout = httpTimeout;
300 // execute the request 296 // execute the request
301 response = (HttpWebResponse) 297 response = (HttpWebResponse)
302 request.GetResponse(); 298 request.GetResponse();
303 299
304 Stream resStream = response.GetResponseStream(); 300 Stream resStream = response.GetResponseStream();
305 301
@@ -317,11 +313,9 @@ namespace OpenSim.Region.Environment.Modules
317 // continue building the string 313 // continue building the string
318 sb.Append(tempString); 314 sb.Append(tempString);
319 } 315 }
320 } 316 } while (count > 0); // any more data to read?
321 while (count > 0); // any more data to read?
322 317
323 response_body = sb.ToString(); 318 response_body = sb.ToString();
324
325 } 319 }
326 catch (Exception e) 320 catch (Exception e)
327 { 321 {
@@ -333,7 +327,6 @@ namespace OpenSim.Region.Environment.Modules
333 327
334 status = 200; 328 status = 200;
335 finished = true; 329 finished = true;
336
337 } 330 }
338 331
339 public void Stop() 332 public void Stop()
@@ -342,8 +335,9 @@ namespace OpenSim.Region.Environment.Modules
342 { 335 {
343 httpThread.Abort(); 336 httpThread.Abort();
344 } 337 }
345 catch (Exception) { } 338 catch (Exception)
339 {
340 }
346 } 341 }
347 } 342 }
348 343} \ No newline at end of file
349 } \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Modules/SunModule.cs b/OpenSim/Region/Environment/Modules/SunModule.cs
index 233c83c..bd6cd63 100644
--- a/OpenSim/Region/Environment/Modules/SunModule.cs
+++ b/OpenSim/Region/Environment/Modules/SunModule.cs
@@ -28,13 +28,12 @@
28 28
29using System; 29using System;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using libsecondlife;
31using Nini.Config; 32using Nini.Config;
32using OpenSim.Region.Environment.Interfaces;
33using OpenSim.Region.Environment.Scenes;
34using OpenSim.Framework; 33using OpenSim.Framework;
35using OpenSim.Framework.Console; 34using OpenSim.Framework.Console;
36using libsecondlife; 35using OpenSim.Region.Environment.Interfaces;
37 36using OpenSim.Region.Environment.Scenes;
38 37
39namespace OpenSim.Region.Environment.Modules 38namespace OpenSim.Region.Environment.Modules
40{ 39{
@@ -55,17 +54,20 @@ namespace OpenSim.Region.Environment.Modules
55 { 54 {
56 m_start = DateTime.Now.Ticks; 55 m_start = DateTime.Now.Ticks;
57 m_frame = 0; 56 m_frame = 0;
58 57
59 // Just in case they don't have the stanzas 58 // Just in case they don't have the stanzas
60 try { 59 try
60 {
61 m_day_length = config.Configs["Sun"].GetDouble("day_length", m_real_day); 61 m_day_length = config.Configs["Sun"].GetDouble("day_length", m_real_day);
62 m_frame_mod = config.Configs["Sun"].GetInt("frame_rate", m_default_frame); 62 m_frame_mod = config.Configs["Sun"].GetInt("frame_rate", m_default_frame);
63 } catch (Exception) { 63 }
64 catch (Exception)
65 {
64 m_day_length = m_real_day; 66 m_day_length = m_real_day;
65 m_frame_mod = m_default_frame; 67 m_frame_mod = m_default_frame;
66 } 68 }
67 69
68 m_dilation = (int)(m_real_day / m_day_length); 70 m_dilation = (int) (m_real_day/m_day_length);
69 m_scene = scene; 71 m_scene = scene;
70 m_log = MainLog.Instance; 72 m_log = MainLog.Instance;
71 scene.EventManager.OnFrame += SunUpdate; 73 scene.EventManager.OnFrame += SunUpdate;
@@ -94,10 +96,11 @@ namespace OpenSim.Region.Environment.Modules
94 { 96 {
95 client.SendSunPos(SunPos(HourOfTheDay()), new LLVector3(0, 0.0f, 10.0f)); 97 client.SendSunPos(SunPos(HourOfTheDay()), new LLVector3(0, 0.0f, 10.0f));
96 } 98 }
97 99
98 public void SunUpdate() 100 public void SunUpdate()
99 { 101 {
100 if (m_frame < m_frame_mod) { 102 if (m_frame < m_frame_mod)
103 {
101 m_frame++; 104 m_frame++;
102 return; 105 return;
103 } 106 }
@@ -115,20 +118,20 @@ namespace OpenSim.Region.Environment.Modules
115 // time when the simulator starts, then run time forward 118 // time when the simulator starts, then run time forward
116 // faster based on time dilation factor. This means that 119 // faster based on time dilation factor. This means that
117 // ticks don't get out of hand 120 // ticks don't get out of hand
118 private double HourOfTheDay() 121 private double HourOfTheDay()
119 { 122 {
120 long m_addticks = (DateTime.Now.Ticks - m_start) * m_dilation; 123 long m_addticks = (DateTime.Now.Ticks - m_start)*m_dilation;
121 DateTime dt = new DateTime(m_start + m_addticks); 124 DateTime dt = new DateTime(m_start + m_addticks);
122 return (double)dt.Hour + ((double)dt.Minute / 60.0); 125 return (double) dt.Hour + ((double) dt.Minute/60.0);
123 } 126 }
124 127
125 private LLVector3 SunPos(double hour) 128 private LLVector3 SunPos(double hour)
126 { 129 {
127 // now we have our radian position 130 // now we have our radian position
128 double rad = (hour / m_real_day) * 2 * Math.PI - (Math.PI / 2.0); 131 double rad = (hour/m_real_day)*2*Math.PI - (Math.PI/2.0);
129 double z = Math.Sin(rad); 132 double z = Math.Sin(rad);
130 double x = Math.Cos(rad); 133 double x = Math.Cos(rad);
131 return new LLVector3((float)x, 0f, (float)z); 134 return new LLVector3((float) x, 0f, (float) z);
132 } 135 }
133 136
134 // TODO: clear this out. This is here so that I remember to 137 // TODO: clear this out. This is here so that I remember to
diff --git a/OpenSim/Region/Environment/Modules/TextureDownloadModule.cs b/OpenSim/Region/Environment/Modules/TextureDownloadModule.cs
index 0adace1..813be8d 100644
--- a/OpenSim/Region/Environment/Modules/TextureDownloadModule.cs
+++ b/OpenSim/Region/Environment/Modules/TextureDownloadModule.cs
@@ -32,6 +32,7 @@ using libsecondlife;
32using libsecondlife.Packets; 32using libsecondlife.Packets;
33using Nini.Config; 33using Nini.Config;
34using OpenSim.Framework; 34using OpenSim.Framework;
35using OpenSim.Framework.Console;
35using OpenSim.Region.Environment.Interfaces; 36using OpenSim.Region.Environment.Interfaces;
36using OpenSim.Region.Environment.Scenes; 37using OpenSim.Region.Environment.Scenes;
37 38
@@ -48,7 +49,8 @@ namespace OpenSim.Region.Environment.Modules
48 49
49 private BlockingQueue<TextureSender> QueueSenders = new BlockingQueue<TextureSender>(); 50 private BlockingQueue<TextureSender> QueueSenders = new BlockingQueue<TextureSender>();
50 51
51 private Dictionary<LLUUID, UserTextureDownloadService> m_userTextureServices = new Dictionary<LLUUID, UserTextureDownloadService>(); 52 private Dictionary<LLUUID, UserTextureDownloadService> m_userTextureServices =
53 new Dictionary<LLUUID, UserTextureDownloadService>();
52 54
53 private Thread m_thread; 55 private Thread m_thread;
54 56
@@ -72,7 +74,6 @@ namespace OpenSim.Region.Environment.Modules
72 m_scene = scene; 74 m_scene = scene;
73 m_scene.EventManager.OnNewClient += NewClient; 75 m_scene.EventManager.OnNewClient += NewClient;
74 } 76 }
75
76 } 77 }
77 78
78 public void PostInitialise() 79 public void PostInitialise()
@@ -115,7 +116,7 @@ namespace OpenSim.Region.Environment.Modules
115 116
116 public void TextureRequest(Object sender, TextureRequestArgs e) 117 public void TextureRequest(Object sender, TextureRequestArgs e)
117 { 118 {
118 IClientAPI client = (IClientAPI)sender; 119 IClientAPI client = (IClientAPI) sender;
119 UserTextureDownloadService textureService; 120 UserTextureDownloadService textureService;
120 if (TryGetUserTextureService(client.AgentId, out textureService)) 121 if (TryGetUserTextureService(client.AgentId, out textureService))
121 { 122 {
@@ -175,7 +176,8 @@ namespace OpenSim.Region.Environment.Modules
175 { 176 {
176 if (!m_textureSenders.ContainsKey(e.RequestedAssetID)) 177 if (!m_textureSenders.ContainsKey(e.RequestedAssetID))
177 { 178 {
178 TextureSender requestHandler = new TextureSender(client, e.RequestedAssetID, e.DiscardLevel, e.PacketNumber); 179 TextureSender requestHandler =
180 new TextureSender(client, e.RequestedAssetID, e.DiscardLevel, e.PacketNumber);
179 m_textureSenders.Add(e.RequestedAssetID, requestHandler); 181 m_textureSenders.Add(e.RequestedAssetID, requestHandler);
180 m_scene.AssetCache.GetAsset(e.RequestedAssetID, TextureCallback); 182 m_scene.AssetCache.GetAsset(e.RequestedAssetID, TextureCallback);
181 } 183 }
@@ -183,7 +185,8 @@ namespace OpenSim.Region.Environment.Modules
183 { 185 {
184 m_textureSenders[e.RequestedAssetID].UpdateRequest(e.DiscardLevel, e.PacketNumber); 186 m_textureSenders[e.RequestedAssetID].UpdateRequest(e.DiscardLevel, e.PacketNumber);
185 m_textureSenders[e.RequestedAssetID].counter = 0; 187 m_textureSenders[e.RequestedAssetID].counter = 0;
186 if ((m_textureSenders[e.RequestedAssetID].ImageLoaded) && (m_textureSenders[e.RequestedAssetID].Sending ==false)) 188 if ((m_textureSenders[e.RequestedAssetID].ImageLoaded) &&
189 (m_textureSenders[e.RequestedAssetID].Sending == false))
187 { 190 {
188 m_textureSenders[e.RequestedAssetID].Sending = true; 191 m_textureSenders[e.RequestedAssetID].Sending = true;
189 m_sharedSendersQueue.Enqueue(m_textureSenders[e.RequestedAssetID]); 192 m_sharedSendersQueue.Enqueue(m_textureSenders[e.RequestedAssetID]);
@@ -256,7 +259,7 @@ namespace OpenSim.Region.Environment.Modules
256 { 259 {
257 m_asset = asset; 260 m_asset = asset;
258 NumPackets = CalculateNumPackets(asset.Data.Length); 261 NumPackets = CalculateNumPackets(asset.Data.Length);
259 PacketCounter = (int)StartPacketNumber; 262 PacketCounter = (int) StartPacketNumber;
260 ImageLoaded = true; 263 ImageLoaded = true;
261 } 264 }
262 265
@@ -264,14 +267,15 @@ namespace OpenSim.Region.Environment.Modules
264 { 267 {
265 RequestedDiscardLevel = discardLevel; 268 RequestedDiscardLevel = discardLevel;
266 StartPacketNumber = packetNumber; 269 StartPacketNumber = packetNumber;
267 PacketCounter = (int)StartPacketNumber; 270 PacketCounter = (int) StartPacketNumber;
268 } 271 }
269 272
270 public bool SendTexturePacket() 273 public bool SendTexturePacket()
271 { 274 {
272 SendPacket(); 275 SendPacket();
273 counter++; 276 counter++;
274 if ((NumPackets == 0) || (RequestedDiscardLevel == -1) || (PacketCounter > NumPackets) || ((RequestedDiscardLevel > 0) && (counter > 50 + (NumPackets / (RequestedDiscardLevel + 1)))) ) 277 if ((NumPackets == 0) || (RequestedDiscardLevel == -1) || (PacketCounter > NumPackets) ||
278 ((RequestedDiscardLevel > 0) && (counter > 50 + (NumPackets/(RequestedDiscardLevel + 1)))))
275 { 279 {
276 return true; 280 return true;
277 } 281 }
@@ -290,7 +294,7 @@ namespace OpenSim.Region.Environment.Modules
290 im.Header.Reliable = false; 294 im.Header.Reliable = false;
291 im.ImageID.Packets = 1; 295 im.ImageID.Packets = 1;
292 im.ImageID.ID = m_asset.FullID; 296 im.ImageID.ID = m_asset.FullID;
293 im.ImageID.Size = (uint)m_asset.Data.Length; 297 im.ImageID.Size = (uint) m_asset.Data.Length;
294 im.ImageData.Data = m_asset.Data; 298 im.ImageData.Data = m_asset.Data;
295 im.ImageID.Codec = 2; 299 im.ImageID.Codec = 2;
296 RequestUser.OutPacket(im, ThrottleOutPacketType.Texture); 300 RequestUser.OutPacket(im, ThrottleOutPacketType.Texture);
@@ -300,9 +304,9 @@ namespace OpenSim.Region.Environment.Modules
300 { 304 {
301 ImageDataPacket im = new ImageDataPacket(); 305 ImageDataPacket im = new ImageDataPacket();
302 im.Header.Reliable = false; 306 im.Header.Reliable = false;
303 im.ImageID.Packets = (ushort)(NumPackets); 307 im.ImageID.Packets = (ushort) (NumPackets);
304 im.ImageID.ID = m_asset.FullID; 308 im.ImageID.ID = m_asset.FullID;
305 im.ImageID.Size = (uint)m_asset.Data.Length; 309 im.ImageID.Size = (uint) m_asset.Data.Length;
306 im.ImageData.Data = new byte[600]; 310 im.ImageData.Data = new byte[600];
307 Array.Copy(m_asset.Data, 0, im.ImageData.Data, 0, 600); 311 Array.Copy(m_asset.Data, 0, im.ImageData.Data, 0, 600);
308 im.ImageID.Codec = 2; 312 im.ImageID.Codec = 2;
@@ -314,18 +318,20 @@ namespace OpenSim.Region.Environment.Modules
314 { 318 {
315 ImagePacketPacket im = new ImagePacketPacket(); 319 ImagePacketPacket im = new ImagePacketPacket();
316 im.Header.Reliable = false; 320 im.Header.Reliable = false;
317 im.ImageID.Packet = (ushort)(PacketCounter); 321 im.ImageID.Packet = (ushort) (PacketCounter);
318 im.ImageID.ID = m_asset.FullID; 322 im.ImageID.ID = m_asset.FullID;
319 int size = m_asset.Data.Length - 600 - (1000 * (PacketCounter - 1)); 323 int size = m_asset.Data.Length - 600 - (1000*(PacketCounter - 1));
320 if (size > 1000) size = 1000; 324 if (size > 1000) size = 1000;
321 im.ImageData.Data = new byte[size]; 325 im.ImageData.Data = new byte[size];
322 try 326 try
323 { 327 {
324 Array.Copy(m_asset.Data, 600 + (1000 * (PacketCounter - 1)), im.ImageData.Data, 0, size); 328 Array.Copy(m_asset.Data, 600 + (1000*(PacketCounter - 1)), im.ImageData.Data, 0, size);
325 } 329 }
326 catch (System.ArgumentOutOfRangeException) 330 catch (ArgumentOutOfRangeException)
327 { 331 {
328 OpenSim.Framework.Console.MainLog.Instance.Warn("TEXTURE", "Unable to separate texture into multiple packets: Array bounds failure on asset:" + m_asset.FullID.ToString() + "- TextureDownloadModule.cs. line:328"); 332 MainLog.Instance.Warn("TEXTURE",
333 "Unable to separate texture into multiple packets: Array bounds failure on asset:" +
334 m_asset.FullID.ToString() + "- TextureDownloadModule.cs. line:328");
329 return; 335 return;
330 } 336 }
331 RequestUser.OutPacket(im, ThrottleOutPacketType.Texture); 337 RequestUser.OutPacket(im, ThrottleOutPacketType.Texture);
@@ -342,14 +348,12 @@ namespace OpenSim.Region.Environment.Modules
342 { 348 {
343 //over 600 bytes so split up file 349 //over 600 bytes so split up file
344 int restData = (length - 600); 350 int restData = (length - 600);
345 int restPackets = ((restData + 999) / 1000); 351 int restPackets = ((restData + 999)/1000);
346 numPackets = restPackets; 352 numPackets = restPackets;
347 } 353 }
348 354
349 return numPackets; 355 return numPackets;
350 } 356 }
351 } 357 }
352
353
354 } 358 }
355} \ No newline at end of file 359} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Modules/WorldCommModule.cs b/OpenSim/Region/Environment/Modules/WorldCommModule.cs
index 0dad998..6b9ae46 100644
--- a/OpenSim/Region/Environment/Modules/WorldCommModule.cs
+++ b/OpenSim/Region/Environment/Modules/WorldCommModule.cs
@@ -135,7 +135,7 @@ namespace OpenSim.Region.Environment.Modules
135 { 135 {
136 m_listenerManager.Remove(handle); 136 m_listenerManager.Remove(handle);
137 } 137 }
138 138
139 // This method scans nearby objects and determines if they are listeners, 139 // This method scans nearby objects and determines if they are listeners,
140 // and if so if this message fits the filter. If it does, then 140 // and if so if this message fits the filter. If it does, then
141 // enqueue the message for delivery to the objects listen event handler. 141 // enqueue the message for delivery to the objects listen event handler.
@@ -490,4 +490,4 @@ namespace OpenSim.Region.Environment.Modules
490 return m_id; 490 return m_id;
491 } 491 }
492 } 492 }
493} 493} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Modules/XMLRPCModule.cs b/OpenSim/Region/Environment/Modules/XMLRPCModule.cs
index f13b2bb..481ba3f 100644
--- a/OpenSim/Region/Environment/Modules/XMLRPCModule.cs
+++ b/OpenSim/Region/Environment/Modules/XMLRPCModule.cs
@@ -33,10 +33,10 @@ using System.Threading;
33using libsecondlife; 33using libsecondlife;
34using Nini.Config; 34using Nini.Config;
35using Nwc.XmlRpc; 35using Nwc.XmlRpc;
36using OpenSim.Framework.Console;
36using OpenSim.Framework.Servers; 37using OpenSim.Framework.Servers;
37using OpenSim.Region.Environment.Interfaces; 38using OpenSim.Region.Environment.Interfaces;
38using OpenSim.Region.Environment.Scenes; 39using OpenSim.Region.Environment.Scenes;
39using OpenSim.Framework.Console;
40 40
41/***************************************************** 41/*****************************************************
42 * 42 *
@@ -116,15 +116,16 @@ namespace OpenSim.Region.Environment.Modules
116 116
117 public void PostInitialise() 117 public void PostInitialise()
118 { 118 {
119 if ( IsEnabled() ) 119 if (IsEnabled())
120 { 120 {
121 m_openChannels = new Dictionary<LLUUID, RPCChannelInfo>(); 121 m_openChannels = new Dictionary<LLUUID, RPCChannelInfo>();
122 m_pendingResponse = new Dictionary<LLUUID, RPCRequestInfo>(); 122 m_pendingResponse = new Dictionary<LLUUID, RPCRequestInfo>();
123 123
124 // Start http server 124 // Start http server
125 // Attach xmlrpc handlers 125 // Attach xmlrpc handlers
126 m_log.Verbose("REMOTE_DATA", "Starting XMLRPC Server on port " + m_remoteDataPort + " for llRemoteData commands."); 126 m_log.Verbose("REMOTE_DATA",
127 BaseHttpServer httpServer = new BaseHttpServer((uint)m_remoteDataPort); 127 "Starting XMLRPC Server on port " + m_remoteDataPort + " for llRemoteData commands.");
128 BaseHttpServer httpServer = new BaseHttpServer((uint) m_remoteDataPort);
128 httpServer.AddXmlRPCHandler("llRemoteData", XmlRpcRemoteData); 129 httpServer.AddXmlRPCHandler("llRemoteData", XmlRpcRemoteData);
129 httpServer.Start(); 130 httpServer.Start();
130 } 131 }
diff --git a/OpenSim/Region/Environment/PermissionManager.cs b/OpenSim/Region/Environment/PermissionManager.cs
index 53fa08a..76601ec 100644
--- a/OpenSim/Region/Environment/PermissionManager.cs
+++ b/OpenSim/Region/Environment/PermissionManager.cs
@@ -35,13 +35,13 @@ namespace OpenSim.Region.Environment
35 public class PermissionManager 35 public class PermissionManager
36 { 36 {
37 protected Scene m_scene; 37 protected Scene m_scene;
38 38
39 // These are here for testing. They will be taken out 39 // These are here for testing. They will be taken out
40 private uint PERM_ALL = (uint)2147483647; 40 private uint PERM_ALL = (uint) 2147483647;
41 private uint PERM_COPY = (uint)32768; 41 private uint PERM_COPY = (uint) 32768;
42 private uint PERM_MODIFY = (uint)16384; 42 private uint PERM_MODIFY = (uint) 16384;
43 private uint PERM_MOVE = (uint)524288; 43 private uint PERM_MOVE = (uint) 524288;
44 private uint PERM_TRANS = (uint)8192; 44 private uint PERM_TRANS = (uint) 8192;
45 // Bypasses the permissions engine (always returns OK) 45 // Bypasses the permissions engine (always returns OK)
46 // disable in any production environment 46 // disable in any production environment
47 // TODO: Change this to false when permissions are a desired default 47 // TODO: Change this to false when permissions are a desired default
@@ -109,10 +109,11 @@ namespace OpenSim.Region.Environment
109 109
110 string reason = "Insufficient permission"; 110 string reason = "Insufficient permission";
111 111
112 Land land = this.m_scene.LandManager.getLandObject(position.X, position.Y); 112 Land land = m_scene.LandManager.getLandObject(position.X, position.Y);
113 if (land == null) return false; 113 if (land == null) return false;
114 114
115 if ((land.landData.landFlags & ((int)Parcel.ParcelFlags.CreateObjects)) == (int)Parcel.ParcelFlags.CreateObjects) 115 if ((land.landData.landFlags & ((int) Parcel.ParcelFlags.CreateObjects)) ==
116 (int) Parcel.ParcelFlags.CreateObjects)
116 permission = true; 117 permission = true;
117 118
118 //TODO: check for group rights 119 //TODO: check for group rights
@@ -143,8 +144,6 @@ namespace OpenSim.Region.Environment
143 144
144 #region Object Permissions 145 #region Object Permissions
145 146
146
147
148 public virtual uint GenerateClientFlags(LLUUID user, LLUUID objID) 147 public virtual uint GenerateClientFlags(LLUUID user, LLUUID objID)
149 { 148 {
150 if (!m_scene.Entities.ContainsKey(objID)) 149 if (!m_scene.Entities.ContainsKey(objID))
@@ -158,7 +157,7 @@ namespace OpenSim.Region.Environment
158 return 0; 157 return 0;
159 } 158 }
160 159
161 SceneObjectGroup task = (SceneObjectGroup)m_scene.Entities[objID]; 160 SceneObjectGroup task = (SceneObjectGroup) m_scene.Entities[objID];
162 LLUUID taskOwner = null; 161 LLUUID taskOwner = null;
163 // Added this because at this point in time it wouldn't be wise for 162 // Added this because at this point in time it wouldn't be wise for
164 // the administrator object permissions to take effect. 163 // the administrator object permissions to take effect.
@@ -274,7 +273,7 @@ namespace OpenSim.Region.Environment
274 273
275 public virtual bool CanEditObjectPosition(LLUUID user, LLUUID obj) 274 public virtual bool CanEditObjectPosition(LLUUID user, LLUUID obj)
276 { 275 {
277 bool permission = GenericObjectPermission(user,obj); 276 bool permission = GenericObjectPermission(user, obj);
278 if (!permission) 277 if (!permission)
279 { 278 {
280 if (!m_scene.Entities.ContainsKey(obj)) 279 if (!m_scene.Entities.ContainsKey(obj))
@@ -288,7 +287,7 @@ namespace OpenSim.Region.Environment
288 return false; 287 return false;
289 } 288 }
290 289
291 SceneObjectGroup task = (SceneObjectGroup)m_scene.Entities[obj]; 290 SceneObjectGroup task = (SceneObjectGroup) m_scene.Entities[obj];
292 LLUUID taskOwner = null; 291 LLUUID taskOwner = null;
293 // Added this because at this point in time it wouldn't be wise for 292 // Added this because at this point in time it wouldn't be wise for
294 // the administrator object permissions to take effect. 293 // the administrator object permissions to take effect.
@@ -298,6 +297,7 @@ namespace OpenSim.Region.Environment
298 } 297 }
299 return permission; 298 return permission;
300 } 299 }
300
301 public virtual bool CanCopyObject(LLUUID user, LLUUID obj) 301 public virtual bool CanCopyObject(LLUUID user, LLUUID obj)
302 { 302 {
303 bool permission = GenericObjectPermission(user, obj); 303 bool permission = GenericObjectPermission(user, obj);
@@ -314,7 +314,7 @@ namespace OpenSim.Region.Environment
314 return false; 314 return false;
315 } 315 }
316 316
317 SceneObjectGroup task = (SceneObjectGroup)m_scene.Entities[obj]; 317 SceneObjectGroup task = (SceneObjectGroup) m_scene.Entities[obj];
318 LLUUID taskOwner = null; 318 LLUUID taskOwner = null;
319 // Added this because at this point in time it wouldn't be wise for 319 // Added this because at this point in time it wouldn't be wise for
320 // the administrator object permissions to take effect. 320 // the administrator object permissions to take effect.
@@ -324,6 +324,7 @@ namespace OpenSim.Region.Environment
324 } 324 }
325 return permission; 325 return permission;
326 } 326 }
327
327 public virtual bool CanReturnObject(LLUUID user, LLUUID obj) 328 public virtual bool CanReturnObject(LLUUID user, LLUUID obj)
328 { 329 {
329 return GenericObjectPermission(user, obj); 330 return GenericObjectPermission(user, obj);
@@ -491,4 +492,4 @@ namespace OpenSim.Region.Environment
491 492
492 #endregion 493 #endregion
493 } 494 }
494} 495} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Scenes/AvatarAnimations.cs b/OpenSim/Region/Environment/Scenes/AvatarAnimations.cs
index cffe846..5466865 100644
--- a/OpenSim/Region/Environment/Scenes/AvatarAnimations.cs
+++ b/OpenSim/Region/Environment/Scenes/AvatarAnimations.cs
@@ -25,11 +25,11 @@
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28using System;
28using System.Collections.Generic; 29using System.Collections.Generic;
29using System.Xml; 30using System.Xml;
30using libsecondlife; 31using libsecondlife;
31using libsecondlife.Packets; 32using OpenSim.Framework.Console;
32
33 33
34namespace OpenSim.Region.Environment.Scenes 34namespace OpenSim.Region.Environment.Scenes
35{ 35{
@@ -37,11 +37,11 @@ namespace OpenSim.Region.Environment.Scenes
37 { 37 {
38 public Dictionary<string, LLUUID> AnimsLLUUID = new Dictionary<string, LLUUID>(); 38 public Dictionary<string, LLUUID> AnimsLLUUID = new Dictionary<string, LLUUID>();
39 public Dictionary<LLUUID, string> AnimsNames = new Dictionary<LLUUID, string>(); 39 public Dictionary<LLUUID, string> AnimsNames = new Dictionary<LLUUID, string>();
40 40
41 public AvatarAnimations() 41 public AvatarAnimations()
42 { 42 {
43 } 43 }
44 44
45 public void LoadAnims() 45 public void LoadAnims()
46 { 46 {
47 //MainLog.Instance.Verbose("CLIENT", "Loading avatar animations"); 47 //MainLog.Instance.Verbose("CLIENT", "Loading avatar animations");
@@ -57,7 +57,7 @@ namespace OpenSim.Region.Environment.Scenes
57 } 57 }
58 } 58 }
59 } 59 }
60 60
61 // MainLog.Instance.Verbose("CLIENT", "Loaded " + AnimsLLUUID.Count.ToString() + " animation(s)"); 61 // MainLog.Instance.Verbose("CLIENT", "Loaded " + AnimsLLUUID.Count.ToString() + " animation(s)");
62 62
63 try 63 try
@@ -68,11 +68,10 @@ namespace OpenSim.Region.Environment.Scenes
68 AnimsNames.Add(kp.Value, kp.Key); 68 AnimsNames.Add(kp.Value, kp.Key);
69 } 69 }
70 } 70 }
71 catch (System.InvalidOperationException) 71 catch (InvalidOperationException)
72 { 72 {
73 OpenSim.Framework.Console.MainLog.Instance.Warn("AVATAR", "Unable to load animation names for an Avatar"); 73 MainLog.Instance.Warn("AVATAR", "Unable to load animation names for an Avatar");
74 } 74 }
75
76 } 75 }
77 } 76 }
78} 77} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Scenes/AvatarAppearance.cs b/OpenSim/Region/Environment/Scenes/AvatarAppearance.cs
index 2ec4dbe..1583124 100644
--- a/OpenSim/Region/Environment/Scenes/AvatarAppearance.cs
+++ b/OpenSim/Region/Environment/Scenes/AvatarAppearance.cs
@@ -1,4 +1,4 @@
1/* 1/*
2* Copyright (c) Contributors, http://opensimulator.org/ 2* Copyright (c) Contributors, http://opensimulator.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
@@ -26,15 +26,9 @@
26* 26*
27*/ 27*/
28 28
29using System;
30using System.Collections.Generic;
31using System.Text;
32using libsecondlife; 29using libsecondlife;
33using libsecondlife.Packets; 30using libsecondlife.Packets;
34using OpenSim.Framework; 31using OpenSim.Framework;
35using OpenSim.Framework.Console;
36using OpenSim.Framework.Communications;
37using OpenSim.Region.Environment.Types;
38 32
39namespace OpenSim.Region.Environment.Scenes 33namespace OpenSim.Region.Environment.Scenes
40{ 34{
@@ -106,8 +100,8 @@ namespace OpenSim.Region.Environment.Scenes
106 // Teravus : Nifty AV Height Getting Maaaaagical formula. Oh how we love turning 0-255 into meters. 100 // Teravus : Nifty AV Height Getting Maaaaagical formula. Oh how we love turning 0-255 into meters.
107 // (float)m_visualParams[25] = Height 101 // (float)m_visualParams[25] = Height
108 // (float)m_visualParams[125] = LegLength 102 // (float)m_visualParams[125] = LegLength
109 m_avatarHeight = (1.50856f + (((float)m_visualParams[25] / 255.0f) * (2.525506f - 1.50856f))) 103 m_avatarHeight = (1.50856f + (((float) m_visualParams[25]/255.0f)*(2.525506f - 1.50856f)))
110 + (((float)m_visualParams[125] / 255.0f) / 1.5f); 104 + (((float) m_visualParams[125]/255.0f)/1.5f);
111 } 105 }
112 106
113 /// <summary> 107 /// <summary>
@@ -144,4 +138,4 @@ namespace OpenSim.Region.Environment.Scenes
144 return textu; 138 return textu;
145 } 139 }
146 } 140 }
147} 141} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Scenes/EntityBase.cs b/OpenSim/Region/Environment/Scenes/EntityBase.cs
index 4556c63..18799e4 100644
--- a/OpenSim/Region/Environment/Scenes/EntityBase.cs
+++ b/OpenSim/Region/Environment/Scenes/EntityBase.cs
@@ -145,7 +145,6 @@ namespace OpenSim.Region.Environment.Scenes
145 return (EntityBase) MemberwiseClone(); 145 return (EntityBase) MemberwiseClone();
146 } 146 }
147 147
148
149 148
150 public abstract void SetText(string text, Vector3 color, double alpha); 149 public abstract void SetText(string text, Vector3 color, double alpha);
151 } 150 }
@@ -161,15 +160,13 @@ namespace OpenSim.Region.Environment.Scenes
161 160
162 public EntityIntersection() 161 public EntityIntersection()
163 { 162 {
164
165
166 } 163 }
164
167 public EntityIntersection(Vector3 _ipoint, float _normal, bool _HitTF) 165 public EntityIntersection(Vector3 _ipoint, float _normal, bool _HitTF)
168 { 166 {
169 ipoint = _ipoint; 167 ipoint = _ipoint;
170 normal = _normal; 168 normal = _normal;
171 HitTF = _HitTF; 169 HitTF = _HitTF;
172 } 170 }
173
174 } 171 }
175} \ No newline at end of file 172} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Scenes/IScenePresenceBody.cs b/OpenSim/Region/Environment/Scenes/IScenePresenceBody.cs
index b9d1232..3e87981 100644
--- a/OpenSim/Region/Environment/Scenes/IScenePresenceBody.cs
+++ b/OpenSim/Region/Environment/Scenes/IScenePresenceBody.cs
@@ -27,7 +27,6 @@
27*/ 27*/
28 28
29using libsecondlife; 29using libsecondlife;
30using libsecondlife.Packets;
31using OpenSim.Framework; 30using OpenSim.Framework;
32 31
33namespace OpenSim.Region.Environment.Scenes 32namespace OpenSim.Region.Environment.Scenes
diff --git a/OpenSim/Region/Environment/Scenes/InnerScene.cs b/OpenSim/Region/Environment/Scenes/InnerScene.cs
index 0ca3405..4233853 100644
--- a/OpenSim/Region/Environment/Scenes/InnerScene.cs
+++ b/OpenSim/Region/Environment/Scenes/InnerScene.cs
@@ -1,4 +1,4 @@
1/* 1/*
2* Copyright (c) Contributors, http://opensimulator.org/ 2* Copyright (c) Contributors, http://opensimulator.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
@@ -28,7 +28,6 @@
28 28
29using System; 29using System;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Text;
32using Axiom.Math; 31using Axiom.Math;
33using libsecondlife; 32using libsecondlife;
34using libsecondlife.Packets; 33using libsecondlife.Packets;
@@ -44,10 +43,13 @@ namespace OpenSim.Region.Environment.Scenes
44 public class InnerScene 43 public class InnerScene
45 { 44 {
46 #region Events 45 #region Events
46
47 public event PhysicsCrash UnRecoverableError; 47 public event PhysicsCrash UnRecoverableError;
48
48 #endregion 49 #endregion
49 50
50 #region Fields 51 #region Fields
52
51 public Dictionary<LLUUID, ScenePresence> ScenePresences; 53 public Dictionary<LLUUID, ScenePresence> ScenePresences;
52 public Dictionary<LLUUID, SceneObjectGroup> SceneObjects; 54 public Dictionary<LLUUID, SceneObjectGroup> SceneObjects;
53 public Dictionary<LLUUID, EntityBase> Entities; 55 public Dictionary<LLUUID, EntityBase> Entities;
@@ -65,6 +67,7 @@ namespace OpenSim.Region.Environment.Scenes
65 internal object m_syncRoot = new object(); 67 internal object m_syncRoot = new object();
66 68
67 public PhysicsScene _PhyScene; 69 public PhysicsScene _PhyScene;
70
68 #endregion 71 #endregion
69 72
70 public InnerScene(Scene parent, RegionInfo regInfo, PermissionManager permissionsMngr) 73 public InnerScene(Scene parent, RegionInfo regInfo, PermissionManager permissionsMngr)
@@ -79,28 +82,27 @@ namespace OpenSim.Region.Environment.Scenes
79 82
80 public PhysicsScene PhysicsScene 83 public PhysicsScene PhysicsScene
81 { 84 {
82 get 85 get { return _PhyScene; }
83 { return _PhyScene; }
84 set 86 set
85 { 87 {
86 // If we're not doing the initial set 88 // If we're not doing the initial set
87 // Then we've got to remove the previous 89 // Then we've got to remove the previous
88 // event handler 90 // event handler
89 try 91 try
90 { 92 {
91 _PhyScene.OnPhysicsCrash -= physicsBasedCrash; 93 _PhyScene.OnPhysicsCrash -= physicsBasedCrash;
92 } 94 }
93 catch (System.NullReferenceException) 95 catch (NullReferenceException)
94 { 96 {
95 // This occurs when storing to _PhyScene the first time. 97 // This occurs when storing to _PhyScene the first time.
96 // Is there a better way to check the event handler before 98 // Is there a better way to check the event handler before
97 // getting here 99 // getting here
98 // This can be safely ignored. We're setting the first inital 100 // This can be safely ignored. We're setting the first inital
99 // there are no event handler's registered. 101 // there are no event handler's registered.
100 } 102 }
101 103
102 _PhyScene = value; 104 _PhyScene = value;
103 105
104 _PhyScene.OnPhysicsCrash += physicsBasedCrash; 106 _PhyScene.OnPhysicsCrash += physicsBasedCrash;
105 } 107 }
106 } 108 }
@@ -113,6 +115,7 @@ namespace OpenSim.Region.Environment.Scenes
113 } 115 }
114 116
115 #region Update Methods 117 #region Update Methods
118
116 internal void UpdatePreparePhysics() 119 internal void UpdatePreparePhysics()
117 { 120 {
118 // If we are using a threaded physics engine 121 // If we are using a threaded physics engine
@@ -141,7 +144,7 @@ namespace OpenSim.Region.Environment.Scenes
141 { 144 {
142 lock (m_syncRoot) 145 lock (m_syncRoot)
143 { 146 {
144 return _PhyScene.Simulate((float)elapsed); 147 return _PhyScene.Simulate((float) elapsed);
145 } 148 }
146 } 149 }
147 150
@@ -151,12 +154,14 @@ namespace OpenSim.Region.Environment.Scenes
151 154
152 foreach (EntityBase entity in moveEntities) 155 foreach (EntityBase entity in moveEntities)
153 { 156 {
154 entity.UpdateMovement(); 157 entity.UpdateMovement();
155 } 158 }
156 } 159 }
160
157 #endregion 161 #endregion
158 162
159 #region Entity Methods 163 #region Entity Methods
164
160 public void AddEntityFromStorage(SceneObjectGroup sceneObject) 165 public void AddEntityFromStorage(SceneObjectGroup sceneObject)
161 { 166 {
162 sceneObject.RegionHandle = m_regInfo.RegionHandle; 167 sceneObject.RegionHandle = m_regInfo.RegionHandle;
@@ -181,14 +186,17 @@ namespace OpenSim.Region.Environment.Scenes
181 m_numPrim++; 186 m_numPrim++;
182 } 187 }
183 } 188 }
189
184 public void AddPhysicalPrim(int number) 190 public void AddPhysicalPrim(int number)
185 { 191 {
186 m_physicalPrim++; 192 m_physicalPrim++;
187 } 193 }
194
188 public void RemovePhysicalPrim(int number) 195 public void RemovePhysicalPrim(int number)
189 { 196 {
190 m_physicalPrim--; 197 m_physicalPrim--;
191 } 198 }
199
192 public void RemovePrim(uint localID, LLUUID avatar_deleter) 200 public void RemovePrim(uint localID, LLUUID avatar_deleter)
193 { 201 {
194 List<EntityBase> EntityList = GetEntities(); 202 List<EntityBase> EntityList = GetEntities();
@@ -197,9 +205,9 @@ namespace OpenSim.Region.Environment.Scenes
197 { 205 {
198 if (obj is SceneObjectGroup) 206 if (obj is SceneObjectGroup)
199 { 207 {
200 if (((SceneObjectGroup)obj).LocalId == localID) 208 if (((SceneObjectGroup) obj).LocalId == localID)
201 { 209 {
202 m_parentScene.RemoveEntity((SceneObjectGroup)obj); 210 m_parentScene.RemoveEntity((SceneObjectGroup) obj);
203 m_numPrim--; 211 m_numPrim--;
204 return; 212 return;
205 } 213 }
@@ -253,7 +261,8 @@ namespace OpenSim.Region.Environment.Scenes
253 261
254 return newAvatar; 262 return newAvatar;
255 } 263 }
256 public void SwapRootChildAgent(bool direction_RC_CR_T_F) 264
265 public void SwapRootChildAgent(bool direction_RC_CR_T_F)
257 { 266 {
258 if (direction_RC_CR_T_F) 267 if (direction_RC_CR_T_F)
259 { 268 {
@@ -266,25 +275,29 @@ namespace OpenSim.Region.Environment.Scenes
266 m_numRootAgents++; 275 m_numRootAgents++;
267 } 276 }
268 } 277 }
278
269 public void removeUserCount(bool TypeRCTF) 279 public void removeUserCount(bool TypeRCTF)
270 { 280 {
271 if (TypeRCTF) 281 if (TypeRCTF)
272 { 282 {
273 m_numRootAgents--; 283 m_numRootAgents--;
274 } 284 }
275 else 285 else
276 { 286 {
277 m_numChildAgents--; 287 m_numChildAgents--;
278 } 288 }
279 } 289 }
290
280 public void RemoveAPrimCount() 291 public void RemoveAPrimCount()
281 { 292 {
282 m_numPrim--; 293 m_numPrim--;
283 } 294 }
295
284 public void AddAPrimCount() 296 public void AddAPrimCount()
285 { 297 {
286 m_numPrim++; 298 m_numPrim++;
287 } 299 }
300
288 public int GetChildAgentCount() 301 public int GetChildAgentCount()
289 { 302 {
290 return m_numChildAgents; 303 return m_numChildAgents;
@@ -375,8 +388,8 @@ namespace OpenSim.Region.Environment.Scenes
375 { 388 {
376 if (ent is SceneObjectGroup) 389 if (ent is SceneObjectGroup)
377 { 390 {
378 if (((SceneObjectGroup)ent).HasChildPrim(localID)) 391 if (((SceneObjectGroup) ent).HasChildPrim(localID))
379 return (SceneObjectGroup)ent; 392 return (SceneObjectGroup) ent;
380 } 393 }
381 } 394 }
382 return null; 395 return null;
@@ -390,8 +403,8 @@ namespace OpenSim.Region.Environment.Scenes
390 { 403 {
391 if (ent is SceneObjectGroup) 404 if (ent is SceneObjectGroup)
392 { 405 {
393 if (((SceneObjectGroup)ent).HasChildPrim(fullID)) 406 if (((SceneObjectGroup) ent).HasChildPrim(fullID))
394 return (SceneObjectGroup)ent; 407 return (SceneObjectGroup) ent;
395 } 408 }
396 } 409 }
397 return null; 410 return null;
@@ -406,7 +419,7 @@ namespace OpenSim.Region.Environment.Scenes
406 { 419 {
407 if (ent is SceneObjectGroup) 420 if (ent is SceneObjectGroup)
408 { 421 {
409 SceneObjectGroup reportingG = (SceneObjectGroup)ent; 422 SceneObjectGroup reportingG = (SceneObjectGroup) ent;
410 EntityIntersection result = reportingG.TestIntersection(hray); 423 EntityIntersection result = reportingG.TestIntersection(hray);
411 if (result.HitTF) 424 if (result.HitTF)
412 { 425 {
@@ -417,7 +430,6 @@ namespace OpenSim.Region.Environment.Scenes
417 } 430 }
418 } 431 }
419 } 432 }
420
421 } 433 }
422 return returnResult; 434 return returnResult;
423 } 435 }
@@ -531,17 +543,16 @@ namespace OpenSim.Region.Environment.Scenes
531 //float distResult = Vector3Distance(avPosition, objPosition); 543 //float distResult = Vector3Distance(avPosition, objPosition);
532 //if (distResult > 512) 544 //if (distResult > 512)
533 //{ 545 //{
534 //int x = 0; 546 //int x = 0;
535 //} 547 //}
536 //if (distResult < presence.DrawDistance) 548 //if (distResult < presence.DrawDistance)
537 //{ 549 //{
538 ((SceneObjectGroup)ent).ScheduleFullUpdateToAvatar(presence); 550 ((SceneObjectGroup) ent).ScheduleFullUpdateToAvatar(presence);
539 //} 551 //}
540
541 } 552 }
542 else 553 else
543 { 554 {
544 ((SceneObjectGroup)ent).ScheduleFullUpdateToAvatar(presence); 555 ((SceneObjectGroup) ent).ScheduleFullUpdateToAvatar(presence);
545 } 556 }
546 } 557 }
547 } 558 }
@@ -554,9 +565,11 @@ namespace OpenSim.Region.Environment.Scenes
554 action(presence.ControllingClient); 565 action(presence.ControllingClient);
555 } 566 }
556 } 567 }
568
557 #endregion 569 #endregion
558 570
559 #region Client Event handlers 571 #region Client Event handlers
572
560 /// <summary> 573 /// <summary>
561 /// 574 ///
562 /// </summary> 575 /// </summary>
@@ -583,13 +596,12 @@ namespace OpenSim.Region.Environment.Scenes
583 /// <param name="AgentID"></param> 596 /// <param name="AgentID"></param>
584 /// <param name="RequestFlags"></param> 597 /// <param name="RequestFlags"></param>
585 /// <param name="ObjectID"></param> 598 /// <param name="ObjectID"></param>
586 public void RequestObjectPropertiesFamily(IClientAPI remoteClient, LLUUID AgentID, uint RequestFlags, LLUUID ObjectID) 599 public void RequestObjectPropertiesFamily(IClientAPI remoteClient, LLUUID AgentID, uint RequestFlags,
600 LLUUID ObjectID)
587 { 601 {
588 SceneObjectGroup group = GetGroupByPrim(ObjectID); 602 SceneObjectGroup group = GetGroupByPrim(ObjectID);
589 if (group != null) 603 if (group != null)
590 group.ServiceObjectPropertiesFamilyRequest(remoteClient, AgentID, RequestFlags); 604 group.ServiceObjectPropertiesFamilyRequest(remoteClient, AgentID, RequestFlags);
591
592
593 } 605 }
594 606
595 /// <summary> 607 /// <summary>
@@ -708,10 +720,9 @@ namespace OpenSim.Region.Environment.Scenes
708 { 720 {
709 if (PermissionsMngr.CanEditObject(remoteClient.AgentId, group.UUID)) 721 if (PermissionsMngr.CanEditObject(remoteClient.AgentId, group.UUID))
710 { 722 {
711 group.UpdatePrimFlags(localID, (ushort)packet.Type, true, packet.ToBytes()); 723 group.UpdatePrimFlags(localID, (ushort) packet.Type, true, packet.ToBytes());
712 } 724 }
713 } 725 }
714
715 } 726 }
716 727
717 public void MoveObject(LLUUID objectID, LLVector3 offset, LLVector3 pos, IClientAPI remoteClient) 728 public void MoveObject(LLUUID objectID, LLVector3 offset, LLVector3 pos, IClientAPI remoteClient)
@@ -763,7 +774,7 @@ namespace OpenSim.Region.Environment.Scenes
763 public void UpdateExtraParam(LLUUID agentID, uint primLocalID, ushort type, bool inUse, byte[] data) 774 public void UpdateExtraParam(LLUUID agentID, uint primLocalID, ushort type, bool inUse, byte[] data)
764 { 775 {
765 SceneObjectGroup group = GetGroupByPrim(primLocalID); 776 SceneObjectGroup group = GetGroupByPrim(primLocalID);
766 777
767 if (group != null) 778 if (group != null)
768 { 779 {
769 if (PermissionsMngr.CanEditObject(agentID, group.UUID)) 780 if (PermissionsMngr.CanEditObject(agentID, group.UUID))
@@ -771,7 +782,6 @@ namespace OpenSim.Region.Environment.Scenes
771 group.UpdateExtraParam(primLocalID, type, inUse, data); 782 group.UpdateExtraParam(primLocalID, type, inUse, data);
772 } 783 }
773 } 784 }
774
775 } 785 }
776 786
777 /// <summary> 787 /// <summary>
@@ -786,7 +796,6 @@ namespace OpenSim.Region.Environment.Scenes
786 { 796 {
787 if (PermissionsMngr.CanEditObjectPosition(agentID, group.GetPartsFullID(primLocalID))) 797 if (PermissionsMngr.CanEditObjectPosition(agentID, group.GetPartsFullID(primLocalID)))
788 { 798 {
789
790 group.UpdateShape(shapeBlock, primLocalID); 799 group.UpdateShape(shapeBlock, primLocalID);
791 } 800 }
792 } 801 }
@@ -806,9 +815,9 @@ namespace OpenSim.Region.Environment.Scenes
806 { 815 {
807 if (ent is SceneObjectGroup) 816 if (ent is SceneObjectGroup)
808 { 817 {
809 if (((SceneObjectGroup)ent).LocalId == parentPrim) 818 if (((SceneObjectGroup) ent).LocalId == parentPrim)
810 { 819 {
811 parenPrim = (SceneObjectGroup)ent; 820 parenPrim = (SceneObjectGroup) ent;
812 break; 821 break;
813 } 822 }
814 } 823 }
@@ -823,9 +832,9 @@ namespace OpenSim.Region.Environment.Scenes
823 { 832 {
824 if (ent is SceneObjectGroup) 833 if (ent is SceneObjectGroup)
825 { 834 {
826 if (((SceneObjectGroup)ent).LocalId == childPrims[i]) 835 if (((SceneObjectGroup) ent).LocalId == childPrims[i])
827 { 836 {
828 children.Add((SceneObjectGroup)ent); 837 children.Add((SceneObjectGroup) ent);
829 } 838 }
830 } 839 }
831 } 840 }
@@ -857,7 +866,7 @@ namespace OpenSim.Region.Environment.Scenes
857 { 866 {
858 if (ent is SceneObjectGroup) 867 if (ent is SceneObjectGroup)
859 { 868 {
860 SceneObjectGroup obj = (SceneObjectGroup)ent; 869 SceneObjectGroup obj = (SceneObjectGroup) ent;
861 sceneObjects.Add(obj.LocalId, obj); 870 sceneObjects.Add(obj.LocalId, obj);
862 } 871 }
863 } 872 }
@@ -882,9 +891,9 @@ namespace OpenSim.Region.Environment.Scenes
882 } 891 }
883 else 892 else
884 { 893 {
885 MainLog.Instance.Verbose("SCENE", 894 MainLog.Instance.Verbose("SCENE",
886 "DelinkObjects(): Could not find a root prim out of {0} as given to a delink request!", 895 "DelinkObjects(): Could not find a root prim out of {0} as given to a delink request!",
887 primIds); 896 primIds);
888 } 897 }
889 } 898 }
890 899
@@ -903,9 +912,9 @@ namespace OpenSim.Region.Environment.Scenes
903 { 912 {
904 if (ent is SceneObjectGroup) 913 if (ent is SceneObjectGroup)
905 { 914 {
906 if (((SceneObjectGroup)ent).LocalId == originalPrim) 915 if (((SceneObjectGroup) ent).LocalId == originalPrim)
907 { 916 {
908 originPrim = (SceneObjectGroup)ent; 917 originPrim = (SceneObjectGroup) ent;
909 break; 918 break;
910 } 919 }
911 } 920 }
@@ -929,7 +938,6 @@ namespace OpenSim.Region.Environment.Scenes
929 { 938 {
930 MainLog.Instance.Warn("client", "Attempted to duplicate nonexistant prim"); 939 MainLog.Instance.Warn("client", "Attempted to duplicate nonexistant prim");
931 } 940 }
932
933 } 941 }
934 942
935 /// <summary> 943 /// <summary>
@@ -943,8 +951,11 @@ namespace OpenSim.Region.Environment.Scenes
943 // We don't really need the double floating point precision... 951 // We don't really need the double floating point precision...
944 // so casting it to a single 952 // so casting it to a single
945 953
946 return (float)Math.Sqrt((v1.x - v2.x) * (v1.x - v2.x) + (v1.y - v2.y) * (v1.y - v2.y) + (v1.z - v2.z) * (v1.z - v2.z)); 954 return
955 (float)
956 Math.Sqrt((v1.x - v2.x)*(v1.x - v2.x) + (v1.y - v2.y)*(v1.y - v2.y) + (v1.z - v2.z)*(v1.z - v2.z));
947 } 957 }
958
948 #endregion 959 #endregion
949 } 960 }
950} 961} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
index 0689177..4c6e1c8 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
@@ -26,14 +26,12 @@
26* 26*
27*/ 27*/
28 28
29using Axiom.Math; 29using System.Collections.Generic;
30using libsecondlife; 30using libsecondlife;
31using libsecondlife.Packets; 31using libsecondlife.Packets;
32using OpenSim.Framework; 32using OpenSim.Framework;
33using OpenSim.Framework.Communications.Cache; 33using OpenSim.Framework.Communications.Cache;
34using OpenSim.Framework.Console; 34using OpenSim.Framework.Console;
35using OpenSim.Region.Physics.Manager;
36using System.Collections.Generic;
37 35
38namespace OpenSim.Region.Environment.Scenes 36namespace OpenSim.Region.Environment.Scenes
39{ 37{
@@ -41,7 +39,7 @@ namespace OpenSim.Region.Environment.Scenes
41 { 39 {
42 //split these method into this partial as a lot of these (hopefully) are only temporary and won't be needed once Caps is more complete 40 //split these method into this partial as a lot of these (hopefully) are only temporary and won't be needed once Caps is more complete
43 // or at least some of they can be moved somewhere else 41 // or at least some of they can be moved somewhere else
44 42
45 /// <summary> 43 /// <summary>
46 /// Add an inventory item to an avatar's inventory. 44 /// Add an inventory item to an avatar's inventory.
47 /// </summary> 45 /// </summary>
@@ -57,7 +55,7 @@ namespace OpenSim.Region.Environment.Scenes
57 remoteClient.SendInventoryItemCreateUpdate(item); 55 remoteClient.SendInventoryItemCreateUpdate(item);
58 } 56 }
59 } 57 }
60 58
61 /// <summary> 59 /// <summary>
62 /// <see>AddInventoryItem(LLUUID, InventoryItemBase)</see> 60 /// <see>AddInventoryItem(LLUUID, InventoryItemBase)</see>
63 /// </summary> 61 /// </summary>
@@ -71,10 +69,10 @@ namespace OpenSim.Region.Environment.Scenes
71 if (!TryGetAvatar(avatarId, out avatar)) 69 if (!TryGetAvatar(avatarId, out avatar))
72 { 70 {
73 MainLog.Instance.Error( 71 MainLog.Instance.Error(
74 "AGENTINVENTORY", "Could not find avatar {0} to add inventory item", avatarId); 72 "AGENTINVENTORY", "Could not find avatar {0} to add inventory item", avatarId);
75 return; 73 return;
76 } 74 }
77 75
78 AddInventoryItem(avatar.ControllingClient, item); 76 AddInventoryItem(avatar.ControllingClient, item);
79 } 77 }
80 78
@@ -95,7 +93,9 @@ namespace OpenSim.Region.Environment.Scenes
95 InventoryItemBase item = userInfo.RootFolder.HasItem(itemID); 93 InventoryItemBase item = userInfo.RootFolder.HasItem(itemID);
96 if (item != null) 94 if (item != null)
97 { 95 {
98 AssetBase asset = CreateAsset(item.inventoryName, item.inventoryDescription, (sbyte) item.invType, (sbyte) item.assetType, data); 96 AssetBase asset =
97 CreateAsset(item.inventoryName, item.inventoryDescription, (sbyte) item.invType,
98 (sbyte) item.assetType, data);
99 AssetCache.AddAsset(asset); 99 AssetCache.AddAsset(asset);
100 100
101 item.assetID = asset.FullID; 101 item.assetID = asset.FullID;
@@ -117,7 +117,7 @@ namespace OpenSim.Region.Environment.Scenes
117 } 117 }
118 return LLUUID.Zero; 118 return LLUUID.Zero;
119 } 119 }
120 120
121 /// <summary> 121 /// <summary>
122 /// <see>CapsUpdatedInventoryItemAsset(IClientAPI, LLUUID, byte[])</see> 122 /// <see>CapsUpdatedInventoryItemAsset(IClientAPI, LLUUID, byte[])</see>
123 /// </summary> 123 /// </summary>
@@ -132,14 +132,14 @@ namespace OpenSim.Region.Environment.Scenes
132 else 132 else
133 { 133 {
134 MainLog.Instance.Error( 134 MainLog.Instance.Error(
135 "AGENTINVENTORY", 135 "AGENTINVENTORY",
136 "Avatar {0} cannot be found to update its inventory item asset", 136 "Avatar {0} cannot be found to update its inventory item asset",
137 avatarId); 137 avatarId);
138 } 138 }
139 139
140 return LLUUID.Zero; 140 return LLUUID.Zero;
141 } 141 }
142 142
143 /// <summary> 143 /// <summary>
144 /// Capability originating call to update the asset of a script in a prim's (task's) inventory 144 /// Capability originating call to update the asset of a script in a prim's (task's) inventory
145 /// </summary> 145 /// </summary>
@@ -149,17 +149,17 @@ namespace OpenSim.Region.Environment.Scenes
149 /// <param name="isScriptRunning">Indicates whether the script to update is currently running</param> 149 /// <param name="isScriptRunning">Indicates whether the script to update is currently running</param>
150 /// <param name="data"></param> 150 /// <param name="data"></param>
151 /// <returns>Asset LLUID created</returns> 151 /// <returns>Asset LLUID created</returns>
152 public void CapsUpdateTaskInventoryScriptAsset(IClientAPI remoteClient, LLUUID itemId, 152 public void CapsUpdateTaskInventoryScriptAsset(IClientAPI remoteClient, LLUUID itemId,
153 LLUUID primId, bool isScriptRunning, byte[] data) 153 LLUUID primId, bool isScriptRunning, byte[] data)
154 { 154 {
155 // TODO Not currently doing anything with the isScriptRunning bool 155 // TODO Not currently doing anything with the isScriptRunning bool
156 156
157 MainLog.Instance.Verbose( 157 MainLog.Instance.Verbose(
158 "PRIMINVENTORY", 158 "PRIMINVENTORY",
159 "Prim inventory script save functionality not yet implemented." 159 "Prim inventory script save functionality not yet implemented."
160 + " remoteClient: {0}, itemID: {1}, primID: {2}, isScriptRunning: {3}", 160 + " remoteClient: {0}, itemID: {1}, primID: {2}, isScriptRunning: {3}",
161 remoteClient, itemId, primId, isScriptRunning); 161 remoteClient, itemId, primId, isScriptRunning);
162 162
163 // TODO 163 // TODO
164 // Retrieve client LLUID 164 // Retrieve client LLUID
165 // Retrieve sog containing primID 165 // Retrieve sog containing primID
@@ -170,13 +170,13 @@ namespace OpenSim.Region.Environment.Scenes
170 // Trigger rerunning of script (use TriggerRezScript event, see RezScript) 170 // Trigger rerunning of script (use TriggerRezScript event, see RezScript)
171 // return new asset id 171 // return new asset id
172 } 172 }
173 173
174 /// <summary> 174 /// <summary>
175 /// <see>CapsUpdateTaskInventoryScriptAsset(IClientAPI, LLUUID, LLUUID, bool, byte[])</see> 175 /// <see>CapsUpdateTaskInventoryScriptAsset(IClientAPI, LLUUID, LLUUID, bool, byte[])</see>
176 /// </summary> 176 /// </summary>
177 private void CapsUpdateTaskInventoryScriptAsset(LLUUID avatarId, LLUUID itemId, 177 private void CapsUpdateTaskInventoryScriptAsset(LLUUID avatarId, LLUUID itemId,
178 LLUUID primId, bool isScriptRunning, byte[] data) 178 LLUUID primId, bool isScriptRunning, byte[] data)
179 { 179 {
180 ScenePresence avatar; 180 ScenePresence avatar;
181 181
182 if (TryGetAvatar(avatarId, out avatar)) 182 if (TryGetAvatar(avatarId, out avatar))
@@ -187,10 +187,10 @@ namespace OpenSim.Region.Environment.Scenes
187 else 187 else
188 { 188 {
189 MainLog.Instance.Error( 189 MainLog.Instance.Error(
190 "PRIMINVENTORY", 190 "PRIMINVENTORY",
191 "Avatar {0} cannot be found to update its prim item asset", 191 "Avatar {0} cannot be found to update its prim item asset",
192 avatarId); 192 avatarId);
193 } 193 }
194 } 194 }
195 195
196 /// <summary> 196 /// <summary>
@@ -204,74 +204,75 @@ namespace OpenSim.Region.Environment.Scenes
204 /// <param name="name">The name of the updated item</param> 204 /// <param name="name">The name of the updated item</param>
205 /// <param name="description">The description of the updated item</param> 205 /// <param name="description">The description of the updated item</param>
206 /// <param name="nextOwnerMask">The permissions of the updated item</param> 206 /// <param name="nextOwnerMask">The permissions of the updated item</param>
207 public void UpdateInventoryItemAsset(IClientAPI remoteClient, LLUUID transactionID, 207 public void UpdateInventoryItemAsset(IClientAPI remoteClient, LLUUID transactionID,
208 LLUUID itemID, string name, string description, 208 LLUUID itemID, string name, string description,
209 uint nextOwnerMask) 209 uint nextOwnerMask)
210 { 210 {
211 CachedUserInfo userInfo 211 CachedUserInfo userInfo
212 = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId); 212 = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId);
213 213
214 if (userInfo != null && userInfo.RootFolder != null) 214 if (userInfo != null && userInfo.RootFolder != null)
215 { 215 {
216 InventoryItemBase item = userInfo.RootFolder.HasItem(itemID); 216 InventoryItemBase item = userInfo.RootFolder.HasItem(itemID);
217 if (item != null) 217 if (item != null)
218 { 218 {
219 if (LLUUID.Zero == transactionID) 219 if (LLUUID.Zero == transactionID)
220 { 220 {
221 item.inventoryName = name; 221 item.inventoryName = name;
222 item.inventoryDescription = description; 222 item.inventoryDescription = description;
223 item.inventoryNextPermissions = nextOwnerMask; 223 item.inventoryNextPermissions = nextOwnerMask;
224 224
225 userInfo.UpdateItem(remoteClient.AgentId, item); 225 userInfo.UpdateItem(remoteClient.AgentId, item);
226 } 226 }
227 else 227 else
228 { 228 {
229 AgentAssetTransactions transactions 229 AgentAssetTransactions transactions
230 = CommsManager.TransactionsManager.GetUserTransActions(remoteClient.AgentId); 230 = CommsManager.TransactionsManager.GetUserTransActions(remoteClient.AgentId);
231 231
232 if (transactions != null) 232 if (transactions != null)
233 { 233 {
234 LLUUID assetID = libsecondlife.LLUUID.Combine(transactionID, remoteClient.SecureSessionId); 234 LLUUID assetID = LLUUID.Combine(transactionID, remoteClient.SecureSessionId);
235 AssetBase asset 235 AssetBase asset
236 = AssetCache.GetAsset( 236 = AssetCache.GetAsset(
237 assetID, (item.assetType == (int)AssetType.Texture ? true : false)); 237 assetID, (item.assetType == (int) AssetType.Texture ? true : false));
238 238
239 if (asset == null) 239 if (asset == null)
240 { 240 {
241 asset = transactions.GetTransactionAsset(transactionID); 241 asset = transactions.GetTransactionAsset(transactionID);
242 } 242 }
243 243
244 if (asset != null && asset.FullID == assetID) 244 if (asset != null && asset.FullID == assetID)
245 { 245 {
246 asset.Name = item.inventoryName; 246 asset.Name = item.inventoryName;
247 asset.Description = item.inventoryDescription; 247 asset.Description = item.inventoryDescription;
248 asset.InvType = (sbyte) item.invType; 248 asset.InvType = (sbyte) item.invType;
249 asset.Type = (sbyte) item.assetType; 249 asset.Type = (sbyte) item.assetType;
250 item.assetID = asset.FullID; 250 item.assetID = asset.FullID;
251 251
252 AssetCache.AddAsset(asset); 252 AssetCache.AddAsset(asset);
253 } 253 }
254 254
255 userInfo.UpdateItem(remoteClient.AgentId, item); 255 userInfo.UpdateItem(remoteClient.AgentId, item);
256 } 256 }
257 } 257 }
258 } 258 }
259 else 259 else
260 { 260 {
261 MainLog.Instance.Warn( 261 MainLog.Instance.Warn(
262 "AGENTINVENTORY", 262 "AGENTINVENTORY",
263 "Item ID " + itemID + " not found for an inventory item update."); 263 "Item ID " + itemID + " not found for an inventory item update.");
264 } 264 }
265 } 265 }
266 else 266 else
267 { 267 {
268 MainLog.Instance.Warn( 268 MainLog.Instance.Warn(
269 "AGENTINVENTORY", 269 "AGENTINVENTORY",
270 "Agent ID " + remoteClient.AgentId + " not found for an inventory item update."); 270 "Agent ID " + remoteClient.AgentId + " not found for an inventory item update.");
271 } 271 }
272 } 272 }
273 273
274 public void CopyInventoryItem(IClientAPI remoteClient, uint callbackID, LLUUID oldAgentID, LLUUID oldItemID, LLUUID newFolderID, string newName) 274 public void CopyInventoryItem(IClientAPI remoteClient, uint callbackID, LLUUID oldAgentID, LLUUID oldItemID,
275 LLUUID newFolderID, string newName)
275 { 276 {
276 InventoryItemBase item = CommsManager.UserProfileCacheService.libraryRoot.HasItem(oldItemID); 277 InventoryItemBase item = CommsManager.UserProfileCacheService.libraryRoot.HasItem(oldItemID);
277 if (item == null) 278 if (item == null)
@@ -308,7 +309,7 @@ namespace OpenSim.Region.Environment.Scenes
308 } 309 }
309 310
310 asset.Name = (newName.Length == 0) ? item.inventoryName : newName; 311 asset.Name = (newName.Length == 0) ? item.inventoryName : newName;
311 312
312 // TODO: preserve current permissions? 313 // TODO: preserve current permissions?
313 CreateNewInventoryItem(remoteClient, newFolderID, callbackID, asset, item.inventoryNextPermissions); 314 CreateNewInventoryItem(remoteClient, newFolderID, callbackID, asset, item.inventoryNextPermissions);
314 } 315 }
@@ -325,12 +326,13 @@ namespace OpenSim.Region.Environment.Scenes
325 return asset; 326 return asset;
326 } 327 }
327 328
328 public void MoveInventoryItem(IClientAPI remoteClient,LLUUID folderID, LLUUID itemID, int length, string newName) 329 public void MoveInventoryItem(IClientAPI remoteClient, LLUUID folderID, LLUUID itemID, int length,
330 string newName)
329 { 331 {
330 MainLog.Instance.Verbose( 332 MainLog.Instance.Verbose(
331 "AGENTINVENTORY", 333 "AGENTINVENTORY",
332 "Moving item for " + remoteClient.AgentId.ToString()); 334 "Moving item for " + remoteClient.AgentId.ToString());
333 335
334 CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId); 336 CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId);
335 if (userInfo == null) 337 if (userInfo == null)
336 { 338 {
@@ -364,8 +366,6 @@ namespace OpenSim.Region.Environment.Scenes
364 MainLog.Instance.Warn("AGENTINVENTORY", "Failed to find item " + itemID.ToString() + ", no root folder"); 366 MainLog.Instance.Warn("AGENTINVENTORY", "Failed to find item " + itemID.ToString() + ", no root folder");
365 return; 367 return;
366 } 368 }
367
368
369 } 369 }
370 370
371 private void CreateNewInventoryItem(IClientAPI remoteClient, LLUUID folderID, uint callbackID, 371 private void CreateNewInventoryItem(IClientAPI remoteClient, LLUUID folderID, uint callbackID,
@@ -406,7 +406,8 @@ namespace OpenSim.Region.Environment.Scenes
406 /// <param name="wearableType"></param> 406 /// <param name="wearableType"></param>
407 /// <param name="nextOwnerMask"></param> 407 /// <param name="nextOwnerMask"></param>
408 public void CreateNewInventoryItem(IClientAPI remoteClient, LLUUID transActionID, LLUUID folderID, 408 public void CreateNewInventoryItem(IClientAPI remoteClient, LLUUID transActionID, LLUUID folderID,
409 uint callbackID, string description, string name, sbyte invType, sbyte assetType, 409 uint callbackID, string description, string name, sbyte invType,
410 sbyte assetType,
410 byte wearableType, uint nextOwnerMask) 411 byte wearableType, uint nextOwnerMask)
411 { 412 {
412 if (transActionID == LLUUID.Zero) 413 if (transActionID == LLUUID.Zero)
@@ -437,8 +438,8 @@ namespace OpenSim.Region.Environment.Scenes
437 { 438 {
438 if (ent is SceneObjectGroup) 439 if (ent is SceneObjectGroup)
439 { 440 {
440 if (((SceneObjectGroup)ent).HasChildPrim(localID)) 441 if (((SceneObjectGroup) ent).HasChildPrim(localID))
441 return (SceneObjectGroup)ent; 442 return (SceneObjectGroup) ent;
442 } 443 }
443 } 444 }
444 return null; 445 return null;
@@ -491,13 +492,13 @@ namespace OpenSim.Region.Environment.Scenes
491 else 492 else
492 { 493 {
493 MainLog.Instance.Warn( 494 MainLog.Instance.Warn(
494 "PRIMINVENTORY", 495 "PRIMINVENTORY",
495 "Removal of item {0} requested of prim {1} but this prim does not exist", 496 "Removal of item {0} requested of prim {1} but this prim does not exist",
496 itemID, 497 itemID,
497 localID); 498 localID);
498 } 499 }
499 } 500 }
500 501
501 /// <summary> 502 /// <summary>
502 /// Update an item in a prim (task) inventory. 503 /// Update an item in a prim (task) inventory.
503 /// This method does not handle scripts, <see>RezScript(IClientAPI, LLUUID, unit)</see> 504 /// This method does not handle scripts, <see>RezScript(IClientAPI, LLUUID, unit)</see>
@@ -506,7 +507,7 @@ namespace OpenSim.Region.Environment.Scenes
506 /// <param name="itemID"></param> 507 /// <param name="itemID"></param>
507 /// <param name="folderID"></param> 508 /// <param name="folderID"></param>
508 /// <param name="primLocalID"></param> 509 /// <param name="primLocalID"></param>
509 public void UpdateTaskInventory(IClientAPI remoteClient, LLUUID itemID, LLUUID folderID, 510 public void UpdateTaskInventory(IClientAPI remoteClient, LLUUID itemID, LLUUID folderID,
510 uint primLocalID) 511 uint primLocalID)
511 { 512 {
512 SceneObjectGroup group = GetGroupByPrim(primLocalID); 513 SceneObjectGroup group = GetGroupByPrim(primLocalID);
@@ -515,17 +516,17 @@ namespace OpenSim.Region.Environment.Scenes
515 // TODO Retrieve itemID from client's inventory to pass on 516 // TODO Retrieve itemID from client's inventory to pass on
516 //group.AddInventoryItem(rmoteClient, primLocalID, null); 517 //group.AddInventoryItem(rmoteClient, primLocalID, null);
517 MainLog.Instance.Verbose( 518 MainLog.Instance.Verbose(
518 "PRIMINVENTORY", 519 "PRIMINVENTORY",
519 "UpdateTaskInventory called with script {0}, folder {1}, primLocalID {2}, user {3}", 520 "UpdateTaskInventory called with script {0}, folder {1}, primLocalID {2}, user {3}",
520 itemID, folderID, primLocalID, remoteClient.Name); 521 itemID, folderID, primLocalID, remoteClient.Name);
521 } 522 }
522 else 523 else
523 { 524 {
524 MainLog.Instance.Warn( 525 MainLog.Instance.Warn(
525 "PRIMINVENTORY", 526 "PRIMINVENTORY",
526 "Update with script {0} requested of prim {1} for {2} but this prim does not exist", 527 "Update with script {0} requested of prim {1} for {2} but this prim does not exist",
527 itemID, primLocalID, remoteClient.Name); 528 itemID, primLocalID, remoteClient.Name);
528 } 529 }
529 } 530 }
530 531
531 /// <summary> 532 /// <summary>
@@ -551,7 +552,7 @@ namespace OpenSim.Region.Environment.Scenes
551 { 552 {
552 isTexture = true; 553 isTexture = true;
553 } 554 }
554 555
555 AssetBase rezAsset = AssetCache.GetAsset(item.assetID, isTexture); 556 AssetBase rezAsset = AssetCache.GetAsset(item.assetID, isTexture);
556 557
557 if (rezAsset != null) 558 if (rezAsset != null)
@@ -569,18 +570,18 @@ namespace OpenSim.Region.Environment.Scenes
569 // TODO: do we care about the value of this bool? 570 // TODO: do we care about the value of this bool?
570 group.AddInventoryItem(remoteClient, localID, item, copyID); 571 group.AddInventoryItem(remoteClient, localID, item, copyID);
571 group.GetProperites(remoteClient); 572 group.GetProperites(remoteClient);
572 573
573 MainLog.Instance.Verbose( 574 MainLog.Instance.Verbose(
574 "PRIMINVENTORY", 575 "PRIMINVENTORY",
575 "Rezzed script {0} (asset {1}) into prim {2} for user {3}", 576 "Rezzed script {0} (asset {1}) into prim {2} for user {3}",
576 item.inventoryName, rezAsset.FullID, localID, remoteClient.Name); 577 item.inventoryName, rezAsset.FullID, localID, remoteClient.Name);
577 } 578 }
578 else 579 else
579 { 580 {
580 MainLog.Instance.Warn( 581 MainLog.Instance.Warn(
581 "PRIMINVENTORY", 582 "PRIMINVENTORY",
582 "Could not rez script {0} into prim {1} for user {2}" 583 "Could not rez script {0} into prim {1} for user {2}"
583 + " because the prim could not be found in the region!", 584 + " because the prim could not be found in the region!",
584 item.inventoryName, localID, remoteClient.Name); 585 item.inventoryName, localID, remoteClient.Name);
585 } 586 }
586 } 587 }
@@ -589,7 +590,7 @@ namespace OpenSim.Region.Environment.Scenes
589 MainLog.Instance.Warn( 590 MainLog.Instance.Warn(
590 "PRIMINVENTORY", 591 "PRIMINVENTORY",
591 "Could not rez script {0} into prim {1} for user {2}" 592 "Could not rez script {0} into prim {1} for user {2}"
592 + " because the item asset {3} could not be found!", 593 + " because the item asset {3} could not be found!",
593 item.inventoryName, localID, item.assetID, remoteClient.Name); 594 item.inventoryName, localID, item.assetID, remoteClient.Name);
594 } 595 }
595 } 596 }
@@ -638,7 +639,8 @@ namespace OpenSim.Region.Environment.Scenes
638 if (PermissionsMngr.CanDeRezObject(remoteClient.AgentId, ((SceneObjectGroup) selectedEnt).UUID)) 639 if (PermissionsMngr.CanDeRezObject(remoteClient.AgentId, ((SceneObjectGroup) selectedEnt).UUID))
639 { 640 {
640 string sceneObjectXml = ((SceneObjectGroup) selectedEnt).ToXmlString(); 641 string sceneObjectXml = ((SceneObjectGroup) selectedEnt).ToXmlString();
641 CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId); 642 CachedUserInfo userInfo =
643 CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId);
642 if (userInfo != null) 644 if (userInfo != null)
643 { 645 {
644 AssetBase asset = CreateAsset( 646 AssetBase asset = CreateAsset(
@@ -661,9 +663,10 @@ namespace OpenSim.Region.Environment.Scenes
661 item.parentFolderID = DeRezPacket.AgentBlock.DestinationID; 663 item.parentFolderID = DeRezPacket.AgentBlock.DestinationID;
662 item.inventoryCurrentPermissions = 2147483647; 664 item.inventoryCurrentPermissions = 2147483647;
663 item.inventoryNextPermissions = 2147483647; 665 item.inventoryNextPermissions = 2147483647;
664 item.inventoryEveryOnePermissions = ((SceneObjectGroup)selectedEnt).RootPart.EveryoneMask; 666 item.inventoryEveryOnePermissions =
665 item.inventoryBasePermissions = ((SceneObjectGroup)selectedEnt).RootPart.BaseMask; 667 ((SceneObjectGroup) selectedEnt).RootPart.EveryoneMask;
666 item.inventoryCurrentPermissions = ((SceneObjectGroup)selectedEnt).RootPart.OwnerMask; 668 item.inventoryBasePermissions = ((SceneObjectGroup) selectedEnt).RootPart.BaseMask;
669 item.inventoryCurrentPermissions = ((SceneObjectGroup) selectedEnt).RootPart.OwnerMask;
667 670
668 userInfo.AddItem(remoteClient.AgentId, item); 671 userInfo.AddItem(remoteClient.AgentId, item);
669 remoteClient.SendInventoryItemCreateUpdate(item); 672 remoteClient.SendInventoryItemCreateUpdate(item);
@@ -730,20 +733,20 @@ namespace OpenSim.Region.Environment.Scenes
730 //bool UsePhysics = (((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Physics) > 0)&& m_physicalPrim); 733 //bool UsePhysics = (((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Physics) > 0)&& m_physicalPrim);
731 //if ((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Phantom) == 0) 734 //if ((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Phantom) == 0)
732 //{ 735 //{
733 //PrimitiveBaseShape pbs = rootPart.Shape; 736 //PrimitiveBaseShape pbs = rootPart.Shape;
734 //rootPart.PhysActor = PhysicsScene.AddPrimShape( 737 //rootPart.PhysActor = PhysicsScene.AddPrimShape(
735 //rootPart.Name, 738 //rootPart.Name,
736 //pbs, 739 //pbs,
737 //new PhysicsVector(rootPart.AbsolutePosition.X, rootPart.AbsolutePosition.Y, 740 //new PhysicsVector(rootPart.AbsolutePosition.X, rootPart.AbsolutePosition.Y,
738 // rootPart.AbsolutePosition.Z), 741 // rootPart.AbsolutePosition.Z),
739 //new PhysicsVector(rootPart.Scale.X, rootPart.Scale.Y, rootPart.Scale.Z), 742 //new PhysicsVector(rootPart.Scale.X, rootPart.Scale.Y, rootPart.Scale.Z),
740 //new Quaternion(rootPart.RotationOffset.W, rootPart.RotationOffset.X, 743 //new Quaternion(rootPart.RotationOffset.W, rootPart.RotationOffset.X,
741 // rootPart.RotationOffset.Y, rootPart.RotationOffset.Z), UsePhysics); 744 // rootPart.RotationOffset.Y, rootPart.RotationOffset.Z), UsePhysics);
742 745
743 // rootPart.DoPhysicsPropertyUpdate(UsePhysics, true); 746 // rootPart.DoPhysicsPropertyUpdate(UsePhysics, true);
744 747
745 // } 748 // }
746 rootPart.ScheduleFullUpdate(); 749 rootPart.ScheduleFullUpdate();
747 } 750 }
748 } 751 }
749} 752} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs
index 6a7c266..999b70f 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs
@@ -29,8 +29,6 @@ using System.Collections.Generic;
29using libsecondlife; 29using libsecondlife;
30using libsecondlife.Packets; 30using libsecondlife.Packets;
31using OpenSim.Framework; 31using OpenSim.Framework;
32using OpenSim.Framework.UserManagement;
33using OpenSim.Framework.Console;
34 32
35namespace OpenSim.Region.Environment.Scenes 33namespace OpenSim.Region.Environment.Scenes
36{ 34{
@@ -45,7 +43,8 @@ namespace OpenSim.Region.Environment.Scenes
45 /// <param name="action">The action to be performed</param> 43 /// <param name="action">The action to be performed</param>
46 /// <param name="north">Distance from the north border where the cursor is located</param> 44 /// <param name="north">Distance from the north border where the cursor is located</param>
47 /// <param name="west">Distance from the west border where the cursor is located</param> 45 /// <param name="west">Distance from the west border where the cursor is located</param>
48 public void ModifyTerrain(float height, float seconds, byte brushsize, byte action, float north, float west, float south, float east, 46 public void ModifyTerrain(float height, float seconds, byte brushsize, byte action, float north, float west,
47 float south, float east,
49 IClientAPI remoteUser) 48 IClientAPI remoteUser)
50 { 49 {
51 // Do a permissions check before allowing terraforming. 50 // Do a permissions check before allowing terraforming.
@@ -157,7 +156,7 @@ namespace OpenSim.Region.Environment.Scenes
157 } 156 }
158 } 157 }
159 } 158 }
160 159
161 public void ProcessAvatarPickerRequest(IClientAPI client, LLUUID avatarID, LLUUID RequestID, string query) 160 public void ProcessAvatarPickerRequest(IClientAPI client, LLUUID avatarID, LLUUID RequestID, string query)
162 { 161 {
163 //EventManager.TriggerAvatarPickerRequest(); 162 //EventManager.TriggerAvatarPickerRequest();
@@ -166,13 +165,14 @@ namespace OpenSim.Region.Environment.Scenes
166 AvatarResponses = CommsManager.GenerateAgentPickerRequestResponse(RequestID, query); 165 AvatarResponses = CommsManager.GenerateAgentPickerRequestResponse(RequestID, query);
167 166
168 AvatarPickerReplyPacket replyPacket = new AvatarPickerReplyPacket(); 167 AvatarPickerReplyPacket replyPacket = new AvatarPickerReplyPacket();
169 AvatarPickerReplyPacket.DataBlock[] searchData = new AvatarPickerReplyPacket.DataBlock[AvatarResponses.Count]; 168 AvatarPickerReplyPacket.DataBlock[] searchData =
169 new AvatarPickerReplyPacket.DataBlock[AvatarResponses.Count];
170 AvatarPickerReplyPacket.AgentDataBlock agentData = new AvatarPickerReplyPacket.AgentDataBlock(); 170 AvatarPickerReplyPacket.AgentDataBlock agentData = new AvatarPickerReplyPacket.AgentDataBlock();
171 171
172 agentData.AgentID = avatarID; 172 agentData.AgentID = avatarID;
173 agentData.QueryID = RequestID; 173 agentData.QueryID = RequestID;
174 replyPacket.AgentData = agentData; 174 replyPacket.AgentData = agentData;
175 byte[] bytes = new byte[AvatarResponses.Count * 32]; 175 byte[] bytes = new byte[AvatarResponses.Count*32];
176 176
177 int i = 0; 177 int i = 0;
178 foreach (AvatarPickerAvatar item in AvatarResponses) 178 foreach (AvatarPickerAvatar item in AvatarResponses)
@@ -180,10 +180,9 @@ namespace OpenSim.Region.Environment.Scenes
180 LLUUID translatedIDtem = item.AvatarID; 180 LLUUID translatedIDtem = item.AvatarID;
181 searchData[i] = new AvatarPickerReplyPacket.DataBlock(); 181 searchData[i] = new AvatarPickerReplyPacket.DataBlock();
182 searchData[i].AvatarID = translatedIDtem; 182 searchData[i].AvatarID = translatedIDtem;
183 searchData[i].FirstName = Helpers.StringToField((string)item.firstName); 183 searchData[i].FirstName = Helpers.StringToField((string) item.firstName);
184 searchData[i].LastName = Helpers.StringToField((string)item.lastName); 184 searchData[i].LastName = Helpers.StringToField((string) item.lastName);
185 i++; 185 i++;
186
187 } 186 }
188 if (AvatarResponses.Count == 0) 187 if (AvatarResponses.Count == 0)
189 { 188 {
@@ -193,4 +192,4 @@ namespace OpenSim.Region.Environment.Scenes
193 client.SendAvatarPickerReply(replyPacket); 192 client.SendAvatarPickerReply(replyPacket);
194 } 193 }
195 } 194 }
196} 195} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs
index 0144c4c..c0fda61 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.cs
@@ -27,27 +27,28 @@
27*/ 27*/
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.IO; 30using System.Drawing;
31using System.Net; 31using System.Drawing.Imaging;
32using System.Threading; 32using System.Threading;
33using System.Timers; 33using System.Timers;
34using System.Xml;
35using Axiom.Math; 34using Axiom.Math;
36using libsecondlife; 35using libsecondlife;
36using libsecondlife.Packets;
37using OpenJPEGNet;
37using OpenSim.Framework; 38using OpenSim.Framework;
38using OpenSim.Framework.Communications; 39using OpenSim.Framework.Communications;
39using OpenSim.Framework.Communications.Cache; 40using OpenSim.Framework.Communications.Cache;
40using OpenSim.Framework.Console; 41using OpenSim.Framework.Console;
41using OpenSim.Region.Environment.LandManagement;
42using OpenSim.Framework.Servers; 42using OpenSim.Framework.Servers;
43using OpenSim.Region.Capabilities;
44using OpenSim.Region.Environment.Interfaces; 43using OpenSim.Region.Environment.Interfaces;
44using OpenSim.Region.Environment.LandManagement;
45using OpenSim.Region.Environment.Modules; 45using OpenSim.Region.Environment.Modules;
46using OpenSim.Region.Environment.Scenes.Scripting; 46using OpenSim.Region.Environment.Scenes.Scripting;
47using OpenSim.Region.Environment.Types;
48using OpenSim.Region.Physics.Manager; 47using OpenSim.Region.Physics.Manager;
49using OpenSim.Region.Terrain; 48using OpenSim.Region.Terrain;
50using Timer = System.Timers.Timer; 49using Caps=OpenSim.Region.Capabilities.Caps;
50using Image=System.Drawing.Image;
51using Timer=System.Timers.Timer;
51 52
52namespace OpenSim.Region.Environment.Scenes 53namespace OpenSim.Region.Environment.Scenes
53{ 54{
@@ -56,6 +57,7 @@ namespace OpenSim.Region.Environment.Scenes
56 public partial class Scene : SceneBase 57 public partial class Scene : SceneBase
57 { 58 {
58 #region Fields 59 #region Fields
60
59 protected Timer m_heartbeatTimer = new Timer(); 61 protected Timer m_heartbeatTimer = new Timer();
60 protected Timer m_restartWaitTimer = new Timer(); 62 protected Timer m_restartWaitTimer = new Timer();
61 63
@@ -88,7 +90,7 @@ namespace OpenSim.Region.Environment.Scenes
88 protected SceneCommunicationService m_sceneGridService; 90 protected SceneCommunicationService m_sceneGridService;
89 protected SceneXmlLoader m_sceneXmlLoader; 91 protected SceneXmlLoader m_sceneXmlLoader;
90 92
91 protected Dictionary<LLUUID, OpenSim.Region.Capabilities.Caps> m_capsHandlers = new Dictionary<LLUUID, OpenSim.Region.Capabilities.Caps>(); 93 protected Dictionary<LLUUID, Caps> m_capsHandlers = new Dictionary<LLUUID, Caps>();
92 protected BaseHttpServer httpListener; 94 protected BaseHttpServer httpListener;
93 95
94 protected Dictionary<string, IRegionModule> Modules = new Dictionary<string, IRegionModule>(); 96 protected Dictionary<string, IRegionModule> Modules = new Dictionary<string, IRegionModule>();
@@ -122,6 +124,7 @@ namespace OpenSim.Region.Environment.Scenes
122 private int m_update_terrain = 50; 124 private int m_update_terrain = 50;
123 private int m_update_land = 1; 125 private int m_update_land = 1;
124 private int m_update_avatars = 1; 126 private int m_update_avatars = 1;
127
125 #endregion 128 #endregion
126 129
127 #region Properties 130 #region Properties
@@ -145,6 +148,7 @@ namespace OpenSim.Region.Environment.Scenes
145 set { m_innerScene.PhysicsScene = value; } 148 set { m_innerScene.PhysicsScene = value; }
146 get { return (m_innerScene.PhysicsScene); } 149 get { return (m_innerScene.PhysicsScene); }
147 } 150 }
151
148 // This gets locked so things stay thread safe. 152 // This gets locked so things stay thread safe.
149 public object SyncRoot 153 public object SyncRoot
150 { 154 {
@@ -204,7 +208,8 @@ namespace OpenSim.Region.Environment.Scenes
204 208
205 #region Constructors 209 #region Constructors
206 210
207 public Scene(RegionInfo regInfo, AgentCircuitManager authen, PermissionManager permissionManager, CommunicationsManager commsMan, SceneCommunicationService sceneGridService, 211 public Scene(RegionInfo regInfo, AgentCircuitManager authen, PermissionManager permissionManager,
212 CommunicationsManager commsMan, SceneCommunicationService sceneGridService,
208 AssetCache assetCach, StorageManager storeManager, BaseHttpServer httpServer, 213 AssetCache assetCach, StorageManager storeManager, BaseHttpServer httpServer,
209 ModuleLoader moduleLoader, bool dumpAssetsToFile, bool physicalPrim, bool SendTasksToChild) 214 ModuleLoader moduleLoader, bool dumpAssetsToFile, bool physicalPrim, bool SendTasksToChild)
210 { 215 {
@@ -230,9 +235,11 @@ namespace OpenSim.Region.Environment.Scenes
230 m_LandManager = new LandManager(this, m_regInfo); 235 m_LandManager = new LandManager(this, m_regInfo);
231 236
232 //Bind Storage Manager functions to some land manager functions for this scene 237 //Bind Storage Manager functions to some land manager functions for this scene
233 EventManager.OnLandObjectAdded += new EventManager.LandObjectAdded(m_storageManager.DataStore.StoreLandObject); 238 EventManager.OnLandObjectAdded +=
234 EventManager.OnLandObjectRemoved += new EventManager.LandObjectRemoved(m_storageManager.DataStore.RemoveLandObject); 239 new EventManager.LandObjectAdded(m_storageManager.DataStore.StoreLandObject);
235 240 EventManager.OnLandObjectRemoved +=
241 new EventManager.LandObjectRemoved(m_storageManager.DataStore.RemoveLandObject);
242
236 m_estateManager = new EstateManager(this, m_regInfo); 243 m_estateManager = new EstateManager(this, m_regInfo);
237 244
238 m_permissionManager = permissionManager; 245 m_permissionManager = permissionManager;
@@ -258,7 +265,7 @@ namespace OpenSim.Region.Environment.Scenes
258 m_sceneObjects = new Dictionary<LLUUID, SceneObjectGroup>(); 265 m_sceneObjects = new Dictionary<LLUUID, SceneObjectGroup>();
259 266
260 MainLog.Instance.Verbose("SCENE", "Creating LandMap"); 267 MainLog.Instance.Verbose("SCENE", "Creating LandMap");
261 Terrain = new TerrainEngine((int)RegionInfo.RegionLocX, (int)RegionInfo.RegionLocY); 268 Terrain = new TerrainEngine((int) RegionInfo.RegionLocX, (int) RegionInfo.RegionLocY);
262 269
263 ScenePresence.LoadAnims(); 270 ScenePresence.LoadAnims();
264 271
@@ -276,7 +283,7 @@ namespace OpenSim.Region.Environment.Scenes
276 protected virtual void RegisterDefaultSceneEvents() 283 protected virtual void RegisterDefaultSceneEvents()
277 { 284 {
278 m_eventManager.OnParcelPrimCountAdd += m_LandManager.addPrimToLandPrimCounts; 285 m_eventManager.OnParcelPrimCountAdd += m_LandManager.addPrimToLandPrimCounts;
279 m_eventManager.OnParcelPrimCountUpdate += this.addPrimsToParcelCounts; 286 m_eventManager.OnParcelPrimCountUpdate += addPrimsToParcelCounts;
280 m_eventManager.OnPermissionError += SendPermissionAlert; 287 m_eventManager.OnPermissionError += SendPermissionAlert;
281 } 288 }
282 289
@@ -295,68 +302,65 @@ namespace OpenSim.Region.Environment.Scenes
295 302
296 if (RegionInfo.RegionHandle != otherRegion.RegionHandle) 303 if (RegionInfo.RegionHandle != otherRegion.RegionHandle)
297 { 304 {
298 for (int i = 0; i < m_neighbours.Count; i++) 305 for (int i = 0; i < m_neighbours.Count; i++)
306 {
307 // The purpose of this loop is to re-update the known neighbors
308 // when another region comes up on top of another one.
309 // The latest region in that location ends up in the
310 // 'known neighbors list'
311 // Additionally, the commFailTF property gets reset to false.
312 if (m_neighbours[i].RegionHandle == otherRegion.RegionHandle)
299 { 313 {
300 // The purpose of this loop is to re-update the known neighbors 314 lock (m_neighbours)
301 // when another region comes up on top of another one.
302 // The latest region in that location ends up in the
303 // 'known neighbors list'
304 // Additionally, the commFailTF property gets reset to false.
305 if (m_neighbours[i].RegionHandle == otherRegion.RegionHandle)
306 { 315 {
307 lock (m_neighbours) 316 m_neighbours[i] = otherRegion;
308 {
309 m_neighbours[i] = otherRegion;
310 }
311 } 317 }
312 } 318 }
319 }
313 320
314 // If the value isn't in the neighbours, add it. 321 // If the value isn't in the neighbours, add it.
315 // If the RegionInfo isn't exact but is for the same XY World location, 322 // If the RegionInfo isn't exact but is for the same XY World location,
316 // then the above loop will fix that. 323 // then the above loop will fix that.
317 324
318 if (!(m_neighbours.Contains(otherRegion))) 325 if (!(m_neighbours.Contains(otherRegion)))
326 {
327 lock (m_neighbours)
319 { 328 {
320 lock (m_neighbours) 329 m_neighbours.Add(otherRegion);
321 {
322 m_neighbours.Add(otherRegion);
323 }
324 } 330 }
325 if ((Math.Abs(otherRegion.RegionLocX - RegionInfo.RegionLocX) <= 1) && (Math.Abs(otherRegion.RegionLocY - RegionInfo.RegionLocY) <= 1)) 331 }
332 if ((Math.Abs(otherRegion.RegionLocX - RegionInfo.RegionLocX) <= 1) &&
333 (Math.Abs(otherRegion.RegionLocY - RegionInfo.RegionLocY) <= 1))
326 { 334 {
327 try 335 try
328 { 336 {
329
330 ForEachScenePresence(delegate(ScenePresence agent) 337 ForEachScenePresence(delegate(ScenePresence agent)
331 { 338 {
332 // If agent is a root agent. 339 // If agent is a root agent.
333 if (!agent.IsChildAgent) 340 if (!agent.IsChildAgent)
334 { 341 {
335 342 //agent.ControllingClient.new
336 //agent.ControllingClient.new 343 //this.CommsManager.InterRegion.InformRegionOfChildAgent(otherRegion.RegionHandle, agent.ControllingClient.RequestClientInfo());
337 //this.CommsManager.InterRegion.InformRegionOfChildAgent(otherRegion.RegionHandle, agent.ControllingClient.RequestClientInfo()); 344 InformClientOfNeighbor(agent, otherRegion);
338 InformClientOfNeighbor(agent, otherRegion); 345 }
339 } 346 }
340 } 347 );
341
342 );
343 } 348 }
344 catch (System.NullReferenceException) 349 catch (NullReferenceException)
345 { 350 {
346 // This means that we're not booted up completely yet. 351 // This means that we're not booted up completely yet.
347 // This shouldn't happen too often anymore. 352 // This shouldn't happen too often anymore.
348 MainLog.Instance.Error("SCENE", "Couldn't inform client of regionup because we got a null reference exception"); 353 MainLog.Instance.Error("SCENE",
354 "Couldn't inform client of regionup because we got a null reference exception");
349 } 355 }
350 } 356 }
351 else 357 else
352 { 358 {
353 MainLog.Instance.Verbose("INTERGRID", "Got notice about far away Region: " + otherRegion.RegionName.ToString() + 359 MainLog.Instance.Verbose("INTERGRID",
354 " at (" + otherRegion.RegionLocX.ToString() + ", " + otherRegion.RegionLocY.ToString() + ")" ); 360 "Got notice about far away Region: " + otherRegion.RegionName.ToString() +
361 " at (" + otherRegion.RegionLocX.ToString() + ", " +
362 otherRegion.RegionLocY.ToString() + ")");
355 } 363 }
356
357
358
359
360 } 364 }
361 return true; 365 return true;
362 } 366 }
@@ -379,11 +383,11 @@ namespace OpenSim.Region.Environment.Scenes
379 { 383 {
380 // Now we figure out what to set the timer to that does the notifications and calls, RestartNow() 384 // Now we figure out what to set the timer to that does the notifications and calls, RestartNow()
381 m_restartTimer.Interval = 15000; 385 m_restartTimer.Interval = 15000;
382 m_incrementsof15seconds = (int)seconds / 15; 386 m_incrementsof15seconds = (int) seconds/15;
383 m_RestartTimerCounter = 0; 387 m_RestartTimerCounter = 0;
384 m_restartTimer.AutoReset = true; 388 m_restartTimer.AutoReset = true;
385 m_restartTimer.Elapsed += new ElapsedEventHandler(RestartTimer_Elapsed); 389 m_restartTimer.Elapsed += new ElapsedEventHandler(RestartTimer_Elapsed);
386 MainLog.Instance.Error("REGION", "Restarting Region in " + (seconds / 60) + " minutes"); 390 MainLog.Instance.Error("REGION", "Restarting Region in " + (seconds/60) + " minutes");
387 m_restartTimer.Start(); 391 m_restartTimer.Start();
388 SendGeneralAlert(RegionInfo.RegionName + ": Restarting in 2 Minutes"); 392 SendGeneralAlert(RegionInfo.RegionName + ": Restarting in 2 Minutes");
389 } 393 }
@@ -399,7 +403,8 @@ namespace OpenSim.Region.Environment.Scenes
399 if (m_RestartTimerCounter <= m_incrementsof15seconds) 403 if (m_RestartTimerCounter <= m_incrementsof15seconds)
400 { 404 {
401 if (m_RestartTimerCounter == 4 || m_RestartTimerCounter == 6 || m_RestartTimerCounter == 7) 405 if (m_RestartTimerCounter == 4 || m_RestartTimerCounter == 6 || m_RestartTimerCounter == 7)
402 SendGeneralAlert(RegionInfo.RegionName + ": Restarting in " + ((8 - m_RestartTimerCounter) * 15) + " seconds"); 406 SendGeneralAlert(RegionInfo.RegionName + ": Restarting in " + ((8 - m_RestartTimerCounter)*15) +
407 " seconds");
403 } 408 }
404 else 409 else
405 { 410 {
@@ -432,21 +437,19 @@ namespace OpenSim.Region.Environment.Scenes
432 { 437 {
433 try 438 try
434 { 439 {
435
436 ForEachScenePresence(delegate(ScenePresence agent) 440 ForEachScenePresence(delegate(ScenePresence agent)
437 { 441 {
438 // If agent is a root agent. 442 // If agent is a root agent.
439 if (!agent.IsChildAgent) 443 if (!agent.IsChildAgent)
440 { 444 {
441 //agent.ControllingClient.new 445 //agent.ControllingClient.new
442 //this.CommsManager.InterRegion.InformRegionOfChildAgent(otherRegion.RegionHandle, agent.ControllingClient.RequestClientInfo()); 446 //this.CommsManager.InterRegion.InformRegionOfChildAgent(otherRegion.RegionHandle, agent.ControllingClient.RequestClientInfo());
443 InformClientOfNeighbor(agent, region); 447 InformClientOfNeighbor(agent, region);
444 } 448 }
445 } 449 }
446 450 );
447 );
448 } 451 }
449 catch (System.NullReferenceException) 452 catch (NullReferenceException)
450 { 453 {
451 // This means that we're not booted up completely yet. 454 // This means that we're not booted up completely yet.
452 // This shouldn't happen too often anymore. 455 // This shouldn't happen too often anymore.
@@ -464,24 +467,22 @@ namespace OpenSim.Region.Environment.Scenes
464 MainLog.Instance.Warn("SCENE", "Closing down the single simulator: " + RegionInfo.RegionName); 467 MainLog.Instance.Warn("SCENE", "Closing down the single simulator: " + RegionInfo.RegionName);
465 // Kick all ROOT agents with the message, 'The simulator is going down' 468 // Kick all ROOT agents with the message, 'The simulator is going down'
466 ForEachScenePresence(delegate(ScenePresence avatar) 469 ForEachScenePresence(delegate(ScenePresence avatar)
467 { 470 {
468 if (avatar.KnownChildRegions.Contains(RegionInfo.RegionHandle)) 471 if (avatar.KnownChildRegions.Contains(RegionInfo.RegionHandle))
469 avatar.KnownChildRegions.Remove(RegionInfo.RegionHandle); 472 avatar.KnownChildRegions.Remove(RegionInfo.RegionHandle);
470 473
471 if (!avatar.IsChildAgent) 474 if (!avatar.IsChildAgent)
472 avatar.ControllingClient.Kick("The simulator is going down."); 475 avatar.ControllingClient.Kick("The simulator is going down.");
473 476
474 avatar.ControllingClient.OutPacket(new libsecondlife.Packets.DisableSimulatorPacket(), ThrottleOutPacketType.Task); 477 avatar.ControllingClient.OutPacket(new DisableSimulatorPacket(),
475 }); 478 ThrottleOutPacketType.Task);
479 });
476 480
477 // Wait here, or the kick messages won't actually get to the agents before the scene terminates. 481 // Wait here, or the kick messages won't actually get to the agents before the scene terminates.
478 Thread.Sleep(500); 482 Thread.Sleep(500);
479 483
480 // Stop all client threads. 484 // Stop all client threads.
481 ForEachScenePresence(delegate(ScenePresence avatar) 485 ForEachScenePresence(delegate(ScenePresence avatar) { avatar.ControllingClient.Close(true); });
482 {
483 avatar.ControllingClient.Close(true);
484 });
485 // Stop updating the scene objects and agents. 486 // Stop updating the scene objects and agents.
486 m_heartbeatTimer.Close(); 487 m_heartbeatTimer.Close();
487 // close the inner scene 488 // close the inner scene
@@ -509,7 +510,7 @@ namespace OpenSim.Region.Environment.Scenes
509 public void StartTimer() 510 public void StartTimer()
510 { 511 {
511 m_heartbeatTimer.Enabled = true; 512 m_heartbeatTimer.Enabled = true;
512 m_heartbeatTimer.Interval = (int)(m_timespan * 1000); 513 m_heartbeatTimer.Interval = (int) (m_timespan*1000);
513 m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); 514 m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat);
514 } 515 }
515 516
@@ -555,30 +556,30 @@ namespace OpenSim.Region.Environment.Scenes
555 if (m_frame == Int32.MaxValue) 556 if (m_frame == Int32.MaxValue)
556 m_frame = 0; 557 m_frame = 0;
557 558
558 if (m_frame % m_update_physics == 0) 559 if (m_frame%m_update_physics == 0)
559 m_innerScene.UpdatePreparePhysics(); 560 m_innerScene.UpdatePreparePhysics();
560 561
561 if (m_frame % m_update_entitymovement == 0) 562 if (m_frame%m_update_entitymovement == 0)
562 m_innerScene.UpdateEntityMovement(); 563 m_innerScene.UpdateEntityMovement();
563 564
564 if (m_frame % m_update_physics == 0) 565 if (m_frame%m_update_physics == 0)
565 physicsFPS = m_innerScene.UpdatePhysics( 566 physicsFPS = m_innerScene.UpdatePhysics(
566 Math.Max(SinceLastFrame.TotalSeconds, m_timespan) 567 Math.Max(SinceLastFrame.TotalSeconds, m_timespan)
567 ); 568 );
568 569
569 if (m_frame % m_update_entities == 0) 570 if (m_frame%m_update_entities == 0)
570 m_innerScene.UpdateEntities(); 571 m_innerScene.UpdateEntities();
571 572
572 if (m_frame % m_update_events == 0) 573 if (m_frame%m_update_events == 0)
573 UpdateEvents(); 574 UpdateEvents();
574 575
575 if (m_frame % m_update_backup == 0) 576 if (m_frame%m_update_backup == 0)
576 UpdateStorageBackup(); 577 UpdateStorageBackup();
577 578
578 if (m_frame % m_update_terrain == 0) 579 if (m_frame%m_update_terrain == 0)
579 UpdateTerrain(); 580 UpdateTerrain();
580 581
581 if (m_frame % m_update_land == 0) 582 if (m_frame%m_update_land == 0)
582 UpdateLand(); 583 UpdateLand();
583 584
584 // if (m_frame%m_update_avatars == 0) 585 // if (m_frame%m_update_avatars == 0)
@@ -592,7 +593,6 @@ namespace OpenSim.Region.Environment.Scenes
592 m_statsReporter.SetChildAgents(m_innerScene.GetChildAgentCount()); 593 m_statsReporter.SetChildAgents(m_innerScene.GetChildAgentCount());
593 m_statsReporter.SetObjects(m_innerScene.GetTotalObjects()); 594 m_statsReporter.SetObjects(m_innerScene.GetTotalObjects());
594 m_statsReporter.SetActiveObjects(m_innerScene.GetActiveObjects()); 595 m_statsReporter.SetActiveObjects(m_innerScene.GetActiveObjects());
595
596 } 596 }
597 catch (NotImplementedException) 597 catch (NotImplementedException)
598 { 598 {
@@ -606,10 +606,11 @@ namespace OpenSim.Region.Environment.Scenes
606 { 606 {
607 updateLock.ReleaseMutex(); 607 updateLock.ReleaseMutex();
608 608
609 m_timedilation = m_timespan / (float)SinceLastFrame.TotalSeconds; 609 m_timedilation = m_timespan/(float) SinceLastFrame.TotalSeconds;
610 m_lastupdate = DateTime.Now; 610 m_lastupdate = DateTime.Now;
611 } 611 }
612 } 612 }
613
613 //Updates the time in the viewer. 614 //Updates the time in the viewer.
614 private void UpdateInWorldTime() 615 private void UpdateInWorldTime()
615 { 616 {
@@ -631,7 +632,7 @@ namespace OpenSim.Region.Environment.Scenes
631 } 632 }
632 } 633 }
633 634
634 private void SendSimStatsPackets(libsecondlife.Packets.SimStatsPacket pack) 635 private void SendSimStatsPackets(SimStatsPacket pack)
635 { 636 {
636 List<ScenePresence> StatSendAgents = GetScenePresences(); 637 List<ScenePresence> StatSendAgents = GetScenePresences();
637 foreach (ScenePresence agent in StatSendAgents) 638 foreach (ScenePresence agent in StatSendAgents)
@@ -639,11 +640,10 @@ namespace OpenSim.Region.Environment.Scenes
639 if (!agent.IsChildAgent) 640 if (!agent.IsChildAgent)
640 { 641 {
641 agent.ControllingClient.OutPacket(pack, ThrottleOutPacketType.Task); 642 agent.ControllingClient.OutPacket(pack, ThrottleOutPacketType.Task);
642
643 } 643 }
644 } 644 }
645
646 } 645 }
646
647 private void UpdateLand() 647 private void UpdateLand()
648 { 648 {
649 if (m_LandManager.landPrimCountTainted) 649 if (m_LandManager.landPrimCountTainted)
@@ -676,7 +676,7 @@ namespace OpenSim.Region.Environment.Scenes
676 { 676 {
677 for (int y = 0; y < 16; y++) 677 for (int y = 0; y < 16; y++)
678 { 678 {
679 if (Terrain.Tainted(x * 16, y * 16)) 679 if (Terrain.Tainted(x*16, y*16))
680 { 680 {
681 client.SendLayerData(x, y, terData); 681 client.SendLayerData(x, y, terData);
682 } 682 }
@@ -724,13 +724,17 @@ namespace OpenSim.Region.Environment.Scenes
724 724
725 public void ExportWorldMap(string fileName) 725 public void ExportWorldMap(string fileName)
726 { 726 {
727 List<MapBlockData> mapBlocks = this.CommsManager.GridService.RequestNeighbourMapBlocks((int)(this.RegionInfo.RegionLocX - 9), (int)(this.RegionInfo.RegionLocY - 9), (int)(this.RegionInfo.RegionLocX + 9), (int)(this.RegionInfo.RegionLocY + 9)); 727 List<MapBlockData> mapBlocks =
728 CommsManager.GridService.RequestNeighbourMapBlocks((int) (RegionInfo.RegionLocX - 9),
729 (int) (RegionInfo.RegionLocY - 9),
730 (int) (RegionInfo.RegionLocX + 9),
731 (int) (RegionInfo.RegionLocY + 9));
728 List<AssetBase> textures = new List<AssetBase>(); 732 List<AssetBase> textures = new List<AssetBase>();
729 List<System.Drawing.Image> bitImages = new List<System.Drawing.Image>(); 733 List<Image> bitImages = new List<Image>();
730 734
731 foreach (MapBlockData mapBlock in mapBlocks) 735 foreach (MapBlockData mapBlock in mapBlocks)
732 { 736 {
733 AssetBase texAsset = this.AssetCache.GetAsset(mapBlock.MapImageId, true); 737 AssetBase texAsset = AssetCache.GetAsset(mapBlock.MapImageId, true);
734 738
735 if (texAsset != null) 739 if (texAsset != null)
736 { 740 {
@@ -738,7 +742,7 @@ namespace OpenSim.Region.Environment.Scenes
738 } 742 }
739 else 743 else
740 { 744 {
741 texAsset = this.AssetCache.GetAsset(mapBlock.MapImageId, true); 745 texAsset = AssetCache.GetAsset(mapBlock.MapImageId, true);
742 if (texAsset != null) 746 if (texAsset != null)
743 { 747 {
744 textures.Add(texAsset); 748 textures.Add(texAsset);
@@ -748,22 +752,22 @@ namespace OpenSim.Region.Environment.Scenes
748 752
749 foreach (AssetBase asset in textures) 753 foreach (AssetBase asset in textures)
750 { 754 {
751 System.Drawing.Image image = OpenJPEGNet.OpenJPEG.DecodeToImage(asset.Data); 755 Image image = OpenJPEG.DecodeToImage(asset.Data);
752 bitImages.Add(image); 756 bitImages.Add(image);
753 } 757 }
754 758
755 System.Drawing.Bitmap mapTexture = new System.Drawing.Bitmap(2560, 2560); 759 Bitmap mapTexture = new Bitmap(2560, 2560);
756 System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(mapTexture); 760 Graphics g = Graphics.FromImage(mapTexture);
757 System.Drawing.SolidBrush sea = new System.Drawing.SolidBrush(System.Drawing.Color.DarkBlue); 761 SolidBrush sea = new SolidBrush(Color.DarkBlue);
758 g.FillRectangle(sea, 0, 0, 2560, 2560); 762 g.FillRectangle(sea, 0, 0, 2560, 2560);
759 763
760 for (int i = 0; i < mapBlocks.Count; i++) 764 for (int i = 0; i < mapBlocks.Count; i++)
761 { 765 {
762 ushort x = (ushort)((mapBlocks[i].X - this.RegionInfo.RegionLocX) + 10); 766 ushort x = (ushort) ((mapBlocks[i].X - RegionInfo.RegionLocX) + 10);
763 ushort y = (ushort)((mapBlocks[i].Y - this.RegionInfo.RegionLocY) + 10); 767 ushort y = (ushort) ((mapBlocks[i].Y - RegionInfo.RegionLocY) + 10);
764 g.DrawImage(bitImages[i], (x * 128), (y * 128), 128, 128); 768 g.DrawImage(bitImages[i], (x*128), (y*128), 128, 128);
765 } 769 }
766 mapTexture.Save(fileName, System.Drawing.Imaging.ImageFormat.Jpeg); 770 mapTexture.Save(fileName, ImageFormat.Jpeg);
767 } 771 }
768 772
769 /// <summary> 773 /// <summary>
@@ -861,7 +865,7 @@ namespace OpenSim.Region.Environment.Scenes
861 public void loadAllLandObjectsFromStorage() 865 public void loadAllLandObjectsFromStorage()
862 { 866 {
863 MainLog.Instance.Verbose("SCENE", "Loading land objects from storage"); 867 MainLog.Instance.Verbose("SCENE", "Loading land objects from storage");
864 List<Framework.LandData> landData = m_storageManager.DataStore.LoadLandObjects(RegionInfo.RegionID); 868 List<LandData> landData = m_storageManager.DataStore.LoadLandObjects(RegionInfo.RegionID);
865 if (landData.Count == 0) 869 if (landData.Count == 0)
866 { 870 {
867 m_LandManager.NoLandDataFromStorage(); 871 m_LandManager.NoLandDataFromStorage();
@@ -871,7 +875,7 @@ namespace OpenSim.Region.Environment.Scenes
871 m_LandManager.IncomingLandObjectsFromStorage(landData); 875 m_LandManager.IncomingLandObjectsFromStorage(landData);
872 } 876 }
873 } 877 }
874 878
875 #endregion 879 #endregion
876 880
877 #region Primitives Methods 881 #region Primitives Methods
@@ -889,8 +893,8 @@ namespace OpenSim.Region.Environment.Scenes
889 SceneObjectPart rootPart = prim.GetChildPart(prim.UUID); 893 SceneObjectPart rootPart = prim.GetChildPart(prim.UUID);
890 rootPart.ApplySanePermissions(); 894 rootPart.ApplySanePermissions();
891 895
892 bool UsePhysics = (((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Physics) > 0) && m_physicalPrim); 896 bool UsePhysics = (((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Physics) > 0) && m_physicalPrim);
893 if ((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Phantom) == 0) 897 if ((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Phantom) == 0)
894 rootPart.PhysActor = PhysicsScene.AddPrimShape( 898 rootPart.PhysActor = PhysicsScene.AddPrimShape(
895 rootPart.Name, 899 rootPart.Name,
896 rootPart.Shape, 900 rootPart.Shape,
@@ -931,9 +935,8 @@ namespace OpenSim.Region.Environment.Scenes
931 935
932 if (PermissionsMngr.CanRezObject(ownerID, pos)) 936 if (PermissionsMngr.CanRezObject(ownerID, pos))
933 { 937 {
934
935 EntityIntersection rayTracing = null; 938 EntityIntersection rayTracing = null;
936 ScenePresence presence = ((ScenePresence)GetScenePresence(ownerID)); 939 ScenePresence presence = ((ScenePresence) GetScenePresence(ownerID));
937 if (presence != null) 940 if (presence != null)
938 { 941 {
939 Vector3 CameraPosition = presence.CameraPosition; 942 Vector3 CameraPosition = presence.CameraPosition;
@@ -941,14 +944,13 @@ namespace OpenSim.Region.Environment.Scenes
941 944
942 float raydistance = m_innerScene.Vector3Distance(CameraPosition, rayEnd); 945 float raydistance = m_innerScene.Vector3Distance(CameraPosition, rayEnd);
943 946
944 Vector3 rayDirection = new Vector3(rayEnd.x / raydistance, rayEnd.y / raydistance, rayEnd.z / raydistance); 947 Vector3 rayDirection = new Vector3(rayEnd.x/raydistance, rayEnd.y/raydistance, rayEnd.z/raydistance);
945 948
946 Ray rezRay = new Ray(CameraPosition, rayDirection); 949 Ray rezRay = new Ray(CameraPosition, rayDirection);
947 950
948 Vector3 RezDirectionFromCamera = rezRay.Direction; 951 Vector3 RezDirectionFromCamera = rezRay.Direction;
949 952
950 rayTracing = m_innerScene.GetClosestIntersectingPrim(rezRay); 953 rayTracing = m_innerScene.GetClosestIntersectingPrim(rezRay);
951
952 } 954 }
953 955
954 if ((rayTracing != null) && (rayTracing.HitTF)) 956 if ((rayTracing != null) && (rayTracing.HitTF))
@@ -957,7 +959,8 @@ namespace OpenSim.Region.Environment.Scenes
957 // We will rez the object somewhere close to the prim. Better math needed. This is a Stub 959 // We will rez the object somewhere close to the prim. Better math needed. This is a Stub
958 //Vector3 Newpos = new Vector3(rayTracing.obj.AbsolutePosition.X,rayTracing.obj.AbsolutePosition.Y,rayTracing.obj.AbsolutePosition.Z); 960 //Vector3 Newpos = new Vector3(rayTracing.obj.AbsolutePosition.X,rayTracing.obj.AbsolutePosition.Y,rayTracing.obj.AbsolutePosition.Z);
959 Vector3 Newpos = rayTracing.ipoint; 961 Vector3 Newpos = rayTracing.ipoint;
960 Vector3 NewScale = new Vector3(rayTracing.obj.Scale.X, rayTracing.obj.Scale.Y, rayTracing.obj.Scale.Z); 962 Vector3 NewScale =
963 new Vector3(rayTracing.obj.Scale.X, rayTracing.obj.Scale.Y, rayTracing.obj.Scale.Z);
961 964
962 Quaternion ParentRot = rayTracing.obj.ParentGroup.Rotation; 965 Quaternion ParentRot = rayTracing.obj.ParentGroup.Rotation;
963 //Quaternion ParentRot = new Quaternion(primParentRot.W,primParentRot.X,primParentRot.Y,primParentRot.Z); 966 //Quaternion ParentRot = new Quaternion(primParentRot.W,primParentRot.X,primParentRot.Y,primParentRot.Z);
@@ -965,7 +968,7 @@ namespace OpenSim.Region.Environment.Scenes
965 LLQuaternion primLocalRot = rayTracing.obj.RotationOffset; 968 LLQuaternion primLocalRot = rayTracing.obj.RotationOffset;
966 Quaternion LocalRot = new Quaternion(primLocalRot.W, primLocalRot.X, primLocalRot.Y, primLocalRot.Z); 969 Quaternion LocalRot = new Quaternion(primLocalRot.W, primLocalRot.X, primLocalRot.Y, primLocalRot.Z);
967 970
968 Quaternion NewRot = LocalRot * ParentRot; 971 Quaternion NewRot = LocalRot*ParentRot;
969 972
970 Vector3 RezPoint = Newpos; 973 Vector3 RezPoint = Newpos;
971 974
@@ -990,8 +993,8 @@ namespace OpenSim.Region.Environment.Scenes
990 //rootPart.ObjectFlags += (uint)LLObject.ObjectFlags.Phantom; 993 //rootPart.ObjectFlags += (uint)LLObject.ObjectFlags.Phantom;
991 } 994 }
992 // if not phantom, add to physics 995 // if not phantom, add to physics
993 bool UsePhysics = (((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Physics) > 0) && m_physicalPrim); 996 bool UsePhysics = (((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Physics) > 0) && m_physicalPrim);
994 if ((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Phantom) == 0) 997 if ((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Phantom) == 0)
995 { 998 {
996 rootPart.PhysActor = 999 rootPart.PhysActor =
997 PhysicsScene.AddPrimShape( 1000 PhysicsScene.AddPrimShape(
@@ -1007,14 +1010,14 @@ namespace OpenSim.Region.Environment.Scenes
1007 } 1010 }
1008 1011
1009 public void AddTree(LLVector3 scale, LLQuaternion rotation, LLVector3 position, 1012 public void AddTree(LLVector3 scale, LLQuaternion rotation, LLVector3 position,
1010 Tree treeType, bool newTree) 1013 Tree treeType, bool newTree)
1011 { 1014 {
1012 PrimitiveBaseShape treeShape = new PrimitiveBaseShape(); 1015 PrimitiveBaseShape treeShape = new PrimitiveBaseShape();
1013 treeShape.PathCurve = 16; 1016 treeShape.PathCurve = 16;
1014 treeShape.PathEnd = 49900; 1017 treeShape.PathEnd = 49900;
1015 treeShape.PCode = newTree ? (byte)PCode.NewTree : (byte)PCode.Tree; 1018 treeShape.PCode = newTree ? (byte) PCode.NewTree : (byte) PCode.Tree;
1016 treeShape.Scale = scale; 1019 treeShape.Scale = scale;
1017 treeShape.State = (byte)treeType; 1020 treeShape.State = (byte) treeType;
1018 AddNewPrim(LLUUID.Random(), position, rotation, treeShape); 1021 AddNewPrim(LLUUID.Random(), position, rotation, treeShape);
1019 } 1022 }
1020 1023
@@ -1135,7 +1138,8 @@ namespace OpenSim.Region.Environment.Scenes
1135 client.OnParcelObjectOwnerRequest += 1138 client.OnParcelObjectOwnerRequest +=
1136 new ParcelObjectOwnerRequest(m_LandManager.handleParcelObjectOwnersRequest); 1139 new ParcelObjectOwnerRequest(m_LandManager.handleParcelObjectOwnersRequest);
1137 client.OnParcelAccessListRequest += new ParcelAccessListRequest(m_LandManager.handleParcelAccessRequest); 1140 client.OnParcelAccessListRequest += new ParcelAccessListRequest(m_LandManager.handleParcelAccessRequest);
1138 client.OnParcelAccessListUpdateRequest += new ParcelAccessListUpdateRequest(m_LandManager.handleParcelAccessUpdateRequest); 1141 client.OnParcelAccessListUpdateRequest +=
1142 new ParcelAccessListUpdateRequest(m_LandManager.handleParcelAccessUpdateRequest);
1139 1143
1140 client.OnEstateOwnerMessage += new EstateOwnerMessageRequest(m_estateManager.handleEstateOwnerMessage); 1144 client.OnEstateOwnerMessage += new EstateOwnerMessageRequest(m_estateManager.handleEstateOwnerMessage);
1141 client.OnRegionInfoRequest += m_estateManager.HandleRegionInfoRequest; 1145 client.OnRegionInfoRequest += m_estateManager.HandleRegionInfoRequest;
@@ -1157,8 +1161,8 @@ namespace OpenSim.Region.Environment.Scenes
1157 client.OnAssetUploadRequest += CommsManager.TransactionsManager.HandleUDPUploadRequest; 1161 client.OnAssetUploadRequest += CommsManager.TransactionsManager.HandleUDPUploadRequest;
1158 client.OnXferReceive += CommsManager.TransactionsManager.HandleXfer; 1162 client.OnXferReceive += CommsManager.TransactionsManager.HandleXfer;
1159 client.OnRezScript += RezScript; 1163 client.OnRezScript += RezScript;
1160 1164
1161 client.OnRequestTaskInventory += RequestTaskInventory; 1165 client.OnRequestTaskInventory += RequestTaskInventory;
1162 client.OnRemoveTaskItem += RemoveTaskInventory; 1166 client.OnRemoveTaskItem += RemoveTaskInventory;
1163 client.OnUpdateTaskInventory += UpdateTaskInventory; 1167 client.OnUpdateTaskInventory += UpdateTaskInventory;
1164 1168
@@ -1216,23 +1220,23 @@ namespace OpenSim.Region.Environment.Scenes
1216 m_innerScene.removeUserCount(true); 1220 m_innerScene.removeUserCount(true);
1217 } 1221 }
1218 } 1222 }
1219 catch (System.NullReferenceException) 1223 catch (NullReferenceException)
1220 { 1224 {
1221 // We don't know which count to remove it from 1225 // We don't know which count to remove it from
1222 // Avatar is already disposed :/ 1226 // Avatar is already disposed :/
1223 } 1227 }
1224 m_eventManager.TriggerOnRemovePresence(agentID); 1228 m_eventManager.TriggerOnRemovePresence(agentID);
1225 Broadcast(delegate(IClientAPI client) 1229 Broadcast(delegate(IClientAPI client)
1226 {
1227 try
1228 {
1229 client.SendKillObject(avatar.RegionHandle, avatar.LocalId);
1230 }
1231 catch (System.NullReferenceException)
1232 { 1230 {
1233 //We can safely ignore null reference exceptions. It means the avatar are dead and cleaned up anyway. 1231 try
1234 } 1232 {
1235 }); 1233 client.SendKillObject(avatar.RegionHandle, avatar.LocalId);
1234 }
1235 catch (NullReferenceException)
1236 {
1237 //We can safely ignore null reference exceptions. It means the avatar are dead and cleaned up anyway.
1238 }
1239 });
1236 1240
1237 ForEachScenePresence( 1241 ForEachScenePresence(
1238 delegate(ScenePresence presence) { presence.CoarseLocationChange(); }); 1242 delegate(ScenePresence presence) { presence.CoarseLocationChange(); });
@@ -1251,7 +1255,7 @@ namespace OpenSim.Region.Environment.Scenes
1251 { 1255 {
1252 avatar.Close(); 1256 avatar.Close();
1253 } 1257 }
1254 catch (System.NullReferenceException) 1258 catch (NullReferenceException)
1255 { 1259 {
1256 //We can safely ignore null reference exceptions. It means the avatar are dead and cleaned up anyway. 1260 //We can safely ignore null reference exceptions. It means the avatar are dead and cleaned up anyway.
1257 } 1261 }
@@ -1263,19 +1267,22 @@ namespace OpenSim.Region.Environment.Scenes
1263 // Remove client agent from profile, so new logins will work 1267 // Remove client agent from profile, so new logins will work
1264 CommsManager.UserService.clearUserAgent(agentID); 1268 CommsManager.UserService.clearUserAgent(agentID);
1265 } 1269 }
1266 public override void CloseAllAgents(uint circuitcode) 1270
1271 public override void CloseAllAgents(uint circuitcode)
1267 { 1272 {
1268 // Called by ClientView to kill all circuit codes 1273 // Called by ClientView to kill all circuit codes
1269 ClientManager.CloseAllAgents(circuitcode); 1274 ClientManager.CloseAllAgents(circuitcode);
1270
1271 } 1275 }
1276
1272 public void NotifyMyCoarseLocationChange() 1277 public void NotifyMyCoarseLocationChange()
1273 { 1278 {
1274 ForEachScenePresence(delegate(ScenePresence presence) { presence.CoarseLocationChange(); }); 1279 ForEachScenePresence(delegate(ScenePresence presence) { presence.CoarseLocationChange(); });
1275 } 1280 }
1281
1276 #endregion 1282 #endregion
1277 1283
1278 #region Entities 1284 #region Entities
1285
1279 /// <summary> 1286 /// <summary>
1280 /// 1287 ///
1281 /// </summary> 1288 /// </summary>
@@ -1312,7 +1319,7 @@ namespace OpenSim.Region.Environment.Scenes
1312 m_sceneGridService.OnCloseAgentConnection += CloseConnection; 1319 m_sceneGridService.OnCloseAgentConnection += CloseConnection;
1313 m_sceneGridService.OnRegionUp += OtherRegionUp; 1320 m_sceneGridService.OnRegionUp += OtherRegionUp;
1314 m_sceneGridService.OnChildAgentUpdate += IncomingChildAgentDataUpdate; 1321 m_sceneGridService.OnChildAgentUpdate += IncomingChildAgentDataUpdate;
1315 1322
1316 1323
1317 m_sceneGridService.KillObject = SendKillObject; 1324 m_sceneGridService.KillObject = SendKillObject;
1318 } 1325 }
@@ -1321,17 +1328,16 @@ namespace OpenSim.Region.Environment.Scenes
1321 /// 1328 ///
1322 /// </summary> 1329 /// </summary>
1323 public void UnRegisterReginWithComms() 1330 public void UnRegisterReginWithComms()
1324 { 1331 {
1325
1326 m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate; 1332 m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate;
1327 m_sceneGridService.OnRegionUp -= OtherRegionUp; 1333 m_sceneGridService.OnRegionUp -= OtherRegionUp;
1328 m_sceneGridService.OnExpectUser -= NewUserConnection; 1334 m_sceneGridService.OnExpectUser -= NewUserConnection;
1329 m_sceneGridService.OnAvatarCrossingIntoRegion -= AgentCrossing; 1335 m_sceneGridService.OnAvatarCrossingIntoRegion -= AgentCrossing;
1330 m_sceneGridService.OnCloseAgentConnection -= CloseConnection; 1336 m_sceneGridService.OnCloseAgentConnection -= CloseConnection;
1331 1337
1332 m_sceneGridService.Close(); 1338 m_sceneGridService.Close();
1333 } 1339 }
1334 1340
1335 1341
1336 /// <summary> 1342 /// <summary>
1337 /// 1343 ///
@@ -1344,18 +1350,19 @@ namespace OpenSim.Region.Environment.Scenes
1344 { 1350 {
1345 if (agent.CapsPath != "") 1351 if (agent.CapsPath != "")
1346 { 1352 {
1347 OpenSim.Region.Capabilities.Caps cap = 1353 Caps cap =
1348 new OpenSim.Region.Capabilities.Caps(AssetCache, httpListener, m_regInfo.ExternalHostName, httpListener.Port, 1354 new Caps(AssetCache, httpListener, m_regInfo.ExternalHostName, httpListener.Port,
1349 agent.CapsPath, agent.AgentID, m_dumpAssetsToFile); 1355 agent.CapsPath, agent.AgentID, m_dumpAssetsToFile);
1350 1356
1351 Util.SetCapsURL(agent.AgentID, "http://" + m_regInfo.ExternalHostName + ":" + httpListener.Port.ToString() + 1357 Util.SetCapsURL(agent.AgentID,
1352 "/CAPS/" + agent.CapsPath + "0000/"); 1358 "http://" + m_regInfo.ExternalHostName + ":" + httpListener.Port.ToString() +
1359 "/CAPS/" + agent.CapsPath + "0000/");
1353 cap.RegisterHandlers(); 1360 cap.RegisterHandlers();
1354 1361
1355 cap.AddNewInventoryItem = AddInventoryItem; 1362 cap.AddNewInventoryItem = AddInventoryItem;
1356 cap.ItemUpdatedCall = CapsUpdateInventoryItemAsset; 1363 cap.ItemUpdatedCall = CapsUpdateInventoryItemAsset;
1357 cap.TaskScriptUpdatedCall = CapsUpdateTaskInventoryScriptAsset; 1364 cap.TaskScriptUpdatedCall = CapsUpdateTaskInventoryScriptAsset;
1358 1365
1359 if (m_capsHandlers.ContainsKey(agent.AgentID)) 1366 if (m_capsHandlers.ContainsKey(agent.AgentID))
1360 { 1367 {
1361 //MainLog.Instance.Warn("client", "Adding duplicate CAPS entry for user " + 1368 //MainLog.Instance.Warn("client", "Adding duplicate CAPS entry for user " +
@@ -1364,7 +1371,7 @@ namespace OpenSim.Region.Environment.Scenes
1364 { 1371 {
1365 m_capsHandlers[agent.AgentID] = cap; 1372 m_capsHandlers[agent.AgentID] = cap;
1366 } 1373 }
1367 catch (System.Collections.Generic.KeyNotFoundException) 1374 catch (KeyNotFoundException)
1368 { 1375 {
1369 // Fix for a potential race condition. 1376 // Fix for a potential race condition.
1370 m_capsHandlers.Add(agent.AgentID, cap); 1377 m_capsHandlers.Add(agent.AgentID, cap);
@@ -1396,10 +1403,10 @@ namespace OpenSim.Region.Environment.Scenes
1396 { 1403 {
1397 m_scenePresences[agentID].MakeRootAgent(position, isFlying); 1404 m_scenePresences[agentID].MakeRootAgent(position, isFlying);
1398 } 1405 }
1399 catch (System.Exception e) 1406 catch (Exception e)
1400 { 1407 {
1401 MainLog.Instance.Verbose("SCENE", "Unable to do Agent Crossing."); 1408 MainLog.Instance.Verbose("SCENE", "Unable to do Agent Crossing.");
1402 MainLog.Instance.Debug("SCENE",e.ToString()); 1409 MainLog.Instance.Debug("SCENE", e.ToString());
1403 } 1410 }
1404 //m_innerScene.SwapRootChildAgent(false); 1411 //m_innerScene.SwapRootChildAgent(false);
1405 } 1412 }
@@ -1419,11 +1426,11 @@ namespace OpenSim.Region.Environment.Scenes
1419 childAgentUpdate.ChildAgentDataUpdate(cAgentData); 1426 childAgentUpdate.ChildAgentDataUpdate(cAgentData);
1420 // Not Implemented: 1427 // Not Implemented:
1421 //TODO: Do we need to pass the message on to one of our neighbors? 1428 //TODO: Do we need to pass the message on to one of our neighbors?
1422
1423 } 1429 }
1424 } 1430 }
1425 return true; 1431 return true;
1426 } 1432 }
1433
1427 /// <summary> 1434 /// <summary>
1428 /// Tell a single agent to disconnect from the region. 1435 /// Tell a single agent to disconnect from the region.
1429 /// </summary> 1436 /// </summary>
@@ -1445,7 +1452,7 @@ namespace OpenSim.Region.Environment.Scenes
1445 m_innerScene.removeUserCount(true); 1452 m_innerScene.removeUserCount(true);
1446 } 1453 }
1447 // Tell a single agent to disconnect from the region. 1454 // Tell a single agent to disconnect from the region.
1448 libsecondlife.Packets.DisableSimulatorPacket disable = new libsecondlife.Packets.DisableSimulatorPacket(); 1455 DisableSimulatorPacket disable = new DisableSimulatorPacket();
1449 presence.ControllingClient.OutPacket(disable, ThrottleOutPacketType.Task); 1456 presence.ControllingClient.OutPacket(disable, ThrottleOutPacketType.Task);
1450 } 1457 }
1451 } 1458 }
@@ -1511,7 +1518,8 @@ namespace OpenSim.Region.Environment.Scenes
1511 { 1518 {
1512 if (m_scenePresences.ContainsKey(remoteClient.AgentId)) 1519 if (m_scenePresences.ContainsKey(remoteClient.AgentId))
1513 { 1520 {
1514 m_sceneGridService.RequestTeleportToLocation(m_scenePresences[remoteClient.AgentId], regionHandle, position, lookAt, flags); 1521 m_sceneGridService.RequestTeleportToLocation(m_scenePresences[remoteClient.AgentId], regionHandle,
1522 position, lookAt, flags);
1515 } 1523 }
1516 } 1524 }
1517 1525
@@ -1551,9 +1559,9 @@ namespace OpenSim.Region.Environment.Scenes
1551 /// <param name="mod"></param> 1559 /// <param name="mod"></param>
1552 public void RegisterModuleInterface<M>(M mod) 1560 public void RegisterModuleInterface<M>(M mod)
1553 { 1561 {
1554 if (!ModuleInterfaces.ContainsKey(typeof(M))) 1562 if (!ModuleInterfaces.ContainsKey(typeof (M)))
1555 { 1563 {
1556 ModuleInterfaces.Add(typeof(M), mod); 1564 ModuleInterfaces.Add(typeof (M), mod);
1557 } 1565 }
1558 } 1566 }
1559 1567
@@ -1563,9 +1571,9 @@ namespace OpenSim.Region.Environment.Scenes
1563 /// <returns></returns> 1571 /// <returns></returns>
1564 public T RequestModuleInterface<T>() 1572 public T RequestModuleInterface<T>()
1565 { 1573 {
1566 if (ModuleInterfaces.ContainsKey(typeof(T))) 1574 if (ModuleInterfaces.ContainsKey(typeof (T)))
1567 { 1575 {
1568 return (T)ModuleInterfaces[typeof(T)]; 1576 return (T) ModuleInterfaces[typeof (T)];
1569 } 1577 }
1570 else 1578 else
1571 { 1579 {
@@ -1642,7 +1650,7 @@ namespace OpenSim.Region.Environment.Scenes
1642 { 1650 {
1643 if (obj is SceneObjectGroup) 1651 if (obj is SceneObjectGroup)
1644 { 1652 {
1645 m_eventManager.TriggerParcelPrimCountAdd((SceneObjectGroup)obj); 1653 m_eventManager.TriggerParcelPrimCountAdd((SceneObjectGroup) obj);
1646 } 1654 }
1647 } 1655 }
1648 } 1656 }
@@ -1650,6 +1658,7 @@ namespace OpenSim.Region.Environment.Scenes
1650 #endregion 1658 #endregion
1651 1659
1652 #region Console Commands 1660 #region Console Commands
1661
1653 #region Alert Methods 1662 #region Alert Methods
1654 1663
1655 private void SendPermissionAlert(LLUUID user, string reason) 1664 private void SendPermissionAlert(LLUUID user, string reason)
@@ -1692,7 +1701,8 @@ namespace OpenSim.Region.Environment.Scenes
1692 /// <param name="sessionID"></param> 1701 /// <param name="sessionID"></param>
1693 /// <param name="token"></param> 1702 /// <param name="token"></param>
1694 /// <param name="controllingClient"></param> 1703 /// <param name="controllingClient"></param>
1695 public void handleRequestGodlikePowers(LLUUID agentID, LLUUID sessionID, LLUUID token, IClientAPI controllingClient) 1704 public void handleRequestGodlikePowers(LLUUID agentID, LLUUID sessionID, LLUUID token,
1705 IClientAPI controllingClient)
1696 { 1706 {
1697 // First check that this is the sim owner 1707 // First check that this is the sim owner
1698 if (agentID == RegionInfo.MasterAvatarAssignedUUID) 1708 if (agentID == RegionInfo.MasterAvatarAssignedUUID)
@@ -1736,37 +1746,38 @@ namespace OpenSim.Region.Environment.Scenes
1736 if (agentID == kickUserID) 1746 if (agentID == kickUserID)
1737 { 1747 {
1738 ClientManager.ForEachClient(delegate(IClientAPI controller) 1748 ClientManager.ForEachClient(delegate(IClientAPI controller)
1739 {
1740 ScenePresence p = GetScenePresence(controller.AgentId);
1741 bool childagent = !p.Equals(null) && p.IsChildAgent;
1742 if (controller.AgentId != godID && !childagent) // Do we really want to kick the initiator of this madness?
1743 { 1749 {
1744 controller.Kick(Helpers.FieldToUTF8String(reason)); 1750 ScenePresence p = GetScenePresence(controller.AgentId);
1745 1751 bool childagent = !p.Equals(null) && p.IsChildAgent;
1746 if (childagent) 1752 if (controller.AgentId != godID && !childagent)
1753 // Do we really want to kick the initiator of this madness?
1747 { 1754 {
1748 m_innerScene.removeUserCount(false); 1755 controller.Kick(Helpers.FieldToUTF8String(reason));
1756
1757 if (childagent)
1758 {
1759 m_innerScene.removeUserCount(false);
1760 }
1761 else
1762 {
1763 m_innerScene.removeUserCount(true);
1764 }
1749 } 1765 }
1750 else
1751 {
1752 m_innerScene.removeUserCount(true);
1753 }
1754
1755 } 1766 }
1756 }
1757 ); 1767 );
1758 // This is a bit crude. It seems the client will be null before it actually stops the thread 1768 // This is a bit crude. It seems the client will be null before it actually stops the thread
1759 // The thread will kill itself eventually :/ 1769 // The thread will kill itself eventually :/
1760 // Is there another way to make sure *all* clients get this 'inter region' message? 1770 // Is there another way to make sure *all* clients get this 'inter region' message?
1761 ClientManager.ForEachClient(delegate(IClientAPI controller) 1771 ClientManager.ForEachClient(delegate(IClientAPI controller)
1762 {
1763 ScenePresence p = GetScenePresence(controller.AgentId);
1764 bool childagent = !p.Equals(null) && p.IsChildAgent;
1765 if (controller.AgentId != godID && !childagent) // Do we really want to kick the initiator of this madness?
1766 { 1772 {
1767 controller.Close(true); 1773 ScenePresence p = GetScenePresence(controller.AgentId);
1774 bool childagent = !p.Equals(null) && p.IsChildAgent;
1775 if (controller.AgentId != godID && !childagent)
1776 // Do we really want to kick the initiator of this madness?
1777 {
1778 controller.Close(true);
1779 }
1768 } 1780 }
1769 }
1770 ); 1781 );
1771 } 1782 }
1772 else 1783 else
@@ -1799,7 +1810,8 @@ namespace OpenSim.Region.Environment.Scenes
1799 /// <param name="agentID"></param> 1810 /// <param name="agentID"></param>
1800 /// <param name="sessionID"></param> 1811 /// <param name="sessionID"></param>
1801 /// <param name="permChanges"></param> 1812 /// <param name="permChanges"></param>
1802 public void HandleObjectPermissionsUpdate(IClientAPI controller, LLUUID agentID, LLUUID sessionID, List<libsecondlife.Packets.ObjectPermissionsPacket.ObjectDataBlock> permChanges) 1813 public void HandleObjectPermissionsUpdate(IClientAPI controller, LLUUID agentID, LLUUID sessionID,
1814 List<ObjectPermissionsPacket.ObjectDataBlock> permChanges)
1803 { 1815 {
1804 // Check for spoofing.. since this is permissions we're talking about here! 1816 // Check for spoofing.. since this is permissions we're talking about here!
1805 if ((controller.SessionId == sessionID) && (controller.AgentId == agentID)) 1817 if ((controller.SessionId == sessionID) && (controller.AgentId == agentID))
@@ -1879,7 +1891,7 @@ namespace OpenSim.Region.Environment.Scenes
1879 { 1891 {
1880 if (ent is SceneObjectGroup) 1892 if (ent is SceneObjectGroup)
1881 { 1893 {
1882 ((SceneObjectGroup)ent).ScheduleGroupForFullUpdate(); 1894 ((SceneObjectGroup) ent).ScheduleGroupForFullUpdate();
1883 } 1895 }
1884 } 1896 }
1885 } 1897 }
@@ -1899,7 +1911,7 @@ namespace OpenSim.Region.Environment.Scenes
1899 { 1911 {
1900 if (ent is SceneObjectGroup) 1912 if (ent is SceneObjectGroup)
1901 { 1913 {
1902 SceneObjectPart part = ((SceneObjectGroup)ent).GetChildPart(((SceneObjectGroup)ent).UUID); 1914 SceneObjectPart part = ((SceneObjectGroup) ent).GetChildPart(((SceneObjectGroup) ent).UUID);
1903 if (part != null) 1915 if (part != null)
1904 { 1916 {
1905 if (part.Name == cmdparams[0]) 1917 if (part.Name == cmdparams[0])
@@ -1967,10 +1979,12 @@ namespace OpenSim.Region.Environment.Scenes
1967 { 1979 {
1968 m_eventManager.TriggerOnPluginConsole(args); 1980 m_eventManager.TriggerOnPluginConsole(args);
1969 } 1981 }
1982
1970 public double GetLandHeight(int x, int y) 1983 public double GetLandHeight(int x, int y)
1971 { 1984 {
1972 return Terrain.GetHeight(x, y); 1985 return Terrain.GetHeight(x, y);
1973 } 1986 }
1987
1974 public LLUUID GetLandOwner(float x, float y) 1988 public LLUUID GetLandOwner(float x, float y)
1975 { 1989 {
1976 Land land = LandManager.getLandObject(x, y); 1990 Land land = LandManager.getLandObject(x, y);
@@ -1983,7 +1997,7 @@ namespace OpenSim.Region.Environment.Scenes
1983 return land.landData.ownerID; 1997 return land.landData.ownerID;
1984 } 1998 }
1985 } 1999 }
1986 2000
1987 public LandData GetLandData(float x, float y) 2001 public LandData GetLandData(float x, float y)
1988 { 2002 {
1989 return LandManager.getLandObject(x, y).landData; 2003 return LandManager.getLandObject(x, y).landData;
@@ -2034,6 +2048,7 @@ namespace OpenSim.Region.Environment.Scenes
2034 { 2048 {
2035 return m_innerScene.ConvertLocalIDToFullID(localID); 2049 return m_innerScene.ConvertLocalIDToFullID(localID);
2036 } 2050 }
2051
2037 public void SwapRootAgentCount(bool rootChildChildRootTF) 2052 public void SwapRootAgentCount(bool rootChildChildRootTF)
2038 { 2053 {
2039 m_innerScene.SwapRootChildAgent(rootChildChildRootTF); 2054 m_innerScene.SwapRootChildAgent(rootChildChildRootTF);
@@ -2108,13 +2123,16 @@ namespace OpenSim.Region.Environment.Scenes
2108 // We don't want to try to send messages if there are no avatar. 2123 // We don't want to try to send messages if there are no avatar.
2109 if (!(m_scenePresences.Equals(null))) 2124 if (!(m_scenePresences.Equals(null)))
2110 { 2125 {
2111 try { 2126 try
2112 List<ScenePresence> presenceList = GetScenePresences(); 2127 {
2128 List<ScenePresence> presenceList = GetScenePresences();
2113 foreach (ScenePresence presence in presenceList) 2129 foreach (ScenePresence presence in presenceList)
2114 { 2130 {
2115 action(presence); 2131 action(presence);
2116 } 2132 }
2117 } catch (Exception e) { 2133 }
2134 catch (Exception e)
2135 {
2118 MainLog.Instance.Verbose("BUG", e.ToString()); 2136 MainLog.Instance.Verbose("BUG", e.ToString());
2119 } 2137 }
2120 } 2138 }
@@ -2181,4 +2199,4 @@ namespace OpenSim.Region.Environment.Scenes
2181 2199
2182 #endregion 2200 #endregion
2183 } 2201 }
2184} 2202} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Scenes/SceneBase.cs b/OpenSim/Region/Environment/Scenes/SceneBase.cs
index 35d88eb..fe8f8da 100644
--- a/OpenSim/Region/Environment/Scenes/SceneBase.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneBase.cs
@@ -26,8 +26,6 @@
26* 26*
27*/ 27*/
28using System; 28using System;
29using System.Collections.Generic;
30using System.Timers;
31using libsecondlife; 29using libsecondlife;
32using OpenSim.Framework; 30using OpenSim.Framework;
33using OpenSim.Framework.Communications.Cache; 31using OpenSim.Framework.Communications.Cache;
@@ -43,8 +41,9 @@ namespace OpenSim.Region.Environment.Scenes
43 public event restart OnRestart; 41 public event restart OnRestart;
44 42
45 #endregion 43 #endregion
46 44
47 #region Fields 45 #region Fields
46
48 private readonly ClientManager m_clientManager = new ClientManager(); 47 private readonly ClientManager m_clientManager = new ClientManager();
49 48
50 public ClientManager ClientManager 49 public ClientManager ClientManager
@@ -92,8 +91,6 @@ namespace OpenSim.Region.Environment.Scenes
92 /// </summary> 91 /// </summary>
93 public abstract void Update(); 92 public abstract void Update();
94 93
95
96
97 #endregion 94 #endregion
98 95
99 #region Terrain Methods 96 #region Terrain Methods
@@ -163,8 +160,8 @@ namespace OpenSim.Region.Environment.Scenes
163 160
164 public abstract bool OtherRegionUp(RegionInfo thisRegion); 161 public abstract bool OtherRegionUp(RegionInfo thisRegion);
165 162
166
167 #endregion 163 #endregion
164
168 #region Shutdown 165 #region Shutdown
169 166
170 /// <summary> 167 /// <summary>
@@ -184,4 +181,4 @@ namespace OpenSim.Region.Environment.Scenes
184 181
185 #endregion 182 #endregion
186 } 183 }
187} 184} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs
index b184af2..3942397 100644
--- a/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs
@@ -1,4 +1,4 @@
1/* 1/*
2* Copyright (c) Contributors, http://opensimulator.org/ 2* Copyright (c) Contributors, http://opensimulator.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
@@ -29,11 +29,10 @@
29using System; 29using System;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Net; 31using System.Net;
32using System.Text;
33using libsecondlife; 32using libsecondlife;
34using OpenSim.Framework; 33using OpenSim.Framework;
35using OpenSim.Framework.Console;
36using OpenSim.Framework.Communications; 34using OpenSim.Framework.Communications;
35using OpenSim.Framework.Console;
37 36
38namespace OpenSim.Region.Environment.Scenes 37namespace OpenSim.Region.Environment.Scenes
39{ 38{
@@ -52,7 +51,7 @@ namespace OpenSim.Region.Environment.Scenes
52 public event PrimCrossing OnPrimCrossingIntoRegion; 51 public event PrimCrossing OnPrimCrossingIntoRegion;
53 public event RegionUp OnRegionUp; 52 public event RegionUp OnRegionUp;
54 public event ChildAgentUpdate OnChildAgentUpdate; 53 public event ChildAgentUpdate OnChildAgentUpdate;
55 54
56 55
57 public KillObjectDelegate KillObject; 56 public KillObjectDelegate KillObject;
58 public string _debugRegionName = ""; 57 public string _debugRegionName = "";
@@ -60,10 +59,7 @@ namespace OpenSim.Region.Environment.Scenes
60 public string debugRegionName 59 public string debugRegionName
61 { 60 {
62 get { return _debugRegionName; } 61 get { return _debugRegionName; }
63 set 62 set { _debugRegionName = value; }
64 {
65 _debugRegionName = value;
66 }
67 } 63 }
68 64
69 public SceneCommunicationService(CommunicationsManager commsMan) 65 public SceneCommunicationService(CommunicationsManager commsMan)
@@ -90,7 +86,6 @@ namespace OpenSim.Region.Environment.Scenes
90 regionCommsHost.OnCloseAgentConnection += CloseConnection; 86 regionCommsHost.OnCloseAgentConnection += CloseConnection;
91 regionCommsHost.OnRegionUp += newRegionUp; 87 regionCommsHost.OnRegionUp += newRegionUp;
92 regionCommsHost.OnChildAgentUpdate += ChildAgentUpdate; 88 regionCommsHost.OnChildAgentUpdate += ChildAgentUpdate;
93
94 } 89 }
95 else 90 else
96 { 91 {
@@ -102,7 +97,6 @@ namespace OpenSim.Region.Environment.Scenes
102 { 97 {
103 if (regionCommsHost != null) 98 if (regionCommsHost != null)
104 { 99 {
105
106 regionCommsHost.OnChildAgentUpdate -= ChildAgentUpdate; 100 regionCommsHost.OnChildAgentUpdate -= ChildAgentUpdate;
107 regionCommsHost.OnRegionUp -= newRegionUp; 101 regionCommsHost.OnRegionUp -= newRegionUp;
108 regionCommsHost.OnExpectUser -= NewUserConnection; 102 regionCommsHost.OnExpectUser -= NewUserConnection;
@@ -115,6 +109,7 @@ namespace OpenSim.Region.Environment.Scenes
115 } 109 }
116 110
117 #region CommsManager Event handlers 111 #region CommsManager Event handlers
112
118 /// <summary> 113 /// <summary>
119 /// 114 ///
120 /// </summary> 115 /// </summary>
@@ -139,6 +134,7 @@ namespace OpenSim.Region.Environment.Scenes
139 } 134 }
140 return true; 135 return true;
141 } 136 }
137
142 protected bool ChildAgentUpdate(ulong regionHandle, ChildAgentDataUpdate cAgentData) 138 protected bool ChildAgentUpdate(ulong regionHandle, ChildAgentDataUpdate cAgentData)
143 { 139 {
144 if (OnChildAgentUpdate != null) 140 if (OnChildAgentUpdate != null)
@@ -155,6 +151,7 @@ namespace OpenSim.Region.Environment.Scenes
155 OnAvatarCrossingIntoRegion(regionHandle, agentID, position, isFlying); 151 OnAvatarCrossingIntoRegion(regionHandle, agentID, position, isFlying);
156 } 152 }
157 } 153 }
154
158 protected void PrimCrossing(ulong regionHandle, LLUUID primID, LLVector3 position, bool isPhysical) 155 protected void PrimCrossing(ulong regionHandle, LLUUID primID, LLVector3 position, bool isPhysical)
159 { 156 {
160 if (OnPrimCrossingIntoRegion != null) 157 if (OnPrimCrossingIntoRegion != null)
@@ -174,12 +171,13 @@ namespace OpenSim.Region.Environment.Scenes
174 #endregion 171 #endregion
175 172
176 #region Inform Client of Neighbours 173 #region Inform Client of Neighbours
174
177 private delegate void InformClientOfNeighbourDelegate( 175 private delegate void InformClientOfNeighbourDelegate(
178 ScenePresence avatar, AgentCircuitData a, ulong regionHandle, IPEndPoint endPoint); 176 ScenePresence avatar, AgentCircuitData a, ulong regionHandle, IPEndPoint endPoint);
179 177
180 private void InformClientOfNeighbourCompleted(IAsyncResult iar) 178 private void InformClientOfNeighbourCompleted(IAsyncResult iar)
181 { 179 {
182 InformClientOfNeighbourDelegate icon = (InformClientOfNeighbourDelegate)iar.AsyncState; 180 InformClientOfNeighbourDelegate icon = (InformClientOfNeighbourDelegate) iar.AsyncState;
183 icon.EndInvoke(iar); 181 icon.EndInvoke(iar);
184 } 182 }
185 183
@@ -215,8 +213,6 @@ namespace OpenSim.Region.Environment.Scenes
215 213
216 //blah.Address = region.RemotingAddress; 214 //blah.Address = region.RemotingAddress;
217 //blah.Port = region.RemotingPort; 215 //blah.Port = region.RemotingPort;
218
219
220 } 216 }
221 217
222 /// <summary> 218 /// <summary>
@@ -227,7 +223,7 @@ namespace OpenSim.Region.Environment.Scenes
227 { 223 {
228 List<SimpleRegionInfo> neighbours = new List<SimpleRegionInfo>(); 224 List<SimpleRegionInfo> neighbours = new List<SimpleRegionInfo>();
229 225
230 //m_commsProvider.GridService.RequestNeighbours(m_regionInfo.RegionLocX, m_regionInfo.RegionLocY); 226 //m_commsProvider.GridService.RequestNeighbours(m_regionInfo.RegionLocX, m_regionInfo.RegionLocY);
231 for (int i = 0; i < lstneighbours.Count; i++) 227 for (int i = 0; i < lstneighbours.Count; i++)
232 { 228 {
233 // We don't want to keep sending to regions that consistently fail on comms. 229 // We don't want to keep sending to regions that consistently fail on comms.
@@ -245,7 +241,6 @@ namespace OpenSim.Region.Environment.Scenes
245 { 241 {
246 for (int i = 0; i < neighbours.Count; i++) 242 for (int i = 0; i < neighbours.Count; i++)
247 { 243 {
248
249 AgentCircuitData agent = avatar.ControllingClient.RequestClientInfo(); 244 AgentCircuitData agent = avatar.ControllingClient.RequestClientInfo();
250 agent.BaseFolder = LLUUID.Zero; 245 agent.BaseFolder = LLUUID.Zero;
251 agent.InventoryFolder = LLUUID.Zero; 246 agent.InventoryFolder = LLUUID.Zero;
@@ -259,6 +254,7 @@ namespace OpenSim.Region.Environment.Scenes
259 } 254 }
260 } 255 }
261 } 256 }
257
262 /// <summary> 258 /// <summary>
263 /// This informs a single neighboring region about agent "avatar". 259 /// This informs a single neighboring region about agent "avatar".
264 /// Calls an asynchronous method to do so.. so it doesn't lag the sim. 260 /// Calls an asynchronous method to do so.. so it doesn't lag the sim.
@@ -278,11 +274,12 @@ namespace OpenSim.Region.Environment.Scenes
278 } 274 }
279 275
280 #endregion 276 #endregion
277
281 public delegate void InformNeighbourThatRegionUpDelegate(RegionInfo region, ulong regionhandle); 278 public delegate void InformNeighbourThatRegionUpDelegate(RegionInfo region, ulong regionhandle);
282 279
283 private void InformNeighborsThatRegionisUpCompleted(IAsyncResult iar) 280 private void InformNeighborsThatRegionisUpCompleted(IAsyncResult iar)
284 { 281 {
285 InformNeighbourThatRegionUpDelegate icon = (InformNeighbourThatRegionUpDelegate)iar.AsyncState; 282 InformNeighbourThatRegionUpDelegate icon = (InformNeighbourThatRegionUpDelegate) iar.AsyncState;
286 icon.EndInvoke(iar); 283 icon.EndInvoke(iar);
287 } 284 }
288 285
@@ -290,7 +287,8 @@ namespace OpenSim.Region.Environment.Scenes
290 private void InformNeighboursThatRegionIsUpAsync(RegionInfo region, ulong regionhandle) 287 private void InformNeighboursThatRegionIsUpAsync(RegionInfo region, ulong regionhandle)
291 { 288 {
292 MainLog.Instance.Notice("INTERGRID", "Starting to inform neighbors that I'm here"); 289 MainLog.Instance.Notice("INTERGRID", "Starting to inform neighbors that I'm here");
293 bool regionAccepted = m_commsProvider.InterRegion.RegionUp((new SearializableRegionInfo(region)), regionhandle); 290 bool regionAccepted =
291 m_commsProvider.InterRegion.RegionUp((new SearializableRegionInfo(region)), regionhandle);
294 292
295 if (regionAccepted) 293 if (regionAccepted)
296 { 294 {
@@ -301,6 +299,7 @@ namespace OpenSim.Region.Environment.Scenes
301 MainLog.Instance.Notice("INTERGRID", "Failed to inform neighbors that I'm here"); 299 MainLog.Instance.Notice("INTERGRID", "Failed to inform neighbors that I'm here");
302 } 300 }
303 } 301 }
302
304 /// <summary> 303 /// <summary>
305 /// Called by scene when region is initialized (not always when it's listening for agents) 304 /// Called by scene when region is initialized (not always when it's listening for agents)
306 /// This is an inter-region message that informs the surrounding neighbors that the sim is up. 305 /// This is an inter-region message that informs the surrounding neighbors that the sim is up.
@@ -317,7 +316,6 @@ namespace OpenSim.Region.Environment.Scenes
317 { 316 {
318 for (int i = 0; i < neighbours.Count; i++) 317 for (int i = 0; i < neighbours.Count; i++)
319 { 318 {
320
321 InformNeighbourThatRegionUpDelegate d = InformNeighboursThatRegionIsUpAsync; 319 InformNeighbourThatRegionUpDelegate d = InformNeighboursThatRegionIsUpAsync;
322 320
323 d.BeginInvoke(region, neighbours[i].RegionHandle, 321 d.BeginInvoke(region, neighbours[i].RegionHandle,
@@ -325,9 +323,10 @@ namespace OpenSim.Region.Environment.Scenes
325 d); 323 d);
326 } 324 }
327 } 325 }
328 326
329 //bool val = m_commsProvider.InterRegion.RegionUp(new SearializableRegionInfo(region)); 327 //bool val = m_commsProvider.InterRegion.RegionUp(new SearializableRegionInfo(region));
330 } 328 }
329
331 public delegate void SendChildAgentDataUpdateDelegate(ulong regionHandle, ChildAgentDataUpdate cAgentData); 330 public delegate void SendChildAgentDataUpdateDelegate(ulong regionHandle, ChildAgentDataUpdate cAgentData);
332 331
333 /// <summary> 332 /// <summary>
@@ -340,7 +339,7 @@ namespace OpenSim.Region.Environment.Scenes
340 private void SendChildAgentDataUpdateAsync(ulong regionHandle, ChildAgentDataUpdate cAgentData) 339 private void SendChildAgentDataUpdateAsync(ulong regionHandle, ChildAgentDataUpdate cAgentData)
341 { 340 {
342 MainLog.Instance.Notice("INTERGRID", "Informing a neighbor about my agent."); 341 MainLog.Instance.Notice("INTERGRID", "Informing a neighbor about my agent.");
343 bool regionAccepted = m_commsProvider.InterRegion.ChildAgentUpdate(regionHandle,cAgentData); 342 bool regionAccepted = m_commsProvider.InterRegion.ChildAgentUpdate(regionHandle, cAgentData);
344 343
345 if (regionAccepted) 344 if (regionAccepted)
346 { 345 {
@@ -351,11 +350,13 @@ namespace OpenSim.Region.Environment.Scenes
351 MainLog.Instance.Notice("INTERGRID", "Failed sending a neighbor an update about my agent"); 350 MainLog.Instance.Notice("INTERGRID", "Failed sending a neighbor an update about my agent");
352 } 351 }
353 } 352 }
353
354 private void SendChildAgentDataUpdateCompleted(IAsyncResult iar) 354 private void SendChildAgentDataUpdateCompleted(IAsyncResult iar)
355 { 355 {
356 SendChildAgentDataUpdateDelegate icon = (SendChildAgentDataUpdateDelegate)iar.AsyncState; 356 SendChildAgentDataUpdateDelegate icon = (SendChildAgentDataUpdateDelegate) iar.AsyncState;
357 icon.EndInvoke(iar); 357 icon.EndInvoke(iar);
358 } 358 }
359
359 public void SendChildAgentDataUpdate(ulong regionHandle, ChildAgentDataUpdate cAgentData) 360 public void SendChildAgentDataUpdate(ulong regionHandle, ChildAgentDataUpdate cAgentData)
360 { 361 {
361 // This assumes that we know what our neighbors are. 362 // This assumes that we know what our neighbors are.
@@ -363,9 +364,8 @@ namespace OpenSim.Region.Environment.Scenes
363 d.BeginInvoke(regionHandle, cAgentData, 364 d.BeginInvoke(regionHandle, cAgentData,
364 SendChildAgentDataUpdateCompleted, 365 SendChildAgentDataUpdateCompleted,
365 d); 366 d);
366
367 } 367 }
368 368
369 369
370 /// <summary> 370 /// <summary>
371 /// Helper function to request neighbors from grid-comms 371 /// Helper function to request neighbors from grid-comms
@@ -401,15 +401,13 @@ namespace OpenSim.Region.Environment.Scenes
401 /// <param name="lookAt"></param> 401 /// <param name="lookAt"></param>
402 /// <param name="flags"></param> 402 /// <param name="flags"></param>
403 public virtual void RequestTeleportToLocation(ScenePresence avatar, ulong regionHandle, LLVector3 position, 403 public virtual void RequestTeleportToLocation(ScenePresence avatar, ulong regionHandle, LLVector3 position,
404 LLVector3 lookAt, uint flags) 404 LLVector3 lookAt, uint flags)
405 { 405 {
406 if (regionHandle == m_regionInfo.RegionHandle) 406 if (regionHandle == m_regionInfo.RegionHandle)
407 { 407 {
408
409 avatar.ControllingClient.SendTeleportLocationStart(); 408 avatar.ControllingClient.SendTeleportLocationStart();
410 avatar.ControllingClient.SendLocalTeleport(position, lookAt, flags); 409 avatar.ControllingClient.SendLocalTeleport(position, lookAt, flags);
411 avatar.Teleport(position); 410 avatar.Teleport(position);
412
413 } 411 }
414 else 412 else
415 { 413 {
@@ -424,20 +422,22 @@ namespace OpenSim.Region.Environment.Scenes
424 agent.child = true; 422 agent.child = true;
425 avatar.Close(); 423 avatar.Close();
426 m_commsProvider.InterRegion.InformRegionOfChildAgent(regionHandle, agent); 424 m_commsProvider.InterRegion.InformRegionOfChildAgent(regionHandle, agent);
427 m_commsProvider.InterRegion.ExpectAvatarCrossing(regionHandle, avatar.ControllingClient.AgentId, position, false); 425 m_commsProvider.InterRegion.ExpectAvatarCrossing(regionHandle, avatar.ControllingClient.AgentId,
426 position, false);
428 AgentCircuitData circuitdata = avatar.ControllingClient.RequestClientInfo(); 427 AgentCircuitData circuitdata = avatar.ControllingClient.RequestClientInfo();
429 string capsPath = Util.GetCapsURL(avatar.ControllingClient.AgentId); 428 string capsPath = Util.GetCapsURL(avatar.ControllingClient.AgentId);
430 avatar.ControllingClient.SendRegionTeleport(regionHandle, 13, reg.ExternalEndPoint, 4, (1 << 4), capsPath); 429 avatar.ControllingClient.SendRegionTeleport(regionHandle, 13, reg.ExternalEndPoint, 4, (1 << 4),
430 capsPath);
431 avatar.MakeChildAgent(); 431 avatar.MakeChildAgent();
432 if (KillObject != null) 432 if (KillObject != null)
433 { 433 {
434 KillObject(avatar.LocalId); 434 KillObject(avatar.LocalId);
435 } 435 }
436 uint newRegionX = (uint)(regionHandle >> 40); 436 uint newRegionX = (uint) (regionHandle >> 40);
437 uint newRegionY = (((uint)(regionHandle)) >> 8); 437 uint newRegionY = (((uint) (regionHandle)) >> 8);
438 uint oldRegionX = (uint)(m_regionInfo.RegionHandle >> 40); 438 uint oldRegionX = (uint) (m_regionInfo.RegionHandle >> 40);
439 uint oldRegionY = (((uint)(m_regionInfo.RegionHandle)) >> 8); 439 uint oldRegionY = (((uint) (m_regionInfo.RegionHandle)) >> 8);
440 if (Util.fast_distance2d((int)(newRegionX - oldRegionX), (int)(newRegionY - oldRegionY)) > 3) 440 if (Util.fast_distance2d((int) (newRegionX - oldRegionX), (int) (newRegionY - oldRegionY)) > 3)
441 { 441 {
442 CloseChildAgentConnections(avatar); 442 CloseChildAgentConnections(avatar);
443 } 443 }
@@ -465,7 +465,8 @@ namespace OpenSim.Region.Environment.Scenes
465 { 465 {
466 foreach (ulong regionHandle in presence.KnownChildRegions) 466 foreach (ulong regionHandle in presence.KnownChildRegions)
467 { 467 {
468 m_commsProvider.InterRegion.TellRegionToCloseChildConnection(regionHandle, presence.ControllingClient.AgentId); 468 m_commsProvider.InterRegion.TellRegionToCloseChildConnection(regionHandle,
469 presence.ControllingClient.AgentId);
469 presence.RemoveNeighbourRegion(regionHandle); 470 presence.RemoveNeighbourRegion(regionHandle);
470 } 471 }
471 } 472 }
@@ -474,6 +475,5 @@ namespace OpenSim.Region.Environment.Scenes
474 { 475 {
475 return m_commsProvider.GridService.GetGridSettings(); 476 return m_commsProvider.GridService.GetGridSettings();
476 } 477 }
477
478 } 478 }
479} 479} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Scenes/SceneEvents.cs b/OpenSim/Region/Environment/Scenes/SceneEvents.cs
index 9c8c62b..a6a8fb6 100644
--- a/OpenSim/Region/Environment/Scenes/SceneEvents.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneEvents.cs
@@ -105,7 +105,7 @@ namespace OpenSim.Region.Environment.Scenes
105 public delegate void LandObjectAdded(Land newParcel, LLUUID regionUUID); 105 public delegate void LandObjectAdded(Land newParcel, LLUUID regionUUID);
106 106
107 public event LandObjectAdded OnLandObjectAdded; 107 public event LandObjectAdded OnLandObjectAdded;
108 108
109 public delegate void LandObjectRemoved(LLUUID globalID); 109 public delegate void LandObjectRemoved(LLUUID globalID);
110 110
111 public event LandObjectRemoved OnLandObjectRemoved; 111 public event LandObjectRemoved OnLandObjectRemoved;
@@ -117,7 +117,7 @@ namespace OpenSim.Region.Environment.Scenes
117 117
118 public void TriggerOnClientMovement(ScenePresence avatar) 118 public void TriggerOnClientMovement(ScenePresence avatar)
119 { 119 {
120 if(OnClientMovement != null) 120 if (OnClientMovement != null)
121 OnClientMovement(avatar); 121 OnClientMovement(avatar);
122 } 122 }
123 123
@@ -223,7 +223,7 @@ namespace OpenSim.Region.Environment.Scenes
223 { 223 {
224 if (OnSceneGroupMove != null) 224 if (OnSceneGroupMove != null)
225 { 225 {
226 return OnSceneGroupMove(groupID, delta); 226 return OnSceneGroupMove(groupID, delta);
227 } 227 }
228 return true; 228 return true;
229 } 229 }
@@ -236,13 +236,14 @@ namespace OpenSim.Region.Environment.Scenes
236 } 236 }
237 } 237 }
238 238
239 public void TriggerLandObjectAdded(Land newParcel,LLUUID regionID) 239 public void TriggerLandObjectAdded(Land newParcel, LLUUID regionID)
240 { 240 {
241 if (OnLandObjectAdded != null) 241 if (OnLandObjectAdded != null)
242 { 242 {
243 OnLandObjectAdded(newParcel, regionID); 243 OnLandObjectAdded(newParcel, regionID);
244 } 244 }
245 } 245 }
246
246 public void TriggerLandObjectRemoved(LLUUID globalID) 247 public void TriggerLandObjectRemoved(LLUUID globalID)
247 { 248 {
248 if (OnLandObjectRemoved != null) 249 if (OnLandObjectRemoved != null)
@@ -250,10 +251,11 @@ namespace OpenSim.Region.Environment.Scenes
250 OnLandObjectRemoved(globalID); 251 OnLandObjectRemoved(globalID);
251 } 252 }
252 } 253 }
254
253 public void TriggerLandObjectUpdated(uint localParcelID, Land newParcel) 255 public void TriggerLandObjectUpdated(uint localParcelID, Land newParcel)
254 { 256 {
255 //triggerLandObjectRemoved(localParcelID); 257 //triggerLandObjectRemoved(localParcelID);
256 TriggerLandObjectAdded(newParcel,newParcel.m_scene.RegionInfo.RegionID); 258 TriggerLandObjectAdded(newParcel, newParcel.m_scene.RegionInfo.RegionID);
257 } 259 }
258 260
259 public void TriggerAvatarEnteringNewParcel(ScenePresence avatar, int localLandID, LLUUID regionID) 261 public void TriggerAvatarEnteringNewParcel(ScenePresence avatar, int localLandID, LLUUID regionID)
diff --git a/OpenSim/Region/Environment/Scenes/SceneManager.cs b/OpenSim/Region/Environment/Scenes/SceneManager.cs
index e822874..1eac61b 100644
--- a/OpenSim/Region/Environment/Scenes/SceneManager.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneManager.cs
@@ -84,7 +84,6 @@ namespace OpenSim.Region.Environment.Scenes
84 { 84 {
85 if (m_localScenes[i].Equals(cscene)) 85 if (m_localScenes[i].Equals(cscene))
86 { 86 {
87
88 m_localScenes[i].Close(); 87 m_localScenes[i].Close();
89 } 88 }
90 } 89 }
@@ -99,7 +98,8 @@ namespace OpenSim.Region.Environment.Scenes
99 98
100 public void HandleRestart(RegionInfo rdata) 99 public void HandleRestart(RegionInfo rdata)
101 { 100 {
102 MainLog.Instance.Error("SCENEMANAGER", "Got Restart message for region:" + rdata.RegionName +" Sending up to main"); 101 MainLog.Instance.Error("SCENEMANAGER",
102 "Got Restart message for region:" + rdata.RegionName + " Sending up to main");
103 int RegionSceneElement = -1; 103 int RegionSceneElement = -1;
104 for (int i = 0; i < m_localScenes.Count; i++) 104 for (int i = 0; i < m_localScenes.Count; i++)
105 { 105 {
@@ -127,7 +127,6 @@ namespace OpenSim.Region.Environment.Scenes
127 127
128 for (int i = 0; i < m_localScenes.Count; i++) 128 for (int i = 0; i < m_localScenes.Count; i++)
129 { 129 {
130
131 if (m_localScenes[i].RegionInfo.RegionHandle == regionHandle) 130 if (m_localScenes[i].RegionInfo.RegionHandle == regionHandle)
132 { 131 {
133 // Inform other regions to tell their avatar about me 132 // Inform other regions to tell their avatar about me
@@ -223,7 +222,7 @@ namespace OpenSim.Region.Environment.Scenes
223 { 222 {
224 ForEachCurrentScene(delegate(Scene scene) { scene.Backup(); }); 223 ForEachCurrentScene(delegate(Scene scene) { scene.Backup(); });
225 } 224 }
226 225
227 public void HandleAlertCommandOnCurrentScene(string[] cmdparams) 226 public void HandleAlertCommandOnCurrentScene(string[] cmdparams)
228 { 227 {
229 ForEachCurrentScene(delegate(Scene scene) { scene.HandleAlertCommand(cmdparams); }); 228 ForEachCurrentScene(delegate(Scene scene) { scene.HandleAlertCommand(cmdparams); });
@@ -423,4 +422,4 @@ namespace OpenSim.Region.Environment.Scenes
423 m_localScenes.ForEach(action); 422 m_localScenes.ForEach(action);
424 } 423 }
425 } 424 }
426} 425} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
index 20d596a..5b74c9b 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
@@ -28,6 +28,7 @@
28 28
29using System; 29using System;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Drawing;
31using System.IO; 32using System.IO;
32using System.Text; 33using System.Text;
33using System.Xml; 34using System.Xml;
@@ -38,7 +39,6 @@ using OpenSim.Framework;
38using OpenSim.Framework.Console; 39using OpenSim.Framework.Console;
39using OpenSim.Region.Environment.Interfaces; 40using OpenSim.Region.Environment.Interfaces;
40using OpenSim.Region.Physics.Manager; 41using OpenSim.Region.Physics.Manager;
41using System.Drawing;
42 42
43namespace OpenSim.Region.Environment.Scenes 43namespace OpenSim.Region.Environment.Scenes
44{ 44{
@@ -74,11 +74,13 @@ namespace OpenSim.Region.Environment.Scenes
74 { 74 {
75 get { return m_rootPart.RotationOffset; } 75 get { return m_rootPart.RotationOffset; }
76 } 76 }
77
77 public LLUUID GroupID 78 public LLUUID GroupID
78 { 79 {
79 get { return m_rootPart.GroupID; } 80 get { return m_rootPart.GroupID; }
80 set { m_rootPart.GroupID = value; } 81 set { m_rootPart.GroupID = value; }
81 } 82 }
83
82 /// <summary> 84 /// <summary>
83 /// 85 ///
84 /// </summary> 86 /// </summary>
@@ -242,7 +244,7 @@ namespace OpenSim.Region.Environment.Scenes
242 part.ParentID = 0; 244 part.ParentID = 0;
243 part.LinkNum = 0; 245 part.LinkNum = 0;
244 m_parts.Add(part.UUID, part); 246 m_parts.Add(part.UUID, part);
245 247
246 SetPartAsRoot(part); 248 SetPartAsRoot(part);
247 249
248 RegionHandle = regionHandle; 250 RegionHandle = regionHandle;
@@ -295,7 +297,6 @@ namespace OpenSim.Region.Environment.Scenes
295 sr.Close(); 297 sr.Close();
296 298
297 299
298
299 m_rootPart.LocalID = m_scene.PrimIDAllocate(); 300 m_rootPart.LocalID = m_scene.PrimIDAllocate();
300 m_rootPart.ParentID = 0; 301 m_rootPart.ParentID = 0;
301 m_rootPart.RegionHandle = m_regionHandle; 302 m_rootPart.RegionHandle = m_regionHandle;
@@ -376,9 +377,10 @@ namespace OpenSim.Region.Environment.Scenes
376 377
377 foreach (SceneObjectPart part in m_parts.Values) 378 foreach (SceneObjectPart part in m_parts.Values)
378 { 379 {
379 380 Vector3 partPosition =
380 Vector3 partPosition = new Vector3(part.AbsolutePosition.X, part.AbsolutePosition.Y, part.AbsolutePosition.Z); 381 new Vector3(part.AbsolutePosition.X, part.AbsolutePosition.Y, part.AbsolutePosition.Z);
381 Quaternion parentrotation = new Quaternion(GroupRotation.W, GroupRotation.X, GroupRotation.Y, GroupRotation.Z); 382 Quaternion parentrotation =
383 new Quaternion(GroupRotation.W, GroupRotation.X, GroupRotation.Y, GroupRotation.Z);
382 384
383 // Telling the prim to raytrace. 385 // Telling the prim to raytrace.
384 EntityIntersection inter = part.TestIntersection(hRay, parentrotation); 386 EntityIntersection inter = part.TestIntersection(hRay, parentrotation);
@@ -389,14 +391,11 @@ namespace OpenSim.Region.Environment.Scenes
389 float idist = 256f; 391 float idist = 256f;
390 392
391 393
392
393
394 if (inter.HitTF) 394 if (inter.HitTF)
395 { 395 {
396 // We need to find the closest prim to return to the testcaller along the ray 396 // We need to find the closest prim to return to the testcaller along the ray
397 if (inter.distance < idist) 397 if (inter.distance < idist)
398 { 398 {
399
400 idist = inter.distance; 399 idist = inter.distance;
401 returnresult.HitTF = true; 400 returnresult.HitTF = true;
402 returnresult.ipoint = inter.ipoint; 401 returnresult.ipoint = inter.ipoint;
@@ -405,15 +404,11 @@ namespace OpenSim.Region.Environment.Scenes
405 returnresult.distance = inter.distance; 404 returnresult.distance = inter.distance;
406 } 405 }
407 } 406 }
408
409
410 } 407 }
411 return returnresult; 408 return returnresult;
412
413 } 409 }
414 410
415 411
416
417 /// <summary> 412 /// <summary>
418 /// 413 ///
419 /// </summary> 414 /// </summary>
@@ -524,7 +519,7 @@ namespace OpenSim.Region.Environment.Scenes
524 /// <returns></returns> 519 /// <returns></returns>
525 public SceneObjectGroup Copy(LLUUID cAgentID, LLUUID cGroupID) 520 public SceneObjectGroup Copy(LLUUID cAgentID, LLUUID cGroupID)
526 { 521 {
527 SceneObjectGroup dupe = (SceneObjectGroup)MemberwiseClone(); 522 SceneObjectGroup dupe = (SceneObjectGroup) MemberwiseClone();
528 dupe.m_parts = new Dictionary<LLUUID, SceneObjectPart>(); 523 dupe.m_parts = new Dictionary<LLUUID, SceneObjectPart>();
529 dupe.m_parts.Clear(); 524 dupe.m_parts.Clear();
530 //dupe.OwnerID = AgentID; 525 //dupe.OwnerID = AgentID;
@@ -549,9 +544,8 @@ namespace OpenSim.Region.Environment.Scenes
549 new PhysicsVector(dupe.RootPart.Scale.X, dupe.RootPart.Scale.Y, dupe.RootPart.Scale.Z), 544 new PhysicsVector(dupe.RootPart.Scale.X, dupe.RootPart.Scale.Y, dupe.RootPart.Scale.Z),
550 new Quaternion(dupe.RootPart.RotationOffset.W, dupe.RootPart.RotationOffset.X, 545 new Quaternion(dupe.RootPart.RotationOffset.W, dupe.RootPart.RotationOffset.X,
551 dupe.RootPart.RotationOffset.Y, dupe.RootPart.RotationOffset.Z), 546 dupe.RootPart.RotationOffset.Y, dupe.RootPart.RotationOffset.Z),
552 dupe.RootPart.PhysActor.IsPhysical); 547 dupe.RootPart.PhysActor.IsPhysical);
553 dupe.RootPart.DoPhysicsPropertyUpdate(dupe.RootPart.PhysActor.IsPhysical, true); 548 dupe.RootPart.DoPhysicsPropertyUpdate(dupe.RootPart.PhysActor.IsPhysical, true);
554
555 } 549 }
556 // Now we've made a copy that replaces this one, we need to 550 // Now we've made a copy that replaces this one, we need to
557 // switch the owner to the person who did the copying 551 // switch the owner to the person who did the copying
@@ -559,8 +553,8 @@ namespace OpenSim.Region.Environment.Scenes
559 // So, we have to make a copy of this one, set it in it's place then set the owner on this one 553 // So, we have to make a copy of this one, set it in it's place then set the owner on this one
560 554
561 SetRootPartOwner(m_rootPart, cAgentID, cGroupID); 555 SetRootPartOwner(m_rootPart, cAgentID, cGroupID);
562 556
563 557
564 m_rootPart.ScheduleFullUpdate(); 558 m_rootPart.ScheduleFullUpdate();
565 559
566 List<SceneObjectPart> partList = new List<SceneObjectPart>(m_parts.Values); 560 List<SceneObjectPart> partList = new List<SceneObjectPart>(m_parts.Values);
@@ -571,7 +565,6 @@ namespace OpenSim.Region.Environment.Scenes
571 dupe.CopyPart(part, OwnerID, GroupID); 565 dupe.CopyPart(part, OwnerID, GroupID);
572 SetPartOwner(part, cAgentID, cGroupID); 566 SetPartOwner(part, cAgentID, cGroupID);
573 part.ScheduleFullUpdate(); 567 part.ScheduleFullUpdate();
574
575 } 568 }
576 } 569 }
577 dupe.UpdateParentIDs(); 570 dupe.UpdateParentIDs();
@@ -601,7 +594,7 @@ namespace OpenSim.Region.Environment.Scenes
601 part.OwnerID = cAgentID; 594 part.OwnerID = cAgentID;
602 part.GroupID = cGroupID; 595 part.GroupID = cGroupID;
603 596
604 597
605 if (part.OwnerID != cAgentID) 598 if (part.OwnerID != cAgentID)
606 { 599 {
607 // Apply Next Owner Permissions if we're not bypassing permissions 600 // Apply Next Owner Permissions if we're not bypassing permissions
@@ -637,6 +630,7 @@ namespace OpenSim.Region.Environment.Scenes
637 m_parts.Add(part.UUID, part); 630 m_parts.Add(part.UUID, part);
638 } 631 }
639 } 632 }
633
640 /// <summary> 634 /// <summary>
641 /// 635 ///
642 /// </summary> 636 /// </summary>
@@ -666,8 +660,8 @@ namespace OpenSim.Region.Environment.Scenes
666 objPropDB.Description = Helpers.StringToField(RootPart.Description); 660 objPropDB.Description = Helpers.StringToField(RootPart.Description);
667 objPropFamilyPack.ObjectData = objPropDB; 661 objPropFamilyPack.ObjectData = objPropDB;
668 remoteClient.OutPacket(objPropFamilyPack, ThrottleOutPacketType.Task); 662 remoteClient.OutPacket(objPropFamilyPack, ThrottleOutPacketType.Task);
669
670 } 663 }
664
671 public void SetPartOwner(SceneObjectPart part, LLUUID cAgentID, LLUUID cGroupID) 665 public void SetPartOwner(SceneObjectPart part, LLUUID cAgentID, LLUUID cGroupID)
672 { 666 {
673 part.OwnerID = cAgentID; 667 part.OwnerID = cAgentID;
@@ -884,12 +878,12 @@ namespace OpenSim.Region.Environment.Scenes
884 Quaternion parentRot = 878 Quaternion parentRot =
885 new Quaternion(m_rootPart.RotationOffset.W, m_rootPart.RotationOffset.X, m_rootPart.RotationOffset.Y, 879 new Quaternion(m_rootPart.RotationOffset.W, m_rootPart.RotationOffset.X, m_rootPart.RotationOffset.Y,
886 m_rootPart.RotationOffset.Z); 880 m_rootPart.RotationOffset.Z);
887 axPos = parentRot.Inverse() * axPos; 881 axPos = parentRot.Inverse()*axPos;
888 linkPart.OffsetPosition = new LLVector3(axPos.x, axPos.y, axPos.z); 882 linkPart.OffsetPosition = new LLVector3(axPos.x, axPos.y, axPos.z);
889 Quaternion oldRot = 883 Quaternion oldRot =
890 new Quaternion(linkPart.RotationOffset.W, linkPart.RotationOffset.X, linkPart.RotationOffset.Y, 884 new Quaternion(linkPart.RotationOffset.W, linkPart.RotationOffset.X, linkPart.RotationOffset.Y,
891 linkPart.RotationOffset.Z); 885 linkPart.RotationOffset.Z);
892 Quaternion newRot = parentRot.Inverse() * oldRot; 886 Quaternion newRot = parentRot.Inverse()*oldRot;
893 linkPart.RotationOffset = new LLQuaternion(newRot.x, newRot.y, newRot.z, newRot.w); 887 linkPart.RotationOffset = new LLQuaternion(newRot.x, newRot.y, newRot.z, newRot.w);
894 linkPart.ParentID = m_rootPart.LocalID; 888 linkPart.ParentID = m_rootPart.LocalID;
895 linkPart.LinkNum = m_parts.Count; 889 linkPart.LinkNum = m_parts.Count;
@@ -949,7 +943,7 @@ namespace OpenSim.Region.Environment.Scenes
949 linkPart.OffsetPosition.Y, 943 linkPart.OffsetPosition.Y,
950 linkPart.OffsetPosition.Z); 944 linkPart.OffsetPosition.Z);
951 945
952 axPos = parentRot * axPos; 946 axPos = parentRot*axPos;
953 linkPart.OffsetPosition = new LLVector3(axPos.x, axPos.y, axPos.z); 947 linkPart.OffsetPosition = new LLVector3(axPos.x, axPos.y, axPos.z);
954 linkPart.GroupPosition = AbsolutePosition + linkPart.OffsetPosition; 948 linkPart.GroupPosition = AbsolutePosition + linkPart.OffsetPosition;
955 linkPart.OffsetPosition = new LLVector3(0, 0, 0); 949 linkPart.OffsetPosition = new LLVector3(0, 0, 0);
@@ -960,7 +954,7 @@ namespace OpenSim.Region.Environment.Scenes
960 linkPart.RotationOffset.X, 954 linkPart.RotationOffset.X,
961 linkPart.RotationOffset.Y, 955 linkPart.RotationOffset.Y,
962 linkPart.RotationOffset.Z); 956 linkPart.RotationOffset.Z);
963 Quaternion newRot = parentRot * oldRot; 957 Quaternion newRot = parentRot*oldRot;
964 linkPart.RotationOffset = new LLQuaternion(newRot.x, newRot.y, newRot.z, newRot.w); 958 linkPart.RotationOffset = new LLQuaternion(newRot.x, newRot.y, newRot.z, newRot.w);
965 959
966 // Add physics information back to delinked part if appropriate 960 // Add physics information back to delinked part if appropriate
@@ -978,7 +972,6 @@ namespace OpenSim.Region.Environment.Scenes
978 linkPart.RotationOffset.Y, linkPart.RotationOffset.Z), 972 linkPart.RotationOffset.Y, linkPart.RotationOffset.Z),
979 m_rootPart.PhysActor.IsPhysical); 973 m_rootPart.PhysActor.IsPhysical);
980 m_rootPart.DoPhysicsPropertyUpdate(m_rootPart.PhysActor.IsPhysical, true); 974 m_rootPart.DoPhysicsPropertyUpdate(m_rootPart.PhysActor.IsPhysical, true);
981
982 } 975 }
983 976
984 SceneObjectGroup objectGroup = new SceneObjectGroup(m_scene, m_regionHandle, linkPart); 977 SceneObjectGroup objectGroup = new SceneObjectGroup(m_scene, m_regionHandle, linkPart);
@@ -990,8 +983,8 @@ namespace OpenSim.Region.Environment.Scenes
990 else 983 else
991 { 984 {
992 MainLog.Instance.Verbose("SCENE", 985 MainLog.Instance.Verbose("SCENE",
993 "DelinkFromGroup(): Child prim local id {0} not found in object with root prim id {1}", 986 "DelinkFromGroup(): Child prim local id {0} not found in object with root prim id {1}",
994 partID, LocalId); 987 partID, LocalId);
995 } 988 }
996 } 989 }
997 990
@@ -1008,7 +1001,7 @@ namespace OpenSim.Region.Environment.Scenes
1008 m_parts.Add(part.UUID, part); 1001 m_parts.Add(part.UUID, part);
1009 1002
1010 Vector3 axiomOldPos = new Vector3(part.OffsetPosition.X, part.OffsetPosition.Y, part.OffsetPosition.Z); 1003 Vector3 axiomOldPos = new Vector3(part.OffsetPosition.X, part.OffsetPosition.Y, part.OffsetPosition.Z);
1011 axiomOldPos = oldGroupRotation * axiomOldPos; 1004 axiomOldPos = oldGroupRotation*axiomOldPos;
1012 axiomOldPos += oldGroupPosition; 1005 axiomOldPos += oldGroupPosition;
1013 LLVector3 oldAbsolutePosition = new LLVector3(axiomOldPos.x, axiomOldPos.y, axiomOldPos.z); 1006 LLVector3 oldAbsolutePosition = new LLVector3(axiomOldPos.x, axiomOldPos.y, axiomOldPos.z);
1014 part.OffsetPosition = oldAbsolutePosition - AbsolutePosition; 1007 part.OffsetPosition = oldAbsolutePosition - AbsolutePosition;
@@ -1018,15 +1011,15 @@ namespace OpenSim.Region.Environment.Scenes
1018 m_rootPart.RotationOffset.Z); 1011 m_rootPart.RotationOffset.Z);
1019 1012
1020 Vector3 axiomPos = new Vector3(part.OffsetPosition.X, part.OffsetPosition.Y, part.OffsetPosition.Z); 1013 Vector3 axiomPos = new Vector3(part.OffsetPosition.X, part.OffsetPosition.Y, part.OffsetPosition.Z);
1021 axiomPos = axiomRootRotation.Inverse() * axiomPos; 1014 axiomPos = axiomRootRotation.Inverse()*axiomPos;
1022 part.OffsetPosition = new LLVector3(axiomPos.x, axiomPos.y, axiomPos.z); 1015 part.OffsetPosition = new LLVector3(axiomPos.x, axiomPos.y, axiomPos.z);
1023 1016
1024 Quaternion axiomPartRotation = 1017 Quaternion axiomPartRotation =
1025 new Quaternion(part.RotationOffset.W, part.RotationOffset.X, part.RotationOffset.Y, 1018 new Quaternion(part.RotationOffset.W, part.RotationOffset.X, part.RotationOffset.Y,
1026 part.RotationOffset.Z); 1019 part.RotationOffset.Z);
1027 1020
1028 axiomPartRotation = oldGroupRotation * axiomPartRotation; 1021 axiomPartRotation = oldGroupRotation*axiomPartRotation;
1029 axiomPartRotation = axiomRootRotation.Inverse() * axiomPartRotation; 1022 axiomPartRotation = axiomRootRotation.Inverse()*axiomPartRotation;
1030 part.RotationOffset = 1023 part.RotationOffset =
1031 new LLQuaternion(axiomPartRotation.x, axiomPartRotation.y, axiomPartRotation.z, axiomPartRotation.w); 1024 new LLQuaternion(axiomPartRotation.x, axiomPartRotation.y, axiomPartRotation.z, axiomPartRotation.w);
1032 } 1025 }
@@ -1056,12 +1049,12 @@ namespace OpenSim.Region.Environment.Scenes
1056 proper.ObjectData = new ObjectPropertiesPacket.ObjectDataBlock[1]; 1049 proper.ObjectData = new ObjectPropertiesPacket.ObjectDataBlock[1];
1057 proper.ObjectData[0] = new ObjectPropertiesPacket.ObjectDataBlock(); 1050 proper.ObjectData[0] = new ObjectPropertiesPacket.ObjectDataBlock();
1058 proper.ObjectData[0].ItemID = LLUUID.Zero; 1051 proper.ObjectData[0].ItemID = LLUUID.Zero;
1059 proper.ObjectData[0].CreationDate = (ulong)m_rootPart.CreationDate; 1052 proper.ObjectData[0].CreationDate = (ulong) m_rootPart.CreationDate;
1060 proper.ObjectData[0].CreatorID = m_rootPart.CreatorID; 1053 proper.ObjectData[0].CreatorID = m_rootPart.CreatorID;
1061 proper.ObjectData[0].FolderID = LLUUID.Zero; 1054 proper.ObjectData[0].FolderID = LLUUID.Zero;
1062 proper.ObjectData[0].FromTaskID = LLUUID.Zero; 1055 proper.ObjectData[0].FromTaskID = LLUUID.Zero;
1063 proper.ObjectData[0].GroupID = LLUUID.Zero; 1056 proper.ObjectData[0].GroupID = LLUUID.Zero;
1064 proper.ObjectData[0].InventorySerial = (short)m_rootPart.InventorySerial; 1057 proper.ObjectData[0].InventorySerial = (short) m_rootPart.InventorySerial;
1065 proper.ObjectData[0].LastOwnerID = m_rootPart.LastOwnerID; 1058 proper.ObjectData[0].LastOwnerID = m_rootPart.LastOwnerID;
1066 proper.ObjectData[0].ObjectID = UUID; 1059 proper.ObjectData[0].ObjectID = UUID;
1067 proper.ObjectData[0].OwnerID = m_rootPart.OwnerID; 1060 proper.ObjectData[0].OwnerID = m_rootPart.OwnerID;
@@ -1155,7 +1148,7 @@ namespace OpenSim.Region.Environment.Scenes
1155 else 1148 else
1156 { 1149 {
1157 MainLog.Instance.Warn( 1150 MainLog.Instance.Warn(
1158 "SCENE", 1151 "SCENE",
1159 "Couldn't find part {0} in object group {1} ({2}) to retreive prim inventory", 1152 "Couldn't find part {0} in object group {1} ({2}) to retreive prim inventory",
1160 localID, LocalId, UUID); 1153 localID, LocalId, UUID);
1161 } 1154 }
@@ -1272,10 +1265,8 @@ namespace OpenSim.Region.Environment.Scenes
1272 public void UpdatePermissions(LLUUID AgentID, byte field, uint localID, uint mask, byte addRemTF) 1265 public void UpdatePermissions(LLUUID AgentID, byte field, uint localID, uint mask, byte addRemTF)
1273 { 1266 {
1274 SceneObjectPart updatePart = GetChildPart(localID); 1267 SceneObjectPart updatePart = GetChildPart(localID);
1275 updatePart.UpdatePermissions(AgentID,field,localID,mask,addRemTF); 1268 updatePart.UpdatePermissions(AgentID, field, localID, mask, addRemTF);
1276 } 1269 }
1277
1278
1279 1270
1280 #endregion 1271 #endregion
1281 1272
@@ -1304,9 +1295,8 @@ namespace OpenSim.Region.Environment.Scenes
1304 new Quaternion(m_rootPart.RotationOffset.W, m_rootPart.RotationOffset.X, 1295 new Quaternion(m_rootPart.RotationOffset.W, m_rootPart.RotationOffset.X,
1305 m_rootPart.RotationOffset.Y, m_rootPart.RotationOffset.Z), 1296 m_rootPart.RotationOffset.Y, m_rootPart.RotationOffset.Z),
1306 m_rootPart.PhysActor.IsPhysical); 1297 m_rootPart.PhysActor.IsPhysical);
1307 bool UsePhysics = ((m_rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Physics) != 0); 1298 bool UsePhysics = ((m_rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Physics) != 0);
1308 m_rootPart.DoPhysicsPropertyUpdate(UsePhysics, true); 1299 m_rootPart.DoPhysicsPropertyUpdate(UsePhysics, true);
1309
1310 } 1300 }
1311 } 1301 }
1312 1302
@@ -1350,11 +1340,10 @@ namespace OpenSim.Region.Environment.Scenes
1350 if (m_scene.EventManager.TriggerGroupMove(UUID, pos)) 1340 if (m_scene.EventManager.TriggerGroupMove(UUID, pos))
1351 { 1341 {
1352 AbsolutePosition = pos; 1342 AbsolutePosition = pos;
1353
1354 } 1343 }
1355 //we need to do a terse update even if the move wasn't allowed 1344 //we need to do a terse update even if the move wasn't allowed
1356 // so that the position is reset in the client (the object snaps back) 1345 // so that the position is reset in the client (the object snaps back)
1357 ScheduleGroupForTerseUpdate(); 1346 ScheduleGroupForTerseUpdate();
1358 } 1347 }
1359 1348
1360 /// <summary> 1349 /// <summary>
@@ -1394,7 +1383,7 @@ namespace OpenSim.Region.Environment.Scenes
1394 Quaternion partRotation = 1383 Quaternion partRotation =
1395 new Quaternion(m_rootPart.RotationOffset.W, m_rootPart.RotationOffset.X, m_rootPart.RotationOffset.Y, 1384 new Quaternion(m_rootPart.RotationOffset.W, m_rootPart.RotationOffset.X, m_rootPart.RotationOffset.Y,
1396 m_rootPart.RotationOffset.Z); 1385 m_rootPart.RotationOffset.Z);
1397 axDiff = partRotation.Inverse() * axDiff; 1386 axDiff = partRotation.Inverse()*axDiff;
1398 diff.X = axDiff.x; 1387 diff.X = axDiff.x;
1399 diff.Y = axDiff.y; 1388 diff.Y = axDiff.y;
1400 diff.Z = axDiff.z; 1389 diff.Z = axDiff.z;
@@ -1496,14 +1485,14 @@ namespace OpenSim.Region.Environment.Scenes
1496 if (prim.UUID != m_rootPart.UUID) 1485 if (prim.UUID != m_rootPart.UUID)
1497 { 1486 {
1498 Vector3 axPos = new Vector3(prim.OffsetPosition.X, prim.OffsetPosition.Y, prim.OffsetPosition.Z); 1487 Vector3 axPos = new Vector3(prim.OffsetPosition.X, prim.OffsetPosition.Y, prim.OffsetPosition.Z);
1499 axPos = oldParentRot * axPos; 1488 axPos = oldParentRot*axPos;
1500 axPos = axRot.Inverse() * axPos; 1489 axPos = axRot.Inverse()*axPos;
1501 prim.OffsetPosition = new LLVector3(axPos.x, axPos.y, axPos.z); 1490 prim.OffsetPosition = new LLVector3(axPos.x, axPos.y, axPos.z);
1502 Quaternion primsRot = 1491 Quaternion primsRot =
1503 new Quaternion(prim.RotationOffset.W, prim.RotationOffset.X, prim.RotationOffset.Y, 1492 new Quaternion(prim.RotationOffset.W, prim.RotationOffset.X, prim.RotationOffset.Y,
1504 prim.RotationOffset.Z); 1493 prim.RotationOffset.Z);
1505 Quaternion newRot = oldParentRot * primsRot; 1494 Quaternion newRot = oldParentRot*primsRot;
1506 newRot = axRot.Inverse() * newRot; 1495 newRot = axRot.Inverse()*newRot;
1507 prim.RotationOffset = new LLQuaternion(newRot.x, newRot.y, newRot.z, newRot.w); 1496 prim.RotationOffset = new LLQuaternion(newRot.x, newRot.y, newRot.z, newRot.w);
1508 prim.ScheduleTerseUpdate(); 1497 prim.ScheduleTerseUpdate();
1509 } 1498 }
@@ -1736,10 +1725,10 @@ namespace OpenSim.Region.Environment.Scenes
1736 1725
1737 public override void SetText(string text, Vector3 color, double alpha) 1726 public override void SetText(string text, Vector3 color, double alpha)
1738 { 1727 {
1739 Color = Color.FromArgb(0xff - (int)(alpha * 0xff), 1728 Color = Color.FromArgb(0xff - (int) (alpha*0xff),
1740 (int)(color.x * 0xff), 1729 (int) (color.x*0xff),
1741 (int)(color.y * 0xff), 1730 (int) (color.y*0xff),
1742 (int)(color.z * 0xff)); 1731 (int) (color.z*0xff));
1743 Text = text; 1732 Text = text;
1744 } 1733 }
1745 1734
@@ -1748,4 +1737,4 @@ namespace OpenSim.Region.Environment.Scenes
1748 m_rootPart.ApplyPhysics(); 1737 m_rootPart.ApplyPhysics();
1749 } 1738 }
1750 } 1739 }
1751} 1740} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
index f226150..90a975c 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
@@ -28,6 +28,7 @@
28 28
29using System; 29using System;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Drawing;
31using System.Xml; 32using System.Xml;
32using System.Xml.Serialization; 33using System.Xml.Serialization;
33using Axiom.Math; 34using Axiom.Math;
@@ -38,23 +39,26 @@ using OpenSim.Framework.Console;
38using OpenSim.Region.Environment.Interfaces; 39using OpenSim.Region.Environment.Interfaces;
39using OpenSim.Region.Environment.Scenes.Scripting; 40using OpenSim.Region.Environment.Scenes.Scripting;
40using OpenSim.Region.Physics.Manager; 41using OpenSim.Region.Physics.Manager;
41using System.Drawing;
42 42
43namespace OpenSim.Region.Environment.Scenes 43namespace OpenSim.Region.Environment.Scenes
44{ 44{
45 public class SceneObjectPart : IScriptHost 45 public class SceneObjectPart : IScriptHost
46 { 46 {
47 private const LLObject.ObjectFlags OBJFULL_MASK_GENERAL = LLObject.ObjectFlags.ObjectCopy | LLObject.ObjectFlags.ObjectModify | LLObject.ObjectFlags.ObjectTransfer; 47 private const LLObject.ObjectFlags OBJFULL_MASK_GENERAL =
48 private const LLObject.ObjectFlags OBJFULL_MASK_OWNER = LLObject.ObjectFlags.ObjectCopy | LLObject.ObjectFlags.ObjectModify | LLObject.ObjectFlags.ObjectOwnerModify | LLObject.ObjectFlags.ObjectTransfer | LLObject.ObjectFlags.ObjectYouOwner; 48 LLObject.ObjectFlags.ObjectCopy | LLObject.ObjectFlags.ObjectModify | LLObject.ObjectFlags.ObjectTransfer;
49
50 private const LLObject.ObjectFlags OBJFULL_MASK_OWNER =
51 LLObject.ObjectFlags.ObjectCopy | LLObject.ObjectFlags.ObjectModify | LLObject.ObjectFlags.ObjectOwnerModify |
52 LLObject.ObjectFlags.ObjectTransfer | LLObject.ObjectFlags.ObjectYouOwner;
53
49 private const uint OBJNEXT_OWNER = 2147483647; 54 private const uint OBJNEXT_OWNER = 2147483647;
50 55
51 private const uint FULL_MASK_PERMISSIONS_GENERAL = 2147483647; 56 private const uint FULL_MASK_PERMISSIONS_GENERAL = 2147483647;
52 private const uint FULL_MASK_PERMISSIONS_OWNER = 2147483647; 57 private const uint FULL_MASK_PERMISSIONS_OWNER = 2147483647;
53 private string m_inventoryFileName = ""; 58 private string m_inventoryFileName = "";
54 private LLUUID m_folderID = LLUUID.Zero; 59 private LLUUID m_folderID = LLUUID.Zero;
55 60
56 [XmlIgnore] 61 [XmlIgnore] public PhysicsActor PhysActor = null;
57 public PhysicsActor PhysActor = null;
58 62
59 protected Dictionary<LLUUID, TaskInventoryItem> TaskInventory = new Dictionary<LLUUID, TaskInventoryItem>(); 63 protected Dictionary<LLUUID, TaskInventoryItem> TaskInventory = new Dictionary<LLUUID, TaskInventoryItem>();
60 public LLUUID LastOwnerID; 64 public LLUUID LastOwnerID;
@@ -72,25 +76,20 @@ namespace OpenSim.Region.Environment.Scenes
72 private Quaternion m_sitTargetOrientation = new Quaternion(0, 0, 0, 1); 76 private Quaternion m_sitTargetOrientation = new Quaternion(0, 0, 0, 1);
73 private LLUUID m_SitTargetAvatar = LLUUID.Zero; 77 private LLUUID m_SitTargetAvatar = LLUUID.Zero;
74 78
75
76
77 79
78 // Main grid has default permissions as follows 80 // Main grid has default permissions as follows
79 // 81 //
80 public uint OwnerMask = FULL_MASK_PERMISSIONS_OWNER; 82 public uint OwnerMask = FULL_MASK_PERMISSIONS_OWNER;
81 public uint NextOwnerMask = OBJNEXT_OWNER; 83 public uint NextOwnerMask = OBJNEXT_OWNER;
82 public uint GroupMask = (uint) LLObject.ObjectFlags.None; 84 public uint GroupMask = (uint) LLObject.ObjectFlags.None;
83 public uint EveryoneMask = (uint) LLObject.ObjectFlags.None; 85 public uint EveryoneMask = (uint) LLObject.ObjectFlags.None;
84 public uint BaseMask = FULL_MASK_PERMISSIONS_OWNER; 86 public uint BaseMask = FULL_MASK_PERMISSIONS_OWNER;
85 87
86 protected byte[] m_particleSystem = new byte[0]; 88 protected byte[] m_particleSystem = new byte[0];
87 89
88 [XmlIgnore] 90 [XmlIgnore] public uint TimeStampFull = 0;
89 public uint TimeStampFull = 0; 91 [XmlIgnore] public uint TimeStampTerse = 0;
90 [XmlIgnore] 92 [XmlIgnore] public uint TimeStampLastActivity = 0; // Will be used for AutoReturn
91 public uint TimeStampTerse = 0;
92 [XmlIgnore]
93 public uint TimeStampLastActivity = 0; // Will be used for AutoReturn
94 93
95 /// <summary> 94 /// <summary>
96 /// Only used internally to schedule client updates 95 /// Only used internally to schedule client updates
@@ -145,16 +144,16 @@ namespace OpenSim.Region.Environment.Scenes
145 144
146 public uint ObjectFlags 145 public uint ObjectFlags
147 { 146 {
148 get { return (uint)m_flags; } 147 get { return (uint) m_flags; }
149 set { m_flags = (LLObject.ObjectFlags)value; } 148 set { m_flags = (LLObject.ObjectFlags) value; }
150 } 149 }
151 150
152 protected LLObject.MaterialType m_material = 0; 151 protected LLObject.MaterialType m_material = 0;
153 152
154 public byte Material 153 public byte Material
155 { 154 {
156 get { return (byte)m_material; } 155 get { return (byte) m_material; }
157 set { m_material = (LLObject.MaterialType)value; } 156 set { m_material = (LLObject.MaterialType) value; }
158 } 157 }
159 158
160 protected ulong m_regionHandle; 159 protected ulong m_regionHandle;
@@ -168,7 +167,6 @@ namespace OpenSim.Region.Environment.Scenes
168 //unkown if this will be kept, added as a way of removing the group position from the group class 167 //unkown if this will be kept, added as a way of removing the group position from the group class
169 protected LLVector3 m_groupPosition; 168 protected LLVector3 m_groupPosition;
170 169
171
172 170
173 public LLVector3 GroupPosition 171 public LLVector3 GroupPosition
174 { 172 {
@@ -225,7 +223,7 @@ namespace OpenSim.Region.Environment.Scenes
225 if (PhysActor != null) 223 if (PhysActor != null)
226 { 224 {
227 if (PhysActor.Orientation.x != 0 || PhysActor.Orientation.y != 0 225 if (PhysActor.Orientation.x != 0 || PhysActor.Orientation.y != 0
228 || PhysActor.Orientation.z != 0 || PhysActor.Orientation.w != 0) 226 || PhysActor.Orientation.z != 0 || PhysActor.Orientation.w != 0)
229 { 227 {
230 m_rotationOffset.X = PhysActor.Orientation.x; 228 m_rotationOffset.X = PhysActor.Orientation.x;
231 m_rotationOffset.Y = PhysActor.Orientation.y; 229 m_rotationOffset.Y = PhysActor.Orientation.y;
@@ -281,6 +279,7 @@ namespace OpenSim.Region.Environment.Scenes
281 } 279 }
282 set { m_velocity = value; } 280 set { m_velocity = value; }
283 } 281 }
282
284 public LLVector3 RotationalVelocity 283 public LLVector3 RotationalVelocity
285 { 284 {
286 get 285 get
@@ -351,6 +350,7 @@ namespace OpenSim.Region.Environment.Scenes
351 { 350 {
352 get { return m_sitTargetPosition; } 351 get { return m_sitTargetPosition; }
353 } 352 }
353
354 public Quaternion SitTargetOrientation 354 public Quaternion SitTargetOrientation
355 { 355 {
356 get { return m_sitTargetOrientation; } 356 get { return m_sitTargetOrientation; }
@@ -383,6 +383,7 @@ namespace OpenSim.Region.Environment.Scenes
383 } 383 }
384 384
385 private int m_linkNum = 0; 385 private int m_linkNum = 0;
386
386 public int LinkNum 387 public int LinkNum
387 { 388 {
388 get { return m_linkNum; } 389 get { return m_linkNum; }
@@ -390,13 +391,14 @@ namespace OpenSim.Region.Environment.Scenes
390 } 391 }
391 392
392 private byte m_clickAction = 0; 393 private byte m_clickAction = 0;
394
393 public byte ClickAction 395 public byte ClickAction
394 { 396 {
395 get { return m_clickAction; } 397 get { return m_clickAction; }
396 set 398 set
397 { 399 {
398 m_clickAction = value; 400 m_clickAction = value;
399 this.ScheduleFullUpdate(); 401 ScheduleFullUpdate();
400 } 402 }
401 } 403 }
402 404
@@ -423,6 +425,7 @@ namespace OpenSim.Region.Environment.Scenes
423 425
424 // FIXME, TODO, ERROR: 'ParentGroup' can't be in here, move it out. 426 // FIXME, TODO, ERROR: 'ParentGroup' can't be in here, move it out.
425 protected SceneObjectGroup m_parentGroup; 427 protected SceneObjectGroup m_parentGroup;
428
426 public SceneObjectGroup ParentGroup 429 public SceneObjectGroup ParentGroup
427 { 430 {
428 get { return m_parentGroup; } 431 get { return m_parentGroup; }
@@ -434,7 +437,6 @@ namespace OpenSim.Region.Environment.Scenes
434 set { m_updateFlag = value; } 437 set { m_updateFlag = value; }
435 } 438 }
436 439
437
438 #region Constructors 440 #region Constructors
439 441
440 /// <summary> 442 /// <summary>
@@ -469,18 +471,18 @@ namespace OpenSim.Region.Environment.Scenes
469 m_regionHandle = regionHandle; 471 m_regionHandle = regionHandle;
470 m_parentGroup = parent; 472 m_parentGroup = parent;
471 473
472 CreationDate = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; 474 CreationDate = (Int32) (DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
473 OwnerID = ownerID; 475 OwnerID = ownerID;
474 CreatorID = OwnerID; 476 CreatorID = OwnerID;
475 LastOwnerID = LLUUID.Zero; 477 LastOwnerID = LLUUID.Zero;
476 UUID = LLUUID.Random(); 478 UUID = LLUUID.Random();
477 LocalID = (uint)(localID); 479 LocalID = (uint) (localID);
478 Shape = shape; 480 Shape = shape;
479 // Todo: Add More Object Parameter from above! 481 // Todo: Add More Object Parameter from above!
480 OwnershipCost = 0; 482 OwnershipCost = 0;
481 ObjectSaleType = (byte)0; 483 ObjectSaleType = (byte) 0;
482 SalePrice = 0; 484 SalePrice = 0;
483 Category = (uint)0; 485 Category = (uint) 0;
484 LastOwnerID = CreatorID; 486 LastOwnerID = CreatorID;
485 // End Todo: /// 487 // End Todo: ///
486 GroupPosition = groupPosition; 488 GroupPosition = groupPosition;
@@ -495,9 +497,9 @@ namespace OpenSim.Region.Environment.Scenes
495 m_folderID = LLUUID.Random(); 497 m_folderID = LLUUID.Random();
496 498
497 m_flags = 0; 499 m_flags = 0;
498 m_flags |= LLObject.ObjectFlags.Touch | 500 m_flags |= LLObject.ObjectFlags.Touch |
499 LLObject.ObjectFlags.AllowInventoryDrop | 501 LLObject.ObjectFlags.AllowInventoryDrop |
500 LLObject.ObjectFlags.CreateSelected; 502 LLObject.ObjectFlags.CreateSelected;
501 503
502 ApplySanePermissions(); 504 ApplySanePermissions();
503 505
@@ -520,18 +522,18 @@ namespace OpenSim.Region.Environment.Scenes
520 { 522 {
521 m_regionHandle = regionHandle; 523 m_regionHandle = regionHandle;
522 m_parentGroup = parent; 524 m_parentGroup = parent;
523 TimeStampTerse = (uint)Util.UnixTimeSinceEpoch(); 525 TimeStampTerse = (uint) Util.UnixTimeSinceEpoch();
524 CreationDate = creationDate; 526 CreationDate = creationDate;
525 OwnerID = ownerID; 527 OwnerID = ownerID;
526 CreatorID = creatorID; 528 CreatorID = creatorID;
527 LastOwnerID = lastOwnerID; 529 LastOwnerID = lastOwnerID;
528 UUID = LLUUID.Random(); 530 UUID = LLUUID.Random();
529 LocalID = (uint)(localID); 531 LocalID = (uint) (localID);
530 Shape = shape; 532 Shape = shape;
531 OwnershipCost = 0; 533 OwnershipCost = 0;
532 ObjectSaleType = (byte)0; 534 ObjectSaleType = (byte) 0;
533 SalePrice = 0; 535 SalePrice = 0;
534 Category = (uint)0; 536 Category = (uint) 0;
535 LastOwnerID = CreatorID; 537 LastOwnerID = CreatorID;
536 OffsetPosition = position; 538 OffsetPosition = position;
537 RotationOffset = rotation; 539 RotationOffset = rotation;
@@ -552,18 +554,18 @@ namespace OpenSim.Region.Environment.Scenes
552 /// <returns></returns> 554 /// <returns></returns>
553 public static SceneObjectPart FromXml(XmlReader xmlReader) 555 public static SceneObjectPart FromXml(XmlReader xmlReader)
554 { 556 {
555 XmlSerializer serializer = new XmlSerializer(typeof(SceneObjectPart)); 557 XmlSerializer serializer = new XmlSerializer(typeof (SceneObjectPart));
556 SceneObjectPart newobject = (SceneObjectPart)serializer.Deserialize(xmlReader); 558 SceneObjectPart newobject = (SceneObjectPart) serializer.Deserialize(xmlReader);
557 return newobject; 559 return newobject;
558 } 560 }
559 561
560 public void ApplyPhysics() 562 public void ApplyPhysics()
561 { 563 {
562 bool isPhysical = ((ObjectFlags & (uint)LLObject.ObjectFlags.Physics) != 0); 564 bool isPhysical = ((ObjectFlags & (uint) LLObject.ObjectFlags.Physics) != 0);
563 bool isPhantom = ((ObjectFlags & (uint)LLObject.ObjectFlags.Phantom) != 0); 565 bool isPhantom = ((ObjectFlags & (uint) LLObject.ObjectFlags.Phantom) != 0);
564 566
565 bool usePhysics = isPhysical && !isPhantom; 567 bool usePhysics = isPhysical && !isPhantom;
566 568
567 if (usePhysics) 569 if (usePhysics)
568 { 570 {
569 PhysActor = m_parentGroup.m_scene.PhysicsScene.AddPrimShape( 571 PhysActor = m_parentGroup.m_scene.PhysicsScene.AddPrimShape(
@@ -576,101 +578,102 @@ namespace OpenSim.Region.Environment.Scenes
576 RotationOffset.Y, RotationOffset.Z), usePhysics); 578 RotationOffset.Y, RotationOffset.Z), usePhysics);
577 } 579 }
578 580
579 DoPhysicsPropertyUpdate(usePhysics, true); 581 DoPhysicsPropertyUpdate(usePhysics, true);
580 } 582 }
583
581 public void ApplyNextOwnerPermissions() 584 public void ApplyNextOwnerPermissions()
582 { 585 {
583 BaseMask = NextOwnerMask; 586 BaseMask = NextOwnerMask;
584 OwnerMask = NextOwnerMask; 587 OwnerMask = NextOwnerMask;
585 } 588 }
589
586 public void ApplySanePermissions() 590 public void ApplySanePermissions()
587 { 591 {
588 // These are some flags that The OwnerMask should never have 592 // These are some flags that The OwnerMask should never have
589 OwnerMask &= ~(uint)LLObject.ObjectFlags.ObjectGroupOwned; 593 OwnerMask &= ~(uint) LLObject.ObjectFlags.ObjectGroupOwned;
590 OwnerMask &= ~(uint)LLObject.ObjectFlags.Physics; 594 OwnerMask &= ~(uint) LLObject.ObjectFlags.Physics;
591 OwnerMask &= ~(uint)LLObject.ObjectFlags.Phantom; 595 OwnerMask &= ~(uint) LLObject.ObjectFlags.Phantom;
592 OwnerMask &= ~(uint)LLObject.ObjectFlags.Scripted; 596 OwnerMask &= ~(uint) LLObject.ObjectFlags.Scripted;
593 OwnerMask &= ~(uint)LLObject.ObjectFlags.Touch; 597 OwnerMask &= ~(uint) LLObject.ObjectFlags.Touch;
594 OwnerMask &= ~(uint)LLObject.ObjectFlags.Temporary; 598 OwnerMask &= ~(uint) LLObject.ObjectFlags.Temporary;
595 OwnerMask &= ~(uint)LLObject.ObjectFlags.TemporaryOnRez; 599 OwnerMask &= ~(uint) LLObject.ObjectFlags.TemporaryOnRez;
596 OwnerMask &= ~(uint)LLObject.ObjectFlags.ZlibCompressed; 600 OwnerMask &= ~(uint) LLObject.ObjectFlags.ZlibCompressed;
597 OwnerMask &= ~(uint)LLObject.ObjectFlags.AllowInventoryDrop; 601 OwnerMask &= ~(uint) LLObject.ObjectFlags.AllowInventoryDrop;
598 OwnerMask &= ~(uint)LLObject.ObjectFlags.AnimSource; 602 OwnerMask &= ~(uint) LLObject.ObjectFlags.AnimSource;
599 OwnerMask &= ~(uint)LLObject.ObjectFlags.Money; 603 OwnerMask &= ~(uint) LLObject.ObjectFlags.Money;
600 OwnerMask &= ~(uint)LLObject.ObjectFlags.CastShadows; 604 OwnerMask &= ~(uint) LLObject.ObjectFlags.CastShadows;
601 OwnerMask &= ~(uint)LLObject.ObjectFlags.InventoryEmpty; 605 OwnerMask &= ~(uint) LLObject.ObjectFlags.InventoryEmpty;
602 OwnerMask &= ~(uint)LLObject.ObjectFlags.CreateSelected; 606 OwnerMask &= ~(uint) LLObject.ObjectFlags.CreateSelected;
603 607
604 608
605 // These are some flags that the next owner mask should never have 609 // These are some flags that the next owner mask should never have
606 NextOwnerMask &= ~(uint)LLObject.ObjectFlags.ObjectYouOwner; 610 NextOwnerMask &= ~(uint) LLObject.ObjectFlags.ObjectYouOwner;
607 NextOwnerMask &= ~(uint)LLObject.ObjectFlags.ObjectTransfer; 611 NextOwnerMask &= ~(uint) LLObject.ObjectFlags.ObjectTransfer;
608 NextOwnerMask &= ~(uint)LLObject.ObjectFlags.ObjectOwnerModify; 612 NextOwnerMask &= ~(uint) LLObject.ObjectFlags.ObjectOwnerModify;
609 NextOwnerMask &= ~(uint)LLObject.ObjectFlags.ObjectGroupOwned; 613 NextOwnerMask &= ~(uint) LLObject.ObjectFlags.ObjectGroupOwned;
610 NextOwnerMask &= ~(uint)LLObject.ObjectFlags.Physics; 614 NextOwnerMask &= ~(uint) LLObject.ObjectFlags.Physics;
611 NextOwnerMask &= ~(uint)LLObject.ObjectFlags.Phantom; 615 NextOwnerMask &= ~(uint) LLObject.ObjectFlags.Phantom;
612 NextOwnerMask &= ~(uint)LLObject.ObjectFlags.Scripted; 616 NextOwnerMask &= ~(uint) LLObject.ObjectFlags.Scripted;
613 NextOwnerMask &= ~(uint)LLObject.ObjectFlags.Touch; 617 NextOwnerMask &= ~(uint) LLObject.ObjectFlags.Touch;
614 NextOwnerMask &= ~(uint)LLObject.ObjectFlags.Temporary; 618 NextOwnerMask &= ~(uint) LLObject.ObjectFlags.Temporary;
615 NextOwnerMask &= ~(uint)LLObject.ObjectFlags.TemporaryOnRez; 619 NextOwnerMask &= ~(uint) LLObject.ObjectFlags.TemporaryOnRez;
616 NextOwnerMask &= ~(uint)LLObject.ObjectFlags.ZlibCompressed; 620 NextOwnerMask &= ~(uint) LLObject.ObjectFlags.ZlibCompressed;
617 NextOwnerMask &= ~(uint)LLObject.ObjectFlags.AllowInventoryDrop; 621 NextOwnerMask &= ~(uint) LLObject.ObjectFlags.AllowInventoryDrop;
618 NextOwnerMask &= ~(uint)LLObject.ObjectFlags.AnimSource; 622 NextOwnerMask &= ~(uint) LLObject.ObjectFlags.AnimSource;
619 NextOwnerMask &= ~(uint)LLObject.ObjectFlags.Money; 623 NextOwnerMask &= ~(uint) LLObject.ObjectFlags.Money;
620 NextOwnerMask &= ~(uint)LLObject.ObjectFlags.CastShadows; 624 NextOwnerMask &= ~(uint) LLObject.ObjectFlags.CastShadows;
621 NextOwnerMask &= ~(uint)LLObject.ObjectFlags.InventoryEmpty; 625 NextOwnerMask &= ~(uint) LLObject.ObjectFlags.InventoryEmpty;
622 NextOwnerMask &= ~(uint)LLObject.ObjectFlags.CreateSelected; 626 NextOwnerMask &= ~(uint) LLObject.ObjectFlags.CreateSelected;
623 627
624 628
625 // These are some flags that the GroupMask should never have 629 // These are some flags that the GroupMask should never have
626 GroupMask &= ~(uint)LLObject.ObjectFlags.ObjectYouOwner; 630 GroupMask &= ~(uint) LLObject.ObjectFlags.ObjectYouOwner;
627 GroupMask &= ~(uint)LLObject.ObjectFlags.ObjectTransfer; 631 GroupMask &= ~(uint) LLObject.ObjectFlags.ObjectTransfer;
628 GroupMask &= ~(uint)LLObject.ObjectFlags.ObjectOwnerModify; 632 GroupMask &= ~(uint) LLObject.ObjectFlags.ObjectOwnerModify;
629 GroupMask &= ~(uint)LLObject.ObjectFlags.ObjectGroupOwned; 633 GroupMask &= ~(uint) LLObject.ObjectFlags.ObjectGroupOwned;
630 GroupMask &= ~(uint)LLObject.ObjectFlags.Physics; 634 GroupMask &= ~(uint) LLObject.ObjectFlags.Physics;
631 GroupMask &= ~(uint)LLObject.ObjectFlags.Phantom; 635 GroupMask &= ~(uint) LLObject.ObjectFlags.Phantom;
632 GroupMask &= ~(uint)LLObject.ObjectFlags.Scripted; 636 GroupMask &= ~(uint) LLObject.ObjectFlags.Scripted;
633 GroupMask &= ~(uint)LLObject.ObjectFlags.Touch; 637 GroupMask &= ~(uint) LLObject.ObjectFlags.Touch;
634 GroupMask &= ~(uint)LLObject.ObjectFlags.Temporary; 638 GroupMask &= ~(uint) LLObject.ObjectFlags.Temporary;
635 GroupMask &= ~(uint)LLObject.ObjectFlags.TemporaryOnRez; 639 GroupMask &= ~(uint) LLObject.ObjectFlags.TemporaryOnRez;
636 GroupMask &= ~(uint)LLObject.ObjectFlags.ZlibCompressed; 640 GroupMask &= ~(uint) LLObject.ObjectFlags.ZlibCompressed;
637 GroupMask &= ~(uint)LLObject.ObjectFlags.AllowInventoryDrop; 641 GroupMask &= ~(uint) LLObject.ObjectFlags.AllowInventoryDrop;
638 GroupMask &= ~(uint)LLObject.ObjectFlags.AnimSource; 642 GroupMask &= ~(uint) LLObject.ObjectFlags.AnimSource;
639 GroupMask &= ~(uint)LLObject.ObjectFlags.Money; 643 GroupMask &= ~(uint) LLObject.ObjectFlags.Money;
640 GroupMask &= ~(uint)LLObject.ObjectFlags.CastShadows; 644 GroupMask &= ~(uint) LLObject.ObjectFlags.CastShadows;
641 GroupMask &= ~(uint)LLObject.ObjectFlags.InventoryEmpty; 645 GroupMask &= ~(uint) LLObject.ObjectFlags.InventoryEmpty;
642 GroupMask &= ~(uint)LLObject.ObjectFlags.CreateSelected; 646 GroupMask &= ~(uint) LLObject.ObjectFlags.CreateSelected;
643 647
644 648
645 // These are some flags that EveryoneMask should never have 649 // These are some flags that EveryoneMask should never have
646 EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectYouOwner; 650 EveryoneMask &= ~(uint) LLObject.ObjectFlags.ObjectYouOwner;
647 EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectTransfer; 651 EveryoneMask &= ~(uint) LLObject.ObjectFlags.ObjectTransfer;
648 EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectOwnerModify; 652 EveryoneMask &= ~(uint) LLObject.ObjectFlags.ObjectOwnerModify;
649 EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectGroupOwned; 653 EveryoneMask &= ~(uint) LLObject.ObjectFlags.ObjectGroupOwned;
650 EveryoneMask &= ~(uint)LLObject.ObjectFlags.Physics; 654 EveryoneMask &= ~(uint) LLObject.ObjectFlags.Physics;
651 EveryoneMask &= ~(uint)LLObject.ObjectFlags.Phantom; 655 EveryoneMask &= ~(uint) LLObject.ObjectFlags.Phantom;
652 EveryoneMask &= ~(uint)LLObject.ObjectFlags.Scripted; 656 EveryoneMask &= ~(uint) LLObject.ObjectFlags.Scripted;
653 EveryoneMask &= ~(uint)LLObject.ObjectFlags.Touch; 657 EveryoneMask &= ~(uint) LLObject.ObjectFlags.Touch;
654 EveryoneMask &= ~(uint)LLObject.ObjectFlags.Temporary; 658 EveryoneMask &= ~(uint) LLObject.ObjectFlags.Temporary;
655 EveryoneMask &= ~(uint)LLObject.ObjectFlags.TemporaryOnRez; 659 EveryoneMask &= ~(uint) LLObject.ObjectFlags.TemporaryOnRez;
656 EveryoneMask &= ~(uint)LLObject.ObjectFlags.ZlibCompressed; 660 EveryoneMask &= ~(uint) LLObject.ObjectFlags.ZlibCompressed;
657 EveryoneMask &= ~(uint)LLObject.ObjectFlags.AllowInventoryDrop; 661 EveryoneMask &= ~(uint) LLObject.ObjectFlags.AllowInventoryDrop;
658 EveryoneMask &= ~(uint)LLObject.ObjectFlags.AnimSource; 662 EveryoneMask &= ~(uint) LLObject.ObjectFlags.AnimSource;
659 EveryoneMask &= ~(uint)LLObject.ObjectFlags.Money; 663 EveryoneMask &= ~(uint) LLObject.ObjectFlags.Money;
660 EveryoneMask &= ~(uint)LLObject.ObjectFlags.CastShadows; 664 EveryoneMask &= ~(uint) LLObject.ObjectFlags.CastShadows;
661 EveryoneMask &= ~(uint)LLObject.ObjectFlags.InventoryEmpty; 665 EveryoneMask &= ~(uint) LLObject.ObjectFlags.InventoryEmpty;
662 EveryoneMask &= ~(uint)LLObject.ObjectFlags.CreateSelected; 666 EveryoneMask &= ~(uint) LLObject.ObjectFlags.CreateSelected;
663
664 667
665 // These are some flags that ObjectFlags (m_flags) should never have
666 ObjectFlags &= ~(uint)LLObject.ObjectFlags.ObjectYouOwner;
667 ObjectFlags &= ~(uint)LLObject.ObjectFlags.ObjectTransfer;
668 ObjectFlags &= ~(uint)LLObject.ObjectFlags.ObjectOwnerModify;
669 ObjectFlags &= ~(uint)LLObject.ObjectFlags.ObjectYouOfficer;
670 ObjectFlags &= ~(uint)LLObject.ObjectFlags.ObjectCopy;
671 ObjectFlags &= ~(uint)LLObject.ObjectFlags.ObjectModify;
672 ObjectFlags &= ~(uint)LLObject.ObjectFlags.ObjectMove;
673 668
669 // These are some flags that ObjectFlags (m_flags) should never have
670 ObjectFlags &= ~(uint) LLObject.ObjectFlags.ObjectYouOwner;
671 ObjectFlags &= ~(uint) LLObject.ObjectFlags.ObjectTransfer;
672 ObjectFlags &= ~(uint) LLObject.ObjectFlags.ObjectOwnerModify;
673 ObjectFlags &= ~(uint) LLObject.ObjectFlags.ObjectYouOfficer;
674 ObjectFlags &= ~(uint) LLObject.ObjectFlags.ObjectCopy;
675 ObjectFlags &= ~(uint) LLObject.ObjectFlags.ObjectModify;
676 ObjectFlags &= ~(uint) LLObject.ObjectFlags.ObjectMove;
674 } 677 }
675 678
676 /// <summary> 679 /// <summary>
@@ -679,13 +682,12 @@ namespace OpenSim.Region.Environment.Scenes
679 /// <param name="xmlWriter"></param> 682 /// <param name="xmlWriter"></param>
680 public void ToXml(XmlWriter xmlWriter) 683 public void ToXml(XmlWriter xmlWriter)
681 { 684 {
682 XmlSerializer serializer = new XmlSerializer(typeof(SceneObjectPart)); 685 XmlSerializer serializer = new XmlSerializer(typeof (SceneObjectPart));
683 serializer.Serialize(xmlWriter, this); 686 serializer.Serialize(xmlWriter, this);
684 } 687 }
685 688
686 public EntityIntersection TestIntersection(Ray iray, Quaternion parentrot) 689 public EntityIntersection TestIntersection(Ray iray, Quaternion parentrot)
687 { 690 {
688
689 // In this case we're using a sphere with a radius of the largest dimention of the prim 691 // In this case we're using a sphere with a radius of the largest dimention of the prim
690 // TODO: Change to take shape into account 692 // TODO: Change to take shape into account
691 693
@@ -693,35 +695,34 @@ namespace OpenSim.Region.Environment.Scenes
693 EntityIntersection returnresult = new EntityIntersection(); 695 EntityIntersection returnresult = new EntityIntersection();
694 Vector3 vAbsolutePosition = new Vector3(AbsolutePosition.X, AbsolutePosition.Y, AbsolutePosition.Z); 696 Vector3 vAbsolutePosition = new Vector3(AbsolutePosition.X, AbsolutePosition.Y, AbsolutePosition.Z);
695 Vector3 vScale = new Vector3(Scale.X, Scale.Y, Scale.Z); 697 Vector3 vScale = new Vector3(Scale.X, Scale.Y, Scale.Z);
696 Quaternion qRotation = new Quaternion(RotationOffset.W, RotationOffset.X, RotationOffset.Y, RotationOffset.Z); 698 Quaternion qRotation =
697 699 new Quaternion(RotationOffset.W, RotationOffset.X, RotationOffset.Y, RotationOffset.Z);
698 700
699 701
700 Quaternion worldRotation = (qRotation * parentrot); 702 Quaternion worldRotation = (qRotation*parentrot);
701 Matrix3 worldRotM = worldRotation.ToRotationMatrix(); 703 Matrix3 worldRotM = worldRotation.ToRotationMatrix();
702 704
703 705
704
705 Vector3 rOrigin = iray.Origin; 706 Vector3 rOrigin = iray.Origin;
706 Vector3 rDirection = iray.Direction; 707 Vector3 rDirection = iray.Direction;
707 708
708 709
709 // Buidling the first part of the Quadratic equation 710 // Buidling the first part of the Quadratic equation
710 Vector3 r2ndDirection = rDirection * rDirection; 711 Vector3 r2ndDirection = rDirection*rDirection;
711 float itestPart1 = r2ndDirection.x + r2ndDirection.y + r2ndDirection.z; 712 float itestPart1 = r2ndDirection.x + r2ndDirection.y + r2ndDirection.z;
712 713
713 // Buidling the second part of the Quadratic equation 714 // Buidling the second part of the Quadratic equation
714 Vector3 tmVal2 = rOrigin - vAbsolutePosition; 715 Vector3 tmVal2 = rOrigin - vAbsolutePosition;
715 Vector3 r2Direction = rDirection * 2.0f; 716 Vector3 r2Direction = rDirection*2.0f;
716 Vector3 tmVal3 = r2Direction * tmVal2; 717 Vector3 tmVal3 = r2Direction*tmVal2;
717 718
718 float itestPart2 = tmVal3.x + tmVal3.y + tmVal3.z; 719 float itestPart2 = tmVal3.x + tmVal3.y + tmVal3.z;
719 720
720 // Buidling the third part of the Quadratic equation 721 // Buidling the third part of the Quadratic equation
721 Vector3 tmVal4 = rOrigin * rOrigin; 722 Vector3 tmVal4 = rOrigin*rOrigin;
722 Vector3 tmVal5 = vAbsolutePosition * vAbsolutePosition; 723 Vector3 tmVal5 = vAbsolutePosition*vAbsolutePosition;
723 724
724 Vector3 tmVal6 = vAbsolutePosition * rOrigin; 725 Vector3 tmVal6 = vAbsolutePosition*rOrigin;
725 726
726 727
727 // Set Radius to the largest dimention of the prim 728 // Set Radius to the largest dimention of the prim
@@ -735,21 +736,22 @@ namespace OpenSim.Region.Environment.Scenes
735 736
736 //radius = radius; 737 //radius = radius;
737 738
738 float itestPart3 = tmVal4.x + tmVal4.y + tmVal4.z + tmVal5.x + tmVal5.y + tmVal5.z - (2.0f * (tmVal6.x + tmVal6.y + tmVal6.z + (radius * radius))); 739 float itestPart3 = tmVal4.x + tmVal4.y + tmVal4.z + tmVal5.x + tmVal5.y + tmVal5.z -
740 (2.0f*(tmVal6.x + tmVal6.y + tmVal6.z + (radius*radius)));
739 741
740 // Yuk Quadradrics.. Solve first 742 // Yuk Quadradrics.. Solve first
741 float rootsqr = (itestPart2 * itestPart2) - (4.0f * itestPart1 * itestPart3); 743 float rootsqr = (itestPart2*itestPart2) - (4.0f*itestPart1*itestPart3);
742 if (rootsqr < 0.0f) 744 if (rootsqr < 0.0f)
743 { 745 {
744 // No intersection 746 // No intersection
745 return returnresult; 747 return returnresult;
746 } 748 }
747 float root = ((-itestPart2) - (float)Math.Sqrt((double)rootsqr)) / (itestPart1 * 2.0f); 749 float root = ((-itestPart2) - (float) Math.Sqrt((double) rootsqr))/(itestPart1*2.0f);
748 750
749 if (root < 0.0f) 751 if (root < 0.0f)
750 { 752 {
751 // perform second quadratic root solution 753 // perform second quadratic root solution
752 root = ((-itestPart2) + (float)Math.Sqrt((double)rootsqr)) / (itestPart1 * 2.0f); 754 root = ((-itestPart2) + (float) Math.Sqrt((double) rootsqr))/(itestPart1*2.0f);
753 755
754 // is there any intersection? 756 // is there any intersection?
755 if (root < 0.0f) 757 if (root < 0.0f)
@@ -761,7 +763,9 @@ namespace OpenSim.Region.Environment.Scenes
761 763
762 // We got an intersection. putting together an EntityIntersection object with the 764 // We got an intersection. putting together an EntityIntersection object with the
763 // intersection information 765 // intersection information
764 Vector3 ipoint = new Vector3(iray.Origin.x + (iray.Direction.x * root), iray.Origin.y + (iray.Direction.y * root), iray.Origin.z + (iray.Direction.z * root)); 766 Vector3 ipoint =
767 new Vector3(iray.Origin.x + (iray.Direction.x*root), iray.Origin.y + (iray.Direction.y*root),
768 iray.Origin.z + (iray.Direction.z*root));
765 769
766 returnresult.HitTF = true; 770 returnresult.HitTF = true;
767 returnresult.ipoint = ipoint; 771 returnresult.ipoint = ipoint;
@@ -775,7 +779,7 @@ namespace OpenSim.Region.Environment.Scenes
775 779
776 LLVector3 distanceConvert1 = new LLVector3(iray.Origin.x, iray.Origin.y, iray.Origin.z); 780 LLVector3 distanceConvert1 = new LLVector3(iray.Origin.x, iray.Origin.y, iray.Origin.z);
777 LLVector3 distanceConvert2 = new LLVector3(ipoint.x, ipoint.y, ipoint.z); 781 LLVector3 distanceConvert2 = new LLVector3(ipoint.x, ipoint.y, ipoint.z);
778 float distance = (float)Util.GetDistanceTo(distanceConvert1, distanceConvert2); 782 float distance = (float) Util.GetDistanceTo(distanceConvert1, distanceConvert2);
779 783
780 returnresult.distance = distance; 784 returnresult.distance = distance;
781 785
@@ -783,7 +787,6 @@ namespace OpenSim.Region.Environment.Scenes
783 } 787 }
784 788
785 789
786
787 /// <summary> 790 /// <summary>
788 /// 791 ///
789 /// </summary> 792 /// </summary>
@@ -797,6 +800,7 @@ namespace OpenSim.Region.Environment.Scenes
797 m_sitTargetPosition = offset; 800 m_sitTargetPosition = offset;
798 m_sitTargetOrientation = orientation; 801 m_sitTargetOrientation = orientation;
799 } 802 }
803
800 public LLVector3 GetSitTargetPositionLL() 804 public LLVector3 GetSitTargetPositionLL()
801 { 805 {
802 return new LLVector3(m_sitTargetPosition.x, m_sitTargetPosition.y, m_sitTargetPosition.z); 806 return new LLVector3(m_sitTargetPosition.x, m_sitTargetPosition.y, m_sitTargetPosition.z);
@@ -804,13 +808,17 @@ namespace OpenSim.Region.Environment.Scenes
804 808
805 public LLQuaternion GetSitTargetOrientationLL() 809 public LLQuaternion GetSitTargetOrientationLL()
806 { 810 {
807 return new LLQuaternion( m_sitTargetOrientation.x, m_sitTargetOrientation.y, m_sitTargetOrientation.z,m_sitTargetOrientation.w); 811 return
812 new LLQuaternion(m_sitTargetOrientation.x, m_sitTargetOrientation.y, m_sitTargetOrientation.z,
813 m_sitTargetOrientation.w);
808 } 814 }
809 815
810 // Utility function so the databases don't have to reference axiom.math 816 // Utility function so the databases don't have to reference axiom.math
811 public void SetSitTargetLL(LLVector3 offset, LLQuaternion orientation) 817 public void SetSitTargetLL(LLVector3 offset, LLQuaternion orientation)
812 { 818 {
813 if (!(offset.X == 0 && offset.Y == 0 && offset.Z == 0 && (orientation.W == 0 || orientation.W == 1) && orientation.X == 0 && orientation.Y == 0 && orientation.Z == 0)) 819 if (
820 !(offset.X == 0 && offset.Y == 0 && offset.Z == 0 && (orientation.W == 0 || orientation.W == 1) &&
821 orientation.X == 0 && orientation.Y == 0 && orientation.Z == 0))
814 { 822 {
815 m_sitTargetPosition = new Vector3(offset.X, offset.Y, offset.Z); 823 m_sitTargetPosition = new Vector3(offset.X, offset.Y, offset.Z);
816 m_sitTargetOrientation = new Quaternion(orientation.W, orientation.X, orientation.Y, orientation.Z); 824 m_sitTargetOrientation = new Quaternion(orientation.W, orientation.X, orientation.Y, orientation.Z);
@@ -869,7 +877,7 @@ namespace OpenSim.Region.Environment.Scenes
869 /// <returns></returns> 877 /// <returns></returns>
870 public SceneObjectPart Copy(uint localID, LLUUID AgentID, LLUUID GroupID) 878 public SceneObjectPart Copy(uint localID, LLUUID AgentID, LLUUID GroupID)
871 { 879 {
872 SceneObjectPart dupe = (SceneObjectPart)MemberwiseClone(); 880 SceneObjectPart dupe = (SceneObjectPart) MemberwiseClone();
873 dupe.m_shape = m_shape.Copy(); 881 dupe.m_shape = m_shape.Copy();
874 dupe.m_regionHandle = m_regionHandle; 882 dupe.m_regionHandle = m_regionHandle;
875 dupe.UUID = LLUUID.Random(); 883 dupe.UUID = LLUUID.Random();
@@ -896,7 +904,7 @@ namespace OpenSim.Region.Environment.Scenes
896 byte[] extraP = new byte[Shape.ExtraParams.Length]; 904 byte[] extraP = new byte[Shape.ExtraParams.Length];
897 Array.Copy(Shape.ExtraParams, extraP, extraP.Length); 905 Array.Copy(Shape.ExtraParams, extraP, extraP.Length);
898 dupe.Shape.ExtraParams = extraP; 906 dupe.Shape.ExtraParams = extraP;
899 bool UsePhysics = ((dupe.ObjectFlags & (uint)LLObject.ObjectFlags.Physics) != 0); 907 bool UsePhysics = ((dupe.ObjectFlags & (uint) LLObject.ObjectFlags.Physics) != 0);
900 dupe.DoPhysicsPropertyUpdate(UsePhysics, true); 908 dupe.DoPhysicsPropertyUpdate(UsePhysics, true);
901 909
902 return dupe; 910 return dupe;
@@ -923,7 +931,7 @@ namespace OpenSim.Region.Environment.Scenes
923 { 931 {
924 m_parentGroup.HasChanged = true; 932 m_parentGroup.HasChanged = true;
925 } 933 }
926 TimeStampFull = (uint)Util.UnixTimeSinceEpoch(); 934 TimeStampFull = (uint) Util.UnixTimeSinceEpoch();
927 m_updateFlag = 2; 935 m_updateFlag = 2;
928 } 936 }
929 937
@@ -931,11 +939,10 @@ namespace OpenSim.Region.Environment.Scenes
931 { 939 {
932 LLObject.ObjectFlags prevflag = m_flags; 940 LLObject.ObjectFlags prevflag = m_flags;
933 //uint objflags = m_flags; 941 //uint objflags = m_flags;
934 if ((ObjectFlags & (uint)flag) == 0) 942 if ((ObjectFlags & (uint) flag) == 0)
935 { 943 {
936 //Console.WriteLine("Adding flag: " + ((LLObject.ObjectFlags) flag).ToString()); 944 //Console.WriteLine("Adding flag: " + ((LLObject.ObjectFlags) flag).ToString());
937 m_flags |= flag; 945 m_flags |= flag;
938
939 } 946 }
940 //uint currflag = (uint)m_flags; 947 //uint currflag = (uint)m_flags;
941 //System.Console.WriteLine("Aprev: " + prevflag.ToString() + " curr: " + m_flags.ToString()); 948 //System.Console.WriteLine("Aprev: " + prevflag.ToString() + " curr: " + m_flags.ToString());
@@ -945,11 +952,10 @@ namespace OpenSim.Region.Environment.Scenes
945 public void RemFlag(LLObject.ObjectFlags flag) 952 public void RemFlag(LLObject.ObjectFlags flag)
946 { 953 {
947 LLObject.ObjectFlags prevflag = m_flags; 954 LLObject.ObjectFlags prevflag = m_flags;
948 if ((ObjectFlags & (uint)flag) != 0) 955 if ((ObjectFlags & (uint) flag) != 0)
949 { 956 {
950 //Console.WriteLine("Removing flag: " + ((LLObject.ObjectFlags)flag).ToString()); 957 //Console.WriteLine("Removing flag: " + ((LLObject.ObjectFlags)flag).ToString());
951 m_flags &= ~flag; 958 m_flags &= ~flag;
952
953 } 959 }
954 //System.Console.WriteLine("prev: " + prevflag.ToString() + " curr: " + m_flags.ToString()); 960 //System.Console.WriteLine("prev: " + prevflag.ToString() + " curr: " + m_flags.ToString());
955 //ScheduleFullUpdate(); 961 //ScheduleFullUpdate();
@@ -966,7 +972,7 @@ namespace OpenSim.Region.Environment.Scenes
966 { 972 {
967 m_parentGroup.HasChanged = true; 973 m_parentGroup.HasChanged = true;
968 } 974 }
969 TimeStampTerse = (uint)Util.UnixTimeSinceEpoch(); 975 TimeStampTerse = (uint) Util.UnixTimeSinceEpoch();
970 m_updateFlag = 1; 976 m_updateFlag = 1;
971 } 977 }
972 } 978 }
@@ -1074,7 +1080,7 @@ namespace OpenSim.Region.Environment.Scenes
1074 { 1080 {
1075 if (m_inventorySerial > 0) 1081 if (m_inventorySerial > 0)
1076 { 1082 {
1077 client.SendTaskInventory(m_uuid, (short)m_inventorySerial, 1083 client.SendTaskInventory(m_uuid, (short) m_inventorySerial,
1078 Helpers.StringToField(m_inventoryFileName)); 1084 Helpers.StringToField(m_inventoryFileName));
1079 return true; 1085 return true;
1080 } 1086 }
@@ -1134,7 +1140,7 @@ namespace OpenSim.Region.Environment.Scenes
1134 bool IsTemporary = false; 1140 bool IsTemporary = false;
1135 bool IsPhantom = false; 1141 bool IsPhantom = false;
1136 bool castsShadows = false; 1142 bool castsShadows = false;
1137 bool wasUsingPhysics = ((ObjectFlags & (uint)LLObject.ObjectFlags.Physics) != 0); 1143 bool wasUsingPhysics = ((ObjectFlags & (uint) LLObject.ObjectFlags.Physics) != 0);
1138 //bool IsLocked = false; 1144 //bool IsLocked = false;
1139 int i = 0; 1145 int i = 0;
1140 1146
@@ -1162,7 +1168,6 @@ namespace OpenSim.Region.Environment.Scenes
1162 { 1168 {
1163 DoPhysicsPropertyUpdate(usePhysics, false); 1169 DoPhysicsPropertyUpdate(usePhysics, false);
1164 } 1170 }
1165
1166 } 1171 }
1167 else 1172 else
1168 { 1173 {
@@ -1174,9 +1179,6 @@ namespace OpenSim.Region.Environment.Scenes
1174 } 1179 }
1175 1180
1176 1181
1177
1178
1179
1180 if (IsPhantom) 1182 if (IsPhantom)
1181 { 1183 {
1182 AddFlag(LLObject.ObjectFlags.Phantom); 1184 AddFlag(LLObject.ObjectFlags.Phantom);
@@ -1220,19 +1222,18 @@ namespace OpenSim.Region.Environment.Scenes
1220 // System.Console.WriteLine("Update: PHY:" + UsePhysics.ToString() + ", T:" + IsTemporary.ToString() + ", PHA:" + IsPhantom.ToString() + " S:" + CastsShadows.ToString()); 1222 // System.Console.WriteLine("Update: PHY:" + UsePhysics.ToString() + ", T:" + IsTemporary.ToString() + ", PHA:" + IsPhantom.ToString() + " S:" + CastsShadows.ToString());
1221 ScheduleFullUpdate(); 1223 ScheduleFullUpdate();
1222 } 1224 }
1225
1223 public void DoPhysicsPropertyUpdate(bool UsePhysics, bool isNew) 1226 public void DoPhysicsPropertyUpdate(bool UsePhysics, bool isNew)
1224 { 1227 {
1225
1226 if (PhysActor != null) 1228 if (PhysActor != null)
1227 { 1229 {
1228 if (UsePhysics != PhysActor.IsPhysical || isNew) 1230 if (UsePhysics != PhysActor.IsPhysical || isNew)
1229 { 1231 {
1230
1231 if (PhysActor.IsPhysical) 1232 if (PhysActor.IsPhysical)
1232 { 1233 {
1233 if (!isNew) 1234 if (!isNew)
1234 this.ParentGroup.m_scene.RemovePhysicalPrim(1); 1235 ParentGroup.m_scene.RemovePhysicalPrim(1);
1235 1236
1236 PhysActor.OnRequestTerseUpdate -= PhysicsRequestingTerseUpdate; 1237 PhysActor.OnRequestTerseUpdate -= PhysicsRequestingTerseUpdate;
1237 PhysActor.OnOutOfBounds -= PhysicsOutOfBounds; 1238 PhysActor.OnOutOfBounds -= PhysicsOutOfBounds;
1238 } 1239 }
@@ -1244,7 +1245,7 @@ namespace OpenSim.Region.Environment.Scenes
1244 //PhysActor = null; 1245 //PhysActor = null;
1245 1246
1246 1247
1247 if ((ObjectFlags & (uint)LLObject.ObjectFlags.Phantom) == 0) 1248 if ((ObjectFlags & (uint) LLObject.ObjectFlags.Phantom) == 0)
1248 { 1249 {
1249 //PhysActor = m_parentGroup.m_scene.PhysicsScene.AddPrimShape( 1250 //PhysActor = m_parentGroup.m_scene.PhysicsScene.AddPrimShape(
1250 //Name, 1251 //Name,
@@ -1256,8 +1257,8 @@ namespace OpenSim.Region.Environment.Scenes
1256 //RotationOffset.Y, RotationOffset.Z), UsePhysics); 1257 //RotationOffset.Y, RotationOffset.Z), UsePhysics);
1257 if (UsePhysics) 1258 if (UsePhysics)
1258 { 1259 {
1259 this.ParentGroup.m_scene.AddPhysicalPrim(1); 1260 ParentGroup.m_scene.AddPhysicalPrim(1);
1260 1261
1261 PhysActor.OnRequestTerseUpdate += PhysicsRequestingTerseUpdate; 1262 PhysActor.OnRequestTerseUpdate += PhysicsRequestingTerseUpdate;
1262 PhysActor.OnOutOfBounds += PhysicsOutOfBounds; 1263 PhysActor.OnOutOfBounds += PhysicsOutOfBounds;
1263 } 1264 }
@@ -1271,15 +1272,15 @@ namespace OpenSim.Region.Environment.Scenes
1271 { 1272 {
1272 m_shape.ExtraParams = new byte[data.Length + 7]; 1273 m_shape.ExtraParams = new byte[data.Length + 7];
1273 int i = 0; 1274 int i = 0;
1274 uint length = (uint)data.Length; 1275 uint length = (uint) data.Length;
1275 m_shape.ExtraParams[i++] = 1; 1276 m_shape.ExtraParams[i++] = 1;
1276 m_shape.ExtraParams[i++] = (byte)(type % 256); 1277 m_shape.ExtraParams[i++] = (byte) (type%256);
1277 m_shape.ExtraParams[i++] = (byte)((type >> 8) % 256); 1278 m_shape.ExtraParams[i++] = (byte) ((type >> 8)%256);
1278 1279
1279 m_shape.ExtraParams[i++] = (byte)(length % 256); 1280 m_shape.ExtraParams[i++] = (byte) (length%256);
1280 m_shape.ExtraParams[i++] = (byte)((length >> 8) % 256); 1281 m_shape.ExtraParams[i++] = (byte) ((length >> 8)%256);
1281 m_shape.ExtraParams[i++] = (byte)((length >> 16) % 256); 1282 m_shape.ExtraParams[i++] = (byte) ((length >> 16)%256);
1282 m_shape.ExtraParams[i++] = (byte)((length >> 24) % 256); 1283 m_shape.ExtraParams[i++] = (byte) ((length >> 24)%256);
1283 Array.Copy(data, 0, m_shape.ExtraParams, i, data.Length); 1284 Array.Copy(data, 0, m_shape.ExtraParams, i, data.Length);
1284 1285
1285 ScheduleFullUpdate(); 1286 ScheduleFullUpdate();
@@ -1305,7 +1306,7 @@ namespace OpenSim.Region.Environment.Scenes
1305 { 1306 {
1306 if (PhysActor != null) 1307 if (PhysActor != null)
1307 { 1308 {
1308 return new LLVector3(PhysActor.CenterOfMass.X,PhysActor.CenterOfMass.Y,PhysActor.CenterOfMass.Z); 1309 return new LLVector3(PhysActor.CenterOfMass.X, PhysActor.CenterOfMass.Y, PhysActor.CenterOfMass.Z);
1309 } 1310 }
1310 else 1311 else
1311 { 1312 {
@@ -1323,7 +1324,7 @@ namespace OpenSim.Region.Environment.Scenes
1323 /// <param name="textureEntry"></param> 1324 /// <param name="textureEntry"></param>
1324 public void UpdateTextureEntry(byte[] textureEntry) 1325 public void UpdateTextureEntry(byte[] textureEntry)
1325 { 1326 {
1326 m_shape.Textures = new LLObject.TextureEntry( textureEntry, 0, textureEntry.Length ); 1327 m_shape.Textures = new LLObject.TextureEntry(textureEntry, 0, textureEntry.Length);
1327 ScheduleFullUpdate(); 1328 ScheduleFullUpdate();
1328 } 1329 }
1329 1330
@@ -1337,20 +1338,20 @@ namespace OpenSim.Region.Environment.Scenes
1337 { 1338 {
1338 if (tex.FaceTextures[i] != null) 1339 if (tex.FaceTextures[i] != null)
1339 { 1340 {
1340 tmpcolor = tex.GetFace((uint)i).RGBA; 1341 tmpcolor = tex.GetFace((uint) i).RGBA;
1341 tmpcolor.A = tmpcolor.A * 255; 1342 tmpcolor.A = tmpcolor.A*255;
1342 tmpcolor.R = tmpcolor.R * 255; 1343 tmpcolor.R = tmpcolor.R*255;
1343 tmpcolor.G = tmpcolor.G * 255; 1344 tmpcolor.G = tmpcolor.G*255;
1344 tmpcolor.B = tmpcolor.B * 255; 1345 tmpcolor.B = tmpcolor.B*255;
1345 tex.FaceTextures[i].RGBA = tmpcolor; 1346 tex.FaceTextures[i].RGBA = tmpcolor;
1346 } 1347 }
1347 } 1348 }
1348 tmpcolor = tex.DefaultTexture.RGBA; 1349 tmpcolor = tex.DefaultTexture.RGBA;
1349 tmpcolor.A = tmpcolor.A * 255; 1350 tmpcolor.A = tmpcolor.A*255;
1350 tmpcolor.R = tmpcolor.R * 255; 1351 tmpcolor.R = tmpcolor.R*255;
1351 tmpcolor.G = tmpcolor.G * 255; 1352 tmpcolor.G = tmpcolor.G*255;
1352 tmpcolor.B = tmpcolor.B * 255; 1353 tmpcolor.B = tmpcolor.B*255;
1353 tex.DefaultTexture.RGBA = tmpcolor; 1354 tex.DefaultTexture.RGBA = tmpcolor;
1354 UpdateTextureEntry(tex.ToBytes()); 1355 UpdateTextureEntry(tex.ToBytes());
1355 } 1356 }
1356 1357
@@ -1416,34 +1417,33 @@ namespace OpenSim.Region.Environment.Scenes
1416 // Are we the owner? 1417 // Are we the owner?
1417 if (AgentID == OwnerID) 1418 if (AgentID == OwnerID)
1418 { 1419 {
1419 MainLog.Instance.Verbose("PERMISSIONS", "field: " + field.ToString() + ", mask: " + mask.ToString() + " addRemTF: " + addRemTF.ToString()); 1420 MainLog.Instance.Verbose("PERMISSIONS",
1420 1421 "field: " + field.ToString() + ", mask: " + mask.ToString() + " addRemTF: " +
1422 addRemTF.ToString());
1423
1421 //Field 8 = EveryoneMask 1424 //Field 8 = EveryoneMask
1422 if (field == (byte)8) 1425 if (field == (byte) 8)
1423 { 1426 {
1424 MainLog.Instance.Verbose("PERMISSIONS", "Left over: " + (OwnerMask - EveryoneMask)); 1427 MainLog.Instance.Verbose("PERMISSIONS", "Left over: " + (OwnerMask - EveryoneMask));
1425 if (addRemTF == (byte)0) 1428 if (addRemTF == (byte) 0)
1426 { 1429 {
1427 //EveryoneMask = (uint)0; 1430 //EveryoneMask = (uint)0;
1428 EveryoneMask &= ~mask; 1431 EveryoneMask &= ~mask;
1429 //EveryoneMask &= ~(uint)57344; 1432 //EveryoneMask &= ~(uint)57344;
1430
1431
1432 } 1433 }
1433 else 1434 else
1434 { 1435 {
1435 //EveryoneMask = (uint)0; 1436 //EveryoneMask = (uint)0;
1436 EveryoneMask |= mask; 1437 EveryoneMask |= mask;
1437 //EveryoneMask |= (uint)57344; 1438 //EveryoneMask |= (uint)57344;
1438
1439 } 1439 }
1440 //ScheduleFullUpdate(); 1440 //ScheduleFullUpdate();
1441 SendFullUpdateToAllClients(); 1441 SendFullUpdateToAllClients();
1442 } 1442 }
1443 //Field 16 = NextownerMask 1443 //Field 16 = NextownerMask
1444 if (field == (byte)16) 1444 if (field == (byte) 16)
1445 { 1445 {
1446 if (addRemTF == (byte)0) 1446 if (addRemTF == (byte) 0)
1447 { 1447 {
1448 NextOwnerMask &= ~mask; 1448 NextOwnerMask &= ~mask;
1449 } 1449 }
@@ -1453,7 +1453,6 @@ namespace OpenSim.Region.Environment.Scenes
1453 } 1453 }
1454 SendFullUpdateToAllClients(); 1454 SendFullUpdateToAllClients();
1455 } 1455 }
1456
1457 } 1456 }
1458 } 1457 }
1459 1458
@@ -1482,7 +1481,8 @@ namespace OpenSim.Region.Environment.Scenes
1482 for (int i = 0; i < avatars.Count; i++) 1481 for (int i = 0; i < avatars.Count; i++)
1483 { 1482 {
1484 // Ugly reference :( 1483 // Ugly reference :(
1485 m_parentGroup.SendPartFullUpdate(avatars[i].ControllingClient, this, avatars[i].GenerateClientFlags(this.UUID)); 1484 m_parentGroup.SendPartFullUpdate(avatars[i].ControllingClient, this,
1485 avatars[i].GenerateClientFlags(UUID));
1486 } 1486 }
1487 } 1487 }
1488 1488
@@ -1515,19 +1515,19 @@ namespace OpenSim.Region.Environment.Scenes
1515 { 1515 {
1516 LLQuaternion lRot; 1516 LLQuaternion lRot;
1517 lRot = RotationOffset; 1517 lRot = RotationOffset;
1518 clientFlags &= ~(uint)LLObject.ObjectFlags.CreateSelected; 1518 clientFlags &= ~(uint) LLObject.ObjectFlags.CreateSelected;
1519 1519
1520 if (remoteClient.AgentId == OwnerID) 1520 if (remoteClient.AgentId == OwnerID)
1521 { 1521 {
1522 if ((uint)(m_flags & LLObject.ObjectFlags.CreateSelected) != 0) 1522 if ((uint) (m_flags & LLObject.ObjectFlags.CreateSelected) != 0)
1523 { 1523 {
1524 clientFlags |= (uint)LLObject.ObjectFlags.CreateSelected; 1524 clientFlags |= (uint) LLObject.ObjectFlags.CreateSelected;
1525 m_flags &= ~LLObject.ObjectFlags.CreateSelected; 1525 m_flags &= ~LLObject.ObjectFlags.CreateSelected;
1526 } 1526 }
1527 } 1527 }
1528 1528
1529 1529
1530 byte[] color = new byte[] { m_color.R, m_color.G, m_color.B, m_color.A }; 1530 byte[] color = new byte[] {m_color.R, m_color.G, m_color.B, m_color.A};
1531 remoteClient.SendPrimitiveToClient(m_regionHandle, 64096, LocalID, m_shape, lPos, clientFlags, m_uuid, 1531 remoteClient.SendPrimitiveToClient(m_regionHandle, 64096, LocalID, m_shape, lPos, clientFlags, m_uuid,
1532 OwnerID, 1532 OwnerID,
1533 m_text, color, ParentID, m_particleSystem, lRot, m_clickAction); 1533 m_text, color, ParentID, m_particleSystem, lRot, m_clickAction);
@@ -1574,26 +1574,28 @@ namespace OpenSim.Region.Environment.Scenes
1574 LLVector3 lPos; 1574 LLVector3 lPos;
1575 lPos = OffsetPosition; 1575 lPos = OffsetPosition;
1576 LLQuaternion mRot = RotationOffset; 1576 LLQuaternion mRot = RotationOffset;
1577 if ((ObjectFlags & (uint)LLObject.ObjectFlags.Physics) == 0) 1577 if ((ObjectFlags & (uint) LLObject.ObjectFlags.Physics) == 0)
1578 { 1578 {
1579 remoteClient.SendPrimTerseUpdate(m_regionHandle, 64096, LocalID, lPos, mRot); 1579 remoteClient.SendPrimTerseUpdate(m_regionHandle, 64096, LocalID, lPos, mRot);
1580 } 1580 }
1581 else 1581 else
1582 { 1582 {
1583 remoteClient.SendPrimTerseUpdate(m_regionHandle, 64096, LocalID, lPos, mRot, Velocity, RotationalVelocity); 1583 remoteClient.SendPrimTerseUpdate(m_regionHandle, 64096, LocalID, lPos, mRot, Velocity,
1584 RotationalVelocity);
1584 } 1585 }
1585 } 1586 }
1586 1587
1587 public void SendTerseUpdateToClient(IClientAPI remoteClient, LLVector3 lPos) 1588 public void SendTerseUpdateToClient(IClientAPI remoteClient, LLVector3 lPos)
1588 { 1589 {
1589 LLQuaternion mRot = RotationOffset; 1590 LLQuaternion mRot = RotationOffset;
1590 if ((ObjectFlags & (uint)LLObject.ObjectFlags.Physics) == 0) 1591 if ((ObjectFlags & (uint) LLObject.ObjectFlags.Physics) == 0)
1591 { 1592 {
1592 remoteClient.SendPrimTerseUpdate(m_regionHandle, 64096, LocalID, lPos, mRot); 1593 remoteClient.SendPrimTerseUpdate(m_regionHandle, 64096, LocalID, lPos, mRot);
1593 } 1594 }
1594 else 1595 else
1595 { 1596 {
1596 remoteClient.SendPrimTerseUpdate(m_regionHandle, 64096, LocalID, lPos, mRot, Velocity, RotationalVelocity); 1597 remoteClient.SendPrimTerseUpdate(m_regionHandle, 64096, LocalID, lPos, mRot, Velocity,
1598 RotationalVelocity);
1597 //System.Console.WriteLine("RVel:" + RotationalVelocity); 1599 //System.Console.WriteLine("RVel:" + RotationalVelocity);
1598 } 1600 }
1599 } 1601 }
@@ -1603,13 +1605,16 @@ namespace OpenSim.Region.Environment.Scenes
1603 public virtual void UpdateMovement() 1605 public virtual void UpdateMovement()
1604 { 1606 {
1605 } 1607 }
1608
1606 #region Events 1609 #region Events
1610
1607 public void PhysicsRequestingTerseUpdate() 1611 public void PhysicsRequestingTerseUpdate()
1608 { 1612 {
1609 ScheduleTerseUpdate(); 1613 ScheduleTerseUpdate();
1610 1614
1611 //SendTerseUpdateToAllClients(); 1615 //SendTerseUpdateToAllClients();
1612 } 1616 }
1617
1613 #endregion 1618 #endregion
1614 1619
1615 public void PhysicsOutOfBounds(PhysicsVector pos) 1620 public void PhysicsOutOfBounds(PhysicsVector pos)
@@ -1626,10 +1631,10 @@ namespace OpenSim.Region.Environment.Scenes
1626 1631
1627 public void SetText(string text, Vector3 color, double alpha) 1632 public void SetText(string text, Vector3 color, double alpha)
1628 { 1633 {
1629 Color = Color.FromArgb(0xff - (int)(alpha * 0xff), 1634 Color = Color.FromArgb(0xff - (int) (alpha*0xff),
1630 (int)(color.x * 0xff), 1635 (int) (color.x*0xff),
1631 (int)(color.y * 0xff), 1636 (int) (color.y*0xff),
1632 (int)(color.z * 0xff)); 1637 (int) (color.z*0xff));
1633 Text = text; 1638 Text = text;
1634 } 1639 }
1635 1640
@@ -1725,7 +1730,6 @@ namespace OpenSim.Region.Environment.Scenes
1725 public TaskInventoryItem() 1730 public TaskInventoryItem()
1726 { 1731 {
1727 } 1732 }
1728
1729 } 1733 }
1730 } 1734 }
1731} 1735} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs
index 9a937a2..9454de0 100644
--- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs
@@ -32,7 +32,6 @@ using libsecondlife;
32using libsecondlife.Packets; 32using libsecondlife.Packets;
33using OpenSim.Framework; 33using OpenSim.Framework;
34using OpenSim.Framework.Console; 34using OpenSim.Framework.Console;
35using OpenSim.Framework.Communications;
36using OpenSim.Region.Environment.Types; 35using OpenSim.Region.Environment.Types;
37using OpenSim.Region.Physics.Manager; 36using OpenSim.Region.Physics.Manager;
38 37
@@ -60,14 +59,14 @@ namespace OpenSim.Region.Environment.Scenes
60 private bool m_setAlwaysRun = false; 59 private bool m_setAlwaysRun = false;
61 60
62 private Quaternion m_bodyRot; 61 private Quaternion m_bodyRot;
63 62
64 public bool IsRestrictedToRegion = false; 63 public bool IsRestrictedToRegion = false;
65 64
66 // Agent moves with a PID controller causing a force to be exerted. 65 // Agent moves with a PID controller causing a force to be exerted.
67 private bool m_newForce = false; 66 private bool m_newForce = false;
68 private bool m_newCoarseLocations = true; 67 private bool m_newCoarseLocations = true;
69 private bool m_gotAllObjectsInScene = false; 68 private bool m_gotAllObjectsInScene = false;
70 69
71 // Default AV Height 70 // Default AV Height
72 private float m_avHeight = 127.0f; 71 private float m_avHeight = 127.0f;
73 72
@@ -76,7 +75,7 @@ namespace OpenSim.Region.Environment.Scenes
76 75
77 private readonly Vector3[] Dir_Vectors = new Vector3[6]; 76 private readonly Vector3[] Dir_Vectors = new Vector3[6];
78 private LLVector3 lastPhysPos = new LLVector3(); 77 private LLVector3 lastPhysPos = new LLVector3();
79 78
80 // Position of agent's camera in world (region cordinates) 79 // Position of agent's camera in world (region cordinates)
81 protected Vector3 m_CameraCenter = new Vector3(0, 0, 0); 80 protected Vector3 m_CameraCenter = new Vector3(0, 0, 0);
82 81
@@ -85,17 +84,18 @@ namespace OpenSim.Region.Environment.Scenes
85 protected Vector3 m_CameraAtAxis = new Vector3(0, 0, 0); 84 protected Vector3 m_CameraAtAxis = new Vector3(0, 0, 0);
86 protected Vector3 m_CameraLeftAxis = new Vector3(0, 0, 0); 85 protected Vector3 m_CameraLeftAxis = new Vector3(0, 0, 0);
87 protected Vector3 m_CameraUpAxis = new Vector3(0, 0, 0); 86 protected Vector3 m_CameraUpAxis = new Vector3(0, 0, 0);
88 private uint m_AgentControlFlags = (uint)0; 87 private uint m_AgentControlFlags = (uint) 0;
89 private LLQuaternion m_headrotation = new LLQuaternion(); 88 private LLQuaternion m_headrotation = new LLQuaternion();
90 private byte m_state = (byte)0; 89 private byte m_state = (byte) 0;
91 90
92 // Agent's Draw distance. 91 // Agent's Draw distance.
93 protected float m_DrawDistance = 0f; 92 protected float m_DrawDistance = 0f;
94 93
95 protected AvatarAppearance m_appearance; 94 protected AvatarAppearance m_appearance;
96 95
97 private readonly List<ulong> m_knownChildRegions = new List<ulong>(); //neighbouring regions we have enabled a child agent in 96 private readonly List<ulong> m_knownChildRegions = new List<ulong>();
98 97 //neighbouring regions we have enabled a child agent in
98
99 99
100 /// <summary> 100 /// <summary>
101 /// Implemented Control Flags 101 /// Implemented Control Flags
@@ -172,6 +172,7 @@ namespace OpenSim.Region.Environment.Scenes
172 } 172 }
173 173
174 protected bool m_allowMovement = true; 174 protected bool m_allowMovement = true;
175
175 public bool AllowMovement 176 public bool AllowMovement
176 { 177 {
177 get { return m_allowMovement; } 178 get { return m_allowMovement; }
@@ -181,8 +182,8 @@ namespace OpenSim.Region.Environment.Scenes
181 /// <summary> 182 /// <summary>
182 /// This works out to be the ClientView object associated with this avatar, or it's UDP connection manager 183 /// This works out to be the ClientView object associated with this avatar, or it's UDP connection manager
183 /// </summary> 184 /// </summary>
184
185 private readonly IClientAPI m_controllingClient; 185 private readonly IClientAPI m_controllingClient;
186
186 protected PhysicsActor m_physicsActor; 187 protected PhysicsActor m_physicsActor;
187 188
188 public IClientAPI ControllingClient 189 public IClientAPI ControllingClient
@@ -228,6 +229,7 @@ namespace OpenSim.Region.Environment.Scenes
228 m_pos = value; 229 m_pos = value;
229 } 230 }
230 } 231 }
232
231 /// <summary> 233 /// <summary>
232 /// Current Velocity of the avatar. 234 /// Current Velocity of the avatar.
233 /// </summary> 235 /// </summary>
@@ -294,6 +296,7 @@ namespace OpenSim.Region.Environment.Scenes
294 { 296 {
295 get { return m_knownChildRegions; } 297 get { return m_knownChildRegions; }
296 } 298 }
299
297 #endregion 300 #endregion
298 301
299 #region Constructor(s) 302 #region Constructor(s)
@@ -336,7 +339,7 @@ namespace OpenSim.Region.Environment.Scenes
336 public ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo, AvatarAppearance appearance) 339 public ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo, AvatarAppearance appearance)
337 : this(client, world, reginfo) 340 : this(client, world, reginfo)
338 { 341 {
339 m_appearance = appearance; 342 m_appearance = appearance;
340 } 343 }
341 344
342 private void RegisterToEvents() 345 private void RegisterToEvents()
@@ -366,6 +369,7 @@ namespace OpenSim.Region.Environment.Scenes
366 Dir_Vectors[5] = new Vector3(0, 0, -1); //DOWN 369 Dir_Vectors[5] = new Vector3(0, 0, -1); //DOWN
367 Dir_Vectors[5] = new Vector3(0, 0, -0.5f); //DOWN_Nudge 370 Dir_Vectors[5] = new Vector3(0, 0, -0.5f); //DOWN_Nudge
368 } 371 }
372
369 #endregion 373 #endregion
370 374
371 public void QueuePartForUpdate(SceneObjectPart part) 375 public void QueuePartForUpdate(SceneObjectPart part)
@@ -381,7 +385,7 @@ namespace OpenSim.Region.Environment.Scenes
381 385
382 public uint GenerateClientFlags(LLUUID ObjectID) 386 public uint GenerateClientFlags(LLUUID ObjectID)
383 { 387 {
384 return m_scene.PermissionsMngr.GenerateClientFlags(this.m_uuid, ObjectID); 388 return m_scene.PermissionsMngr.GenerateClientFlags(m_uuid, ObjectID);
385 } 389 }
386 390
387 public void SendPrimUpdates() 391 public void SendPrimUpdates()
@@ -461,6 +465,7 @@ namespace OpenSim.Region.Environment.Scenes
461 } 465 }
462 466
463 #region Status Methods 467 #region Status Methods
468
464 /// <summary> 469 /// <summary>
465 /// This turns a child agent, into a root agent 470 /// This turns a child agent, into a root agent
466 /// This is called when an agent teleports into a region, or if an 471 /// This is called when an agent teleports into a region, or if an
@@ -531,6 +536,7 @@ namespace OpenSim.Region.Environment.Scenes
531 public void StopMovement() 536 public void StopMovement()
532 { 537 {
533 } 538 }
539
534 public void StopFlying() 540 public void StopFlying()
535 { 541 {
536 // It turns out to get the agent to stop flying, you have to feed it stop flying velocities 542 // It turns out to get the agent to stop flying, you have to feed it stop flying velocities
@@ -560,9 +566,11 @@ namespace OpenSim.Region.Environment.Scenes
560 m_knownChildRegions.Remove(regionHandle); 566 m_knownChildRegions.Remove(regionHandle);
561 } 567 }
562 } 568 }
569
563 #endregion 570 #endregion
564 571
565 #region Event Handlers 572 #region Event Handlers
573
566 /// <summary> 574 /// <summary>
567 /// Sets avatar height in the phyiscs plugin 575 /// Sets avatar height in the phyiscs plugin
568 /// </summary> 576 /// </summary>
@@ -603,7 +611,6 @@ namespace OpenSim.Region.Environment.Scenes
603 /// </summary> 611 /// </summary>
604 public void HandleAgentUpdate(IClientAPI remoteClient, AgentUpdatePacket agentData) 612 public void HandleAgentUpdate(IClientAPI remoteClient, AgentUpdatePacket agentData)
605 { 613 {
606
607 //if (m_isChildAgent) 614 //if (m_isChildAgent)
608 //{ 615 //{
609 // // Console.WriteLine("DEBUG: HandleAgentUpdate: child agent"); 616 // // Console.WriteLine("DEBUG: HandleAgentUpdate: child agent");
@@ -639,7 +646,7 @@ namespace OpenSim.Region.Environment.Scenes
639 // The Agent's Draw distance setting 646 // The Agent's Draw distance setting
640 m_DrawDistance = agentData.AgentData.Far; 647 m_DrawDistance = agentData.AgentData.Far;
641 648
642 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_STAND_UP) != 0) 649 if ((flags & (uint) AgentManager.ControlFlags.AGENT_CONTROL_STAND_UP) != 0)
643 { 650 {
644 StandUp(); 651 StandUp();
645 } 652 }
@@ -649,7 +656,7 @@ namespace OpenSim.Region.Environment.Scenes
649 return; 656 return;
650 } 657 }
651 658
652 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_SIT_ON_GROUND) != 0) 659 if ((flags & (uint) AgentManager.ControlFlags.AGENT_CONTROL_SIT_ON_GROUND) != 0)
653 { 660 {
654 // TODO: This doesn't quite work yet -- probably a parent ID problem 661 // TODO: This doesn't quite work yet -- probably a parent ID problem
655 // m_parentID = (what should this be?) 662 // m_parentID = (what should this be?)
@@ -672,7 +679,7 @@ namespace OpenSim.Region.Environment.Scenes
672 Quaternion q = new Quaternion(bodyRotation.W, bodyRotation.X, bodyRotation.Y, bodyRotation.Z); 679 Quaternion q = new Quaternion(bodyRotation.W, bodyRotation.X, bodyRotation.Y, bodyRotation.Z);
673 bool oldflying = PhysicsActor.Flying; 680 bool oldflying = PhysicsActor.Flying;
674 681
675 PhysicsActor.Flying = ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0); 682 PhysicsActor.Flying = ((flags & (uint) AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0);
676 if (PhysicsActor.Flying != oldflying) 683 if (PhysicsActor.Flying != oldflying)
677 { 684 {
678 update_movementflag = true; 685 update_movementflag = true;
@@ -686,23 +693,23 @@ namespace OpenSim.Region.Environment.Scenes
686 693
687 if (m_parentID == 0) 694 if (m_parentID == 0)
688 { 695 {
689 foreach (Dir_ControlFlags DCF in Enum.GetValues(typeof(Dir_ControlFlags))) 696 foreach (Dir_ControlFlags DCF in Enum.GetValues(typeof (Dir_ControlFlags)))
690 { 697 {
691 if ((flags & (uint)DCF) != 0) 698 if ((flags & (uint) DCF) != 0)
692 { 699 {
693 DCFlagKeyPressed = true; 700 DCFlagKeyPressed = true;
694 agent_control_v3 += Dir_Vectors[i]; 701 agent_control_v3 += Dir_Vectors[i];
695 if ((m_movementflag & (uint)DCF) == 0) 702 if ((m_movementflag & (uint) DCF) == 0)
696 { 703 {
697 m_movementflag += (byte)(uint)DCF; 704 m_movementflag += (byte) (uint) DCF;
698 update_movementflag = true; 705 update_movementflag = true;
699 } 706 }
700 } 707 }
701 else 708 else
702 { 709 {
703 if ((m_movementflag & (uint)DCF) != 0) 710 if ((m_movementflag & (uint) DCF) != 0)
704 { 711 {
705 m_movementflag -= (byte)(uint)DCF; 712 m_movementflag -= (byte) (uint) DCF;
706 update_movementflag = true; 713 update_movementflag = true;
707 } 714 }
708 } 715 }
@@ -719,8 +726,9 @@ namespace OpenSim.Region.Environment.Scenes
719 if (m_physicsActor.Flying) 726 if (m_physicsActor.Flying)
720 { 727 {
721 // Are the landing controls requirements filled? 728 // Are the landing controls requirements filled?
722 bool controlland = (((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) || ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)); 729 bool controlland = (((flags & (uint) AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) ||
723 730 ((flags & (uint) AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0));
731
724 // Are the collision requirements fulfilled? 732 // Are the collision requirements fulfilled?
725 bool colliding = (m_physicsActor.IsColliding == true); 733 bool colliding = (m_physicsActor.IsColliding == true);
726 734
@@ -748,7 +756,6 @@ namespace OpenSim.Region.Environment.Scenes
748 { 756 {
749 if (m_parentID != 0) 757 if (m_parentID != 0)
750 { 758 {
751
752 SceneObjectPart part = m_scene.GetSceneObjectPart(m_parentID); 759 SceneObjectPart part = m_scene.GetSceneObjectPart(m_parentID);
753 if (part != null) 760 if (part != null)
754 { 761 {
@@ -757,7 +764,7 @@ namespace OpenSim.Region.Environment.Scenes
757 part.SetAvatarOnSitTarget(LLUUID.Zero); 764 part.SetAvatarOnSitTarget(LLUUID.Zero);
758 } 765 }
759 766
760 m_pos += m_parentPosition + new LLVector3(0.0f, 0.0f, 2.0f * m_sitAvatarHeight); 767 m_pos += m_parentPosition + new LLVector3(0.0f, 0.0f, 2.0f*m_sitAvatarHeight);
761 m_parentPosition = new LLVector3(); 768 m_parentPosition = new LLVector3();
762 769
763 if (m_physicsActor == null) 770 if (m_physicsActor == null)
@@ -778,14 +785,14 @@ namespace OpenSim.Region.Environment.Scenes
778 785
779 bool autopilot = true; 786 bool autopilot = true;
780 LLVector3 pos = new LLVector3(); 787 LLVector3 pos = new LLVector3();
781 LLQuaternion sitOrientation = new LLQuaternion(0,0,0,1); 788 LLQuaternion sitOrientation = new LLQuaternion(0, 0, 0, 1);
782 789
783 SceneObjectPart part = m_scene.GetSceneObjectPart(targetID); 790 SceneObjectPart part = m_scene.GetSceneObjectPart(targetID);
784 if (part != null) 791 if (part != null)
785 { 792 {
786 // TODO: determine position to sit at based on scene geometry; don't trust offset from client 793 // TODO: determine position to sit at based on scene geometry; don't trust offset from client
787 // see http://wiki.secondlife.com/wiki/User:Andrew_Linden/Office_Hours/2007_11_06 for details on how LL does it 794 // see http://wiki.secondlife.com/wiki/User:Andrew_Linden/Office_Hours/2007_11_06 for details on how LL does it
788 795
789 796
790 // Is a sit target available? 797 // Is a sit target available?
791 Vector3 avSitOffSet = part.GetSitTargetPosition(); 798 Vector3 avSitOffSet = part.GetSitTargetPosition();
@@ -793,15 +800,17 @@ namespace OpenSim.Region.Environment.Scenes
793 LLUUID avOnTargetAlready = part.GetAvatarOnSitTarget(); 800 LLUUID avOnTargetAlready = part.GetAvatarOnSitTarget();
794 801
795 bool SitTargetUnOccupied = (!(avOnTargetAlready != LLUUID.Zero)); 802 bool SitTargetUnOccupied = (!(avOnTargetAlready != LLUUID.Zero));
796 bool SitTargetisSet = (!(avSitOffSet.x == 0 && avSitOffSet.y == 0 && avSitOffSet.z == 0 && avSitOrientation.w == 0 && avSitOrientation.x == 0 && avSitOrientation.y == 0 && avSitOrientation.z == 1)); 803 bool SitTargetisSet =
804 (!(avSitOffSet.x == 0 && avSitOffSet.y == 0 && avSitOffSet.z == 0 && avSitOrientation.w == 0 &&
805 avSitOrientation.x == 0 && avSitOrientation.y == 0 && avSitOrientation.z == 1));
797 806
798 if (SitTargetisSet && SitTargetUnOccupied) 807 if (SitTargetisSet && SitTargetUnOccupied)
799 { 808 {
800 part.SetAvatarOnSitTarget(UUID); 809 part.SetAvatarOnSitTarget(UUID);
801 offset = new LLVector3(avSitOffSet.x,avSitOffSet.y,avSitOffSet.z); 810 offset = new LLVector3(avSitOffSet.x, avSitOffSet.y, avSitOffSet.z);
802 sitOrientation = new LLQuaternion(avSitOrientation.w,avSitOrientation.x,avSitOrientation.y,avSitOrientation.z); 811 sitOrientation =
812 new LLQuaternion(avSitOrientation.w, avSitOrientation.x, avSitOrientation.y, avSitOrientation.z);
803 autopilot = false; 813 autopilot = false;
804
805 } 814 }
806 815
807 816
@@ -817,43 +826,37 @@ namespace OpenSim.Region.Environment.Scenes
817 826
818 if (autopilot) 827 if (autopilot)
819 { 828 {
820
821 if (Util.GetDistanceTo(AbsolutePosition, pos) < 4.5) 829 if (Util.GetDistanceTo(AbsolutePosition, pos) < 4.5)
822 { 830 {
823 autopilot = false; 831 autopilot = false;
824 832
825 RemoveFromPhysicalScene(); 833 RemoveFromPhysicalScene();
826 AbsolutePosition = pos + new LLVector3(0.0f, 0.0f, m_sitAvatarHeight); 834 AbsolutePosition = pos + new LLVector3(0.0f, 0.0f, m_sitAvatarHeight);
827
828 } 835 }
829 else 836 else
830 { 837 {
831
832 } 838 }
833 } 839 }
834 else 840 else
835 { 841 {
836 RemoveFromPhysicalScene(); 842 RemoveFromPhysicalScene();
837
838
839 } 843 }
840 } // Physactor != null 844 } // Physactor != null
841 } // part != null 845 } // part != null
842 846
843 847
844 avatarSitResponse.SitTransform.AutoPilot = autopilot; 848 avatarSitResponse.SitTransform.AutoPilot = autopilot;
845 avatarSitResponse.SitTransform.SitPosition = offset; 849 avatarSitResponse.SitTransform.SitPosition = offset;
846 avatarSitResponse.SitTransform.SitRotation = sitOrientation; 850 avatarSitResponse.SitTransform.SitRotation = sitOrientation;
847 851
848 remoteClient.OutPacket(avatarSitResponse, ThrottleOutPacketType.Task); 852 remoteClient.OutPacket(avatarSitResponse, ThrottleOutPacketType.Task);
849 853
850 // This calls HandleAgentSit twice, once from here, and the client calls 854 // This calls HandleAgentSit twice, once from here, and the client calls
851 // HandleAgentSit itself after it gets to the location 855 // HandleAgentSit itself after it gets to the location
852 // It doesn't get to the location until we've moved them there though 856 // It doesn't get to the location until we've moved them there though
853 // which happens in HandleAgentSit :P 857 // which happens in HandleAgentSit :P
854 if (!autopilot) 858 if (!autopilot)
855 HandleAgentSit(remoteClient, UUID); 859 HandleAgentSit(remoteClient, UUID);
856
857 } 860 }
858 861
859 public void HandleAgentRequestSit(IClientAPI remoteClient, LLUUID agentID, LLUUID targetID, LLVector3 offset) 862 public void HandleAgentRequestSit(IClientAPI remoteClient, LLUUID agentID, LLUUID targetID, LLVector3 offset)
@@ -863,7 +866,6 @@ namespace OpenSim.Region.Environment.Scenes
863 StandUp(); 866 StandUp();
864 } 867 }
865 868
866
867 869
868 SceneObjectPart part = m_scene.GetSceneObjectPart(targetID); 870 SceneObjectPart part = m_scene.GetSceneObjectPart(targetID);
869 871
@@ -919,7 +921,6 @@ namespace OpenSim.Region.Environment.Scenes
919 // This may seem stupid, but Our Full updates don't send avatar rotation :P 921 // This may seem stupid, but Our Full updates don't send avatar rotation :P
920 // So we're also sending a terse update (which has avatar rotation) 922 // So we're also sending a terse update (which has avatar rotation)
921 SendTerseUpdateToAllClients(); 923 SendTerseUpdateToAllClients();
922
923 } 924 }
924 925
925 /// <summary> 926 /// <summary>
@@ -1003,7 +1004,7 @@ namespace OpenSim.Region.Environment.Scenes
1003 // We are flying 1004 // We are flying
1004 SetMovementAnimation(Animations.AnimsLLUUID["FLY"], 1); 1005 SetMovementAnimation(Animations.AnimsLLUUID["FLY"], 1);
1005 } 1006 }
1006 else if (((m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) && 1007 else if (((m_movementflag & (uint) AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) &&
1007 PhysicsActor.IsColliding) 1008 PhysicsActor.IsColliding)
1008 { 1009 {
1009 // Client is pressing the page down button and moving and is colliding with something 1010 // Client is pressing the page down button and moving and is colliding with something
@@ -1014,7 +1015,8 @@ namespace OpenSim.Region.Environment.Scenes
1014 // Client is moving and falling at a velocity greater then 6 meters per unit 1015 // Client is moving and falling at a velocity greater then 6 meters per unit
1015 SetMovementAnimation(Animations.AnimsLLUUID["FALLDOWN"], 1); 1016 SetMovementAnimation(Animations.AnimsLLUUID["FALLDOWN"], 1);
1016 } 1017 }
1017 else if (!PhysicsActor.IsColliding && Velocity.Z > 0 && (m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0) 1018 else if (!PhysicsActor.IsColliding && Velocity.Z > 0 &&
1019 (m_movementflag & (uint) AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0)
1018 { 1020 {
1019 // Client is moving, and colliding and pressing the page up button but isn't flying 1021 // Client is moving, and colliding and pressing the page up button but isn't flying
1020 SetMovementAnimation(Animations.AnimsLLUUID["JUMP"], 1); 1022 SetMovementAnimation(Animations.AnimsLLUUID["JUMP"], 1);
@@ -1034,7 +1036,7 @@ namespace OpenSim.Region.Environment.Scenes
1034 { 1036 {
1035 // Not moving 1037 // Not moving
1036 1038
1037 if (((m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) && 1039 if (((m_movementflag & (uint) AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) &&
1038 PhysicsActor.IsColliding) 1040 PhysicsActor.IsColliding)
1039 { 1041 {
1040 // Client pressing the page down button 1042 // Client pressing the page down button
@@ -1045,7 +1047,8 @@ namespace OpenSim.Region.Environment.Scenes
1045 // Not colliding and not flying, and we're falling at high speed 1047 // Not colliding and not flying, and we're falling at high speed
1046 SetMovementAnimation(Animations.AnimsLLUUID["FALLDOWN"], 1); 1048 SetMovementAnimation(Animations.AnimsLLUUID["FALLDOWN"], 1);
1047 } 1049 }
1048 else if (!PhysicsActor.IsColliding && Velocity.Z > 0 && !m_physicsActor.Flying && (m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0) 1050 else if (!PhysicsActor.IsColliding && Velocity.Z > 0 && !m_physicsActor.Flying &&
1051 (m_movementflag & (uint) AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0)
1049 { 1052 {
1050 // This is the standing jump 1053 // This is the standing jump
1051 SetMovementAnimation(Animations.AnimsLLUUID["JUMP"], 1); 1054 SetMovementAnimation(Animations.AnimsLLUUID["JUMP"], 1);
@@ -1063,6 +1066,7 @@ namespace OpenSim.Region.Environment.Scenes
1063 } 1066 }
1064 } 1067 }
1065 } 1068 }
1069
1066 /// <summary> 1070 /// <summary>
1067 /// Adds a new movement 1071 /// Adds a new movement
1068 /// </summary> 1072 /// </summary>
@@ -1075,10 +1079,10 @@ namespace OpenSim.Region.Environment.Scenes
1075 } 1079 }
1076 m_rotation = rotation; 1080 m_rotation = rotation;
1077 NewForce newVelocity = new NewForce(); 1081 NewForce newVelocity = new NewForce();
1078 Vector3 direc = rotation * vec; 1082 Vector3 direc = rotation*vec;
1079 direc.Normalize(); 1083 direc.Normalize();
1080 1084
1081 direc *= 0.03f * 128f; 1085 direc *= 0.03f*128f;
1082 if (m_physicsActor.Flying) 1086 if (m_physicsActor.Flying)
1083 { 1087 {
1084 direc *= 4; 1088 direc *= 4;
@@ -1108,7 +1112,6 @@ namespace OpenSim.Region.Environment.Scenes
1108 SetMovementAnimation(Animations.AnimsLLUUID["JUMP"], 1); 1112 SetMovementAnimation(Animations.AnimsLLUUID["JUMP"], 1);
1109 } 1113 }
1110 } 1114 }
1111
1112 } 1115 }
1113 1116
1114 newVelocity.X = direc.x; 1117 newVelocity.X = direc.x;
@@ -1173,7 +1176,7 @@ namespace OpenSim.Region.Environment.Scenes
1173 { 1176 {
1174 LLVector3 pos = m_pos; 1177 LLVector3 pos = m_pos;
1175 LLVector3 vel = Velocity; 1178 LLVector3 vel = Velocity;
1176 LLQuaternion rot=new LLQuaternion(m_bodyRot.x, m_bodyRot.y, m_bodyRot.z, m_bodyRot.w); 1179 LLQuaternion rot = new LLQuaternion(m_bodyRot.x, m_bodyRot.y, m_bodyRot.z, m_bodyRot.w);
1177 remoteClient.SendAvatarTerseUpdate(m_regionHandle, 64096, LocalId, new LLVector3(pos.X, pos.Y, pos.Z), 1180 remoteClient.SendAvatarTerseUpdate(m_regionHandle, 64096, LocalId, new LLVector3(pos.X, pos.Y, pos.Z),
1178 new LLVector3(vel.X, vel.Y, vel.Z), rot); 1181 new LLVector3(vel.X, vel.Y, vel.Z), rot);
1179 } 1182 }
@@ -1213,7 +1216,8 @@ namespace OpenSim.Region.Environment.Scenes
1213 public void SendFullUpdateToOtherClient(ScenePresence remoteAvatar) 1216 public void SendFullUpdateToOtherClient(ScenePresence remoteAvatar)
1214 { 1217 {
1215 remoteAvatar.m_controllingClient.SendAvatarData(m_regionInfo.RegionHandle, m_firstname, m_lastname, m_uuid, 1218 remoteAvatar.m_controllingClient.SendAvatarData(m_regionInfo.RegionHandle, m_firstname, m_lastname, m_uuid,
1216 LocalId, m_pos, m_appearance.TextureEntry.ToBytes(), m_parentID); 1219 LocalId, m_pos, m_appearance.TextureEntry.ToBytes(),
1220 m_parentID);
1217 } 1221 }
1218 1222
1219 /// <summary> 1223 /// <summary>
@@ -1303,10 +1307,8 @@ namespace OpenSim.Region.Environment.Scenes
1303 /// <param name="seqs"></param> 1307 /// <param name="seqs"></param>
1304 public void SendAnimPack(LLUUID[] animations, int[] seqs) 1308 public void SendAnimPack(LLUUID[] animations, int[] seqs)
1305 { 1309 {
1306 m_scene.Broadcast(delegate(IClientAPI client) 1310 m_scene.Broadcast(
1307 { 1311 delegate(IClientAPI client) { client.SendAnimations(animations, seqs, m_controllingClient.AgentId); });
1308 client.SendAnimations(animations, seqs, m_controllingClient.AgentId);
1309 });
1310 } 1312 }
1311 1313
1312 /// <summary> 1314 /// <summary>
@@ -1320,6 +1322,7 @@ namespace OpenSim.Region.Environment.Scenes
1320 #endregion 1322 #endregion
1321 1323
1322 #region Significant Movement Method 1324 #region Significant Movement Method
1325
1323 /// <summary> 1326 /// <summary>
1324 /// This checks for a significant movement and sends a courselocationchange update 1327 /// This checks for a significant movement and sends a courselocationchange update
1325 /// </summary> 1328 /// </summary>
@@ -1349,9 +1352,9 @@ namespace OpenSim.Region.Environment.Scenes
1349 LLVector3 vel = Velocity; 1352 LLVector3 vel = Velocity;
1350 1353
1351 float timeStep = 0.1f; 1354 float timeStep = 0.1f;
1352 pos2.X = pos2.X + (vel.X * timeStep); 1355 pos2.X = pos2.X + (vel.X*timeStep);
1353 pos2.Y = pos2.Y + (vel.Y * timeStep); 1356 pos2.Y = pos2.Y + (vel.Y*timeStep);
1354 pos2.Z = pos2.Z + (vel.Z * timeStep); 1357 pos2.Z = pos2.Z + (vel.Z*timeStep);
1355 1358
1356 if ((pos2.X < 0) || (pos2.X > 256)) 1359 if ((pos2.X < 0) || (pos2.X > 256))
1357 { 1360 {
@@ -1411,7 +1414,7 @@ namespace OpenSim.Region.Environment.Scenes
1411 } 1414 }
1412 1415
1413 LLVector3 vel = m_velocity; 1416 LLVector3 vel = m_velocity;
1414 ulong neighbourHandle = Helpers.UIntsToLong((uint)(neighbourx * 256), (uint)(neighboury * 256)); 1417 ulong neighbourHandle = Helpers.UIntsToLong((uint) (neighbourx*256), (uint) (neighboury*256));
1415 SimpleRegionInfo neighbourRegion = m_scene.RequestNeighbouringRegionInfo(neighbourHandle); 1418 SimpleRegionInfo neighbourRegion = m_scene.RequestNeighbouringRegionInfo(neighbourHandle);
1416 if (neighbourRegion != null) 1419 if (neighbourRegion != null)
1417 { 1420 {
@@ -1432,6 +1435,7 @@ namespace OpenSim.Region.Environment.Scenes
1432 } 1435 }
1433 1436
1434 #endregion 1437 #endregion
1438
1435 /// <summary> 1439 /// <summary>
1436 /// This allows the Sim owner the abiility to kick users from their sim currently. 1440 /// This allows the Sim owner the abiility to kick users from their sim currently.
1437 /// It tells the client that the agent has permission to do so. 1441 /// It tells the client that the agent has permission to do so.
@@ -1445,7 +1449,7 @@ namespace OpenSim.Region.Environment.Scenes
1445 adb.AgentID = agentID; 1449 adb.AgentID = agentID;
1446 adb.SessionID = sessionID; // More security 1450 adb.SessionID = sessionID; // More security
1447 1451
1448 gdb.GodLevel = (byte)100; 1452 gdb.GodLevel = (byte) 100;
1449 gdb.Token = token; 1453 gdb.Token = token;
1450 //respondPacket.AgentData = (GrantGodlikePowersPacket.AgentDataBlock)ablock; 1454 //respondPacket.AgentData = (GrantGodlikePowersPacket.AgentDataBlock)ablock;
1451 respondPacket.GrantData = gdb; 1455 respondPacket.GrantData = gdb;
@@ -1462,7 +1466,8 @@ namespace OpenSim.Region.Environment.Scenes
1462 // 1466 //
1463 m_DrawDistance = cAgentData.drawdistance; 1467 m_DrawDistance = cAgentData.drawdistance;
1464 m_pos = new LLVector3(cAgentData.Position.x, cAgentData.Position.y, cAgentData.Position.z); 1468 m_pos = new LLVector3(cAgentData.Position.x, cAgentData.Position.y, cAgentData.Position.z);
1465 m_CameraCenter = new Vector3(cAgentData.cameraPosition.x, cAgentData.cameraPosition.y, cAgentData.cameraPosition.z); 1469 m_CameraCenter =
1470 new Vector3(cAgentData.cameraPosition.x, cAgentData.cameraPosition.y, cAgentData.cameraPosition.z);
1466 m_godlevel = cAgentData.godlevel; 1471 m_godlevel = cAgentData.godlevel;
1467 ControllingClient.SetChildAgentThrottle(cAgentData.throttles); 1472 ControllingClient.SetChildAgentThrottle(cAgentData.throttles);
1468 //cAgentData.AVHeight; 1473 //cAgentData.AVHeight;
@@ -1555,6 +1560,7 @@ namespace OpenSim.Region.Environment.Scenes
1555 m_physicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients; 1560 m_physicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients;
1556 m_physicsActor.OnCollisionUpdate += PhysicsCollisionUpdate; 1561 m_physicsActor.OnCollisionUpdate += PhysicsCollisionUpdate;
1557 } 1562 }
1563
1558 // Event called by the physics plugin to tell the avatar about a collision. 1564 // Event called by the physics plugin to tell the avatar about a collision.
1559 private void PhysicsCollisionUpdate(EventArgs e) 1565 private void PhysicsCollisionUpdate(EventArgs e)
1560 { 1566 {
@@ -1567,4 +1573,4 @@ namespace OpenSim.Region.Environment.Scenes
1567 RemoveFromPhysicalScene(); 1573 RemoveFromPhysicalScene();
1568 } 1574 }
1569 } 1575 }
1570} 1576} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Scenes/SceneXmlLoader.cs b/OpenSim/Region/Environment/Scenes/SceneXmlLoader.cs
index aeb9c61..8c4a951 100644
--- a/OpenSim/Region/Environment/Scenes/SceneXmlLoader.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneXmlLoader.cs
@@ -28,17 +28,16 @@
28 28
29using System; 29using System;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Text;
32using System.Xml;
33using System.IO; 31using System.IO;
34using libsecondlife; 32using System.Xml;
35using Axiom.Math; 33using Axiom.Math;
34using libsecondlife;
36using OpenSim.Framework; 35using OpenSim.Framework;
37using OpenSim.Region.Physics.Manager; 36using OpenSim.Region.Physics.Manager;
38 37
39namespace OpenSim.Region.Environment.Scenes 38namespace OpenSim.Region.Environment.Scenes
40{ 39{
41 public class SceneXmlLoader // can move to a module? 40 public class SceneXmlLoader // can move to a module?
42 { 41 {
43 protected InnerScene m_innerScene; 42 protected InnerScene m_innerScene;
44 protected RegionInfo m_regInfo; 43 protected RegionInfo m_regInfo;
@@ -78,8 +77,9 @@ namespace OpenSim.Region.Environment.Scenes
78 SceneObjectPart rootPart = obj.GetChildPart(obj.UUID); 77 SceneObjectPart rootPart = obj.GetChildPart(obj.UUID);
79 // Apply loadOffsets for load/import and move combinations 78 // Apply loadOffsets for load/import and move combinations
80 rootPart.GroupPosition = rootPart.AbsolutePosition + loadOffset; 79 rootPart.GroupPosition = rootPart.AbsolutePosition + loadOffset;
81 bool UsePhysics = (((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Physics) > 0) && m_parentScene.m_physicalPrim); 80 bool UsePhysics = (((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Physics) > 0) &&
82 if ((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Phantom) == 0) 81 m_parentScene.m_physicalPrim);
82 if ((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Phantom) == 0)
83 { 83 {
84 rootPart.PhysActor = m_innerScene.PhysicsScene.AddPrimShape( 84 rootPart.PhysActor = m_innerScene.PhysicsScene.AddPrimShape(
85 rootPart.Name, 85 rootPart.Name,
@@ -91,7 +91,6 @@ namespace OpenSim.Region.Environment.Scenes
91 new Quaternion(rootPart.RotationOffset.W, rootPart.RotationOffset.X, 91 new Quaternion(rootPart.RotationOffset.W, rootPart.RotationOffset.X,
92 rootPart.RotationOffset.Y, rootPart.RotationOffset.Z), UsePhysics); 92 rootPart.RotationOffset.Y, rootPart.RotationOffset.Z), UsePhysics);
93 rootPart.DoPhysicsPropertyUpdate(UsePhysics, true); 93 rootPart.DoPhysicsPropertyUpdate(UsePhysics, true);
94
95 } 94 }
96 primCount++; 95 primCount++;
97 } 96 }
@@ -115,7 +114,7 @@ namespace OpenSim.Region.Environment.Scenes
115 { 114 {
116 if (ent is SceneObjectGroup) 115 if (ent is SceneObjectGroup)
117 { 116 {
118 stream.WriteLine(((SceneObjectGroup)ent).ToXmlString()); 117 stream.WriteLine(((SceneObjectGroup) ent).ToXmlString());
119 primCount++; 118 primCount++;
120 } 119 }
121 } 120 }
@@ -152,8 +151,9 @@ namespace OpenSim.Region.Environment.Scenes
152 m_innerScene.AddEntityFromStorage(obj); 151 m_innerScene.AddEntityFromStorage(obj);
153 152
154 SceneObjectPart rootPart = obj.GetChildPart(obj.UUID); 153 SceneObjectPart rootPart = obj.GetChildPart(obj.UUID);
155 bool UsePhysics = (((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Physics) > 0) && m_parentScene.m_physicalPrim); 154 bool UsePhysics = (((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Physics) > 0) &&
156 if ((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Phantom) == 0) 155 m_parentScene.m_physicalPrim);
156 if ((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Phantom) == 0)
157 { 157 {
158 rootPart.PhysActor = m_innerScene.PhysicsScene.AddPrimShape( 158 rootPart.PhysActor = m_innerScene.PhysicsScene.AddPrimShape(
159 rootPart.Name, 159 rootPart.Name,
@@ -180,7 +180,7 @@ namespace OpenSim.Region.Environment.Scenes
180 { 180 {
181 if (ent is SceneObjectGroup) 181 if (ent is SceneObjectGroup)
182 { 182 {
183 stream.WriteLine(((SceneObjectGroup)ent).ToXmlString2()); 183 stream.WriteLine(((SceneObjectGroup) ent).ToXmlString2());
184 primCount++; 184 primCount++;
185 } 185 }
186 } 186 }
@@ -188,6 +188,5 @@ namespace OpenSim.Region.Environment.Scenes
188 stream.Close(); 188 stream.Close();
189 file.Close(); 189 file.Close();
190 } 190 }
191
192 } 191 }
193} 192} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Scenes/Scripting/ScriptEngineInterface.cs b/OpenSim/Region/Environment/Scenes/Scripting/ScriptEngineInterface.cs
index 294a6c9..d781806 100644
--- a/OpenSim/Region/Environment/Scenes/Scripting/ScriptEngineInterface.cs
+++ b/OpenSim/Region/Environment/Scenes/Scripting/ScriptEngineInterface.cs
@@ -37,4 +37,4 @@ namespace OpenSim.Region.Environment.Scenes.Scripting
37 void Shutdown(); 37 void Shutdown();
38// void StartScript(string ScriptID, IScriptHost ObjectID); 38// void StartScript(string ScriptID, IScriptHost ObjectID);
39 } 39 }
40} 40} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Scenes/Scripting/ScriptEngineLoader.cs b/OpenSim/Region/Environment/Scenes/Scripting/ScriptEngineLoader.cs
index d3fdad6..5dbe500 100644
--- a/OpenSim/Region/Environment/Scenes/Scripting/ScriptEngineLoader.cs
+++ b/OpenSim/Region/Environment/Scenes/Scripting/ScriptEngineLoader.cs
@@ -121,4 +121,4 @@ namespace OpenSim.Region.Environment.Scenes.Scripting
121 return ret; 121 return ret;
122 } 122 }
123 } 123 }
124} 124} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Scenes/SimStatsReporter.cs b/OpenSim/Region/Environment/Scenes/SimStatsReporter.cs
index bfdacfe..b183c04 100644
--- a/OpenSim/Region/Environment/Scenes/SimStatsReporter.cs
+++ b/OpenSim/Region/Environment/Scenes/SimStatsReporter.cs
@@ -27,22 +27,19 @@
27*/ 27*/
28 28
29using System; 29using System;
30using System.Collections.Generic;
31using System.Text;
32using System.Timers; 30using System.Timers;
33using libsecondlife.Packets; 31using libsecondlife.Packets;
34using OpenSim.Framework; 32using OpenSim.Framework;
35using Timer = System.Timers.Timer;
36 33
37namespace OpenSim.Region.Environment.Scenes 34namespace OpenSim.Region.Environment.Scenes
38{ 35{
39 public class SimStatsReporter 36 public class SimStatsReporter
40 { 37 {
41 public delegate void SendStatResult(SimStatsPacket pack); 38 public delegate void SendStatResult(SimStatsPacket pack);
42 39
43 public event SendStatResult OnSendStatsResult; 40 public event SendStatResult OnSendStatsResult;
44 41
45 private enum Stats : uint 42 private enum Stats : uint
46 { 43 {
47 TimeDilation = 0, 44 TimeDilation = 0,
48 SimFPS = 1, 45 SimFPS = 1,
@@ -72,7 +69,7 @@ namespace OpenSim.Region.Environment.Scenes
72 private RegionInfo ReportingRegion; 69 private RegionInfo ReportingRegion;
73 70
74 private Timer m_report = new Timer(); 71 private Timer m_report = new Timer();
75 72
76 73
77 public SimStatsReporter(RegionInfo regionData) 74 public SimStatsReporter(RegionInfo regionData)
78 { 75 {
@@ -93,23 +90,24 @@ namespace OpenSim.Region.Environment.Scenes
93 statpack.Region.RegionY = ReportingRegion.RegionLocY; 90 statpack.Region.RegionY = ReportingRegion.RegionLocY;
94 try 91 try
95 { 92 {
96 statpack.Region.RegionFlags = (uint)ReportingRegion.EstateSettings.regionFlags; 93 statpack.Region.RegionFlags = (uint) ReportingRegion.EstateSettings.regionFlags;
97 } 94 }
98 catch(System.Exception) 95 catch (Exception)
99 { 96 {
100 statpack.Region.RegionFlags = (uint)0; 97 statpack.Region.RegionFlags = (uint) 0;
101 } 98 }
102 statpack.Region.ObjectCapacity = (uint)15000; 99 statpack.Region.ObjectCapacity = (uint) 15000;
103 100
104 #region various statistic googly moogly 101 #region various statistic googly moogly
105 float simfps = (int)(m_fps * 5); 102
103 float simfps = (int) (m_fps*5);
106 104
107 if (simfps > 45) 105 if (simfps > 45)
108 simfps = simfps - (simfps - 45); 106 simfps = simfps - (simfps - 45);
109 if (simfps < 0) 107 if (simfps < 0)
110 simfps = 0; 108 simfps = 0;
111 109
112 float physfps = (m_pfps / statsUpdatesEveryMS); 110 float physfps = (m_pfps/statsUpdatesEveryMS);
113 111
114 if (physfps > 50) 112 if (physfps > 50)
115 physfps = physfps - (physfps - 50); 113 physfps = physfps - (physfps - 50);
@@ -120,49 +118,49 @@ namespace OpenSim.Region.Environment.Scenes
120 #endregion 118 #endregion
121 119
122 sb[0] = new SimStatsPacket.StatBlock(); 120 sb[0] = new SimStatsPacket.StatBlock();
123 sb[0].StatID = (uint)Stats.TimeDilation; 121 sb[0].StatID = (uint) Stats.TimeDilation;
124 sb[0].StatValue = (m_timeDilation); 122 sb[0].StatValue = (m_timeDilation);
125 123
126 sb[1] = new SimStatsPacket.StatBlock(); 124 sb[1] = new SimStatsPacket.StatBlock();
127 sb[1].StatID = (uint)Stats.SimFPS; 125 sb[1].StatID = (uint) Stats.SimFPS;
128 sb[1].StatValue = simfps; 126 sb[1].StatValue = simfps;
129 127
130 sb[2] = new SimStatsPacket.StatBlock(); 128 sb[2] = new SimStatsPacket.StatBlock();
131 sb[2].StatID = (uint)Stats.PhysicsFPS; 129 sb[2].StatID = (uint) Stats.PhysicsFPS;
132 sb[2].StatValue = physfps; 130 sb[2].StatValue = physfps;
133 131
134 sb[3] = new SimStatsPacket.StatBlock(); 132 sb[3] = new SimStatsPacket.StatBlock();
135 sb[3].StatID = (uint)Stats.AgentUpdates; 133 sb[3].StatID = (uint) Stats.AgentUpdates;
136 sb[3].StatValue = (m_agentUpdates / statsUpdatesEveryMS); 134 sb[3].StatValue = (m_agentUpdates/statsUpdatesEveryMS);
137 135
138 sb[4] = new SimStatsPacket.StatBlock(); 136 sb[4] = new SimStatsPacket.StatBlock();
139 sb[4].StatID = (uint)Stats.Agents; 137 sb[4].StatID = (uint) Stats.Agents;
140 sb[4].StatValue = m_rootAgents; 138 sb[4].StatValue = m_rootAgents;
141 139
142 sb[5] = new SimStatsPacket.StatBlock(); 140 sb[5] = new SimStatsPacket.StatBlock();
143 sb[5].StatID = (uint)Stats.ChildAgents; 141 sb[5].StatID = (uint) Stats.ChildAgents;
144 sb[5].StatValue = m_childAgents; 142 sb[5].StatValue = m_childAgents;
145 143
146 sb[6] = new SimStatsPacket.StatBlock(); 144 sb[6] = new SimStatsPacket.StatBlock();
147 sb[6].StatID = (uint)Stats.TotalPrim; 145 sb[6].StatID = (uint) Stats.TotalPrim;
148 sb[6].StatValue = m_numPrim; 146 sb[6].StatValue = m_numPrim;
149 147
150 sb[7] = new SimStatsPacket.StatBlock(); 148 sb[7] = new SimStatsPacket.StatBlock();
151 sb[7].StatID = (uint)Stats.ActivePrim; 149 sb[7].StatID = (uint) Stats.ActivePrim;
152 sb[7].StatValue = m_activePrim; 150 sb[7].StatValue = m_activePrim;
153 151
154 sb[8] = new SimStatsPacket.StatBlock(); 152 sb[8] = new SimStatsPacket.StatBlock();
155 sb[8].StatID = (uint)Stats.InPacketsPerSecond; 153 sb[8].StatID = (uint) Stats.InPacketsPerSecond;
156 sb[8].StatValue = (int)(m_inPacketsPerSecond / statsUpdatesEveryMS); 154 sb[8].StatValue = (int) (m_inPacketsPerSecond/statsUpdatesEveryMS);
157 155
158 sb[9] = new SimStatsPacket.StatBlock(); 156 sb[9] = new SimStatsPacket.StatBlock();
159 sb[9].StatID = (uint)Stats.OutPacketsPerSecond; 157 sb[9].StatID = (uint) Stats.OutPacketsPerSecond;
160 sb[9].StatValue = (int)(m_outPacketsPerSecond / statsUpdatesEveryMS); 158 sb[9].StatValue = (int) (m_outPacketsPerSecond/statsUpdatesEveryMS);
161 159
162 sb[10] = new SimStatsPacket.StatBlock(); 160 sb[10] = new SimStatsPacket.StatBlock();
163 sb[10].StatID = (uint)Stats.UnAckedBytes; 161 sb[10].StatID = (uint) Stats.UnAckedBytes;
164 sb[10].StatValue = (int) (m_unAckedBytes / statsUpdatesEveryMS); 162 sb[10].StatValue = (int) (m_unAckedBytes/statsUpdatesEveryMS);
165 163
166 statpack.Stat = sb; 164 statpack.Stat = sb;
167 165
168 if (OnSendStatsResult != null) 166 if (OnSendStatsResult != null)
@@ -181,8 +179,8 @@ namespace OpenSim.Region.Environment.Scenes
181 m_inPacketsPerSecond = 0; 179 m_inPacketsPerSecond = 0;
182 m_outPacketsPerSecond = 0; 180 m_outPacketsPerSecond = 0;
183 m_unAckedBytes = 0; 181 m_unAckedBytes = 0;
184
185 } 182 }
183
186 public void SetTimeDilation(float td) 184 public void SetTimeDilation(float td)
187 { 185 {
188 m_timeDilation = td; 186 m_timeDilation = td;
@@ -191,47 +189,56 @@ namespace OpenSim.Region.Environment.Scenes
191 189
192 if (m_timeDilation < 0) 190 if (m_timeDilation < 0)
193 m_timeDilation = 0.0f; 191 m_timeDilation = 0.0f;
194
195 } 192 }
193
196 public void SetRootAgents(int rootAgents) 194 public void SetRootAgents(int rootAgents)
197 { 195 {
198 m_rootAgents = rootAgents; 196 m_rootAgents = rootAgents;
199 } 197 }
198
200 public void SetChildAgents(int childAgents) 199 public void SetChildAgents(int childAgents)
201 { 200 {
202 m_childAgents = childAgents; 201 m_childAgents = childAgents;
203 } 202 }
203
204 public void SetObjects(int objects) 204 public void SetObjects(int objects)
205 { 205 {
206 m_numPrim = objects; 206 m_numPrim = objects;
207 } 207 }
208
208 public void SetActiveObjects(int objects) 209 public void SetActiveObjects(int objects)
209 { 210 {
210 m_activePrim = objects; 211 m_activePrim = objects;
211 } 212 }
213
212 public void AddFPS(int frames) 214 public void AddFPS(int frames)
213 { 215 {
214 m_fps += frames; 216 m_fps += frames;
215 } 217 }
218
216 public void AddPhysicsFPS(float frames) 219 public void AddPhysicsFPS(float frames)
217 { 220 {
218 m_pfps += frames; 221 m_pfps += frames;
219 } 222 }
223
220 public void AddAgentUpdates(float numUpdates) 224 public void AddAgentUpdates(float numUpdates)
221 { 225 {
222 m_agentUpdates += numUpdates; 226 m_agentUpdates += numUpdates;
223 } 227 }
228
224 public void AddInPackets(int numPackets) 229 public void AddInPackets(int numPackets)
225 { 230 {
226 m_inPacketsPerSecond += numPackets; 231 m_inPacketsPerSecond += numPackets;
227 } 232 }
233
228 public void AddOutPackets(int numPackets) 234 public void AddOutPackets(int numPackets)
229 { 235 {
230 m_outPacketsPerSecond += numPackets; 236 m_outPacketsPerSecond += numPackets;
231 } 237 }
238
232 public void AddunAckedBytes(int numBytes) 239 public void AddunAckedBytes(int numBytes)
233 { 240 {
234 m_unAckedBytes += numBytes; 241 m_unAckedBytes += numBytes;
235 } 242 }
236 } 243 }
237} 244} \ No newline at end of file