aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorAdam Frisby2008-05-01 16:35:00 +0000
committerAdam Frisby2008-05-01 16:35:00 +0000
commit13526097f24b7a8ad63b1d482c44b44397fa055f (patch)
tree7a82c20ed7c63e2aea5ad3863325e37f64e1cbea
parent* Breaking all the code, breaking all the code..! (diff)
downloadopensim-SC-13526097f24b7a8ad63b1d482c44b44397fa055f.zip
opensim-SC-13526097f24b7a8ad63b1d482c44b44397fa055f.tar.gz
opensim-SC-13526097f24b7a8ad63b1d482c44b44397fa055f.tar.bz2
opensim-SC-13526097f24b7a8ad63b1d482c44b44397fa055f.tar.xz
* Spring cleaning on Region.Environment.
* Converted a large number of read-only fields to be actually, readonly. * Reformatted code sections. * Removed redundant code.
-rw-r--r--OpenSim/Region/Environment/InstantMessageReceiver.cs5
-rw-r--r--OpenSim/Region/Environment/Interfaces/IAgentAssetTransactions.cs2
-rw-r--r--OpenSim/Region/Environment/Interfaces/IAvatarFactory.cs4
-rw-r--r--OpenSim/Region/Environment/Interfaces/IHttpRequests.cs2
-rw-r--r--OpenSim/Region/Environment/Interfaces/ILandChannel.cs5
-rw-r--r--OpenSim/Region/Environment/Interfaces/IRegionDataStore.cs6
-rw-r--r--OpenSim/Region/Environment/Interfaces/IRegionModule.cs6
-rw-r--r--OpenSim/Region/Environment/Interfaces/ISimChat.cs2
-rw-r--r--OpenSim/Region/Environment/Interfaces/IWorldComm.cs2
-rw-r--r--OpenSim/Region/Environment/Interfaces/IXMLRPC.cs2
-rw-r--r--OpenSim/Region/Environment/Interfaces/IXfer.cs2
-rw-r--r--OpenSim/Region/Environment/ModuleLoader.cs36
-rw-r--r--OpenSim/Region/Environment/Modules/Agent/AssetDownload/AssetDownloadModule.cs21
-rw-r--r--OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AgentAssetsTransactions.cs20
-rw-r--r--OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AssetTransactionModule.cs13
-rw-r--r--OpenSim/Region/Environment/Modules/Agent/TextureDownload/TextureDownloadModule.cs9
-rw-r--r--OpenSim/Region/Environment/Modules/Agent/TextureDownload/TextureNotFoundSender.cs6
-rw-r--r--OpenSim/Region/Environment/Modules/Agent/TextureSender/TextureSender.cs19
-rw-r--r--OpenSim/Region/Environment/Modules/Agent/Xfer/XferModule.cs12
-rw-r--r--OpenSim/Region/Environment/Modules/Avatar/Chat/ChatModule.cs56
-rw-r--r--OpenSim/Region/Environment/Modules/Avatar/Currency/SampleMoney/SampleMoneyModule.cs80
-rw-r--r--OpenSim/Region/Environment/Modules/Avatar/Friends/FriendsModule.cs34
-rw-r--r--OpenSim/Region/Environment/Modules/Avatar/Groups/GroupsModule.cs10
-rw-r--r--OpenSim/Region/Environment/Modules/Avatar/Inventory/InventoryModule.cs2
-rw-r--r--OpenSim/Region/Environment/Modules/Avatar/Profiles/AvatarProfilesModule.cs6
-rw-r--r--OpenSim/Region/Environment/Modules/Framework/Commander.cs22
-rw-r--r--OpenSim/Region/Environment/Modules/Framework/CommanderTestModule.cs2
-rw-r--r--OpenSim/Region/Environment/Modules/Grid/Interregion/InterregionModule.cs4
-rw-r--r--OpenSim/Region/Environment/Modules/Scripting/DynamicTexture/DynamicTextureModule.cs10
-rw-r--r--OpenSim/Region/Environment/Modules/Scripting/HttpRequest/ScriptsHttpRequests.cs6
-rw-r--r--OpenSim/Region/Environment/Modules/Scripting/LoadImageURL/LoadImageURLModule.cs10
-rw-r--r--OpenSim/Region/Environment/Modules/Scripting/VectorRender/VectorRenderModule.cs10
-rw-r--r--OpenSim/Region/Environment/Modules/Scripting/WorldComm/WorldCommModule.cs8
-rw-r--r--OpenSim/Region/Environment/Modules/Scripting/XMLRPC/XMLRPCModule.cs24
-rw-r--r--OpenSim/Region/Environment/Modules/World/Land/LandChannel.cs30
-rw-r--r--OpenSim/Region/Environment/Modules/World/Land/LandManagementModule.cs6
-rw-r--r--OpenSim/Region/Environment/Modules/World/Land/LandObject.cs30
-rw-r--r--OpenSim/Region/Environment/Modules/World/Serialiser/SerialiserModule.cs14
-rw-r--r--OpenSim/Region/Environment/Modules/World/Sun/SunModule.cs2
-rw-r--r--OpenSim/Region/Environment/Modules/World/Terrain/Effects/CookieCutter.cs2
-rw-r--r--OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/LLRAW.cs4
-rw-r--r--OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/Terragen.cs6
-rw-r--r--OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/FlattenSphere.cs1
-rw-r--r--OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/NoiseSphere.cs2
-rw-r--r--OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/RevertSphere.cs2
-rw-r--r--OpenSim/Region/Environment/Modules/World/Terrain/TerrainException.cs2
-rw-r--r--OpenSim/Region/Environment/Modules/World/Terrain/TerrainModule.cs6
-rw-r--r--OpenSim/Region/Environment/Modules/World/TreePopulator/TreePopulatorModule.cs4
-rw-r--r--OpenSim/Region/Environment/PermissionManager.cs361
-rw-r--r--OpenSim/Region/Environment/Scenes/AvatarAnimations.cs6
-rw-r--r--OpenSim/Region/Environment/Scenes/AvatarAppearance.cs123
-rw-r--r--OpenSim/Region/Environment/Scenes/EntityBase.cs193
-rw-r--r--OpenSim/Region/Environment/Scenes/IScenePresenceBody.cs2
-rw-r--r--OpenSim/Region/Environment/Scenes/InnerScene.cs198
-rw-r--r--OpenSim/Region/Environment/Scenes/Scene.Inventory.cs316
-rw-r--r--OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs30
-rw-r--r--OpenSim/Region/Environment/Scenes/Scene.cs561
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneBase.cs71
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs534
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneEvents.cs337
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneManager.cs82
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneObjectGroup.Inventory.cs59
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs377
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs150
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneObjectPart.cs1964
-rw-r--r--OpenSim/Region/Environment/Scenes/ScenePresence.cs1502
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneXmlLoader.cs10
-rw-r--r--OpenSim/Region/Environment/Scenes/Scripting/IScriptHost.cs2
-rw-r--r--OpenSim/Region/Environment/Scenes/Scripting/NullScriptHost.cs8
-rw-r--r--OpenSim/Region/Environment/Scenes/Scripting/ScriptEngineInterface.cs2
-rw-r--r--OpenSim/Region/Environment/Scenes/Scripting/ScriptEngineLoader.cs4
-rw-r--r--OpenSim/Region/Environment/Scenes/SimStatsReporter.cs274
-rw-r--r--OpenSim/Region/Environment/Scenes/UndoState.cs20
-rw-r--r--OpenSim/Region/Environment/StorageManager.cs14
-rw-r--r--OpenSim/Region/Environment/Types/BasicQuadTreeNode.cs53
-rw-r--r--OpenSim/Region/Environment/Types/UpdateQueue.cs103
76 files changed, 3896 insertions, 4029 deletions
diff --git a/OpenSim/Region/Environment/InstantMessageReceiver.cs b/OpenSim/Region/Environment/InstantMessageReceiver.cs
index b82b4aa..cc7880d 100644
--- a/OpenSim/Region/Environment/InstantMessageReceiver.cs
+++ b/OpenSim/Region/Environment/InstantMessageReceiver.cs
@@ -32,13 +32,10 @@ namespace OpenSim.Region.Environment
32 /// <summary> 32 /// <summary>
33 /// Bit Vector for Which Modules to send an instant message to from the Scene or an Associated Module 33 /// Bit Vector for Which Modules to send an instant message to from the Scene or an Associated Module
34 /// </summary> 34 /// </summary>
35
36 // This prevents the Modules from sending Instant messages to other modules through the scene 35 // This prevents the Modules from sending Instant messages to other modules through the scene
37 // and then receiving the same messages 36 // and then receiving the same messages
38
39 // This is mostly here because on LLSL and the SecondLife Client, IMs,Groups and friends are linked 37 // This is mostly here because on LLSL and the SecondLife Client, IMs,Groups and friends are linked
40 // inseparably 38 // inseparably
41
42 [Flags] 39 [Flags]
43 public enum InstantMessageReceiver : uint 40 public enum InstantMessageReceiver : uint
44 { 41 {
@@ -51,4 +48,4 @@ namespace OpenSim.Region.Environment
51 /// <summary>The Groups Module</summary> 48 /// <summary>The Groups Module</summary>
52 GroupsModule = 0x00000004 49 GroupsModule = 0x00000004
53 } 50 }
54} 51} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Interfaces/IAgentAssetTransactions.cs b/OpenSim/Region/Environment/Interfaces/IAgentAssetTransactions.cs
index c099fa1..5d2ec89 100644
--- a/OpenSim/Region/Environment/Interfaces/IAgentAssetTransactions.cs
+++ b/OpenSim/Region/Environment/Interfaces/IAgentAssetTransactions.cs
@@ -41,4 +41,4 @@ namespace OpenSim.Region.Environment.Interfaces
41 41
42 void RemoveAgentAssetTransactions(LLUUID userID); 42 void RemoveAgentAssetTransactions(LLUUID userID);
43 } 43 }
44} 44} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Interfaces/IAvatarFactory.cs b/OpenSim/Region/Environment/Interfaces/IAvatarFactory.cs
index 3ebbaab..d5473fb 100644
--- a/OpenSim/Region/Environment/Interfaces/IAvatarFactory.cs
+++ b/OpenSim/Region/Environment/Interfaces/IAvatarFactory.cs
@@ -30,9 +30,9 @@ using OpenSim.Region.Environment.Scenes;
30 30
31namespace OpenSim.Region.Environment.Interfaces 31namespace OpenSim.Region.Environment.Interfaces
32{ 32{
33 public interface IAvatarFactory 33 public interface IAvatarFactory
34 { 34 {
35 bool TryGetAvatarAppearance(LLUUID avatarId, out AvatarAppearance appearance); 35 bool TryGetAvatarAppearance(LLUUID avatarId, out AvatarAppearance appearance);
36 void UpdateDatabase(LLUUID userID, AvatarAppearance avatAppearance); 36 void UpdateDatabase(LLUUID userID, AvatarAppearance avatAppearance);
37 } 37 }
38} 38} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Interfaces/IHttpRequests.cs b/OpenSim/Region/Environment/Interfaces/IHttpRequests.cs
index 46ba9b2..8e2c978 100644
--- a/OpenSim/Region/Environment/Interfaces/IHttpRequests.cs
+++ b/OpenSim/Region/Environment/Interfaces/IHttpRequests.cs
@@ -39,4 +39,4 @@ namespace OpenSim.Region.Environment.Interfaces
39 HttpRequestClass GetNextCompletedRequest(); 39 HttpRequestClass GetNextCompletedRequest();
40 void RemoveCompletedRequest(LLUUID id); 40 void RemoveCompletedRequest(LLUUID id);
41 } 41 }
42} 42} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Interfaces/ILandChannel.cs b/OpenSim/Region/Environment/Interfaces/ILandChannel.cs
index 464a213..8486f70 100644
--- a/OpenSim/Region/Environment/Interfaces/ILandChannel.cs
+++ b/OpenSim/Region/Environment/Interfaces/ILandChannel.cs
@@ -70,7 +70,8 @@ namespace OpenSim.Region.Environment.Interfaces
70 void handleSignificantClientMovement(IClientAPI remote_client); 70 void handleSignificantClientMovement(IClientAPI remote_client);
71 void handleAnyClientMovement(ScenePresence avatar); 71 void handleAnyClientMovement(ScenePresence avatar);
72 void handleParcelAccessRequest(LLUUID agentID, LLUUID sessionID, uint flags, int sequenceID, int landLocalID, IClientAPI remote_client); 72 void handleParcelAccessRequest(LLUUID agentID, LLUUID sessionID, uint flags, int sequenceID, int landLocalID, IClientAPI remote_client);
73 void handleParcelAccessUpdateRequest(LLUUID agentID, LLUUID sessionID, uint flags, int landLocalID, List<ParcelManager.ParcelAccessEntry> entries, IClientAPI remote_client);
74 73
74 void handleParcelAccessUpdateRequest(LLUUID agentID, LLUUID sessionID, uint flags, int landLocalID, List<ParcelManager.ParcelAccessEntry> entries,
75 IClientAPI remote_client);
75 } 76 }
76} 77} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Interfaces/IRegionDataStore.cs b/OpenSim/Region/Environment/Interfaces/IRegionDataStore.cs
index c757461..e7af0a9 100644
--- a/OpenSim/Region/Environment/Interfaces/IRegionDataStore.cs
+++ b/OpenSim/Region/Environment/Interfaces/IRegionDataStore.cs
@@ -48,7 +48,7 @@ namespace OpenSim.Region.Environment.Interfaces
48 /// <param name="obj"></param> 48 /// <param name="obj"></param>
49 /// <param name="regionUUID"></param> 49 /// <param name="regionUUID"></param>
50 void StoreObject(SceneObjectGroup obj, LLUUID regionUUID); 50 void StoreObject(SceneObjectGroup obj, LLUUID regionUUID);
51 51
52 /// <summary> 52 /// <summary>
53 /// Entirely removes the object, including inventory 53 /// Entirely removes the object, including inventory
54 /// </summary> 54 /// </summary>
@@ -56,7 +56,7 @@ namespace OpenSim.Region.Environment.Interfaces
56 /// <param name="regionUUID"></param> 56 /// <param name="regionUUID"></param>
57 /// <returns></returns> 57 /// <returns></returns>
58 void RemoveObject(LLUUID uuid, LLUUID regionUUID); 58 void RemoveObject(LLUUID uuid, LLUUID regionUUID);
59 59
60 /// <summary> 60 /// <summary>
61 /// Store a prim's inventory 61 /// Store a prim's inventory
62 /// </summary> 62 /// </summary>
@@ -74,4 +74,4 @@ namespace OpenSim.Region.Environment.Interfaces
74 74
75 void Shutdown(); 75 void Shutdown();
76 } 76 }
77} 77} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Interfaces/IRegionModule.cs b/OpenSim/Region/Environment/Interfaces/IRegionModule.cs
index ffa4f32..80698d5 100644
--- a/OpenSim/Region/Environment/Interfaces/IRegionModule.cs
+++ b/OpenSim/Region/Environment/Interfaces/IRegionModule.cs
@@ -32,10 +32,10 @@ namespace OpenSim.Region.Environment.Interfaces
32{ 32{
33 public interface IRegionModule 33 public interface IRegionModule
34 { 34 {
35 string Name { get; }
36 bool IsSharedModule { get; }
35 void Initialise(Scene scene, IConfigSource source); 37 void Initialise(Scene scene, IConfigSource source);
36 void PostInitialise(); 38 void PostInitialise();
37 void Close(); 39 void Close();
38 string Name { get; }
39 bool IsSharedModule { get; }
40 } 40 }
41} 41} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Interfaces/ISimChat.cs b/OpenSim/Region/Environment/Interfaces/ISimChat.cs
index d52e58b..9335b00 100644
--- a/OpenSim/Region/Environment/Interfaces/ISimChat.cs
+++ b/OpenSim/Region/Environment/Interfaces/ISimChat.cs
@@ -34,4 +34,4 @@ namespace OpenSim.Region.Environment.Interfaces
34 { 34 {
35 void SimChat(Object sender, ChatFromViewerArgs e); 35 void SimChat(Object sender, ChatFromViewerArgs e);
36 } 36 }
37} 37} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Interfaces/IWorldComm.cs b/OpenSim/Region/Environment/Interfaces/IWorldComm.cs
index 8a63c54..992db19 100644
--- a/OpenSim/Region/Environment/Interfaces/IWorldComm.cs
+++ b/OpenSim/Region/Environment/Interfaces/IWorldComm.cs
@@ -43,4 +43,4 @@ namespace OpenSim.Region.Environment.Interfaces
43 uint PeekNextMessageLocalID(); 43 uint PeekNextMessageLocalID();
44 LLUUID PeekNextMessageItemID(); 44 LLUUID PeekNextMessageItemID();
45 } 45 }
46} 46} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Interfaces/IXMLRPC.cs b/OpenSim/Region/Environment/Interfaces/IXMLRPC.cs
index 6c1d025..959b0b7 100644
--- a/OpenSim/Region/Environment/Interfaces/IXMLRPC.cs
+++ b/OpenSim/Region/Environment/Interfaces/IXMLRPC.cs
@@ -45,4 +45,4 @@ namespace OpenSim.Region.Environment.Interfaces
45 void RemoveCompletedSRDRequest(LLUUID id); 45 void RemoveCompletedSRDRequest(LLUUID id);
46 void CancelSRDRequests(LLUUID itemID); 46 void CancelSRDRequests(LLUUID itemID);
47 } 47 }
48} 48} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Interfaces/IXfer.cs b/OpenSim/Region/Environment/Interfaces/IXfer.cs
index bad1833..bb2caca 100644
--- a/OpenSim/Region/Environment/Interfaces/IXfer.cs
+++ b/OpenSim/Region/Environment/Interfaces/IXfer.cs
@@ -31,4 +31,4 @@ namespace OpenSim.Region.Environment.Interfaces
31 { 31 {
32 bool AddNewFile(string fileName, byte[] data); 32 bool AddNewFile(string fileName, byte[] data);
33 } 33 }
34} 34} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/ModuleLoader.cs b/OpenSim/Region/Environment/ModuleLoader.cs
index 3f8b9ff..caaa28f 100644
--- a/OpenSim/Region/Environment/ModuleLoader.cs
+++ b/OpenSim/Region/Environment/ModuleLoader.cs
@@ -47,12 +47,11 @@ namespace OpenSim.Region.Environment
47 public class ModuleLoader 47 public class ModuleLoader
48 { 48 {
49 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 49 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
50 50 private readonly IConfigSource m_config;
51 public Dictionary<string, Assembly> LoadedAssemblys = new Dictionary<string, Assembly>();
52 51
53 private readonly List<IRegionModule> m_loadedModules = new List<IRegionModule>(); 52 private readonly List<IRegionModule> m_loadedModules = new List<IRegionModule>();
54 private readonly Dictionary<string, IRegionModule> m_loadedSharedModules = new Dictionary<string, IRegionModule>(); 53 private readonly Dictionary<string, IRegionModule> m_loadedSharedModules = new Dictionary<string, IRegionModule>();
55 private readonly IConfigSource m_config; 54 public Dictionary<string, Assembly> LoadedAssemblys = new Dictionary<string, Assembly>();
56 55
57 public ModuleLoader(IConfigSource config) 56 public ModuleLoader(IConfigSource config)
58 { 57 {
@@ -86,7 +85,8 @@ namespace OpenSim.Region.Environment
86 DynamicTextureModule dynamicModule = new DynamicTextureModule(); 85 DynamicTextureModule dynamicModule = new DynamicTextureModule();
87 if (m_loadedSharedModules.ContainsKey(dynamicModule.Name)) 86 if (m_loadedSharedModules.ContainsKey(dynamicModule.Name))
88 { 87 {
89 m_log.ErrorFormat("[MODULES]: Module name \"{0}\" already exists in module list. Module type {1} not added!", dynamicModule.Name, "DynamicTextureModule"); 88 m_log.ErrorFormat("[MODULES]: Module name \"{0}\" already exists in module list. Module type {1} not added!", dynamicModule.Name,
89 "DynamicTextureModule");
90 } 90 }
91 else 91 else
92 { 92 {
@@ -123,15 +123,15 @@ namespace OpenSim.Region.Environment
123 m_loadedSharedModules.Add(loadMod.Name, loadMod); 123 m_loadedSharedModules.Add(loadMod.Name, loadMod);
124 } 124 }
125 125
126 // AvatarFactoryModule avatarFactory = new AvatarFactoryModule(); 126 // AvatarFactoryModule avatarFactory = new AvatarFactoryModule();
127 // if (m_loadedSharedModules.ContainsKey(avatarFactory.Name)) 127 // if (m_loadedSharedModules.ContainsKey(avatarFactory.Name))
128 // { 128 // {
129 // m_log.ErrorFormat("[MODULES]: Module name \"{0}\" already exists in module list. Module type {1} not added!", avatarFactory.Name, "AvarFactoryModule"); 129 // m_log.ErrorFormat("[MODULES]: Module name \"{0}\" already exists in module list. Module type {1} not added!", avatarFactory.Name, "AvarFactoryModule");
130 // } 130 // }
131 // else 131 // else
132 // { 132 // {
133 // m_loadedSharedModules.Add(avatarFactory.Name, avatarFactory); 133 // m_loadedSharedModules.Add(avatarFactory.Name, avatarFactory);
134 // } 134 // }
135 135
136 XMLRPCModule xmlRpcMod = new XMLRPCModule(); 136 XMLRPCModule xmlRpcMod = new XMLRPCModule();
137 if (m_loadedSharedModules.ContainsKey(xmlRpcMod.Name)) 137 if (m_loadedSharedModules.ContainsKey(xmlRpcMod.Name))
@@ -149,13 +149,13 @@ namespace OpenSim.Region.Environment
149 AssetTransactionModule transactionsModule = new AssetTransactionModule(); 149 AssetTransactionModule transactionsModule = new AssetTransactionModule();
150 if (m_loadedSharedModules.ContainsKey(transactionsModule.Name)) 150 if (m_loadedSharedModules.ContainsKey(transactionsModule.Name))
151 { 151 {
152 m_log.ErrorFormat("[MODULES]: Module name \"{0}\" already exists in module list. Module type {1} not added!", transactionsModule.Name, "TransactionModule"); 152 m_log.ErrorFormat("[MODULES]: Module name \"{0}\" already exists in module list. Module type {1} not added!", transactionsModule.Name,
153 "TransactionModule");
153 } 154 }
154 else 155 else
155 { 156 {
156 m_loadedSharedModules.Add(transactionsModule.Name, transactionsModule); 157 m_loadedSharedModules.Add(transactionsModule.Name, transactionsModule);
157 } 158 }
158
159 } 159 }
160 160
161 public void InitialiseSharedModules(Scene scene) 161 public void InitialiseSharedModules(Scene scene)
@@ -284,7 +284,7 @@ namespace OpenSim.Region.Environment
284 { 284 {
285 if (pluginType.GetInterface("IRegionModule") != null) 285 if (pluginType.GetInterface("IRegionModule") != null)
286 { 286 {
287 modules.Add((IRegionModule)Activator.CreateInstance(pluginType)); 287 modules.Add((IRegionModule) Activator.CreateInstance(pluginType));
288 } 288 }
289 } 289 }
290 } 290 }
@@ -320,8 +320,8 @@ namespace OpenSim.Region.Environment
320 public void UnloadModule(IRegionModule rm) 320 public void UnloadModule(IRegionModule rm)
321 { 321 {
322 rm.Close(); 322 rm.Close();
323 323
324 m_loadedModules.Remove(rm); 324 m_loadedModules.Remove(rm);
325 } 325 }
326 } 326 }
327} 327} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Modules/Agent/AssetDownload/AssetDownloadModule.cs b/OpenSim/Region/Environment/Modules/Agent/AssetDownload/AssetDownloadModule.cs
index 48db51b..550b673 100644
--- a/OpenSim/Region/Environment/Modules/Agent/AssetDownload/AssetDownloadModule.cs
+++ b/OpenSim/Region/Environment/Modules/Agent/AssetDownload/AssetDownloadModule.cs
@@ -40,15 +40,16 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetDownload
40 /// <summary> 40 /// <summary>
41 /// Asset requests with data which are ready to be sent back to requesters. This includes textures. 41 /// Asset requests with data which are ready to be sent back to requesters. This includes textures.
42 /// </summary> 42 /// </summary>
43 private List<AssetRequest> AssetRequests; 43 private readonly List<AssetRequest> AssetRequests;
44 44
45 private Scene m_scene; 45 private readonly Dictionary<LLUUID, Scene> RegisteredScenes = new Dictionary<LLUUID, Scene>();
46 private Dictionary<LLUUID, Scene> RegisteredScenes = new Dictionary<LLUUID, Scene>();
47 46
48 /// 47 ///
49 /// Assets requests (for each user) which are waiting for asset server data. This includes texture requests 48 /// Assets requests (for each user) which are waiting for asset server data. This includes texture requests
50 /// </summary> 49 /// </summary>
51 private Dictionary<LLUUID, Dictionary<LLUUID, AssetRequest>> RequestedAssets; 50 private readonly Dictionary<LLUUID, Dictionary<LLUUID, AssetRequest>> RequestedAssets;
51
52 private Scene m_scene;
52 53
53 public AssetDownloadModule() 54 public AssetDownloadModule()
54 { 55 {
@@ -205,22 +206,18 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetDownload
205 { 206 {
206 public AssetBase AssetInf; 207 public AssetBase AssetInf;
207 public byte AssetRequestSource = 2; 208 public byte AssetRequestSource = 2;
208 public long DataPointer = 0; 209 public long DataPointer;
209 public int DiscardLevel = -1; 210 public int DiscardLevel = -1;
210 public AssetBase ImageInfo; 211 public AssetBase ImageInfo;
211 public bool IsTextureRequest; 212 public bool IsTextureRequest;
212 public int NumPackets = 0; 213 public int NumPackets;
213 public int PacketCounter = 0; 214 public int PacketCounter;
214 public byte[] Params = null; 215 public byte[] Params;
215 public LLUUID RequestAssetID; 216 public LLUUID RequestAssetID;
216 public IClientAPI RequestUser; 217 public IClientAPI RequestUser;
217 public LLUUID TransferRequestID; 218 public LLUUID TransferRequestID;
218 //public bool AssetInCache; 219 //public bool AssetInCache;
219 //public int TimeRequested; 220 //public int TimeRequested;
220
221 public AssetRequest()
222 {
223 }
224 } 221 }
225 222
226 #endregion 223 #endregion
diff --git a/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AgentAssetsTransactions.cs b/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AgentAssetsTransactions.cs
index 555d5f4..008daa2 100644
--- a/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AgentAssetsTransactions.cs
+++ b/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AgentAssetsTransactions.cs
@@ -44,7 +44,7 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction
44 // = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); 44 // = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
45 45
46 // Fields 46 // Fields
47 private bool m_dumpAssetsToFile; 47 private readonly bool m_dumpAssetsToFile;
48 public AgentAssetTransactionsManager Manager; 48 public AgentAssetTransactionsManager Manager;
49 public LLUUID UserID; 49 public LLUUID UserID;
50 public Dictionary<LLUUID, AssetXferUploader> XferUploaders = new Dictionary<LLUUID, AssetXferUploader>(); 50 public Dictionary<LLUUID, AssetXferUploader> XferUploaders = new Dictionary<LLUUID, AssetXferUploader>();
@@ -141,23 +141,23 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction
141 public class AssetXferUploader 141 public class AssetXferUploader
142 { 142 {
143 // Fields 143 // Fields
144 private readonly bool m_dumpAssetToFile;
145 private readonly AgentAssetTransactions m_userTransactions;
144 public bool AddToInventory; 146 public bool AddToInventory;
145 public AssetBase Asset; 147 public AssetBase Asset;
146 public LLUUID InventFolder = LLUUID.Zero; 148 public LLUUID InventFolder = LLUUID.Zero;
147 private sbyte invType = 0; 149 private sbyte invType;
148 private bool m_createItem = false; 150 private bool m_createItem;
149 private string m_description = String.Empty; 151 private string m_description = String.Empty;
150 private bool m_dumpAssetToFile; 152 private bool m_finished;
151 private bool m_finished = false;
152 private string m_name = String.Empty; 153 private string m_name = String.Empty;
153 private bool m_storeLocal; 154 private bool m_storeLocal;
154 private AgentAssetTransactions m_userTransactions; 155 private uint nextPerm;
155 private uint nextPerm = 0;
156 private IClientAPI ourClient; 156 private IClientAPI ourClient;
157 public LLUUID TransactionID = LLUUID.Zero; 157 public LLUUID TransactionID = LLUUID.Zero;
158 private sbyte type = 0; 158 private sbyte type;
159 public bool UploadComplete; 159 public bool UploadComplete;
160 private byte wearableType = 0; 160 private byte wearableType;
161 public ulong XferID; 161 public ulong XferID;
162 162
163 public AssetXferUploader(AgentAssetTransactions transactions, bool dumpAssetToFile) 163 public AssetXferUploader(AgentAssetTransactions transactions, bool dumpAssetToFile)
@@ -390,7 +390,7 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction
390 item.BasePermissions = 2147483647; 390 item.BasePermissions = 2147483647;
391 item.CurrentPermissions = 2147483647; 391 item.CurrentPermissions = 2147483647;
392 item.NextPermissions = nextPerm; 392 item.NextPermissions = nextPerm;
393 item.Flags = (uint) wearableType; 393 item.Flags = wearableType;
394 394
395 userInfo.AddItem(ourClient.AgentId, item); 395 userInfo.AddItem(ourClient.AgentId, item);
396 ourClient.SendInventoryItemCreateUpdate(item); 396 ourClient.SendInventoryItemCreateUpdate(item);
diff --git a/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AssetTransactionModule.cs b/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AssetTransactionModule.cs
index fcd0e0c..d7f5804 100644
--- a/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AssetTransactionModule.cs
+++ b/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AssetTransactionModule.cs
@@ -40,16 +40,11 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction
40 public class AssetTransactionModule : IRegionModule, IAgentAssetTransactions 40 public class AssetTransactionModule : IRegionModule, IAgentAssetTransactions
41 { 41 {
42 private readonly Dictionary<LLUUID, Scene> RegisteredScenes = new Dictionary<LLUUID, Scene>(); 42 private readonly Dictionary<LLUUID, Scene> RegisteredScenes = new Dictionary<LLUUID, Scene>();
43 private bool m_dumpAssetsToFile = false; 43 private bool m_dumpAssetsToFile;
44 private Scene m_scene = null; 44 private Scene m_scene;
45 45
46 private AgentAssetTransactionsManager m_transactionManager; 46 private AgentAssetTransactionsManager m_transactionManager;
47 47
48 public AssetTransactionModule()
49 {
50 // System.Console.WriteLine("creating AgentAssetTransactionModule");
51 }
52
53 #region IAgentAssetTransactions Members 48 #region IAgentAssetTransactions Members
54 49
55 public void HandleItemCreationFromTransaction(IClientAPI remoteClient, LLUUID transactionID, LLUUID folderID, 50 public void HandleItemCreationFromTransaction(IClientAPI remoteClient, LLUUID transactionID, LLUUID folderID,
@@ -145,13 +140,13 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction
145 /// <summary> 140 /// <summary>
146 /// Each agent has its own singleton collection of transactions 141 /// Each agent has its own singleton collection of transactions
147 /// </summary> 142 /// </summary>
148 private Dictionary<LLUUID, AgentAssetTransactions> AgentTransactions = 143 private readonly Dictionary<LLUUID, AgentAssetTransactions> AgentTransactions =
149 new Dictionary<LLUUID, AgentAssetTransactions>(); 144 new Dictionary<LLUUID, AgentAssetTransactions>();
150 145
151 /// <summary> 146 /// <summary>
152 /// Should we dump uploaded assets to the filesystem? 147 /// Should we dump uploaded assets to the filesystem?
153 /// </summary> 148 /// </summary>
154 private bool m_dumpAssetsToFile; 149 private readonly bool m_dumpAssetsToFile;
155 150
156 public Scene MyScene; 151 public Scene MyScene;
157 152
diff --git a/OpenSim/Region/Environment/Modules/Agent/TextureDownload/TextureDownloadModule.cs b/OpenSim/Region/Environment/Modules/Agent/TextureDownload/TextureDownloadModule.cs
index 474ac75..96ef61f 100644
--- a/OpenSim/Region/Environment/Modules/Agent/TextureDownload/TextureDownloadModule.cs
+++ b/OpenSim/Region/Environment/Modules/Agent/TextureDownload/TextureDownloadModule.cs
@@ -47,6 +47,8 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload
47 private readonly BlockingQueue<ITextureSender> m_queueSenders 47 private readonly BlockingQueue<ITextureSender> m_queueSenders
48 = new BlockingQueue<ITextureSender>(); 48 = new BlockingQueue<ITextureSender>();
49 49
50 private readonly List<Scene> m_scenes = new List<Scene>();
51
50 /// <summary> 52 /// <summary>
51 /// Each user has their own texture download service. 53 /// Each user has their own texture download service.
52 /// </summary> 54 /// </summary>
@@ -54,14 +56,9 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload
54 new Dictionary<LLUUID, UserTextureDownloadService>(); 56 new Dictionary<LLUUID, UserTextureDownloadService>();
55 57
56 private Scene m_scene; 58 private Scene m_scene;
57 private List<Scene> m_scenes = new List<Scene>();
58 59
59 private Thread m_thread; 60 private Thread m_thread;
60 61
61 public TextureDownloadModule()
62 {
63 }
64
65 #region IRegionModule Members 62 #region IRegionModule Members
66 63
67 public void Initialise(Scene scene, IConfigSource config) 64 public void Initialise(Scene scene, IConfigSource config)
@@ -69,7 +66,7 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload
69 if (m_scene == null) 66 if (m_scene == null)
70 { 67 {
71 //Console.WriteLine("Creating Texture download module"); 68 //Console.WriteLine("Creating Texture download module");
72 m_thread = new Thread(new ThreadStart(ProcessTextureSenders)); 69 m_thread = new Thread(ProcessTextureSenders);
73 m_thread.Name = "ProcessTextureSenderThread"; 70 m_thread.Name = "ProcessTextureSenderThread";
74 m_thread.IsBackground = true; 71 m_thread.IsBackground = true;
75 m_thread.Start(); 72 m_thread.Start();
diff --git a/OpenSim/Region/Environment/Modules/Agent/TextureDownload/TextureNotFoundSender.cs b/OpenSim/Region/Environment/Modules/Agent/TextureDownload/TextureNotFoundSender.cs
index 70e44d4..7d4c919 100644
--- a/OpenSim/Region/Environment/Modules/Agent/TextureDownload/TextureNotFoundSender.cs
+++ b/OpenSim/Region/Environment/Modules/Agent/TextureDownload/TextureNotFoundSender.cs
@@ -40,13 +40,13 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload
40 //private static readonly log4net.ILog m_log 40 //private static readonly log4net.ILog m_log
41 // = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); 41 // = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
42 42
43 private bool m_cancel = false; 43 private readonly LLUUID m_textureId;
44 private bool m_cancel;
44 private IClientAPI m_client; 45 private IClientAPI m_client;
45 46
46 // See ITextureSender 47 // See ITextureSender
47 48
48 private bool m_sending = false; 49 private bool m_sending;
49 private LLUUID m_textureId;
50 50
51 // See ITextureSender 51 // See ITextureSender
52 52
diff --git a/OpenSim/Region/Environment/Modules/Agent/TextureSender/TextureSender.cs b/OpenSim/Region/Environment/Modules/Agent/TextureSender/TextureSender.cs
index 02c541b..44b9a23 100644
--- a/OpenSim/Region/Environment/Modules/Agent/TextureSender/TextureSender.cs
+++ b/OpenSim/Region/Environment/Modules/Agent/TextureSender/TextureSender.cs
@@ -43,12 +43,14 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureSender
43 private static readonly ILog m_log 43 private static readonly ILog m_log
44 = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 44 = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
45 45
46 private readonly IClientAPI RequestUser;
47
46 /// <summary> 48 /// <summary>
47 /// Records the number of times texture send has been called. 49 /// Records the number of times texture send has been called.
48 /// </summary> 50 /// </summary>
49 public int counter = 0; 51 public int counter;
50 52
51 public bool ImageLoaded = false; 53 public bool ImageLoaded;
52 54
53 /// <summary> 55 /// <summary>
54 /// Holds the texture asset to send. 56 /// Holds the texture asset to send.
@@ -57,27 +59,26 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureSender
57 59
58 //public LLUUID assetID { get { return m_asset.FullID; } } 60 //public LLUUID assetID { get { return m_asset.FullID; } }
59 61
60 private bool m_cancel = false; 62 private bool m_cancel;
61 63
62 // See ITextureSender 64 // See ITextureSender
63 65
64 private bool m_sending = false; 66 private bool m_sending;
65 67
66 /// <summary> 68 /// <summary>
67 /// This is actually the number of extra packets required to send the texture data! We always assume 69 /// This is actually the number of extra packets required to send the texture data! We always assume
68 /// at least one is required. 70 /// at least one is required.
69 /// </summary> 71 /// </summary>
70 private int NumPackets = 0; 72 private int NumPackets;
71 73
72 /// <summary> 74 /// <summary>
73 /// Holds the packet number to send next. In this case, each packet is 1000 bytes long and starts 75 /// Holds the packet number to send next. In this case, each packet is 1000 bytes long and starts
74 /// at the 600th byte (0th indexed). 76 /// at the 600th byte (0th indexed).
75 /// </summary> 77 /// </summary>
76 private int PacketCounter = 0; 78 private int PacketCounter;
77 79
78 private int RequestedDiscardLevel = -1; 80 private int RequestedDiscardLevel = -1;
79 private IClientAPI RequestUser; 81 private uint StartPacketNumber;
80 private uint StartPacketNumber = 0;
81 82
82 public TextureSender(IClientAPI client, int discardLevel, uint packetNumber) 83 public TextureSender(IClientAPI client, int discardLevel, uint packetNumber)
83 { 84 {
@@ -190,7 +191,7 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureSender
190 catch (ArgumentOutOfRangeException) 191 catch (ArgumentOutOfRangeException)
191 { 192 {
192 m_log.Error("[TEXTURE SENDER]: Unable to separate texture into multiple packets: Array bounds failure on asset:" + 193 m_log.Error("[TEXTURE SENDER]: Unable to separate texture into multiple packets: Array bounds failure on asset:" +
193 m_asset.FullID.ToString()); 194 m_asset.FullID);
194 return; 195 return;
195 } 196 }
196 RequestUser.OutPacket(im, ThrottleOutPacketType.Texture); 197 RequestUser.OutPacket(im, ThrottleOutPacketType.Texture);
diff --git a/OpenSim/Region/Environment/Modules/Agent/Xfer/XferModule.cs b/OpenSim/Region/Environment/Modules/Agent/Xfer/XferModule.cs
index 8e90d17..eaf2198 100644
--- a/OpenSim/Region/Environment/Modules/Agent/Xfer/XferModule.cs
+++ b/OpenSim/Region/Environment/Modules/Agent/Xfer/XferModule.cs
@@ -41,10 +41,6 @@ namespace OpenSim.Region.Environment.Modules.Agent.Xfer
41 public Dictionary<string, byte[]> NewFiles = new Dictionary<string, byte[]>(); 41 public Dictionary<string, byte[]> NewFiles = new Dictionary<string, byte[]>();
42 public Dictionary<ulong, XferDownLoad> Transfers = new Dictionary<ulong, XferDownLoad>(); 42 public Dictionary<ulong, XferDownLoad> Transfers = new Dictionary<ulong, XferDownLoad>();
43 43
44 public XferModule()
45 {
46 }
47
48 #region IRegionModule Members 44 #region IRegionModule Members
49 45
50 public void Initialise(Scene scene, IConfigSource config) 46 public void Initialise(Scene scene, IConfigSource config)
@@ -149,11 +145,11 @@ namespace OpenSim.Region.Environment.Modules.Agent.Xfer
149 public IClientAPI Client; 145 public IClientAPI Client;
150 private bool complete; 146 private bool complete;
151 public byte[] Data = new byte[0]; 147 public byte[] Data = new byte[0];
152 public int DataPointer = 0; 148 public int DataPointer;
153 public string FileName = String.Empty; 149 public string FileName = String.Empty;
154 public uint Packet = 0; 150 public uint Packet;
155 public uint Serial = 1; 151 public uint Serial = 1;
156 public ulong XferID = 0; 152 public ulong XferID;
157 153
158 public XferDownLoad(string fileName, byte[] data, ulong xferID, IClientAPI client) 154 public XferDownLoad(string fileName, byte[] data, ulong xferID, IClientAPI client)
159 { 155 {
@@ -217,7 +213,7 @@ namespace OpenSim.Region.Environment.Modules.Agent.Xfer
217 { 213 {
218 byte[] transferData = new byte[Data.Length - DataPointer]; 214 byte[] transferData = new byte[Data.Length - DataPointer];
219 Array.Copy(Data, DataPointer, transferData, 0, Data.Length - DataPointer); 215 Array.Copy(Data, DataPointer, transferData, 0, Data.Length - DataPointer);
220 uint endPacket = Packet |= (uint) 0x80000000; 216 uint endPacket = Packet |= 0x80000000;
221 Client.SendXferPacket(XferID, endPacket, transferData); 217 Client.SendXferPacket(XferID, endPacket, transferData);
222 Packet++; 218 Packet++;
223 DataPointer += (Data.Length - DataPointer); 219 DataPointer += (Data.Length - DataPointer);
diff --git a/OpenSim/Region/Environment/Modules/Avatar/Chat/ChatModule.cs b/OpenSim/Region/Environment/Modules/Avatar/Chat/ChatModule.cs
index 15720fc..8d42681 100644
--- a/OpenSim/Region/Environment/Modules/Avatar/Chat/ChatModule.cs
+++ b/OpenSim/Region/Environment/Modules/Avatar/Chat/ChatModule.cs
@@ -44,15 +44,15 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
44 public class ChatModule : IRegionModule, ISimChat 44 public class ChatModule : IRegionModule, ISimChat
45 { 45 {
46 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 46 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
47 private string m_defaultzone = null; 47 private readonly List<Scene> m_scenes = new List<Scene>();
48 private string m_defaultzone;
48 49
49 private IRCChatModule m_irc = null; 50 private IRCChatModule m_irc;
50 private Thread m_irc_connector = null; 51 private Thread m_irc_connector;
51 52
52 private string m_last_leaving_user = null; 53 private string m_last_leaving_user;
53 private string m_last_new_user = null; 54 private string m_last_new_user;
54 private int m_saydistance = 30; 55 private int m_saydistance = 30;
55 private List<Scene> m_scenes = new List<Scene>();
56 private int m_shoutdistance = 100; 56 private int m_shoutdistance = 100;
57 internal object m_syncInit = new object(); 57 internal object m_syncInit = new object();
58 internal object m_syncLogout = new object(); 58 internal object m_syncLogout = new object();
@@ -257,7 +257,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
257 } 257 }
258 catch (Exception ex) 258 catch (Exception ex)
259 { 259 {
260 m_log.Error("[IRC]: NewClient exception trap:" + ex.ToString()); 260 m_log.Error("[IRC]: NewClient exception trap:" + ex);
261 } 261 }
262 } 262 }
263 263
@@ -284,7 +284,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
284 } 284 }
285 catch (Exception ex) 285 catch (Exception ex)
286 { 286 {
287 m_log.Error("[IRC]: ClientLoggedOut exception trap:" + ex.ToString()); 287 m_log.Error("[IRC]: ClientLoggedOut exception trap:" + ex);
288 } 288 }
289 } 289 }
290 } 290 }
@@ -372,24 +372,24 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
372 #endregion 372 #endregion
373 373
374 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 374 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
375 private Thread listener;
376 375
377 private string m_basenick = null; 376 private readonly string m_basenick;
378 private string m_channel = null; 377 private readonly string m_channel;
379 private bool m_connected = false; 378 private readonly bool m_enabled;
380 private bool m_enabled = false; 379 private readonly uint m_port = 6668;
381 private List<Scene> m_last_scenes = null; 380 private readonly string m_privmsgformat = "PRIVMSG {0} :<{1} in {2}>: {3}";
382 private string m_nick = null; 381 private readonly string m_user = "USER OpenSimBot 8 * :I'm a OpenSim to irc bot";
383 private uint m_port = 6668; 382 private Thread listener;
384 private string m_privmsgformat = "PRIVMSG {0} :<{1} in {2}>: {3}"; 383 private bool m_connected;
384 private List<Scene> m_last_scenes;
385 private string m_nick;
385 private StreamReader m_reader; 386 private StreamReader m_reader;
386 private List<Scene> m_scenes = null; 387 private List<Scene> m_scenes;
387 private string m_server = null; 388 private string m_server;
388 389
389 private NetworkStream m_stream; 390 private NetworkStream m_stream;
390 internal object m_syncConnect = new object(); 391 internal object m_syncConnect = new object();
391 private TcpClient m_tcp; 392 private TcpClient m_tcp;
392 private string m_user = "USER OpenSimBot 8 * :I'm a OpenSim to irc bot";
393 private StreamWriter m_writer; 393 private StreamWriter m_writer;
394 394
395 private Thread pingSender; 395 private Thread pingSender;
@@ -478,13 +478,13 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
478 m_reader = new StreamReader(m_stream); 478 m_reader = new StreamReader(m_stream);
479 m_writer = new StreamWriter(m_stream); 479 m_writer = new StreamWriter(m_stream);
480 480
481 pingSender = new Thread(new ThreadStart(PingRun)); 481 pingSender = new Thread(PingRun);
482 pingSender.Name = "PingSenderThread"; 482 pingSender.Name = "PingSenderThread";
483 pingSender.IsBackground = true; 483 pingSender.IsBackground = true;
484 pingSender.Start(); 484 pingSender.Start();
485 ThreadTracker.Add(pingSender); 485 ThreadTracker.Add(pingSender);
486 486
487 listener = new Thread(new ThreadStart(ListenerRun)); 487 listener = new Thread(ListenerRun);
488 listener.Name = "IRCChatModuleListenerThread"; 488 listener.Name = "IRCChatModuleListenerThread";
489 listener.IsBackground = true; 489 listener.IsBackground = true;
490 listener.Start(); 490 listener.Start();
@@ -545,7 +545,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
545 } 545 }
546 catch (Exception ex) 546 catch (Exception ex)
547 { 547 {
548 m_log.Error("[IRC]: PrivMsg exception trap:" + ex.ToString()); 548 m_log.Error("[IRC]: PrivMsg exception trap:" + ex);
549 } 549 }
550 } 550 }
551 551
@@ -588,7 +588,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
588 { 588 {
589 try 589 try
590 { 590 {
591 if (m_connected == true) 591 if (m_connected)
592 { 592 {
593 m_writer.WriteLine("PING :" + m_server); 593 m_writer.WriteLine("PING :" + m_server);
594 m_writer.Flush(); 594 m_writer.Flush();
@@ -602,7 +602,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
602 } 602 }
603 catch (Exception ex) 603 catch (Exception ex)
604 { 604 {
605 m_log.Error("[IRC]: PingRun exception trap:" + ex.ToString() + "\n" + ex.StackTrace); 605 m_log.Error("[IRC]: PingRun exception trap:" + ex + "\n" + ex.StackTrace);
606 } 606 }
607 } 607 }
608 } 608 }
@@ -615,7 +615,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
615 { 615 {
616 try 616 try
617 { 617 {
618 while ((m_connected == true) && ((inputLine = m_reader.ReadLine()) != null)) 618 while (m_connected && ((inputLine = m_reader.ReadLine()) != null))
619 { 619 {
620 // Console.WriteLine(inputLine); 620 // Console.WriteLine(inputLine);
621 if (inputLine.Contains(m_channel)) 621 if (inputLine.Contains(m_channel))
@@ -659,7 +659,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
659 } 659 }
660 catch (Exception ex) 660 catch (Exception ex)
661 { 661 {
662 m_log.Error("[IRC]: ListenerRun exception trap:" + ex.ToString() + "\n" + ex.StackTrace); 662 m_log.Error("[IRC]: ListenerRun exception trap:" + ex + "\n" + ex.StackTrace);
663 } 663 }
664 } 664 }
665 } 665 }
@@ -685,7 +685,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
685 } 685 }
686 catch (Exception ex) // IRC gate should not crash Sim 686 catch (Exception ex) // IRC gate should not crash Sim
687 { 687 {
688 m_log.Error("[IRC]: BroadcastSim Exception Trap:" + ex.ToString() + "\n" + ex.StackTrace); 688 m_log.Error("[IRC]: BroadcastSim Exception Trap:" + ex + "\n" + ex.StackTrace);
689 } 689 }
690 } 690 }
691 691
diff --git a/OpenSim/Region/Environment/Modules/Avatar/Currency/SampleMoney/SampleMoneyModule.cs b/OpenSim/Region/Environment/Modules/Avatar/Currency/SampleMoney/SampleMoneyModule.cs
index 966c5e2..cc6fd77 100644
--- a/OpenSim/Region/Environment/Modules/Avatar/Currency/SampleMoney/SampleMoneyModule.cs
+++ b/OpenSim/Region/Environment/Modules/Avatar/Currency/SampleMoney/SampleMoneyModule.cs
@@ -65,55 +65,55 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney
65 public class SampleMoneyModule : IMoneyModule 65 public class SampleMoneyModule : IMoneyModule
66 { 66 {
67 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 67 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
68 private readonly Dictionary<LLUUID, int> m_KnownClientFunds = new Dictionary<LLUUID, int>();
69
70 /// <summary>
71 /// Region UUIDS indexed by AgentID
72 /// </summary>
73 private readonly Dictionary<LLUUID, LLUUID> m_rootAgents = new Dictionary<LLUUID, LLUUID>();
74
75 /// <summary>
76 /// Scenes by Region Handle
77 /// </summary>
78 private readonly Dictionary<ulong, Scene> m_scenel = new Dictionary<ulong, Scene>();
68 79
69 /// <summary> 80 /// <summary>
70 /// Where Stipends come from and Fees go to. 81 /// Where Stipends come from and Fees go to.
71 /// </summary> 82 /// </summary>
72 private LLUUID EconomyBaseAccount = LLUUID.Zero; 83 private LLUUID EconomyBaseAccount = LLUUID.Zero;
73 84
74 private float EnergyEfficiency = 0f; 85 private float EnergyEfficiency;
75 private bool gridmode = false; 86 private bool gridmode;
76 private ObjectPaid handerOnObjectPaid; 87 private ObjectPaid handerOnObjectPaid;
77 private bool m_enabled = true; 88 private bool m_enabled = true;
78 89
79 private IConfigSource m_gConfig; 90 private IConfigSource m_gConfig;
80 91
81 private bool m_keepMoneyAcrossLogins = true; 92 private bool m_keepMoneyAcrossLogins = true;
82 private Dictionary<LLUUID, int> m_KnownClientFunds = new Dictionary<LLUUID, int>();
83 private string m_LandAddress = String.Empty; 93 private string m_LandAddress = String.Empty;
84 94
85 private int m_minFundsBeforeRefresh = 100; 95 private int m_minFundsBeforeRefresh = 100;
86 private string m_MoneyAddress = String.Empty; 96 private string m_MoneyAddress = String.Empty;
87 97
88 /// <summary>
89 /// Region UUIDS indexed by AgentID
90 /// </summary>
91 private Dictionary<LLUUID, LLUUID> m_rootAgents = new Dictionary<LLUUID, LLUUID>();
92
93 /// <summary>
94 /// Scenes by Region Handle
95 /// </summary>
96 private Dictionary<ulong, Scene> m_scenel = new Dictionary<ulong, Scene>();
97
98 private int m_stipend = 1000; 98 private int m_stipend = 1000;
99 99
100 private int ObjectCapacity = 45000; 100 private int ObjectCapacity = 45000;
101 private int ObjectCount = 0; 101 private int ObjectCount;
102 private int PriceEnergyUnit = 0; 102 private int PriceEnergyUnit;
103 private int PriceGroupCreate = 0; 103 private int PriceGroupCreate;
104 private int PriceObjectClaim = 0; 104 private int PriceObjectClaim;
105 private float PriceObjectRent = 0f; 105 private float PriceObjectRent;
106 private float PriceObjectScaleFactor = 0f; 106 private float PriceObjectScaleFactor;
107 private int PriceParcelClaim = 0; 107 private int PriceParcelClaim;
108 private float PriceParcelClaimFactor = 0f; 108 private float PriceParcelClaimFactor;
109 private int PriceParcelRent = 0; 109 private int PriceParcelRent;
110 private int PricePublicObjectDecay = 0; 110 private int PricePublicObjectDecay;
111 private int PricePublicObjectDelete = 0; 111 private int PricePublicObjectDelete;
112 private int PriceRentLight = 0; 112 private int PriceRentLight;
113 private int PriceUpload = 0; 113 private int PriceUpload;
114 private int TeleportMinPrice = 0; 114 private int TeleportMinPrice;
115 115
116 private float TeleportPriceExponent = 0f; 116 private float TeleportPriceExponent;
117 private int UserLevelPaysFees = 2; 117 private int UserLevelPaysFees = 2;
118 private Scene XMLRPCHandler; 118 private Scene XMLRPCHandler;
119 119
@@ -305,7 +305,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney
305 Hashtable hbinfo = 305 Hashtable hbinfo =
306 GetBalanceForUserFromMoneyServer(client.AgentId, client.SecureSessionId, s.RegionInfo.originRegionID.ToString(), 306 GetBalanceForUserFromMoneyServer(client.AgentId, client.SecureSessionId, s.RegionInfo.originRegionID.ToString(),
307 s.RegionInfo.regionSecret); 307 s.RegionInfo.regionSecret);
308 if ((bool) hbinfo["success"] == true) 308 if ((bool) hbinfo["success"])
309 { 309 {
310 Helpers.TryParse((string) hbinfo["agentId"], out agentID); 310 Helpers.TryParse((string) hbinfo["agentId"], out agentID);
311 try 311 try
@@ -333,7 +333,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney
333 else 333 else
334 { 334 {
335 m_log.WarnFormat("[MONEY]: Getting Money for user {0} failed with the following message:{1}", agentID, 335 m_log.WarnFormat("[MONEY]: Getting Money for user {0} failed with the following message:{1}", agentID,
336 (string) hbinfo["errorMessage"]); 336 hbinfo["errorMessage"]);
337 client.SendAlertMessage((string) hbinfo["errorMessage"]); 337 client.SendAlertMessage((string) hbinfo["errorMessage"]);
338 } 338 }
339 SendMoneyBalance(client, agentID, client.SessionId, LLUUID.Zero); 339 SendMoneyBalance(client, agentID, client.SessionId, LLUUID.Zero);
@@ -660,7 +660,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney
660 660
661 Hashtable hresult = genericCurrencyXMLRPCRequest(ht, "regionMoveMoney"); 661 Hashtable hresult = genericCurrencyXMLRPCRequest(ht, "regionMoveMoney");
662 662
663 if ((bool) hresult["success"] == true) 663 if ((bool) hresult["success"])
664 { 664 {
665 int funds1 = 0; 665 int funds1 = 0;
666 int funds2 = 0; 666 int funds2 = 0;
@@ -718,7 +718,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney
718 Hashtable hbinfo = 718 Hashtable hbinfo =
719 GetBalanceForUserFromMoneyServer(aClient.AgentId, aClient.SecureSessionId, s.RegionInfo.originRegionID.ToString(), 719 GetBalanceForUserFromMoneyServer(aClient.AgentId, aClient.SecureSessionId, s.RegionInfo.originRegionID.ToString(),
720 s.RegionInfo.regionSecret); 720 s.RegionInfo.regionSecret);
721 if ((bool) hbinfo["success"] == true) 721 if ((bool) hbinfo["success"])
722 { 722 {
723 try 723 try
724 { 724 {
@@ -743,7 +743,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney
743 else 743 else
744 { 744 {
745 m_log.WarnFormat("[MONEY]: Getting Money for user {0} failed with the following message:{1}", agentId, 745 m_log.WarnFormat("[MONEY]: Getting Money for user {0} failed with the following message:{1}", agentId,
746 (string) hbinfo["errorMessage"]); 746 hbinfo["errorMessage"]);
747 aClient.SendAlertMessage((string) hbinfo["errorMessage"]); 747 aClient.SendAlertMessage((string) hbinfo["errorMessage"]);
748 } 748 }
749 } 749 }
@@ -812,7 +812,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney
812 string secret = (string) requestData["secret"]; 812 string secret = (string) requestData["secret"];
813 813
814 Scene userScene = GetRandomScene(); 814 Scene userScene = GetRandomScene();
815 if (userScene.RegionInfo.regionSecret.ToString() == secret) 815 if (userScene.RegionInfo.regionSecret == secret)
816 { 816 {
817 IClientAPI client = LocateClientObject(agentId); 817 IClientAPI client = LocateClientObject(agentId);
818 818
@@ -1238,7 +1238,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney
1238 { 1238 {
1239 lock (e) 1239 lock (e)
1240 { 1240 {
1241 if (e.economyValidated == true && e.transactionID == 0) 1241 if (e.economyValidated && e.transactionID == 0)
1242 { 1242 {
1243 e.transactionID = Util.UnixTimeSinceEpoch(); 1243 e.transactionID = Util.UnixTimeSinceEpoch();
1244 1244
@@ -1328,7 +1328,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney
1328 else 1328 else
1329 { 1329 {
1330 m_log.Warn("[MONEY]: Potential Fraud Warning, got money transfer request for avatar that isn't in this simulator - Details; Sender:" + 1330 m_log.Warn("[MONEY]: Potential Fraud Warning, got money transfer request for avatar that isn't in this simulator - Details; Sender:" +
1331 e.sender.ToString() + " Receiver: " + e.receiver.ToString() + " Amount: " + e.amount.ToString()); 1331 e.sender + " Receiver: " + e.receiver + " Amount: " + e.amount);
1332 } 1332 }
1333 } 1333 }
1334 1334
@@ -1400,7 +1400,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney
1400 { 1400 {
1401 Hashtable hresult = 1401 Hashtable hresult =
1402 claim_user(avatar.UUID, avatar.ControllingClient.SecureSessionId, regionID, RegionItem.RegionInfo.regionSecret); 1402 claim_user(avatar.UUID, avatar.ControllingClient.SecureSessionId, regionID, RegionItem.RegionInfo.regionSecret);
1403 if ((bool) hresult["success"] == true) 1403 if ((bool) hresult["success"])
1404 { 1404 {
1405 int funds = 0; 1405 int funds = 0;
1406 try 1406 try
@@ -1432,7 +1432,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney
1432 if (RegionItem != null) 1432 if (RegionItem != null)
1433 { 1433 {
1434 Hashtable hresult = claim_user(avatar.UUID, avatar.ControllingClient.SecureSessionId, regionID, RegionItem.RegionInfo.regionSecret); 1434 Hashtable hresult = claim_user(avatar.UUID, avatar.ControllingClient.SecureSessionId, regionID, RegionItem.RegionInfo.regionSecret);
1435 if ((bool) hresult["success"] == true) 1435 if ((bool) hresult["success"])
1436 { 1436 {
1437 int funds = 0; 1437 int funds = 0;
1438 try 1438 try
@@ -1460,7 +1460,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney
1460 #endregion 1460 #endregion
1461 } 1461 }
1462 1462
1463 public enum TransactionType : int 1463 public enum TransactionType
1464 { 1464 {
1465 SystemGenerated = 0, 1465 SystemGenerated = 0,
1466 RegionMoneyRequest = 1, 1466 RegionMoneyRequest = 1,
diff --git a/OpenSim/Region/Environment/Modules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/Environment/Modules/Avatar/Friends/FriendsModule.cs
index dd6a92e..1dffc62 100644
--- a/OpenSim/Region/Environment/Modules/Avatar/Friends/FriendsModule.cs
+++ b/OpenSim/Region/Environment/Modules/Avatar/Friends/FriendsModule.cs
@@ -42,10 +42,10 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
42 { 42 {
43 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 43 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
44 44
45 private Dictionary<LLUUID, List<FriendListItem>> FriendLists = new Dictionary<LLUUID, List<FriendListItem>>(); 45 private readonly Dictionary<LLUUID, List<FriendListItem>> FriendLists = new Dictionary<LLUUID, List<FriendListItem>>();
46 private Dictionary<LLUUID, LLUUID> m_pendingFriendRequests = new Dictionary<LLUUID, LLUUID>(); 46 private readonly Dictionary<LLUUID, LLUUID> m_pendingFriendRequests = new Dictionary<LLUUID, LLUUID>();
47 private Dictionary<LLUUID, ulong> m_rootAgents = new Dictionary<LLUUID, ulong>(); 47 private readonly Dictionary<LLUUID, ulong> m_rootAgents = new Dictionary<LLUUID, ulong>();
48 private List<Scene> m_scene = new List<Scene>(); 48 private readonly List<Scene> m_scene = new List<Scene>();
49 49
50 #region IRegionModule Members 50 #region IRegionModule Members
51 51
@@ -213,7 +213,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
213 List<LLUUID> updateUsers = new List<LLUUID>(); 213 List<LLUUID> updateUsers = new List<LLUUID>();
214 foreach (FriendListItem fli in lfli) 214 foreach (FriendListItem fli in lfli)
215 { 215 {
216 if (fli.onlinestatus == true) 216 if (fli.onlinestatus)
217 { 217 {
218 updateUsers.Add(fli.Friend); 218 updateUsers.Add(fli.Friend);
219 } 219 }
@@ -357,20 +357,20 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
357 // https://wiki.secondlife.com/wiki/ImprovedInstantMessage 357 // https://wiki.secondlife.com/wiki/ImprovedInstantMessage
358 358
359 // 38 == Offer friendship 359 // 38 == Offer friendship
360 if (dialog == (byte) 38) 360 if (dialog == 38)
361 { 361 {
362 LLUUID friendTransactionID = LLUUID.Random(); 362 LLUUID friendTransactionID = LLUUID.Random();
363 363
364 m_pendingFriendRequests.Add(friendTransactionID, fromAgentID); 364 m_pendingFriendRequests.Add(friendTransactionID, fromAgentID);
365 365
366 m_log.Info("[FRIEND]: 38 - From:" + fromAgentID.ToString() + " To: " + toAgentID.ToString() + " Session:" + imSessionID.ToString() + " Message:" + 366 m_log.Info("[FRIEND]: 38 - From:" + fromAgentID + " To: " + toAgentID + " Session:" + imSessionID + " Message:" +
367 message); 367 message);
368 GridInstantMessage msg = new GridInstantMessage(); 368 GridInstantMessage msg = new GridInstantMessage();
369 msg.fromAgentID = fromAgentID.UUID; 369 msg.fromAgentID = fromAgentID.UUID;
370 msg.fromAgentSession = fromAgentSession.UUID; 370 msg.fromAgentSession = fromAgentSession.UUID;
371 msg.toAgentID = toAgentID.UUID; 371 msg.toAgentID = toAgentID.UUID;
372 msg.imSessionID = friendTransactionID.UUID; // This is the item we're mucking with here 372 msg.imSessionID = friendTransactionID.UUID; // This is the item we're mucking with here
373 m_log.Info("[FRIEND]: Filling Session: " + msg.imSessionID.ToString()); 373 m_log.Info("[FRIEND]: Filling Session: " + msg.imSessionID);
374 msg.timestamp = timestamp; 374 msg.timestamp = timestamp;
375 if (client != null) 375 if (client != null)
376 { 376 {
@@ -393,16 +393,16 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
393 } 393 }
394 394
395 // 39 == Accept Friendship 395 // 39 == Accept Friendship
396 if (dialog == (byte) 39) 396 if (dialog == 39)
397 { 397 {
398 m_log.Info("[FRIEND]: 39 - From:" + fromAgentID.ToString() + " To: " + toAgentID.ToString() + " Session:" + imSessionID.ToString() + " Message:" + 398 m_log.Info("[FRIEND]: 39 - From:" + fromAgentID + " To: " + toAgentID + " Session:" + imSessionID + " Message:" +
399 message); 399 message);
400 } 400 }
401 401
402 // 40 == Decline Friendship 402 // 40 == Decline Friendship
403 if (dialog == (byte) 40) 403 if (dialog == 40)
404 { 404 {
405 m_log.Info("[FRIEND]: 40 - From:" + fromAgentID.ToString() + " To: " + toAgentID.ToString() + " Session:" + imSessionID.ToString() + " Message:" + 405 m_log.Info("[FRIEND]: 40 - From:" + fromAgentID + " To: " + toAgentID + " Session:" + imSessionID + " Message:" +
406 message); 406 message);
407 } 407 }
408 } 408 }
@@ -433,14 +433,14 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
433 msg.ParentEstateID = 0; 433 msg.ParentEstateID = 0;
434 msg.timestamp = (uint) Util.UnixTimeSinceEpoch(); 434 msg.timestamp = (uint) Util.UnixTimeSinceEpoch();
435 msg.RegionID = SceneAgentIn.RegionInfo.RegionID.UUID; 435 msg.RegionID = SceneAgentIn.RegionInfo.RegionID.UUID;
436 msg.dialog = (byte) 39; // Approved friend request 436 msg.dialog = 39; // Approved friend request
437 msg.Position = new sLLVector3(); 437 msg.Position = new sLLVector3();
438 msg.offline = (byte) 0; 438 msg.offline = 0;
439 msg.binaryBucket = new byte[0]; 439 msg.binaryBucket = new byte[0];
440 // We don't really care which scene we pipe it through, it goes to the shared IM Module and/or the database 440 // We don't really care which scene we pipe it through, it goes to the shared IM Module and/or the database
441 441
442 SceneAgentIn.TriggerGridInstantMessage(msg, InstantMessageReceiver.IMModule); 442 SceneAgentIn.TriggerGridInstantMessage(msg, InstantMessageReceiver.IMModule);
443 SceneAgentIn.StoreAddFriendship(m_pendingFriendRequests[transactionID], agentID, (uint) 1); 443 SceneAgentIn.StoreAddFriendship(m_pendingFriendRequests[transactionID], agentID, 1);
444 m_pendingFriendRequests.Remove(transactionID); 444 m_pendingFriendRequests.Remove(transactionID);
445 445
446 // TODO: Inform agent that the friend is online 446 // TODO: Inform agent that the friend is online
@@ -471,9 +471,9 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
471 msg.ParentEstateID = 0; 471 msg.ParentEstateID = 0;
472 msg.timestamp = (uint) Util.UnixTimeSinceEpoch(); 472 msg.timestamp = (uint) Util.UnixTimeSinceEpoch();
473 msg.RegionID = SceneAgentIn.RegionInfo.RegionID.UUID; 473 msg.RegionID = SceneAgentIn.RegionInfo.RegionID.UUID;
474 msg.dialog = (byte) 40; // Deny friend request 474 msg.dialog = 40; // Deny friend request
475 msg.Position = new sLLVector3(); 475 msg.Position = new sLLVector3();
476 msg.offline = (byte) 0; 476 msg.offline = 0;
477 msg.binaryBucket = new byte[0]; 477 msg.binaryBucket = new byte[0];
478 SceneAgentIn.TriggerGridInstantMessage(msg, InstantMessageReceiver.IMModule); 478 SceneAgentIn.TriggerGridInstantMessage(msg, InstantMessageReceiver.IMModule);
479 m_pendingFriendRequests.Remove(transactionID); 479 m_pendingFriendRequests.Remove(transactionID);
diff --git a/OpenSim/Region/Environment/Modules/Avatar/Groups/GroupsModule.cs b/OpenSim/Region/Environment/Modules/Avatar/Groups/GroupsModule.cs
index 6edc44d..858cf21 100644
--- a/OpenSim/Region/Environment/Modules/Avatar/Groups/GroupsModule.cs
+++ b/OpenSim/Region/Environment/Modules/Avatar/Groups/GroupsModule.cs
@@ -41,10 +41,10 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Groups
41 { 41 {
42 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 42 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
43 43
44 private Dictionary<LLUUID, GroupList> m_grouplistmap = new Dictionary<LLUUID, GroupList>(); 44 private readonly Dictionary<LLUUID, GroupList> m_grouplistmap = new Dictionary<LLUUID, GroupList>();
45 private Dictionary<LLUUID, GroupData> m_groupmap = new Dictionary<LLUUID, GroupData>(); 45 private readonly Dictionary<LLUUID, GroupData> m_groupmap = new Dictionary<LLUUID, GroupData>();
46 private Dictionary<LLUUID, IClientAPI> m_iclientmap = new Dictionary<LLUUID, IClientAPI>(); 46 private readonly Dictionary<LLUUID, IClientAPI> m_iclientmap = new Dictionary<LLUUID, IClientAPI>();
47 private List<Scene> m_scene = new List<Scene>(); 47 private readonly List<Scene> m_scene = new List<Scene>();
48 48
49 #region IRegionModule Members 49 #region IRegionModule Members
50 50
@@ -214,7 +214,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Groups
214 } 214 }
215 else 215 else
216 { 216 {
217 m_log.Info("[GROUP]: Removing all reference to groups for " + agentID.ToString()); 217 m_log.Info("[GROUP]: Removing all reference to groups for " + agentID);
218 } 218 }
219 m_iclientmap.Remove(agentID); 219 m_iclientmap.Remove(agentID);
220 } 220 }
diff --git a/OpenSim/Region/Environment/Modules/Avatar/Inventory/InventoryModule.cs b/OpenSim/Region/Environment/Modules/Avatar/Inventory/InventoryModule.cs
index 624f307..9f2d461 100644
--- a/OpenSim/Region/Environment/Modules/Avatar/Inventory/InventoryModule.cs
+++ b/OpenSim/Region/Environment/Modules/Avatar/Inventory/InventoryModule.cs
@@ -46,7 +46,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Inventory
46 /// occurs in the initial offer message, not the accept message. So this dictionary links 46 /// occurs in the initial offer message, not the accept message. So this dictionary links
47 /// IM Session Ids to ItemIds 47 /// IM Session Ids to ItemIds
48 /// </summary> 48 /// </summary>
49 private IDictionary<LLUUID, LLUUID> m_pendingOffers = new Dictionary<LLUUID, LLUUID>(); 49 private readonly IDictionary<LLUUID, LLUUID> m_pendingOffers = new Dictionary<LLUUID, LLUUID>();
50 50
51 private Scene m_scene; 51 private Scene m_scene;
52 52
diff --git a/OpenSim/Region/Environment/Modules/Avatar/Profiles/AvatarProfilesModule.cs b/OpenSim/Region/Environment/Modules/Avatar/Profiles/AvatarProfilesModule.cs
index 15825b6..87f0177 100644
--- a/OpenSim/Region/Environment/Modules/Avatar/Profiles/AvatarProfilesModule.cs
+++ b/OpenSim/Region/Environment/Modules/Avatar/Profiles/AvatarProfilesModule.cs
@@ -41,10 +41,6 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Profiles
41 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 41 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
42 private Scene m_scene; 42 private Scene m_scene;
43 43
44 public AvatarProfilesModule()
45 {
46 }
47
48 #region IRegionModule Members 44 #region IRegionModule Members
49 45
50 public void Initialise(Scene scene, IConfigSource config) 46 public void Initialise(Scene scene, IConfigSource config)
@@ -104,7 +100,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Profiles
104 } 100 }
105 else 101 else
106 { 102 {
107 m_log.Debug("[AvatarProfilesModule]: Got null for profile for " + avatarID.ToString()); 103 m_log.Debug("[AvatarProfilesModule]: Got null for profile for " + avatarID);
108 } 104 }
109 } 105 }
110 106
diff --git a/OpenSim/Region/Environment/Modules/Framework/Commander.cs b/OpenSim/Region/Environment/Modules/Framework/Commander.cs
index 4430c10..d226c3d 100644
--- a/OpenSim/Region/Environment/Modules/Framework/Commander.cs
+++ b/OpenSim/Region/Environment/Modules/Framework/Commander.cs
@@ -42,11 +42,11 @@ namespace OpenSim.Region.Environment.Modules.Framework
42 public class Command : ICommand 42 public class Command : ICommand
43 { 43 {
44 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 44 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
45 private List<CommandArgument> m_args = new List<CommandArgument>(); 45 private readonly List<CommandArgument> m_args = new List<CommandArgument>();
46 46
47 private Action<object[]> m_command; 47 private readonly Action<object[]> m_command;
48 private string m_help; 48 private readonly string m_help;
49 private string m_name; 49 private readonly string m_name;
50 50
51 public Command(string name, Action<Object[]> command, string help) 51 public Command(string name, Action<Object[]> command, string help)
52 { 52 {
@@ -164,9 +164,9 @@ namespace OpenSim.Region.Environment.Modules.Framework
164 /// </summary> 164 /// </summary>
165 public class CommandArgument 165 public class CommandArgument
166 { 166 {
167 private string m_help; 167 private readonly string m_help;
168 private string m_name; 168 private readonly string m_name;
169 private string m_type; 169 private readonly string m_type;
170 private Object m_val; 170 private Object m_val;
171 171
172 public CommandArgument(string name, string help, string type) 172 public CommandArgument(string name, string help, string type)
@@ -204,8 +204,8 @@ namespace OpenSim.Region.Environment.Modules.Framework
204 public class Commander : ICommander 204 public class Commander : ICommander
205 { 205 {
206 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 206 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
207 private Dictionary<string, ICommand> m_commands = new Dictionary<string, ICommand>(); 207 private readonly Dictionary<string, ICommand> m_commands = new Dictionary<string, ICommand>();
208 private string m_name; 208 private readonly string m_name;
209 209
210 public Commander(string name) 210 public Commander(string name)
211 { 211 {
@@ -235,11 +235,11 @@ namespace OpenSim.Region.Environment.Modules.Framework
235 } 235 }
236 classSrc = classSrc.Remove(classSrc.Length - 1); // Delete the last comma 236 classSrc = classSrc.Remove(classSrc.Length - 1); // Delete the last comma
237 classSrc += " )\n\t{\n"; 237 classSrc += " )\n\t{\n";
238 classSrc += "\t\tObject[] args = new Object[" + com.Arguments.Count.ToString() + "];\n"; 238 classSrc += "\t\tObject[] args = new Object[" + com.Arguments.Count + "];\n";
239 int i = 0; 239 int i = 0;
240 foreach (KeyValuePair<string, string> arg in com.Arguments) 240 foreach (KeyValuePair<string, string> arg in com.Arguments)
241 { 241 {
242 classSrc += "\t\targs[" + i.ToString() + "] = " + Util.Md5Hash(arg.Key) + " " + ";\n"; 242 classSrc += "\t\targs[" + i + "] = " + Util.Md5Hash(arg.Key) + " " + ";\n";
243 i++; 243 i++;
244 } 244 }
245 classSrc += "\t\tGetCommander(\"" + m_name + "\").Run(\"" + com.Name + "\", args);\n"; 245 classSrc += "\t\tGetCommander(\"" + m_name + "\").Run(\"" + com.Name + "\", args);\n";
diff --git a/OpenSim/Region/Environment/Modules/Framework/CommanderTestModule.cs b/OpenSim/Region/Environment/Modules/Framework/CommanderTestModule.cs
index 7b5c981..3df9129 100644
--- a/OpenSim/Region/Environment/Modules/Framework/CommanderTestModule.cs
+++ b/OpenSim/Region/Environment/Modules/Framework/CommanderTestModule.cs
@@ -34,7 +34,7 @@ namespace OpenSim.Region.Environment.Modules.Framework
34{ 34{
35 public class CommanderTestModule : IRegionModule, ICommandableModule 35 public class CommanderTestModule : IRegionModule, ICommandableModule
36 { 36 {
37 private Commander m_commander = new Commander("CommanderTest"); 37 private readonly Commander m_commander = new Commander("CommanderTest");
38 private Scene m_scene; 38 private Scene m_scene;
39 39
40 #region ICommandableModule Members 40 #region ICommandableModule Members
diff --git a/OpenSim/Region/Environment/Modules/Grid/Interregion/InterregionModule.cs b/OpenSim/Region/Environment/Modules/Grid/Interregion/InterregionModule.cs
index 2ca4df9..ac2ac0b 100644
--- a/OpenSim/Region/Environment/Modules/Grid/Interregion/InterregionModule.cs
+++ b/OpenSim/Region/Environment/Modules/Grid/Interregion/InterregionModule.cs
@@ -29,14 +29,14 @@ namespace OpenSim.Region.Environment.Modules.Grid.Interregion
29 #endregion 29 #endregion
30 30
31 private readonly Dictionary<Type, Object> m_interfaces = new Dictionary<Type, object>(); 31 private readonly Dictionary<Type, Object> m_interfaces = new Dictionary<Type, object>();
32 private readonly Object m_lockObject = new object();
32 private readonly List<Location> m_myLocations = new List<Location>(); 33 private readonly List<Location> m_myLocations = new List<Location>();
33 34
34 private readonly Dictionary<Location, string[]> m_neighbourInterfaces = new Dictionary<Location, string[]>(); 35 private readonly Dictionary<Location, string[]> m_neighbourInterfaces = new Dictionary<Location, string[]>();
35 private readonly Dictionary<Location, RemotingObject> m_neighbourRemote = new Dictionary<Location, RemotingObject>(); 36 private readonly Dictionary<Location, RemotingObject> m_neighbourRemote = new Dictionary<Location, RemotingObject>();
36 private IConfigSource m_config; 37 private IConfigSource m_config;
37 private bool m_enabled = false; 38 private bool m_enabled;
38 39
39 private Object m_lockObject = new object();
40 private RemotingObject m_myRemote; 40 private RemotingObject m_myRemote;
41 private TcpChannel m_tcpChannel; 41 private TcpChannel m_tcpChannel;
42 private int m_tcpPort = 10101; 42 private int m_tcpPort = 10101;
diff --git a/OpenSim/Region/Environment/Modules/Scripting/DynamicTexture/DynamicTextureModule.cs b/OpenSim/Region/Environment/Modules/Scripting/DynamicTexture/DynamicTextureModule.cs
index c0e3d3b..d926714 100644
--- a/OpenSim/Region/Environment/Modules/Scripting/DynamicTexture/DynamicTextureModule.cs
+++ b/OpenSim/Region/Environment/Modules/Scripting/DynamicTexture/DynamicTextureModule.cs
@@ -40,12 +40,12 @@ namespace OpenSim.Region.Environment.Modules.Scripting.DynamicTexture
40{ 40{
41 public class DynamicTextureModule : IRegionModule, IDynamicTextureManager 41 public class DynamicTextureModule : IRegionModule, IDynamicTextureManager
42 { 42 {
43 private Dictionary<LLUUID, Scene> RegisteredScenes = new Dictionary<LLUUID, Scene>(); 43 private readonly Dictionary<LLUUID, Scene> RegisteredScenes = new Dictionary<LLUUID, Scene>();
44 44
45 private Dictionary<string, IDynamicTextureRender> RenderPlugins = 45 private readonly Dictionary<string, IDynamicTextureRender> RenderPlugins =
46 new Dictionary<string, IDynamicTextureRender>(); 46 new Dictionary<string, IDynamicTextureRender>();
47 47
48 private Dictionary<LLUUID, DynamicTextureUpdater> Updaters = new Dictionary<LLUUID, DynamicTextureUpdater>(); 48 private readonly Dictionary<LLUUID, DynamicTextureUpdater> Updaters = new Dictionary<LLUUID, DynamicTextureUpdater>();
49 49
50 #region IDynamicTextureManager Members 50 #region IDynamicTextureManager Members
51 51
@@ -176,14 +176,14 @@ namespace OpenSim.Region.Environment.Modules.Scripting.DynamicTexture
176 176
177 public class DynamicTextureUpdater 177 public class DynamicTextureUpdater
178 { 178 {
179 public bool BlendWithOldTexture = false; 179 public bool BlendWithOldTexture;
180 public string BodyData; 180 public string BodyData;
181 public string ContentType; 181 public string ContentType;
182 public byte FrontAlpha = 255; 182 public byte FrontAlpha = 255;
183 public LLUUID LastAssetID; 183 public LLUUID LastAssetID;
184 public string Params; 184 public string Params;
185 public LLUUID PrimID; 185 public LLUUID PrimID;
186 public bool SetNewFrontAlpha = false; 186 public bool SetNewFrontAlpha;
187 public LLUUID SimUUID; 187 public LLUUID SimUUID;
188 public LLUUID UpdaterID; 188 public LLUUID UpdaterID;
189 public int UpdateTimer; 189 public int UpdateTimer;
diff --git a/OpenSim/Region/Environment/Modules/Scripting/HttpRequest/ScriptsHttpRequests.cs b/OpenSim/Region/Environment/Modules/Scripting/HttpRequest/ScriptsHttpRequests.cs
index e1339a3..4bde33b 100644
--- a/OpenSim/Region/Environment/Modules/Scripting/HttpRequest/ScriptsHttpRequests.cs
+++ b/OpenSim/Region/Environment/Modules/Scripting/HttpRequest/ScriptsHttpRequests.cs
@@ -84,7 +84,7 @@ namespace OpenSim.Region.Environment.Modules.Scripting.HttpRequest
84{ 84{
85 public class HttpRequestModule : IRegionModule, IHttpRequests 85 public class HttpRequestModule : IRegionModule, IHttpRequests
86 { 86 {
87 private object HttpListLock = new object(); 87 private readonly object HttpListLock = new object();
88 private int httpTimeout = 30000; 88 private int httpTimeout = 30000;
89 private string m_name = "HttpScriptRequests"; 89 private string m_name = "HttpScriptRequests";
90 90
@@ -93,10 +93,6 @@ namespace OpenSim.Region.Environment.Modules.Scripting.HttpRequest
93 private Scene m_scene; 93 private Scene m_scene;
94 private Queue<HttpRequestClass> rpcQueue = new Queue<HttpRequestClass>(); 94 private Queue<HttpRequestClass> rpcQueue = new Queue<HttpRequestClass>();
95 95
96 public HttpRequestModule()
97 {
98 }
99
100 #region IHttpRequests Members 96 #region IHttpRequests Members
101 97
102 public LLUUID MakeHttpRequest(string url, string parameters, string body) 98 public LLUUID MakeHttpRequest(string url, string parameters, string body)
diff --git a/OpenSim/Region/Environment/Modules/Scripting/LoadImageURL/LoadImageURLModule.cs b/OpenSim/Region/Environment/Modules/Scripting/LoadImageURL/LoadImageURLModule.cs
index c828ef0..f39f16d 100644
--- a/OpenSim/Region/Environment/Modules/Scripting/LoadImageURL/LoadImageURLModule.cs
+++ b/OpenSim/Region/Environment/Modules/Scripting/LoadImageURL/LoadImageURLModule.cs
@@ -120,9 +120,9 @@ namespace OpenSim.Region.Environment.Modules.Scripting.LoadImageURL
120 120
121 private void MakeHttpRequest(string url, LLUUID requestID) 121 private void MakeHttpRequest(string url, LLUUID requestID)
122 { 122 {
123 WebRequest request = HttpWebRequest.Create(url); 123 WebRequest request = WebRequest.Create(url);
124 RequestState state = new RequestState((HttpWebRequest) request, requestID); 124 RequestState state = new RequestState((HttpWebRequest) request, requestID);
125 IAsyncResult result = request.BeginGetResponse(new AsyncCallback(HttpRequestReturn), state); 125 IAsyncResult result = request.BeginGetResponse(HttpRequestReturn, state);
126 126
127 TimeSpan t = (DateTime.UtcNow - new DateTime(1970, 1, 1)); 127 TimeSpan t = (DateTime.UtcNow - new DateTime(1970, 1, 1));
128 state.TimeOfRequest = (int) t.TotalSeconds; 128 state.TimeOfRequest = (int) t.TotalSeconds;
@@ -131,7 +131,7 @@ namespace OpenSim.Region.Environment.Modules.Scripting.LoadImageURL
131 private void HttpRequestReturn(IAsyncResult result) 131 private void HttpRequestReturn(IAsyncResult result)
132 { 132 {
133 RequestState state = (RequestState) result.AsyncState; 133 RequestState state = (RequestState) result.AsyncState;
134 WebRequest request = (WebRequest) state.Request; 134 WebRequest request = state.Request;
135 HttpWebResponse response = (HttpWebResponse) request.EndGetResponse(result); 135 HttpWebResponse response = (HttpWebResponse) request.EndGetResponse(result);
136 if (response.StatusCode == HttpStatusCode.OK) 136 if (response.StatusCode == HttpStatusCode.OK)
137 { 137 {
@@ -175,9 +175,9 @@ namespace OpenSim.Region.Environment.Modules.Scripting.LoadImageURL
175 175
176 public class RequestState 176 public class RequestState
177 { 177 {
178 public HttpWebRequest Request = null; 178 public HttpWebRequest Request;
179 public LLUUID RequestID = LLUUID.Zero; 179 public LLUUID RequestID = LLUUID.Zero;
180 public int TimeOfRequest = 0; 180 public int TimeOfRequest;
181 181
182 public RequestState(HttpWebRequest request, LLUUID requestID) 182 public RequestState(HttpWebRequest request, LLUUID requestID)
183 { 183 {
diff --git a/OpenSim/Region/Environment/Modules/Scripting/VectorRender/VectorRenderModule.cs b/OpenSim/Region/Environment/Modules/Scripting/VectorRender/VectorRenderModule.cs
index 626c60f..8e434c7 100644
--- a/OpenSim/Region/Environment/Modules/Scripting/VectorRender/VectorRenderModule.cs
+++ b/OpenSim/Region/Environment/Modules/Scripting/VectorRender/VectorRenderModule.cs
@@ -48,10 +48,6 @@ namespace OpenSim.Region.Environment.Modules.Scripting.VectorRender
48 private Scene m_scene; 48 private Scene m_scene;
49 private IDynamicTextureManager m_textureManager; 49 private IDynamicTextureManager m_textureManager;
50 50
51 public VectorRenderModule()
52 {
53 }
54
55 #region IDynamicTextureRender Members 51 #region IDynamicTextureRender Members
56 52
57 public string GetContentType() 53 public string GetContentType()
@@ -138,7 +134,7 @@ namespace OpenSim.Region.Environment.Modules.Scripting.VectorRender
138 catch (Exception e) 134 catch (Exception e)
139 { 135 {
140//Ckrinke: Add a WriteLine to remove the warning about 'e' defined but not used 136//Ckrinke: Add a WriteLine to remove the warning about 'e' defined but not used
141 Console.WriteLine("Problem with Draw. Please verify parameters." + e.ToString()); 137 Console.WriteLine("Problem with Draw. Please verify parameters." + e);
142 } 138 }
143 139
144 if ((size < 128) || (size > 1024)) 140 if ((size < 128) || (size > 1024))
@@ -260,7 +256,7 @@ namespace OpenSim.Region.Environment.Modules.Scripting.VectorRender
260 endPoint.X = (int) x; 256 endPoint.X = (int) x;
261 endPoint.Y = (int) y; 257 endPoint.Y = (int) y;
262 Image image = ImageHttpRequest(nextLine); 258 Image image = ImageHttpRequest(nextLine);
263 graph.DrawImage(image, (float) startPoint.X, (float) startPoint.Y, x, y); 259 graph.DrawImage(image, startPoint.X, startPoint.Y, x, y);
264 startPoint.X += endPoint.X; 260 startPoint.X += endPoint.X;
265 startPoint.Y += endPoint.Y; 261 startPoint.Y += endPoint.Y;
266 } 262 }
@@ -353,7 +349,7 @@ namespace OpenSim.Region.Environment.Modules.Scripting.VectorRender
353 349
354 private Bitmap ImageHttpRequest(string url) 350 private Bitmap ImageHttpRequest(string url)
355 { 351 {
356 WebRequest request = HttpWebRequest.Create(url); 352 WebRequest request = WebRequest.Create(url);
357//Ckrinke: Comment out for now as 'str' is unused. Bring it back into play later when it is used. 353//Ckrinke: Comment out for now as 'str' is unused. Bring it back into play later when it is used.
358//Ckrinke Stream str = null; 354//Ckrinke Stream str = null;
359 HttpWebResponse response = (HttpWebResponse) (request).GetResponse(); 355 HttpWebResponse response = (HttpWebResponse) (request).GetResponse();
diff --git a/OpenSim/Region/Environment/Modules/Scripting/WorldComm/WorldCommModule.cs b/OpenSim/Region/Environment/Modules/Scripting/WorldComm/WorldCommModule.cs
index e79b2bd..c4c1718 100644
--- a/OpenSim/Region/Environment/Modules/Scripting/WorldComm/WorldCommModule.cs
+++ b/OpenSim/Region/Environment/Modules/Scripting/WorldComm/WorldCommModule.cs
@@ -75,10 +75,6 @@ namespace OpenSim.Region.Environment.Modules.Scripting.WorldComm
75 private Queue m_pendingQ; 75 private Queue m_pendingQ;
76 private Scene m_scene; 76 private Scene m_scene;
77 77
78 public WorldCommModule()
79 {
80 }
81
82 #region IRegionModule Members 78 #region IRegionModule Members
83 79
84 public void Initialise(Scene scene, IConfigSource config) 80 public void Initialise(Scene scene, IConfigSource config)
@@ -324,8 +320,8 @@ namespace OpenSim.Region.Environment.Modules.Scripting.WorldComm
324 public class ListenerManager 320 public class ListenerManager
325 { 321 {
326 //private Dictionary<int, ListenerInfo> m_listeners; 322 //private Dictionary<int, ListenerInfo> m_listeners;
323 private readonly Hashtable m_listeners = Hashtable.Synchronized(new Hashtable());
327 private object ListenersLock = new object(); 324 private object ListenersLock = new object();
328 private Hashtable m_listeners = Hashtable.Synchronized(new Hashtable());
329 private int m_MaxListeners = 100; 325 private int m_MaxListeners = 100;
330 326
331 public int AddListener(uint localID, LLUUID itemID, LLUUID hostID, int channel, string name, string id, string msg) 327 public int AddListener(uint localID, LLUUID itemID, LLUUID hostID, int channel, string name, string id, string msg)
@@ -485,6 +481,7 @@ namespace OpenSim.Region.Environment.Modules.Scripting.WorldComm
485 481
486 public class ListenerInfo 482 public class ListenerInfo
487 { 483 {
484 private readonly LLUUID m_sourceItemID; // ID of the scenePart or avatar source of the message
488 private bool m_active; // Listener is active or not 485 private bool m_active; // Listener is active or not
489 private int m_channel; // Channel 486 private int m_channel; // Channel
490 private int m_handle; // Assigned handle of this listener 487 private int m_handle; // Assigned handle of this listener
@@ -494,7 +491,6 @@ namespace OpenSim.Region.Environment.Modules.Scripting.WorldComm
494 private uint m_localID; // Local ID from script engine 491 private uint m_localID; // Local ID from script engine
495 private string m_message; // The message 492 private string m_message; // The message
496 private string m_name; // Object name to filter messages from 493 private string m_name; // Object name to filter messages from
497 private LLUUID m_sourceItemID; // ID of the scenePart or avatar source of the message
498 494
499 public ListenerInfo(uint localID, int handle, LLUUID ItemID, LLUUID hostID, int channel, string name, LLUUID id, string message) 495 public ListenerInfo(uint localID, int handle, LLUUID ItemID, LLUUID hostID, int channel, string name, LLUUID id, string message)
500 { 496 {
diff --git a/OpenSim/Region/Environment/Modules/Scripting/XMLRPC/XMLRPCModule.cs b/OpenSim/Region/Environment/Modules/Scripting/XMLRPC/XMLRPCModule.cs
index a039d42..4f6808e 100644
--- a/OpenSim/Region/Environment/Modules/Scripting/XMLRPC/XMLRPCModule.cs
+++ b/OpenSim/Region/Environment/Modules/Scripting/XMLRPC/XMLRPCModule.cs
@@ -78,20 +78,20 @@ namespace OpenSim.Region.Environment.Modules.Scripting.XMLRPC
78 public class XMLRPCModule : IRegionModule, IXMLRPC 78 public class XMLRPCModule : IRegionModule, IXMLRPC
79 { 79 {
80 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 80 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
81 private readonly List<Scene> m_scenes = new List<Scene>();
82 private readonly object XMLRPCListLock = new object();
81 83
82 private string m_name = "XMLRPCModule"; 84 private string m_name = "XMLRPCModule";
83 85
84 // <channel id, RPCChannelInfo> 86 // <channel id, RPCChannelInfo>
85 private Dictionary<LLUUID, RPCChannelInfo> m_openChannels; 87 private Dictionary<LLUUID, RPCChannelInfo> m_openChannels;
86 private Dictionary<LLUUID, SendRemoteDataRequest> m_pendingSRDResponses; 88 private Dictionary<LLUUID, SendRemoteDataRequest> m_pendingSRDResponses;
87 private int m_remoteDataPort = 0; 89 private int m_remoteDataPort;
88 90
89 private Dictionary<LLUUID, RPCRequestInfo> m_rpcPending; 91 private Dictionary<LLUUID, RPCRequestInfo> m_rpcPending;
90 private Dictionary<LLUUID, RPCRequestInfo> m_rpcPendingResponses; 92 private Dictionary<LLUUID, RPCRequestInfo> m_rpcPendingResponses;
91 private List<Scene> m_scenes = new List<Scene>();
92 private int RemoteReplyScriptTimeout = 9000; 93 private int RemoteReplyScriptTimeout = 9000;
93 private int RemoteReplyScriptWait = 300; 94 private int RemoteReplyScriptWait = 300;
94 private object XMLRPCListLock = new object();
95 95
96 #region IRegionModule Members 96 #region IRegionModule Members
97 97
@@ -428,15 +428,15 @@ namespace OpenSim.Region.Environment.Modules.Scripting.XMLRPC
428 428
429 public class RPCRequestInfo 429 public class RPCRequestInfo
430 { 430 {
431 private LLUUID m_ChannelKey; 431 private readonly LLUUID m_ChannelKey;
432 private string m_IntVal; 432 private readonly string m_IntVal;
433 private LLUUID m_ItemID; 433 private readonly LLUUID m_ItemID;
434 private uint m_localID; 434 private readonly uint m_localID;
435 private LLUUID m_MessageID; 435 private readonly LLUUID m_MessageID;
436 private readonly string m_StrVal;
436 private bool m_processed; 437 private bool m_processed;
437 private int m_respInt; 438 private int m_respInt;
438 private string m_respStr; 439 private string m_respStr;
439 private string m_StrVal;
440 440
441 public RPCRequestInfo(uint localID, LLUUID itemID, LLUUID channelKey, string strVal, string intVal) 441 public RPCRequestInfo(uint localID, LLUUID itemID, LLUUID channelKey, string strVal, string intVal)
442 { 442 {
@@ -514,9 +514,9 @@ namespace OpenSim.Region.Environment.Modules.Scripting.XMLRPC
514 514
515 public class RPCChannelInfo 515 public class RPCChannelInfo
516 { 516 {
517 private LLUUID m_ChannelKey; 517 private readonly LLUUID m_ChannelKey;
518 private LLUUID m_itemID; 518 private readonly LLUUID m_itemID;
519 private uint m_localID; 519 private readonly uint m_localID;
520 520
521 public RPCChannelInfo(uint localID, LLUUID itemID, LLUUID channelID) 521 public RPCChannelInfo(uint localID, LLUUID itemID, LLUUID channelID)
522 { 522 {
diff --git a/OpenSim/Region/Environment/Modules/World/Land/LandChannel.cs b/OpenSim/Region/Environment/Modules/World/Land/LandChannel.cs
index 9ac3cc3..20d02c4 100644
--- a/OpenSim/Region/Environment/Modules/World/Land/LandChannel.cs
+++ b/OpenSim/Region/Environment/Modules/World/Land/LandChannel.cs
@@ -44,8 +44,8 @@ namespace OpenSim.Region.Environment.Modules.World.Land
44 //Land types set with flags in ParcelOverlay. 44 //Land types set with flags in ParcelOverlay.
45 //Only one of these can be used. 45 //Only one of these can be used.
46 public const float BAN_LINE_SAFETY_HIEGHT = 100; 46 public const float BAN_LINE_SAFETY_HIEGHT = 100;
47 public const byte LAND_FLAG_PROPERTY_BORDER_SOUTH = (byte) 128; //Equals 10000000 47 public const byte LAND_FLAG_PROPERTY_BORDER_SOUTH = 128; //Equals 10000000
48 public const byte LAND_FLAG_PROPERTY_BORDER_WEST = (byte) 64; //Equals 01000000 48 public const byte LAND_FLAG_PROPERTY_BORDER_WEST = 64; //Equals 01000000
49 49
50 //RequestResults (I think these are right, they seem to work): 50 //RequestResults (I think these are right, they seem to work):
51 public const int LAND_RESULT_MULTIPLE = 1; // The request they made contained more than a single peice of land 51 public const int LAND_RESULT_MULTIPLE = 1; // The request they made contained more than a single peice of land
@@ -55,26 +55,26 @@ namespace OpenSim.Region.Environment.Modules.World.Land
55 public const int LAND_SELECT_OBJECTS_GROUP = 4; 55 public const int LAND_SELECT_OBJECTS_GROUP = 4;
56 public const int LAND_SELECT_OBJECTS_OTHER = 8; 56 public const int LAND_SELECT_OBJECTS_OTHER = 8;
57 public const int LAND_SELECT_OBJECTS_OWNER = 2; 57 public const int LAND_SELECT_OBJECTS_OWNER = 2;
58 public const byte LAND_TYPE_IS_BEING_AUCTIONED = (byte) 5; //Equals 00000101 58 public const byte LAND_TYPE_IS_BEING_AUCTIONED = 5; //Equals 00000101
59 public const byte LAND_TYPE_IS_FOR_SALE = (byte) 4; //Equals 00000100 59 public const byte LAND_TYPE_IS_FOR_SALE = 4; //Equals 00000100
60 public const byte LAND_TYPE_OWNED_BY_GROUP = (byte) 2; //Equals 00000010 60 public const byte LAND_TYPE_OWNED_BY_GROUP = 2; //Equals 00000010
61 public const byte LAND_TYPE_OWNED_BY_OTHER = (byte) 1; //Equals 00000001 61 public const byte LAND_TYPE_OWNED_BY_OTHER = 1; //Equals 00000001
62 public const byte LAND_TYPE_OWNED_BY_REQUESTER = (byte) 3; //Equals 00000011 62 public const byte LAND_TYPE_OWNED_BY_REQUESTER = 3; //Equals 00000011
63 public const byte LAND_TYPE_PUBLIC = (byte) 0; //Equals 00000000 63 public const byte LAND_TYPE_PUBLIC = 0; //Equals 00000000
64 64
65 //These are other constants. Yay! 65 //These are other constants. Yay!
66 public const int START_LAND_LOCAL_ID = 1; 66 public const int START_LAND_LOCAL_ID = 1;
67 67
68 #endregion 68 #endregion
69 69
70 private int[,] landIDList = new int[64,64]; 70 private readonly int[,] landIDList = new int[64,64];
71 private Dictionary<int, ILandObject> landList = new Dictionary<int, ILandObject>(); 71 private readonly Dictionary<int, ILandObject> landList = new Dictionary<int, ILandObject>();
72 private readonly Scene m_scene;
72 73
73 private bool landPrimCountTainted = false; 74 private bool landPrimCountTainted;
74 private int lastLandLocalID = START_LAND_LOCAL_ID - 1; 75 private int lastLandLocalID = START_LAND_LOCAL_ID - 1;
75 76
76 private bool m_allowedForcefulBans = true; 77 private bool m_allowedForcefulBans = true;
77 private Scene m_scene;
78 78
79 public LandChannel(Scene scene) 79 public LandChannel(Scene scene)
80 { 80 {
@@ -192,7 +192,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
192 { 192 {
193 lastLandLocalID++; 193 lastLandLocalID++;
194 new_land.landData.localID = lastLandLocalID; 194 new_land.landData.localID = lastLandLocalID;
195 landList.Add(lastLandLocalID, (LandObject) new_land.Copy()); 195 landList.Add(lastLandLocalID, new_land.Copy());
196 196
197 197
198 bool[,] landBitmap = new_land.getLandBitmap(); 198 bool[,] landBitmap = new_land.getLandBitmap();
@@ -532,7 +532,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
532 { 532 {
533 for (x = 0; x < 64; x++) 533 for (x = 0; x < 64; x++)
534 { 534 {
535 byte tempByte = (byte) 0; //This represents the byte for the current 4x4 535 byte tempByte = 0; //This represents the byte for the current 4x4
536 ILandObject currentParcelBlock = null; 536 ILandObject currentParcelBlock = null;
537 537
538 try 538 try
@@ -611,7 +611,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
611 packet = (ParcelOverlayPacket) PacketPool.Instance.GetPacket(PacketType.ParcelOverlay); 611 packet = (ParcelOverlayPacket) PacketPool.Instance.GetPacket(PacketType.ParcelOverlay);
612 packet.ParcelData.Data = byteArray; 612 packet.ParcelData.Data = byteArray;
613 packet.ParcelData.SequenceID = sequenceID; 613 packet.ParcelData.SequenceID = sequenceID;
614 remote_client.OutPacket((Packet) packet, ThrottleOutPacketType.Task); 614 remote_client.OutPacket(packet, ThrottleOutPacketType.Task);
615 sequenceID++; 615 sequenceID++;
616 byteArray = new byte[LAND_BLOCKS_PER_PACKET]; 616 byteArray = new byte[LAND_BLOCKS_PER_PACKET];
617 } 617 }
diff --git a/OpenSim/Region/Environment/Modules/World/Land/LandManagementModule.cs b/OpenSim/Region/Environment/Modules/World/Land/LandManagementModule.cs
index 877bed5..e6e1ae4 100644
--- a/OpenSim/Region/Environment/Modules/World/Land/LandManagementModule.cs
+++ b/OpenSim/Region/Environment/Modules/World/Land/LandManagementModule.cs
@@ -45,14 +45,14 @@ namespace OpenSim.Region.Environment.Modules.World.Land
45 45
46 m_scene.EventManager.OnParcelPrimCountAdd += landChannel.addPrimToLandPrimCounts; 46 m_scene.EventManager.OnParcelPrimCountAdd += landChannel.addPrimToLandPrimCounts;
47 m_scene.EventManager.OnParcelPrimCountUpdate += landChannel.updateLandPrimCounts; 47 m_scene.EventManager.OnParcelPrimCountUpdate += landChannel.updateLandPrimCounts;
48 m_scene.EventManager.OnAvatarEnteringNewParcel += new EventManager.AvatarEnteringNewParcel(landChannel.handleAvatarChangingParcel); 48 m_scene.EventManager.OnAvatarEnteringNewParcel += landChannel.handleAvatarChangingParcel;
49 m_scene.EventManager.OnClientMovement += new EventManager.ClientMovement(landChannel.handleAnyClientMovement); 49 m_scene.EventManager.OnClientMovement += landChannel.handleAnyClientMovement;
50 m_scene.EventManager.OnValidateLandBuy += landChannel.handleLandValidationRequest; 50 m_scene.EventManager.OnValidateLandBuy += landChannel.handleLandValidationRequest;
51 m_scene.EventManager.OnLandBuy += landChannel.handleLandBuyRequest; 51 m_scene.EventManager.OnLandBuy += landChannel.handleLandBuyRequest;
52 52
53 lock (m_scene) 53 lock (m_scene)
54 { 54 {
55 m_scene.LandChannel = (ILandChannel) landChannel; 55 m_scene.LandChannel = landChannel;
56 } 56 }
57 } 57 }
58 58
diff --git a/OpenSim/Region/Environment/Modules/World/Land/LandObject.cs b/OpenSim/Region/Environment/Modules/World/Land/LandObject.cs
index e297b10..54fe9ae 100644
--- a/OpenSim/Region/Environment/Modules/World/Land/LandObject.cs
+++ b/OpenSim/Region/Environment/Modules/World/Land/LandObject.cs
@@ -73,6 +73,8 @@ namespace OpenSim.Region.Environment.Modules.World.Land
73 get { return m_scene.RegionInfo.RegionID; } 73 get { return m_scene.RegionInfo.RegionID; }
74 } 74 }
75 75
76 #endregion
77
76 #region Constructors 78 #region Constructors
77 79
78 public LandObject(LLUUID owner_id, bool is_group_owned, Scene scene) 80 public LandObject(LLUUID owner_id, bool is_group_owned, Scene scene)
@@ -98,7 +100,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
98 { 100 {
99 if (x >= 0 && y >= 0 && x <= Constants.RegionSize && x <= Constants.RegionSize) 101 if (x >= 0 && y >= 0 && x <= Constants.RegionSize && x <= Constants.RegionSize)
100 { 102 {
101 return (landBitmap[x / 4, y / 4] == true); 103 return landBitmap[x / 4, y / 4];
102 } 104 }
103 else 105 else
104 { 106 {
@@ -148,7 +150,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
148 updatePacket.ParcelData.GroupID = landData.groupID; 150 updatePacket.ParcelData.GroupID = landData.groupID;
149 updatePacket.ParcelData.GroupPrims = landData.groupPrims; 151 updatePacket.ParcelData.GroupPrims = landData.groupPrims;
150 updatePacket.ParcelData.IsGroupOwned = landData.isGroupOwned; 152 updatePacket.ParcelData.IsGroupOwned = landData.isGroupOwned;
151 updatePacket.ParcelData.LandingType = (byte) landData.landingType; 153 updatePacket.ParcelData.LandingType = landData.landingType;
152 updatePacket.ParcelData.LocalID = landData.localID; 154 updatePacket.ParcelData.LocalID = landData.localID;
153 if (landData.area > 0) 155 if (landData.area > 0)
154 { 156 {
@@ -212,7 +214,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
212 landData.selectedPrims; 214 landData.selectedPrims;
213 updatePacket.ParcelData.UserLocation = landData.userLocation; 215 updatePacket.ParcelData.UserLocation = landData.userLocation;
214 updatePacket.ParcelData.UserLookAt = landData.userLookAt; 216 updatePacket.ParcelData.UserLookAt = landData.userLookAt;
215 remote_client.OutPacket((Packet) updatePacket, ThrottleOutPacketType.Task); 217 remote_client.OutPacket(updatePacket, ThrottleOutPacketType.Task);
216 } 218 }
217 219
218 public void updateLandProperties(ParcelPropertiesUpdatePacket packet, IClientAPI remote_client) 220 public void updateLandProperties(ParcelPropertiesUpdatePacket packet, IClientAPI remote_client)
@@ -355,7 +357,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
355 { 357 {
356 ParcelAccessListReplyPacket.ListBlock listBlock = new ParcelAccessListReplyPacket.ListBlock(); 358 ParcelAccessListReplyPacket.ListBlock listBlock = new ParcelAccessListReplyPacket.ListBlock();
357 359
358 listBlock.Flags = (uint) 0; 360 listBlock.Flags = 0;
359 listBlock.ID = entry.AgentID; 361 listBlock.ID = entry.AgentID;
360 listBlock.Time = 0; 362 listBlock.Time = 0;
361 363
@@ -367,7 +369,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
367 { 369 {
368 ParcelAccessListReplyPacket.ListBlock listBlock = new ParcelAccessListReplyPacket.ListBlock(); 370 ParcelAccessListReplyPacket.ListBlock listBlock = new ParcelAccessListReplyPacket.ListBlock();
369 371
370 listBlock.Flags = (uint) 0; 372 listBlock.Flags = 0;
371 listBlock.ID = LLUUID.Zero; 373 listBlock.ID = LLUUID.Zero;
372 listBlock.Time = 0; 374 listBlock.Time = 0;
373 375
@@ -390,7 +392,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
390 replyPacket.Data.SequenceID = 0; 392 replyPacket.Data.SequenceID = 0;
391 393
392 replyPacket.List = createAccessListArrayByFlag(ParcelManager.AccessList.Access); 394 replyPacket.List = createAccessListArrayByFlag(ParcelManager.AccessList.Access);
393 remote_client.OutPacket((Packet) replyPacket, ThrottleOutPacketType.Task); 395 remote_client.OutPacket(replyPacket, ThrottleOutPacketType.Task);
394 } 396 }
395 397
396 if (flags == (uint) ParcelManager.AccessList.Ban || flags == (uint) ParcelManager.AccessList.Both) 398 if (flags == (uint) ParcelManager.AccessList.Ban || flags == (uint) ParcelManager.AccessList.Both)
@@ -402,7 +404,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
402 replyPacket.Data.SequenceID = 0; 404 replyPacket.Data.SequenceID = 0;
403 405
404 replyPacket.List = createAccessListArrayByFlag(ParcelManager.AccessList.Ban); 406 replyPacket.List = createAccessListArrayByFlag(ParcelManager.AccessList.Ban);
405 remote_client.OutPacket((Packet) replyPacket, ThrottleOutPacketType.Task); 407 remote_client.OutPacket(replyPacket, ThrottleOutPacketType.Task);
406 } 408 }
407 } 409 }
408 410
@@ -482,7 +484,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
482 { 484 {
483 for (y = 0; y < 64; y++) 485 for (y = 0; y < 64; y++)
484 { 486 {
485 if (landBitmap[x, y] == true) 487 if (landBitmap[x, y])
486 { 488 {
487 if (min_x > x) min_x = x; 489 if (min_x > x) min_x = x;
488 if (min_y > y) min_y = y; 490 if (min_y > y) min_y = y;
@@ -499,7 +501,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
499 if (ty > 255) 501 if (ty > 255)
500 ty = 255; 502 ty = 255;
501 landData.AABBMin = 503 landData.AABBMin =
502 new LLVector3((float) (min_x * 4), (float) (min_y * 4), 504 new LLVector3((min_x * 4), (min_y * 4),
503 (float) m_scene.Heightmap[tx, ty]); 505 (float) m_scene.Heightmap[tx, ty]);
504 506
505 tx = max_x * 4; 507 tx = max_x * 4;
@@ -509,7 +511,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
509 if (ty > 255) 511 if (ty > 255)
510 ty = 255; 512 ty = 255;
511 landData.AABBMax = 513 landData.AABBMax =
512 new LLVector3((float) (max_x * 4), (float) (max_y * 4), 514 new LLVector3((max_x * 4), (max_y * 4),
513 (float) m_scene.Heightmap[tx, ty]); 515 (float) m_scene.Heightmap[tx, ty]);
514 landData.area = tempArea; 516 landData.area = tempArea;
515 } 517 }
@@ -657,7 +659,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
657 if (i % 8 == 0) 659 if (i % 8 == 0)
658 { 660 {
659 tempConvertArr[byteNum] = tempByte; 661 tempConvertArr[byteNum] = tempByte;
660 tempByte = (byte) 0; 662 tempByte = 0;
661 i = 0; 663 i = 0;
662 byteNum++; 664 byteNum++;
663 } 665 }
@@ -677,7 +679,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
677 tempByte = landData.landBitmapByteArray[i]; 679 tempByte = landData.landBitmapByteArray[i];
678 for (bitNum = 0; bitNum < 8; bitNum++) 680 for (bitNum = 0; bitNum < 8; bitNum++)
679 { 681 {
680 bool bit = Convert.ToBoolean(Convert.ToByte(tempByte >> bitNum) & (byte) 1); 682 bool bit = Convert.ToBoolean(Convert.ToByte(tempByte >> bitNum) & 1);
681 tempConvertMap[x, y] = bit; 683 tempConvertMap[x, y] = bit;
682 x++; 684 x++;
683 if (x > 63) 685 if (x > 63)
@@ -751,7 +753,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
751 resultLocalIDs.RemoveAt(0); 753 resultLocalIDs.RemoveAt(0);
752 } 754 }
753 pack.Data = data; 755 pack.Data = data;
754 remote_client.OutPacket((Packet) pack, ThrottleOutPacketType.Task); 756 remote_client.OutPacket(pack, ThrottleOutPacketType.Task);
755 } 757 }
756 } 758 }
757 759
@@ -922,7 +924,5 @@ namespace OpenSim.Region.Environment.Modules.World.Land
922 #endregion 924 #endregion
923 925
924 #endregion 926 #endregion
925
926 #endregion
927 } 927 }
928} \ No newline at end of file 928} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Modules/World/Serialiser/SerialiserModule.cs b/OpenSim/Region/Environment/Modules/World/Serialiser/SerialiserModule.cs
index 4406e17..854d2ee 100644
--- a/OpenSim/Region/Environment/Modules/World/Serialiser/SerialiserModule.cs
+++ b/OpenSim/Region/Environment/Modules/World/Serialiser/SerialiserModule.cs
@@ -37,10 +37,10 @@ namespace OpenSim.Region.Environment.Modules.World.Serialiser
37{ 37{
38 public class SerialiserModule : IRegionModule, IRegionSerialiser 38 public class SerialiserModule : IRegionModule, IRegionSerialiser
39 { 39 {
40 private Commander m_commander = new Commander("Export"); 40 private readonly Commander m_commander = new Commander("Export");
41 private List<Scene> m_regions = new List<Scene>(); 41 private readonly List<Scene> m_regions = new List<Scene>();
42 private readonly List<IFileSerialiser> m_serialisers = new List<IFileSerialiser>();
42 private string m_savedir = "exports" + "/"; 43 private string m_savedir = "exports" + "/";
43 private List<IFileSerialiser> m_serialisers = new List<IFileSerialiser>();
44 44
45 #region IRegionModule Members 45 #region IRegionModule Members
46 46
@@ -105,8 +105,8 @@ namespace OpenSim.Region.Environment.Modules.World.Serialiser
105 105
106 TextWriter regionInfoWriter = new StreamWriter(saveDir + "README.TXT"); 106 TextWriter regionInfoWriter = new StreamWriter(saveDir + "README.TXT");
107 regionInfoWriter.WriteLine("Region Name: " + scene.RegionInfo.RegionName); 107 regionInfoWriter.WriteLine("Region Name: " + scene.RegionInfo.RegionName);
108 regionInfoWriter.WriteLine("Region ID: " + scene.RegionInfo.RegionID.ToString()); 108 regionInfoWriter.WriteLine("Region ID: " + scene.RegionInfo.RegionID);
109 regionInfoWriter.WriteLine("Backup Time: UTC " + DateTime.UtcNow.ToString()); 109 regionInfoWriter.WriteLine("Backup Time: UTC " + DateTime.UtcNow);
110 regionInfoWriter.WriteLine("Serialise Version: 0.1"); 110 regionInfoWriter.WriteLine("Serialise Version: 0.1");
111 regionInfoWriter.Close(); 111 regionInfoWriter.Close();
112 112
@@ -141,7 +141,7 @@ namespace OpenSim.Region.Environment.Modules.World.Serialiser
141 { 141 {
142 if (region.RegionInfo.RegionName == (string) args[0]) 142 if (region.RegionInfo.RegionName == (string) args[0])
143 { 143 {
144 List<string> results = SerialiseRegion(region, m_savedir + region.RegionInfo.RegionID.ToString() + "/"); 144 List<string> results = SerialiseRegion(region, m_savedir + region.RegionInfo.RegionID + "/");
145 } 145 }
146 } 146 }
147 } 147 }
@@ -150,7 +150,7 @@ namespace OpenSim.Region.Environment.Modules.World.Serialiser
150 { 150 {
151 foreach (Scene region in m_regions) 151 foreach (Scene region in m_regions)
152 { 152 {
153 List<string> results = SerialiseRegion(region, m_savedir + region.RegionInfo.RegionID.ToString() + "/"); 153 List<string> results = SerialiseRegion(region, m_savedir + region.RegionInfo.RegionID + "/");
154 } 154 }
155 } 155 }
156 156
diff --git a/OpenSim/Region/Environment/Modules/World/Sun/SunModule.cs b/OpenSim/Region/Environment/Modules/World/Sun/SunModule.cs
index 47ce258..05fae22 100644
--- a/OpenSim/Region/Environment/Modules/World/Sun/SunModule.cs
+++ b/OpenSim/Region/Environment/Modules/World/Sun/SunModule.cs
@@ -127,7 +127,7 @@ namespace OpenSim.Region.Environment.Modules.World.Sun
127 { 127 {
128 long m_addticks = (DateTime.Now.Ticks - m_start) * m_dilation; 128 long m_addticks = (DateTime.Now.Ticks - m_start) * m_dilation;
129 DateTime dt = new DateTime(m_start + m_addticks); 129 DateTime dt = new DateTime(m_start + m_addticks);
130 return (double) dt.Hour + ((double) dt.Minute / 60.0); 130 return dt.Hour + (dt.Minute / 60.0);
131 } 131 }
132 132
133 private LLVector3 SunPos(double hour) 133 private LLVector3 SunPos(double hour)
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/Effects/CookieCutter.cs b/OpenSim/Region/Environment/Modules/World/Terrain/Effects/CookieCutter.cs
index a2e0c40..331c49d 100644
--- a/OpenSim/Region/Environment/Modules/World/Terrain/Effects/CookieCutter.cs
+++ b/OpenSim/Region/Environment/Modules/World/Terrain/Effects/CookieCutter.cs
@@ -78,7 +78,7 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.Effects
78 { 78 {
79 for (y = 0; y < map.Height; y++) 79 for (y = 0; y < map.Height; y++)
80 { 80 {
81 if (cliffMask[x, y] == true) 81 if (cliffMask[x, y])
82 eroder.PaintEffect(map, x, y, 4, 0.1); 82 eroder.PaintEffect(map, x, y, 4, 0.1);
83 } 83 }
84 } 84 }
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/LLRAW.cs b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/LLRAW.cs
index 5d6723f..90728da 100644
--- a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/LLRAW.cs
+++ b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/LLRAW.cs
@@ -47,7 +47,7 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders
47 { 47 {
48 for (x = 0; x < retval.Width; x++) 48 for (x = 0; x < retval.Width; x++)
49 { 49 {
50 retval[x, y] = (double) bs.ReadByte() * ((double) bs.ReadByte() / 127.0); 50 retval[x, y] = bs.ReadByte() * (bs.ReadByte() / 127.0);
51 bs.ReadBytes(11); // Advance the stream to next bytes. 51 bs.ReadBytes(11); // Advance the stream to next bytes.
52 } 52 }
53 } 53 }
@@ -76,7 +76,7 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders
76 { 76 {
77 for (j = 0; j < 256; j++) 77 for (j = 0; j < 256; j++)
78 { 78 {
79 lookupHeightTable[i + (j * 256)] = ((double) i * ((double) j / 127.0)); 79 lookupHeightTable[i + (j * 256)] = (i * (j / 127.0));
80 } 80 }
81 } 81 }
82 82
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/Terragen.cs b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/Terragen.cs
index 7cb4b00..04c3f1a 100644
--- a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/Terragen.cs
+++ b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/Terragen.cs
@@ -50,14 +50,14 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders
50 BinaryReader bs = new BinaryReader(s); 50 BinaryReader bs = new BinaryReader(s);
51 51
52 bool eof = false; 52 bool eof = false;
53 if (ASCIIEncoding.ASCII.GetString(bs.ReadBytes(16)) == "TERRAGENTERRAIN ") 53 if (Encoding.ASCII.GetString(bs.ReadBytes(16)) == "TERRAGENTERRAIN ")
54 { 54 {
55 // Terragen file 55 // Terragen file
56 while (eof == false) 56 while (eof == false)
57 { 57 {
58 int w = 256; 58 int w = 256;
59 int h = 256; 59 int h = 256;
60 string tmp = ASCIIEncoding.ASCII.GetString(bs.ReadBytes(4)); 60 string tmp = Encoding.ASCII.GetString(bs.ReadBytes(4));
61 switch (tmp) 61 switch (tmp)
62 { 62 {
63 case "SIZE": 63 case "SIZE":
@@ -84,7 +84,7 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders
84 { 84 {
85 for (y = 0; y < h; y++) 85 for (y = 0; y < h; y++)
86 { 86 {
87 retval[x, y] = (double) baseHeight + (double) bs.ReadInt16() * (double) heightScale / 65536.0; 87 retval[x, y] = baseHeight + bs.ReadInt16() * (double) heightScale / 65536.0;
88 } 88 }
89 } 89 }
90 break; 90 break;
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/FlattenSphere.cs b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/FlattenSphere.cs
index dee455f..fa52a00 100644
--- a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/FlattenSphere.cs
+++ b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/FlattenSphere.cs
@@ -31,7 +31,6 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes
31{ 31{
32 public class FlattenSphere : ITerrainPaintableEffect 32 public class FlattenSphere : ITerrainPaintableEffect
33 { 33 {
34
35 #region ITerrainPaintableEffect Members 34 #region ITerrainPaintableEffect Members
36 35
37 public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength, double duration) 36 public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength, double duration)
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/NoiseSphere.cs b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/NoiseSphere.cs
index 8ae583e..5037533 100644
--- a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/NoiseSphere.cs
+++ b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/NoiseSphere.cs
@@ -57,7 +57,7 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes
57 z *= z; 57 z *= z;
58 z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry)); 58 z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry));
59 59
60 double noise = TerrainUtil.PerlinNoise2D((double) x / (double) Constants.RegionSize, (double) y / (double) Constants.RegionSize, 8, 1.0); 60 double noise = TerrainUtil.PerlinNoise2D(x / (double) Constants.RegionSize, y / (double) Constants.RegionSize, 8, 1.0);
61 61
62 if (z > 0.0) 62 if (z > 0.0)
63 map[x, y] += noise * z * duration; 63 map[x, y] += noise * z * duration;
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/RevertSphere.cs b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/RevertSphere.cs
index b47e041..acce32e 100644
--- a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/RevertSphere.cs
+++ b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/RevertSphere.cs
@@ -32,7 +32,7 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes
32{ 32{
33 public class RevertSphere : ITerrainPaintableEffect 33 public class RevertSphere : ITerrainPaintableEffect
34 { 34 {
35 private ITerrainChannel m_revertmap; 35 private readonly ITerrainChannel m_revertmap;
36 36
37 public RevertSphere(ITerrainChannel revertmap) 37 public RevertSphere(ITerrainChannel revertmap)
38 { 38 {
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/TerrainException.cs b/OpenSim/Region/Environment/Modules/World/Terrain/TerrainException.cs
index f5c0fe4..2411de0 100644
--- a/OpenSim/Region/Environment/Modules/World/Terrain/TerrainException.cs
+++ b/OpenSim/Region/Environment/Modules/World/Terrain/TerrainException.cs
@@ -31,7 +31,7 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain
31{ 31{
32 public class TerrainException : Exception 32 public class TerrainException : Exception
33 { 33 {
34 public TerrainException() : base() 34 public TerrainException()
35 { 35 {
36 } 36 }
37 37
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/TerrainModule.cs b/OpenSim/Region/Environment/Modules/World/Terrain/TerrainModule.cs
index eff6159..c105620 100644
--- a/OpenSim/Region/Environment/Modules/World/Terrain/TerrainModule.cs
+++ b/OpenSim/Region/Environment/Modules/World/Terrain/TerrainModule.cs
@@ -83,7 +83,7 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain
83 private Dictionary<string, ITerrainEffect> m_plugineffects; 83 private Dictionary<string, ITerrainEffect> m_plugineffects;
84 private ITerrainChannel m_revert; 84 private ITerrainChannel m_revert;
85 private Scene m_scene; 85 private Scene m_scene;
86 private bool m_tainted = false; 86 private bool m_tainted;
87 87
88 #region ICommandableModule Members 88 #region ICommandableModule Members
89 89
@@ -223,6 +223,8 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain
223 } 223 }
224 } 224 }
225 225
226 #endregion
227
226 #region Plugin Loading Methods 228 #region Plugin Loading Methods
227 229
228 private void LoadPlugins() 230 private void LoadPlugins()
@@ -276,8 +278,6 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain
276 278
277 #endregion 279 #endregion
278 280
279 #endregion
280
281 /// <summary> 281 /// <summary>
282 /// Installs into terrain module the standard suite of brushes 282 /// Installs into terrain module the standard suite of brushes
283 /// </summary> 283 /// </summary>
diff --git a/OpenSim/Region/Environment/Modules/World/TreePopulator/TreePopulatorModule.cs b/OpenSim/Region/Environment/Modules/World/TreePopulator/TreePopulatorModule.cs
index 4b22700..d964fe4 100644
--- a/OpenSim/Region/Environment/Modules/World/TreePopulator/TreePopulatorModule.cs
+++ b/OpenSim/Region/Environment/Modules/World/TreePopulator/TreePopulatorModule.cs
@@ -66,10 +66,10 @@ namespace OpenSim.Region.Environment.Modules.World.TreePopulator
66 m_trees = new List<LLUUID>(); 66 m_trees = new List<LLUUID>();
67 m_scene = scene; 67 m_scene = scene;
68 68
69 m_scene.EventManager.OnPluginConsole += new EventManager.OnPluginConsoleDelegate(EventManager_OnPluginConsole); 69 m_scene.EventManager.OnPluginConsole += EventManager_OnPluginConsole;
70 70
71 Timer CalculateTrees = new Timer(m_tree_updates); 71 Timer CalculateTrees = new Timer(m_tree_updates);
72 CalculateTrees.Elapsed += new ElapsedEventHandler(CalculateTrees_Elapsed); 72 CalculateTrees.Elapsed += CalculateTrees_Elapsed;
73 CalculateTrees.Start(); 73 CalculateTrees.Start();
74 m_log.Debug("[TREES]: Initialised tree module"); 74 m_log.Debug("[TREES]: Initialised tree module");
75 } 75 }
diff --git a/OpenSim/Region/Environment/PermissionManager.cs b/OpenSim/Region/Environment/PermissionManager.cs
index fd8387b..b2829a1 100644
--- a/OpenSim/Region/Environment/PermissionManager.cs
+++ b/OpenSim/Region/Environment/PermissionManager.cs
@@ -33,27 +33,21 @@ namespace OpenSim.Region.Environment
33{ 33{
34 public class PermissionManager 34 public class PermissionManager
35 { 35 {
36 // Bypasses the permissions engine (always returns OK)
37 // disable in any production environment
38 // TODO: Change this to false when permissions are a desired default
39 // TODO: Move to configuration option.
40 private bool m_bypassPermissions = true;
36 protected Scene m_scene; 41 protected Scene m_scene;
37 42
38 // These are here for testing. They will be taken out 43 // These are here for testing. They will be taken out
39
40 //private uint PERM_ALL = (uint)2147483647; 44 //private uint PERM_ALL = (uint)2147483647;
41 private uint PERM_COPY = (uint)32768; 45 private uint PERM_COPY = 32768;
42 //private uint PERM_MODIFY = (uint)16384; 46 //private uint PERM_MODIFY = (uint)16384;
43 private uint PERM_MOVE = (uint)524288;
44 //private uint PERM_TRANS = (uint)8192; 47 //private uint PERM_TRANS = (uint)8192;
45 private uint PERM_LOCKED = (uint)540672; 48 private uint PERM_LOCKED = 540672;
46 // Bypasses the permissions engine (always returns OK) 49 private uint PERM_MOVE = 524288;
47 // disable in any production environment
48 // TODO: Change this to false when permissions are a desired default
49 // TODO: Move to configuration option.
50 private bool m_bypassPermissions = true;
51 50
52 public bool BypassPermissions
53 {
54 get { return m_bypassPermissions; }
55 set { m_bypassPermissions = value; }
56 }
57 51
58 public PermissionManager() 52 public PermissionManager()
59 { 53 {
@@ -64,6 +58,12 @@ namespace OpenSim.Region.Environment
64 m_scene = scene; 58 m_scene = scene;
65 } 59 }
66 60
61 public bool BypassPermissions
62 {
63 get { return m_bypassPermissions; }
64 set { m_bypassPermissions = value; }
65 }
66
67 public void Initialise(Scene scene) 67 public void Initialise(Scene scene)
68 { 68 {
69 m_scene = scene; 69 m_scene = scene;
@@ -129,8 +129,8 @@ namespace OpenSim.Region.Environment
129 ILandObject land = m_scene.LandChannel.getLandObject(position.X, position.Y); 129 ILandObject land = m_scene.LandChannel.getLandObject(position.X, position.Y);
130 if (land == null) return false; 130 if (land == null) return false;
131 131
132 if ((land.landData.landFlags & ((int)Parcel.ParcelFlags.CreateObjects)) == 132 if ((land.landData.landFlags & ((int) Parcel.ParcelFlags.CreateObjects)) ==
133 (int)Parcel.ParcelFlags.CreateObjects) 133 (int) Parcel.ParcelFlags.CreateObjects)
134 permission = true; 134 permission = true;
135 135
136 //TODO: check for group rights 136 //TODO: check for group rights
@@ -168,8 +168,6 @@ namespace OpenSim.Region.Environment
168 /// <returns>Has permission?</returns> 168 /// <returns>Has permission?</returns>
169 public virtual bool CanObjectEntry(LLUUID user, LLVector3 oldPos, LLVector3 newPos) 169 public virtual bool CanObjectEntry(LLUUID user, LLVector3 oldPos, LLVector3 newPos)
170 { 170 {
171
172
173 if ((newPos.X > 257f || newPos.X < -1f || newPos.Y > 257f || newPos.Y < -1f)) 171 if ((newPos.X > 257f || newPos.X < -1f || newPos.Y > 257f || newPos.Y < -1f))
174 { 172 {
175 return true; 173 return true;
@@ -193,7 +191,7 @@ namespace OpenSim.Region.Environment
193 return true; 191 return true;
194 } 192 }
195 193
196 if ((land2.landData.landFlags & ((int)Parcel.ParcelFlags.AllowAllObjectEntry)) != 0) 194 if ((land2.landData.landFlags & ((int) Parcel.ParcelFlags.AllowAllObjectEntry)) != 0)
197 { 195 {
198 return true; 196 return true;
199 } 197 }
@@ -210,11 +208,142 @@ namespace OpenSim.Region.Environment
210 return false; 208 return false;
211 } 209 }
212 210
211 public virtual bool CanEditScript(LLUUID user, LLUUID script)
212 {
213 return IsAdministrator(user);
214 }
215
216 public virtual bool CanRunScript(LLUUID user, LLUUID script)
217 {
218 return IsAdministrator(user);
219 }
220
221 public virtual bool CanRunConsoleCommand(LLUUID user)
222 {
223 return IsAdministrator(user);
224 }
225
226 public virtual bool CanTerraform(LLUUID user, LLVector3 position)
227 {
228 bool permission = false;
229
230 // Estate override
231 if (GenericEstatePermission(user))
232 permission = true;
233
234 float X = position.X;
235 float Y = position.Y;
236
237 if (X > 255)
238 X = 255;
239 if (Y > 255)
240 Y = 255;
241 if (X < 0)
242 X = 0;
243 if (Y < 0)
244 Y = 0;
245
246 // Land owner can terraform too
247 ILandObject parcel = m_scene.LandChannel.getLandObject(X, Y);
248 if (parcel != null && GenericParcelPermission(user, parcel))
249 permission = true;
250
251 if (!permission)
252 SendPermissionError(user, "Not authorized to terraform at this location.");
253
254 return permission;
255 }
256
257 #region Estate Permissions
258
259 public virtual bool GenericEstatePermission(LLUUID user)
260 {
261 // Default: deny
262 bool permission = false;
263
264 // Estate admins should be able to use estate tools
265 if (IsEstateManager(user))
266 permission = true;
267
268 // Administrators always have permission
269 if (IsAdministrator(user))
270 permission = true;
271
272 return permission;
273 }
274
275 public virtual bool CanEditEstateTerrain(LLUUID user)
276 {
277 return GenericEstatePermission(user);
278 }
279
280 public virtual bool CanRestartSim(LLUUID user)
281 {
282 // Since this is potentially going on a grid...
283
284 return GenericEstatePermission(user);
285 //return m_scene.RegionInfo.MasterAvatarAssignedUUID == user;
286 }
287
288 #endregion
289
290 #region Parcel Permissions
291
292 protected virtual bool GenericParcelPermission(LLUUID user, ILandObject parcel)
293 {
294 bool permission = false;
295
296 if (parcel.landData.ownerID == user)
297 {
298 permission = true;
299 }
300
301 if (parcel.landData.isGroupOwned)
302 {
303 // TODO: Need to do some extra checks here. Requires group code.
304 }
305
306 if (IsEstateManager(user))
307 {
308 permission = true;
309 }
310
311 if (IsAdministrator(user))
312 {
313 permission = true;
314 }
315
316 return permission;
317 }
318
319 protected virtual bool GenericParcelPermission(LLUUID user, LLVector3 pos)
320 {
321 ILandObject parcel = m_scene.LandChannel.getLandObject(pos.X, pos.Y);
322 if (parcel == null) return false;
323 return GenericParcelPermission(user, parcel);
324 }
325
326 public virtual bool CanEditParcel(LLUUID user, ILandObject parcel)
327 {
328 return GenericParcelPermission(user, parcel);
329 }
330
331 public virtual bool CanSellParcel(LLUUID user, ILandObject parcel)
332 {
333 return GenericParcelPermission(user, parcel);
334 }
335
336 public virtual bool CanAbandonParcel(LLUUID user, ILandObject parcel)
337 {
338 return GenericParcelPermission(user, parcel);
339 }
340
341 #endregion
342
213 #region Object Permissions 343 #region Object Permissions
214 344
215 public virtual uint GenerateClientFlags(LLUUID user, LLUUID objID) 345 public virtual uint GenerateClientFlags(LLUUID user, LLUUID objID)
216 { 346 {
217
218 // Here's the way this works, 347 // Here's the way this works,
219 // ObjectFlags and Permission flags are two different enumerations 348 // ObjectFlags and Permission flags are two different enumerations
220 // ObjectFlags, however, tells the client to change what it will allow the user to do. 349 // ObjectFlags, however, tells the client to change what it will allow the user to do.
@@ -226,32 +355,33 @@ namespace OpenSim.Region.Environment
226 // Outside of this method, they should never be added to objectflags! 355 // Outside of this method, they should never be added to objectflags!
227 // -teravus 356 // -teravus
228 357
229 SceneObjectPart task=m_scene.GetSceneObjectPart(objID); 358 SceneObjectPart task = m_scene.GetSceneObjectPart(objID);
230 359
231 // this shouldn't ever happen.. return no permissions/objectflags. 360 // this shouldn't ever happen.. return no permissions/objectflags.
232 if (task == null) 361 if (task == null)
233 return (uint)0; 362 return 0;
234 363
235 uint objflags = task.GetEffectiveObjectFlags(); 364 uint objflags = task.GetEffectiveObjectFlags();
236 LLUUID objectOwner = task.OwnerID; 365 LLUUID objectOwner = task.OwnerID;
237 366
238 367
239 // Remove any of the objectFlags that are temporary. These will get added back if appropriate 368 // Remove any of the objectFlags that are temporary. These will get added back if appropriate
240 // in the next bit of code 369 // in the next bit of code
241 370
242 objflags &= (uint) 371 objflags &= (uint)
243 ~(LLObject.ObjectFlags.ObjectCopy | // Tells client you can copy the object 372 ~(LLObject.ObjectFlags.ObjectCopy | // Tells client you can copy the object
244 LLObject.ObjectFlags.ObjectModify | // tells client you can modify the object 373 LLObject.ObjectFlags.ObjectModify | // tells client you can modify the object
245 LLObject.ObjectFlags.ObjectMove | // tells client that you can move the object (only, no mod) 374 LLObject.ObjectFlags.ObjectMove | // tells client that you can move the object (only, no mod)
246 LLObject.ObjectFlags.ObjectTransfer | // tells the client that you can /take/ the object if you don't own it 375 LLObject.ObjectFlags.ObjectTransfer | // tells the client that you can /take/ the object if you don't own it
247 LLObject.ObjectFlags.ObjectYouOwner | // Tells client that you're the owner of the object 376 LLObject.ObjectFlags.ObjectYouOwner | // Tells client that you're the owner of the object
248 LLObject.ObjectFlags.ObjectYouOfficer // Tells client that you've got group object editing permission. Used when ObjectGroupOwned is set 377 LLObject.ObjectFlags.ObjectYouOfficer
249 ); 378 // Tells client that you've got group object editing permission. Used when ObjectGroupOwned is set
379 );
250 380
251 // Creating the three ObjectFlags options for this method to choose from. 381 // Creating the three ObjectFlags options for this method to choose from.
252 // Customize the OwnerMask 382 // Customize the OwnerMask
253 uint objectOwnerMask = ApplyObjectModifyMasks(task.OwnerMask, objflags); 383 uint objectOwnerMask = ApplyObjectModifyMasks(task.OwnerMask, objflags);
254 objectOwnerMask |= (uint)LLObject.ObjectFlags.ObjectYouOwner; 384 objectOwnerMask |= (uint) LLObject.ObjectFlags.ObjectYouOwner;
255 385
256 // Customize the GroupMask 386 // Customize the GroupMask
257 uint objectGroupMask = ApplyObjectModifyMasks(task.GroupMask, objflags); 387 uint objectGroupMask = ApplyObjectModifyMasks(task.GroupMask, objflags);
@@ -261,8 +391,8 @@ namespace OpenSim.Region.Environment
261 391
262 392
263 // Hack to allow collaboration until Groups and Group Permissions are implemented 393 // Hack to allow collaboration until Groups and Group Permissions are implemented
264 if ((objectEveryoneMask & (uint)LLObject.ObjectFlags.ObjectMove) != 0) 394 if ((objectEveryoneMask & (uint) LLObject.ObjectFlags.ObjectMove) != 0)
265 objectEveryoneMask |= (uint)LLObject.ObjectFlags.ObjectModify; 395 objectEveryoneMask |= (uint) LLObject.ObjectFlags.ObjectModify;
266 396
267 if (m_bypassPermissions) 397 if (m_bypassPermissions)
268 return objectOwnerMask; 398 return objectOwnerMask;
@@ -287,7 +417,6 @@ namespace OpenSim.Region.Environment
287 return objectOwnerMask; 417 return objectOwnerMask;
288 418
289 419
290
291 // Admin should be able to edit anything in the sim (including admin objects) 420 // Admin should be able to edit anything in the sim (including admin objects)
292 if (IsAdministrator(user)) 421 if (IsAdministrator(user))
293 return objectOwnerMask; 422 return objectOwnerMask;
@@ -297,30 +426,29 @@ namespace OpenSim.Region.Environment
297 } 426 }
298 427
299 428
300
301 private uint ApplyObjectModifyMasks(uint setPermissionMask, uint objectFlagsMask) 429 private uint ApplyObjectModifyMasks(uint setPermissionMask, uint objectFlagsMask)
302 { 430 {
303 // We are adding the temporary objectflags to the object's objectflags based on the 431 // We are adding the temporary objectflags to the object's objectflags based on the
304 // permission flag given. These change the F flags on the client. 432 // permission flag given. These change the F flags on the client.
305 433
306 if ((setPermissionMask & (uint)PermissionMask.Copy) != 0) 434 if ((setPermissionMask & (uint) PermissionMask.Copy) != 0)
307 { 435 {
308 objectFlagsMask |= (uint)LLObject.ObjectFlags.ObjectCopy; 436 objectFlagsMask |= (uint) LLObject.ObjectFlags.ObjectCopy;
309 } 437 }
310 438
311 if ((setPermissionMask & (uint)PermissionMask.Move) != 0) 439 if ((setPermissionMask & (uint) PermissionMask.Move) != 0)
312 { 440 {
313 objectFlagsMask |= (uint)LLObject.ObjectFlags.ObjectMove; 441 objectFlagsMask |= (uint) LLObject.ObjectFlags.ObjectMove;
314 } 442 }
315 443
316 if ((setPermissionMask & (uint)PermissionMask.Modify) != 0) 444 if ((setPermissionMask & (uint) PermissionMask.Modify) != 0)
317 { 445 {
318 objectFlagsMask |= (uint)LLObject.ObjectFlags.ObjectModify; 446 objectFlagsMask |= (uint) LLObject.ObjectFlags.ObjectModify;
319 } 447 }
320 448
321 if ((setPermissionMask & (uint)PermissionMask.Transfer) != 0) 449 if ((setPermissionMask & (uint) PermissionMask.Transfer) != 0)
322 { 450 {
323 objectFlagsMask |= (uint)LLObject.ObjectFlags.ObjectTransfer; 451 objectFlagsMask |= (uint) LLObject.ObjectFlags.ObjectTransfer;
324 } 452 }
325 453
326 return objectFlagsMask; 454 return objectFlagsMask;
@@ -344,7 +472,7 @@ namespace OpenSim.Region.Environment
344 } 472 }
345 473
346 474
347 SceneObjectGroup group = (SceneObjectGroup)m_scene.Entities[objId]; 475 SceneObjectGroup group = (SceneObjectGroup) m_scene.Entities[objId];
348 476
349 LLUUID objectOwner = group.OwnerID; 477 LLUUID objectOwner = group.OwnerID;
350 locked = ((group.RootPart.OwnerMask & PERM_LOCKED) == 0); 478 locked = ((group.RootPart.OwnerMask & PERM_LOCKED) == 0);
@@ -432,7 +560,7 @@ namespace OpenSim.Region.Environment
432 } 560 }
433 561
434 562
435 SceneObjectGroup task = (SceneObjectGroup)m_scene.Entities[obj]; 563 SceneObjectGroup task = (SceneObjectGroup) m_scene.Entities[obj];
436 564
437 565
438 LLUUID taskOwner = null; 566 LLUUID taskOwner = null;
@@ -447,7 +575,6 @@ namespace OpenSim.Region.Environment
447 // Locked 575 // Locked
448 if ((task.RootPart.OwnerMask & PERM_LOCKED) == 0) 576 if ((task.RootPart.OwnerMask & PERM_LOCKED) == 0)
449 permission = false; 577 permission = false;
450
451 } 578 }
452 else 579 else
453 { 580 {
@@ -464,7 +591,7 @@ namespace OpenSim.Region.Environment
464 } 591 }
465 592
466 593
467 SceneObjectGroup group = (SceneObjectGroup)m_scene.Entities[obj]; 594 SceneObjectGroup group = (SceneObjectGroup) m_scene.Entities[obj];
468 595
469 LLUUID objectOwner = group.OwnerID; 596 LLUUID objectOwner = group.OwnerID;
470 locked = ((group.RootPart.OwnerMask & PERM_LOCKED) == 0); 597 locked = ((group.RootPart.OwnerMask & PERM_LOCKED) == 0);
@@ -502,7 +629,7 @@ namespace OpenSim.Region.Environment
502 return false; 629 return false;
503 } 630 }
504 631
505 SceneObjectGroup task = (SceneObjectGroup)m_scene.Entities[obj]; 632 SceneObjectGroup task = (SceneObjectGroup) m_scene.Entities[obj];
506 LLUUID taskOwner = null; 633 LLUUID taskOwner = null;
507 // Added this because at this point in time it wouldn't be wise for 634 // Added this because at this point in time it wouldn't be wise for
508 // the administrator object permissions to take effect. 635 // the administrator object permissions to take effect.
@@ -558,137 +685,5 @@ namespace OpenSim.Region.Environment
558 } 685 }
559 686
560 #endregion 687 #endregion
561
562 public virtual bool CanEditScript(LLUUID user, LLUUID script)
563 {
564 return IsAdministrator(user);
565 }
566
567 public virtual bool CanRunScript(LLUUID user, LLUUID script)
568 {
569 return IsAdministrator(user);
570 }
571
572 public virtual bool CanRunConsoleCommand(LLUUID user)
573 {
574 return IsAdministrator(user);
575 }
576
577 public virtual bool CanTerraform(LLUUID user, LLVector3 position)
578 {
579 bool permission = false;
580
581 // Estate override
582 if (GenericEstatePermission(user))
583 permission = true;
584
585 float X = position.X;
586 float Y = position.Y;
587
588 if (X > 255)
589 X = 255;
590 if (Y > 255)
591 Y = 255;
592 if (X < 0)
593 X = 0;
594 if (Y < 0)
595 Y = 0;
596
597 // Land owner can terraform too
598 ILandObject parcel = m_scene.LandChannel.getLandObject(X, Y);
599 if (parcel != null && GenericParcelPermission(user, parcel))
600 permission = true;
601
602 if (!permission)
603 SendPermissionError(user, "Not authorized to terraform at this location.");
604
605 return permission;
606 }
607
608 #region Estate Permissions
609
610 public virtual bool GenericEstatePermission(LLUUID user)
611 {
612 // Default: deny
613 bool permission = false;
614
615 // Estate admins should be able to use estate tools
616 if (IsEstateManager(user))
617 permission = true;
618
619 // Administrators always have permission
620 if (IsAdministrator(user))
621 permission = true;
622
623 return permission;
624 }
625
626 public virtual bool CanEditEstateTerrain(LLUUID user)
627 {
628 return GenericEstatePermission(user);
629 }
630
631 public virtual bool CanRestartSim(LLUUID user)
632 {
633 // Since this is potentially going on a grid...
634
635 return GenericEstatePermission(user);
636 //return m_scene.RegionInfo.MasterAvatarAssignedUUID == user;
637 }
638
639 #endregion
640
641 #region Parcel Permissions
642
643 protected virtual bool GenericParcelPermission(LLUUID user, ILandObject parcel)
644 {
645 bool permission = false;
646
647 if (parcel.landData.ownerID == user)
648 {
649 permission = true;
650 }
651
652 if (parcel.landData.isGroupOwned)
653 {
654 // TODO: Need to do some extra checks here. Requires group code.
655 }
656
657 if (IsEstateManager(user))
658 {
659 permission = true;
660 }
661
662 if (IsAdministrator(user))
663 {
664 permission = true;
665 }
666
667 return permission;
668 }
669
670 protected virtual bool GenericParcelPermission(LLUUID user, LLVector3 pos)
671 {
672 ILandObject parcel = m_scene.LandChannel.getLandObject(pos.X, pos.Y);
673 if (parcel == null) return false;
674 return GenericParcelPermission(user, parcel);
675 }
676
677 public virtual bool CanEditParcel(LLUUID user, ILandObject parcel)
678 {
679 return GenericParcelPermission(user, parcel);
680 }
681
682 public virtual bool CanSellParcel(LLUUID user, ILandObject parcel)
683 {
684 return GenericParcelPermission(user, parcel);
685 }
686
687 public virtual bool CanAbandonParcel(LLUUID user, ILandObject parcel)
688 {
689 return GenericParcelPermission(user, parcel);
690 }
691
692 #endregion
693 } 688 }
694} 689} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Scenes/AvatarAnimations.cs b/OpenSim/Region/Environment/Scenes/AvatarAnimations.cs
index fe9c8e7..2fc2a10 100644
--- a/OpenSim/Region/Environment/Scenes/AvatarAnimations.cs
+++ b/OpenSim/Region/Environment/Scenes/AvatarAnimations.cs
@@ -46,8 +46,8 @@ namespace OpenSim.Region.Environment.Scenes
46 { 46 {
47 if (nod.Attributes["name"] != null) 47 if (nod.Attributes["name"] != null)
48 { 48 {
49 string name = (string)nod.Attributes["name"].Value; 49 string name = nod.Attributes["name"].Value;
50 LLUUID id = (LLUUID)nod.InnerText; 50 LLUUID id = (LLUUID) nod.InnerText;
51 51
52 AnimsLLUUID.Add(name, id); 52 AnimsLLUUID.Add(name, id);
53 AnimsNames.Add(id, name); 53 AnimsNames.Add(id, name);
@@ -56,4 +56,4 @@ namespace OpenSim.Region.Environment.Scenes
56 } 56 }
57 } 57 }
58 } 58 }
59} 59} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Scenes/AvatarAppearance.cs b/OpenSim/Region/Environment/Scenes/AvatarAppearance.cs
index 8f29507..860399c 100644
--- a/OpenSim/Region/Environment/Scenes/AvatarAppearance.cs
+++ b/OpenSim/Region/Environment/Scenes/AvatarAppearance.cs
@@ -37,14 +37,54 @@ namespace OpenSim.Region.Environment.Scenes
37 [Serializable] 37 [Serializable]
38 public class AvatarAppearance : ISerializable 38 public class AvatarAppearance : ISerializable
39 { 39 {
40 protected float m_avatarHeight;
40 protected LLUUID m_scenePresenceID; 41 protected LLUUID m_scenePresenceID;
42 protected LLObject.TextureEntry m_textureEntry;
43 protected byte[] m_visualParams;
44 protected AvatarWearable[] m_wearables;
45
46 protected int m_wearablesSerial = 1;
47
48 public AvatarAppearance()
49 {
50 }
51
52 public AvatarAppearance(LLUUID avatarID, AvatarWearable[] wearables, byte[] visualParams)
53 {
54 m_scenePresenceID = avatarID;
55 m_wearablesSerial = 1;
56 m_wearables = wearables;
57 m_visualParams = visualParams;
58 m_textureEntry = GetDefaultTextureEntry();
59 }
60
61 protected AvatarAppearance(SerializationInfo info, StreamingContext context)
62 {
63 //System.Console.WriteLine("AvatarAppearance Deserialize BGN");
64
65 if (info == null)
66 {
67 throw new ArgumentNullException("info");
68 }
69
70 m_scenePresenceID = new LLUUID((Guid) info.GetValue("m_scenePresenceID", typeof (Guid)));
71 m_wearablesSerial = (int) info.GetValue("m_wearablesSerial", typeof (int));
72 m_visualParams = (byte[]) info.GetValue("m_visualParams", typeof (byte[]));
73 m_wearables = (AvatarWearable[]) info.GetValue("m_wearables", typeof (AvatarWearable[]));
74
75 byte[] m_textureEntry_work = (byte[]) info.GetValue("m_textureEntry", typeof (byte[]));
76 m_textureEntry = new LLObject.TextureEntry(m_textureEntry_work, 0, m_textureEntry_work.Length);
77
78 m_avatarHeight = (float) info.GetValue("m_avatarHeight", typeof (float));
79
80 //System.Console.WriteLine("AvatarAppearance Deserialize END");
81 }
41 82
42 public LLUUID ScenePresenceID 83 public LLUUID ScenePresenceID
43 { 84 {
44 get { return m_scenePresenceID; } 85 get { return m_scenePresenceID; }
45 set { m_scenePresenceID = value; } 86 set { m_scenePresenceID = value; }
46 } 87 }
47 protected int m_wearablesSerial = 1;
48 88
49 public int WearablesSerial 89 public int WearablesSerial
50 { 90 {
@@ -52,51 +92,52 @@ namespace OpenSim.Region.Environment.Scenes
52 set { m_wearablesSerial = value; } 92 set { m_wearablesSerial = value; }
53 } 93 }
54 94
55 protected byte[] m_visualParams;
56
57 public byte[] VisualParams 95 public byte[] VisualParams
58 { 96 {
59 get { return m_visualParams; } 97 get { return m_visualParams; }
60 set { m_visualParams = value; } 98 set { m_visualParams = value; }
61 } 99 }
62 100
63 protected AvatarWearable[] m_wearables;
64
65 public AvatarWearable[] Wearables 101 public AvatarWearable[] Wearables
66 { 102 {
67 get { return m_wearables; } 103 get { return m_wearables; }
68 set { m_wearables = value; } 104 set { m_wearables = value; }
69 } 105 }
70 106
71 protected LLObject.TextureEntry m_textureEntry;
72
73 public LLObject.TextureEntry TextureEntry 107 public LLObject.TextureEntry TextureEntry
74 { 108 {
75 get { return m_textureEntry; } 109 get { return m_textureEntry; }
76 set { m_textureEntry = value; } 110 set { m_textureEntry = value; }
77 } 111 }
78 112
79 protected float m_avatarHeight = 0;
80
81 public float AvatarHeight 113 public float AvatarHeight
82 { 114 {
83 get { return m_avatarHeight; } 115 get { return m_avatarHeight; }
84 set { m_avatarHeight = value; } 116 set { m_avatarHeight = value; }
85 } 117 }
86 118
87 public AvatarAppearance() 119 #region ISerializable Members
88 {
89 }
90 120
91 public AvatarAppearance(LLUUID avatarID, AvatarWearable[] wearables, byte[] visualParams) 121 [SecurityPermission(SecurityAction.LinkDemand,
122 Flags = SecurityPermissionFlag.SerializationFormatter)]
123 public virtual void GetObjectData(
124 SerializationInfo info, StreamingContext context)
92 { 125 {
93 m_scenePresenceID = avatarID; 126 if (info == null)
94 m_wearablesSerial = 1; 127 {
95 m_wearables = wearables; 128 throw new ArgumentNullException("info");
96 m_visualParams = visualParams; 129 }
97 m_textureEntry = GetDefaultTextureEntry(); 130
131 info.AddValue("m_scenePresenceID", m_scenePresenceID.UUID);
132 info.AddValue("m_wearablesSerial", m_wearablesSerial);
133 info.AddValue("m_visualParams", m_visualParams);
134 info.AddValue("m_wearables", m_wearables);
135 info.AddValue("m_textureEntry", m_textureEntry.ToBytes());
136 info.AddValue("m_avatarHeight", m_avatarHeight);
98 } 137 }
99 138
139 #endregion
140
100 /// <summary> 141 /// <summary>
101 /// 142 ///
102 /// </summary> 143 /// </summary>
@@ -115,8 +156,8 @@ namespace OpenSim.Region.Environment.Scenes
115 // Teravus : Nifty AV Height Getting Maaaaagical formula. Oh how we love turning 0-255 into meters. 156 // Teravus : Nifty AV Height Getting Maaaaagical formula. Oh how we love turning 0-255 into meters.
116 // (float)m_visualParams[25] = Height 157 // (float)m_visualParams[25] = Height
117 // (float)m_visualParams[125] = LegLength 158 // (float)m_visualParams[125] = LegLength
118 m_avatarHeight = (1.50856f + (((float) m_visualParams[25]/255.0f)*(2.525506f - 1.50856f))) 159 m_avatarHeight = (1.50856f + ((m_visualParams[25] / 255.0f) * (2.525506f - 1.50856f)))
119 + (((float) m_visualParams[125]/255.0f)/1.5f); 160 + ((m_visualParams[125] / 255.0f) / 1.5f);
120 } 161 }
121 162
122 /// <summary> 163 /// <summary>
@@ -152,45 +193,5 @@ namespace OpenSim.Region.Environment.Scenes
152 textu.CreateFace(6).TextureID = new LLUUID("00000000-0000-1111-9999-000000000011"); 193 textu.CreateFace(6).TextureID = new LLUUID("00000000-0000-1111-9999-000000000011");
153 return textu; 194 return textu;
154 } 195 }
155
156 protected AvatarAppearance(SerializationInfo info, StreamingContext context)
157 {
158 //System.Console.WriteLine("AvatarAppearance Deserialize BGN");
159
160 if (info == null)
161 {
162 throw new ArgumentNullException("info");
163 }
164
165 m_scenePresenceID = new LLUUID((Guid)info.GetValue("m_scenePresenceID", typeof(Guid)));
166 m_wearablesSerial = (int)info.GetValue("m_wearablesSerial", typeof(int));
167 m_visualParams = (byte[])info.GetValue("m_visualParams", typeof(byte[]));
168 m_wearables = (AvatarWearable[])info.GetValue("m_wearables", typeof(AvatarWearable[]));
169
170 byte[] m_textureEntry_work = (byte[])info.GetValue("m_textureEntry", typeof(byte[]));
171 m_textureEntry = new LLObject.TextureEntry(m_textureEntry_work, 0, m_textureEntry_work.Length);
172
173 m_avatarHeight = (float)info.GetValue("m_avatarHeight", typeof(float));
174
175 //System.Console.WriteLine("AvatarAppearance Deserialize END");
176 }
177
178 [SecurityPermission(SecurityAction.LinkDemand,
179 Flags = SecurityPermissionFlag.SerializationFormatter)]
180 public virtual void GetObjectData(
181 SerializationInfo info, StreamingContext context)
182 {
183 if (info == null)
184 {
185 throw new ArgumentNullException("info");
186 }
187
188 info.AddValue("m_scenePresenceID", m_scenePresenceID.UUID);
189 info.AddValue("m_wearablesSerial", m_wearablesSerial);
190 info.AddValue("m_visualParams", m_visualParams);
191 info.AddValue("m_wearables", m_wearables);
192 info.AddValue("m_textureEntry", m_textureEntry.ToBytes());
193 info.AddValue("m_avatarHeight", m_avatarHeight);
194 }
195 } 196 }
196} 197} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Scenes/EntityBase.cs b/OpenSim/Region/Environment/Scenes/EntityBase.cs
index 11bafb7..7e43718 100644
--- a/OpenSim/Region/Environment/Scenes/EntityBase.cs
+++ b/OpenSim/Region/Environment/Scenes/EntityBase.cs
@@ -36,23 +36,83 @@ namespace OpenSim.Region.Environment.Scenes
36 [Serializable] 36 [Serializable]
37 public abstract class EntityBase : ISerializable 37 public abstract class EntityBase : ISerializable
38 { 38 {
39 protected uint m_localId;
40 protected string m_name;
41 protected LLVector3 m_pos;
42 protected Quaternion m_rotation = new Quaternion(0, 0, 1, 0);
43 protected LLVector3 m_rotationalvelocity;
39 protected Scene m_scene; 44 protected Scene m_scene;
40 45
46 protected LLUUID m_uuid;
47 protected LLVector3 m_velocity;
48
49 /// <summary>
50 /// Creates a new Entity (should not occur on it's own)
51 /// </summary>
52 public EntityBase()
53 {
54 m_uuid = LLUUID.Zero;
55
56 m_pos = new LLVector3();
57 m_velocity = new LLVector3();
58 Rotation = new Quaternion();
59 m_name = "(basic entity)";
60 m_rotationalvelocity = new LLVector3(0, 0, 0);
61 }
62
63 protected EntityBase(SerializationInfo info, StreamingContext context)
64 {
65 //System.Console.WriteLine("EntityBase Deserialize BGN");
66
67 if (info == null)
68 {
69 throw new ArgumentNullException("info");
70 }
71
72 m_uuid = new LLUUID((Guid) info.GetValue("m_uuid", typeof (Guid)));
73 m_name = (string) info.GetValue("m_name", typeof (string));
74
75 m_pos
76 = new LLVector3(
77 (float) info.GetValue("m_pos.X", typeof (float)),
78 (float) info.GetValue("m_pos.Y", typeof (float)),
79 (float) info.GetValue("m_pos.Z", typeof (float)));
80
81 m_velocity
82 = new LLVector3(
83 (float) info.GetValue("m_velocity.X", typeof (float)),
84 (float) info.GetValue("m_velocity.Y", typeof (float)),
85 (float) info.GetValue("m_velocity.Z", typeof (float)));
86
87 m_rotationalvelocity
88 = new LLVector3(
89 (float) info.GetValue("m_rotationalvelocity.X", typeof (float)),
90 (float) info.GetValue("m_rotationalvelocity.Y", typeof (float)),
91 (float) info.GetValue("m_rotationalvelocity.Z", typeof (float)));
92
93 m_rotation
94 = new Quaternion(
95 (float) info.GetValue("m_rotation.w", typeof (float)),
96 (float) info.GetValue("m_rotation.x", typeof (float)),
97 (float) info.GetValue("m_rotation.y", typeof (float)),
98 (float) info.GetValue("m_rotation.z", typeof (float)));
99
100 m_localId = (uint) info.GetValue("m_localId", typeof (uint));
101
102 //System.Console.WriteLine("EntityBase Deserialize END");
103 }
104
41 public Scene Scene 105 public Scene Scene
42 { 106 {
43 get { return m_scene; } 107 get { return m_scene; }
44 } 108 }
45 109
46 protected LLUUID m_uuid;
47
48 public virtual LLUUID UUID 110 public virtual LLUUID UUID
49 { 111 {
50 get { return m_uuid; } 112 get { return m_uuid; }
51 set { m_uuid = value; } 113 set { m_uuid = value; }
52 } 114 }
53 115
54 protected string m_name;
55
56 /// <summary> 116 /// <summary>
57 /// 117 ///
58 /// </summary> 118 /// </summary>
@@ -62,8 +122,6 @@ namespace OpenSim.Region.Environment.Scenes
62 set { m_name = value; } 122 set { m_name = value; }
63 } 123 }
64 124
65 protected LLVector3 m_pos;
66
67 /// <summary> 125 /// <summary>
68 /// 126 ///
69 /// </summary> 127 /// </summary>
@@ -73,9 +131,6 @@ namespace OpenSim.Region.Environment.Scenes
73 set { m_pos = value; } 131 set { m_pos = value; }
74 } 132 }
75 133
76 protected LLVector3 m_velocity;
77 protected LLVector3 m_rotationalvelocity;
78
79 /// <summary> 134 /// <summary>
80 /// 135 ///
81 /// </summary> 136 /// </summary>
@@ -85,104 +140,24 @@ namespace OpenSim.Region.Environment.Scenes
85 set { m_velocity = value; } 140 set { m_velocity = value; }
86 } 141 }
87 142
88 protected Quaternion m_rotation = new Quaternion(0, 0, 1, 0);
89
90 public virtual Quaternion Rotation 143 public virtual Quaternion Rotation
91 { 144 {
92 get { return m_rotation; } 145 get { return m_rotation; }
93 set { m_rotation = value; } 146 set { m_rotation = value; }
94 } 147 }
95 148
96 protected uint m_localId;
97
98 public virtual uint LocalId 149 public virtual uint LocalId
99 { 150 {
100 get { return m_localId; } 151 get { return m_localId; }
101 set { m_localId = value; } 152 set { m_localId = value; }
102 } 153 }
103 154
104 /// <summary> 155 #region ISerializable Members
105 /// Creates a new Entity (should not occur on it's own)
106 /// </summary>
107 public EntityBase()
108 {
109 m_uuid = LLUUID.Zero;
110
111 m_pos = new LLVector3();
112 m_velocity = new LLVector3();
113 Rotation = new Quaternion();
114 m_name = "(basic entity)";
115 m_rotationalvelocity = new LLVector3(0, 0, 0);
116 }
117
118 /// <summary>
119 ///
120 /// </summary>
121 public abstract void UpdateMovement();
122
123 /// <summary>
124 /// Performs any updates that need to be done at each frame.
125 /// </summary>
126 public abstract void Update();
127
128 /// <summary>
129 /// Copies the entity
130 /// </summary>
131 /// <returns></returns>
132 public virtual EntityBase Copy()
133 {
134 return (EntityBase) MemberwiseClone();
135 }
136
137
138 public abstract void SetText(string text, Vector3 color, double alpha);
139
140 protected EntityBase(SerializationInfo info, StreamingContext context)
141 {
142 //System.Console.WriteLine("EntityBase Deserialize BGN");
143
144 if (info == null)
145 {
146 throw new ArgumentNullException("info");
147 }
148
149 m_uuid = new LLUUID((Guid)info.GetValue("m_uuid", typeof(Guid)));
150 m_name = (string)info.GetValue("m_name", typeof(string));
151
152 m_pos
153 = new LLVector3(
154 (float)info.GetValue("m_pos.X", typeof(float)),
155 (float)info.GetValue("m_pos.Y", typeof(float)),
156 (float)info.GetValue("m_pos.Z", typeof(float)));
157
158 m_velocity
159 = new LLVector3(
160 (float)info.GetValue("m_velocity.X", typeof(float)),
161 (float)info.GetValue("m_velocity.Y", typeof(float)),
162 (float)info.GetValue("m_velocity.Z", typeof(float)));
163
164 m_rotationalvelocity
165 = new LLVector3(
166 (float)info.GetValue("m_rotationalvelocity.X", typeof(float)),
167 (float)info.GetValue("m_rotationalvelocity.Y", typeof(float)),
168 (float)info.GetValue("m_rotationalvelocity.Z", typeof(float)));
169
170 m_rotation
171 = new Quaternion(
172 (float)info.GetValue("m_rotation.w", typeof(float)),
173 (float)info.GetValue("m_rotation.x", typeof(float)),
174 (float)info.GetValue("m_rotation.y", typeof(float)),
175 (float)info.GetValue("m_rotation.z", typeof(float)));
176
177 m_localId = (uint)info.GetValue("m_localId", typeof(uint));
178
179 //System.Console.WriteLine("EntityBase Deserialize END");
180 }
181 156
182 [SecurityPermission(SecurityAction.LinkDemand, 157 [SecurityPermission(SecurityAction.LinkDemand,
183 Flags = SecurityPermissionFlag.SerializationFormatter)] 158 Flags = SecurityPermissionFlag.SerializationFormatter)]
184 public virtual void GetObjectData( 159 public virtual void GetObjectData(
185 SerializationInfo info, StreamingContext context) 160 SerializationInfo info, StreamingContext context)
186 { 161 {
187 if (info == null) 162 if (info == null)
188 { 163 {
@@ -215,18 +190,42 @@ namespace OpenSim.Region.Environment.Scenes
215 190
216 info.AddValue("m_localId", m_localId); 191 info.AddValue("m_localId", m_localId);
217 } 192 }
193
194 #endregion
195
196 /// <summary>
197 ///
198 /// </summary>
199 public abstract void UpdateMovement();
200
201 /// <summary>
202 /// Performs any updates that need to be done at each frame.
203 /// </summary>
204 public abstract void Update();
205
206 /// <summary>
207 /// Copies the entity
208 /// </summary>
209 /// <returns></returns>
210 public virtual EntityBase Copy()
211 {
212 return (EntityBase) MemberwiseClone();
213 }
214
215
216 public abstract void SetText(string text, Vector3 color, double alpha);
218 } 217 }
219 218
220 //Nested Classes 219 //Nested Classes
221 public class EntityIntersection 220 public class EntityIntersection
222 { 221 {
223 public Vector3 ipoint = new Vector3(0, 0, 0);
224 public Vector3 normal = new Vector3(0, 0, 0);
225 public Vector3 AAfaceNormal = new Vector3(0, 0, 0); 222 public Vector3 AAfaceNormal = new Vector3(0, 0, 0);
223 public float distance;
226 public int face = -1; 224 public int face = -1;
227 public bool HitTF = false; 225 public bool HitTF;
226 public Vector3 ipoint = new Vector3(0, 0, 0);
227 public Vector3 normal = new Vector3(0, 0, 0);
228 public SceneObjectPart obj; 228 public SceneObjectPart obj;
229 public float distance = 0;
230 229
231 public EntityIntersection() 230 public EntityIntersection()
232 { 231 {
@@ -239,4 +238,4 @@ namespace OpenSim.Region.Environment.Scenes
239 HitTF = _HitTF; 238 HitTF = _HitTF;
240 } 239 }
241 } 240 }
242} 241} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Scenes/IScenePresenceBody.cs b/OpenSim/Region/Environment/Scenes/IScenePresenceBody.cs
index 3a20190..508eb67 100644
--- a/OpenSim/Region/Environment/Scenes/IScenePresenceBody.cs
+++ b/OpenSim/Region/Environment/Scenes/IScenePresenceBody.cs
@@ -34,4 +34,4 @@ namespace OpenSim.Region.Environment.Scenes
34 { 34 {
35 void processMovement(IClientAPI remoteClient, uint flags, LLQuaternion bodyRotation); 35 void processMovement(IClientAPI remoteClient, uint flags, LLQuaternion bodyRotation);
36 } 36 }
37} 37} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Scenes/InnerScene.cs b/OpenSim/Region/Environment/Scenes/InnerScene.cs
index da286ad..3889741 100644
--- a/OpenSim/Region/Environment/Scenes/InnerScene.cs
+++ b/OpenSim/Region/Environment/Scenes/InnerScene.cs
@@ -46,36 +46,33 @@ namespace OpenSim.Region.Environment.Scenes
46 46
47 #region Events 47 #region Events
48 48
49 private PhysicsCrash handlerPhysicsCrash;
49 public event PhysicsCrash UnRecoverableError; 50 public event PhysicsCrash UnRecoverableError;
50 private PhysicsCrash handlerPhysicsCrash = null;
51 51
52 #endregion 52 #endregion
53 53
54 #region Fields 54 #region Fields
55 55
56 public Dictionary<LLUUID, ScenePresence> ScenePresences;
57 // SceneObjects is not currently populated or used. 56 // SceneObjects is not currently populated or used.
58 //public Dictionary<LLUUID, SceneObjectGroup> SceneObjects; 57 //public Dictionary<LLUUID, SceneObjectGroup> SceneObjects;
58 public PhysicsScene _PhyScene;
59 public Dictionary<LLUUID, EntityBase> Entities; 59 public Dictionary<LLUUID, EntityBase> Entities;
60 public Dictionary<LLUUID, ScenePresence> RestorePresences; 60 protected int m_activeScripts;
61 61 protected int m_numChildAgents;
62 public BasicQuadTreeNode QuadTree; 62 protected int m_numPrim;
63 63 protected int m_numRootAgents;
64 protected RegionInfo m_regInfo;
65 protected Scene m_parentScene; 64 protected Scene m_parentScene;
66 protected PermissionManager PermissionsMngr; 65 protected int m_physicalPrim;
67 protected List<EntityBase> m_updateList = new List<EntityBase>(); 66 protected RegionInfo m_regInfo;
68 protected int m_numRootAgents = 0;
69 protected int m_numPrim = 0;
70 protected int m_numChildAgents = 0;
71 protected int m_physicalPrim = 0;
72 67
73 protected int m_activeScripts = 0; 68 protected int m_scriptLPS;
74 protected int m_scriptLPS = 0;
75 69
76 internal object m_syncRoot = new object(); 70 internal object m_syncRoot = new object();
77 71 protected List<EntityBase> m_updateList = new List<EntityBase>();
78 public PhysicsScene _PhyScene; 72 protected PermissionManager PermissionsMngr;
73 public BasicQuadTreeNode QuadTree;
74 public Dictionary<LLUUID, ScenePresence> RestorePresences;
75 public Dictionary<LLUUID, ScenePresence> ScenePresences;
79 76
80 #endregion 77 #endregion
81 78
@@ -84,7 +81,7 @@ namespace OpenSim.Region.Environment.Scenes
84 m_parentScene = parent; 81 m_parentScene = parent;
85 m_regInfo = regInfo; 82 m_regInfo = regInfo;
86 PermissionsMngr = permissionsMngr; 83 PermissionsMngr = permissionsMngr;
87 QuadTree = new BasicQuadTreeNode(null, "/0/", 0, 0, (short)Constants.RegionSize, (short)Constants.RegionSize); 84 QuadTree = new BasicQuadTreeNode(null, "/0/", 0, 0, (short) Constants.RegionSize, (short) Constants.RegionSize);
88 QuadTree.Subdivide(); 85 QuadTree.Subdivide();
89 QuadTree.Subdivide(); 86 QuadTree.Subdivide();
90 } 87 }
@@ -162,7 +159,7 @@ namespace OpenSim.Region.Environment.Scenes
162 { 159 {
163 lock (m_syncRoot) 160 lock (m_syncRoot)
164 { 161 {
165 return _PhyScene.Simulate((float)elapsed); 162 return _PhyScene.Simulate((float) elapsed);
166 } 163 }
167 } 164 }
168 165
@@ -187,7 +184,6 @@ namespace OpenSim.Region.Environment.Scenes
187 foreach (SceneObjectPart part in sceneObject.Children.Values) 184 foreach (SceneObjectPart part in sceneObject.Children.Values)
188 { 185 {
189 part.LocalId = m_parentScene.PrimIDAllocate(); 186 part.LocalId = m_parentScene.PrimIDAllocate();
190
191 } 187 }
192 sceneObject.UpdateParentIDs(); 188 sceneObject.UpdateParentIDs();
193 AddEntity(sceneObject); 189 AddEntity(sceneObject);
@@ -233,7 +229,7 @@ namespace OpenSim.Region.Environment.Scenes
233 for (int i = 0; i < m_updateList.Count; i++) 229 for (int i = 0; i < m_updateList.Count; i++)
234 { 230 {
235 EntityBase entity = m_updateList[i]; 231 EntityBase entity = m_updateList[i];
236 232
237 // Don't abort the whole update if one entity happens to give us an exception. 233 // Don't abort the whole update if one entity happens to give us an exception.
238 try 234 try
239 { 235 {
@@ -249,7 +245,7 @@ namespace OpenSim.Region.Environment.Scenes
249 } 245 }
250 catch (Exception e) 246 catch (Exception e)
251 { 247 {
252 m_log.ErrorFormat("[INNER SCENE]: Failed to update {0}, - {1}", entity.Name, e);//entity.m_uuid 248 m_log.ErrorFormat("[INNER SCENE]: Failed to update {0}, - {1}", entity.Name, e); //entity.m_uuid
253 } 249 }
254 } 250 }
255 m_updateList.Clear(); 251 m_updateList.Clear();
@@ -284,15 +280,16 @@ namespace OpenSim.Region.Environment.Scenes
284 { 280 {
285 if (obj is SceneObjectGroup) 281 if (obj is SceneObjectGroup)
286 { 282 {
287 if (((SceneObjectGroup)obj).LocalId == localID) 283 if ((obj).LocalId == localID)
288 { 284 {
289 m_parentScene.RemoveEntity((SceneObjectGroup)obj); 285 m_parentScene.RemoveEntity((SceneObjectGroup) obj);
290 m_numPrim--; 286 m_numPrim--;
291 return; 287 return;
292 } 288 }
293 } 289 }
294 } 290 }
295 } 291 }
292
296 public void DetachObject(uint objectLocalID, IClientAPI remoteClient) 293 public void DetachObject(uint objectLocalID, IClientAPI remoteClient)
297 { 294 {
298 List<EntityBase> EntityList = GetEntities(); 295 List<EntityBase> EntityList = GetEntities();
@@ -301,29 +298,25 @@ namespace OpenSim.Region.Environment.Scenes
301 { 298 {
302 if (obj is SceneObjectGroup) 299 if (obj is SceneObjectGroup)
303 { 300 {
304 if (((SceneObjectGroup)obj).LocalId == objectLocalID) 301 if ((obj).LocalId == objectLocalID)
305 { 302 {
306 SceneObjectGroup group = (SceneObjectGroup)obj; 303 SceneObjectGroup group = (SceneObjectGroup) obj;
307 304
308 //group.DetachToGround(); 305 //group.DetachToGround();
309 DetachSingleAttachmentToInv(group.GetFromAssetID(),remoteClient); 306 DetachSingleAttachmentToInv(group.GetFromAssetID(), remoteClient);
310 } 307 }
311 } 308 }
312 } 309 }
313
314 } 310 }
315 311
316 public void HandleUndo(IClientAPI remoteClient, LLUUID primId) 312 public void HandleUndo(IClientAPI remoteClient, LLUUID primId)
317 { 313 {
318 if (primId != LLUUID.Zero) 314 if (primId != LLUUID.Zero)
319 { 315 {
320 SceneObjectPart part = m_parentScene.GetSceneObjectPart(primId); 316 SceneObjectPart part = m_parentScene.GetSceneObjectPart(primId);
321 if (part != null) 317 if (part != null)
322 part.Undo(); 318 part.Undo();
323
324 } 319 }
325
326
327 } 320 }
328 321
329 /// <summary> 322 /// <summary>
@@ -338,27 +331,29 @@ namespace OpenSim.Region.Environment.Scenes
338 // Calls attach with a Zero position 331 // Calls attach with a Zero position
339 AttachObject(remoteClient, objectLocalID, AttachmentPt, rot, LLVector3.Zero); 332 AttachObject(remoteClient, objectLocalID, AttachmentPt, rot, LLVector3.Zero);
340 } 333 }
341 public void RezSingleAttachment(IClientAPI remoteClient, LLUUID itemID, uint AttachmentPt,uint ItemFlags, uint NextOwnerMask) 334
335 public void RezSingleAttachment(IClientAPI remoteClient, LLUUID itemID, uint AttachmentPt, uint ItemFlags, uint NextOwnerMask)
342 { 336 {
343 SceneObjectGroup objatt = m_parentScene.RezObject(remoteClient, itemID, LLVector3.Zero, LLVector3.Zero, LLUUID.Zero, (byte)1, true, 337 SceneObjectGroup objatt = m_parentScene.RezObject(remoteClient, itemID, LLVector3.Zero, LLVector3.Zero, LLUUID.Zero, 1, true,
344 (uint)(PermissionMask.Copy | PermissionMask.Move | PermissionMask.Modify | PermissionMask.Transfer), 338 (uint)
345 (uint)(PermissionMask.Copy | PermissionMask.Move | PermissionMask.Modify | PermissionMask.Transfer), 339 (PermissionMask.Copy | PermissionMask.Move | PermissionMask.Modify | PermissionMask.Transfer),
346 (uint)(PermissionMask.Copy | PermissionMask.Move | PermissionMask.Modify | PermissionMask.Transfer), 340 (uint)
347 ItemFlags, false, false, remoteClient.AgentId, true); 341 (PermissionMask.Copy | PermissionMask.Move | PermissionMask.Modify | PermissionMask.Transfer),
342 (uint)
343 (PermissionMask.Copy | PermissionMask.Move | PermissionMask.Modify | PermissionMask.Transfer),
344 ItemFlags, false, false, remoteClient.AgentId, true);
348 345
349 if (objatt != null) 346 if (objatt != null)
350 { 347 {
351 AttachObject(remoteClient,objatt.LocalId,AttachmentPt,new LLQuaternion(0,0,0,1),objatt.AbsolutePosition); 348 AttachObject(remoteClient, objatt.LocalId, AttachmentPt, new LLQuaternion(0, 0, 0, 1), objatt.AbsolutePosition);
352 objatt.ScheduleGroupForFullUpdate(); 349 objatt.ScheduleGroupForFullUpdate();
353 } 350 }
354
355 } 351 }
356 352
357 // What makes this method odd and unique is it tries to detach using an LLUUID.... Yay for standards. 353 // What makes this method odd and unique is it tries to detach using an LLUUID.... Yay for standards.
358 // To LocalId or LLUUID, *THAT* is the question. How now Brown LLUUID?? 354 // To LocalId or LLUUID, *THAT* is the question. How now Brown LLUUID??
359 public void DetachSingleAttachmentToInv(LLUUID itemID, IClientAPI remoteClient) 355 public void DetachSingleAttachmentToInv(LLUUID itemID, IClientAPI remoteClient)
360 { 356 {
361
362 if (itemID == LLUUID.Zero) // If this happened, someone made a mistake.... 357 if (itemID == LLUUID.Zero) // If this happened, someone made a mistake....
363 return; 358 return;
364 359
@@ -368,17 +363,16 @@ namespace OpenSim.Region.Environment.Scenes
368 { 363 {
369 if (obj is SceneObjectGroup) 364 if (obj is SceneObjectGroup)
370 { 365 {
371 if (((SceneObjectGroup)obj).GetFromAssetID() == itemID) 366 if (((SceneObjectGroup) obj).GetFromAssetID() == itemID)
372 { 367 {
373 SceneObjectGroup group = (SceneObjectGroup)obj; 368 SceneObjectGroup group = (SceneObjectGroup) obj;
374 group.DetachToInventoryPrep(); 369 group.DetachToInventoryPrep();
375 m_log.Debug("[DETACH]: Saving attachpoint: " + ((uint)group.GetAttachmentPoint()).ToString()); 370 m_log.Debug("[DETACH]: Saving attachpoint: " + ((uint) group.GetAttachmentPoint()));
376 m_parentScene.updateKnownAsset(remoteClient, group, group.GetFromAssetID(),group.OwnerID); 371 m_parentScene.updateKnownAsset(remoteClient, group, group.GetFromAssetID(), group.OwnerID);
377 m_parentScene.DeleteSceneObjectGroup(group); 372 m_parentScene.DeleteSceneObjectGroup(group);
378 } 373 }
379 } 374 }
380 } 375 }
381
382 } 376 }
383 377
384 public void AttachObject(IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, LLQuaternion rot, LLVector3 attachPos) 378 public void AttachObject(IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, LLQuaternion rot, LLVector3 attachPos)
@@ -388,39 +382,34 @@ namespace OpenSim.Region.Environment.Scenes
388 { 382 {
389 if (obj is SceneObjectGroup) 383 if (obj is SceneObjectGroup)
390 { 384 {
391 if (((SceneObjectGroup)obj).LocalId == objectLocalID) 385 if ((obj).LocalId == objectLocalID)
392 { 386 {
393 SceneObjectGroup group = (SceneObjectGroup)obj; 387 SceneObjectGroup group = (SceneObjectGroup) obj;
394 388
395 // If the attachment point isn't the same as the one previously used 389 // If the attachment point isn't the same as the one previously used
396 // set it's offset position = 0 so that it appears on the attachment point 390 // set it's offset position = 0 so that it appears on the attachment point
397 // and not in a weird location somewhere unknown. 391 // and not in a weird location somewhere unknown.
398 if (AttachmentPt != 0 && AttachmentPt != (uint)group.GetAttachmentPoint()) 392 if (AttachmentPt != 0 && AttachmentPt != group.GetAttachmentPoint())
399 { 393 {
400
401 attachPos = LLVector3.Zero; 394 attachPos = LLVector3.Zero;
402 } 395 }
403 396
404 // AttachmentPt 0 means the client chose to 'wear' the attachment. 397 // AttachmentPt 0 means the client chose to 'wear' the attachment.
405 if (AttachmentPt == 0) 398 if (AttachmentPt == 0)
406 { 399 {
407
408 // Check object for stored attachment point 400 // Check object for stored attachment point
409 AttachmentPt = (uint)group.GetAttachmentPoint(); 401 AttachmentPt = group.GetAttachmentPoint();
410
411
412 } 402 }
413 403
414 // if we still didn't find a suitable attachment point....... 404 // if we still didn't find a suitable attachment point.......
415 if (AttachmentPt == 0) 405 if (AttachmentPt == 0)
416 { 406 {
417 // Stick it on left hand with Zero Offset from the attachment point. 407 // Stick it on left hand with Zero Offset from the attachment point.
418 AttachmentPt = (uint)AttachmentPoint.LeftHand; 408 AttachmentPt = (uint) AttachmentPoint.LeftHand;
419 attachPos = LLVector3.Zero; 409 attachPos = LLVector3.Zero;
420 } 410 }
421 m_log.Debug("[ATTACH]: Using attachpoint: " + AttachmentPt.ToString()); 411 m_log.Debug("[ATTACH]: Using attachpoint: " + AttachmentPt);
422 412
423
424 413
425 // Saves and gets assetID 414 // Saves and gets assetID
426 if (group.GetFromAssetID() == LLUUID.Zero) 415 if (group.GetFromAssetID() == LLUUID.Zero)
@@ -431,16 +420,14 @@ namespace OpenSim.Region.Environment.Scenes
431 group.SetFromAssetID(newAssetID); 420 group.SetFromAssetID(newAssetID);
432 } 421 }
433 group.AttachToAgent(remoteClient.AgentId, AttachmentPt, attachPos); 422 group.AttachToAgent(remoteClient.AgentId, AttachmentPt, attachPos);
434
435 } 423 }
436
437 } 424 }
438 } 425 }
439
440 } 426 }
427
441 // Use the above method. 428 // Use the above method.
442 public void AttachObject(IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, LLQuaternion rot, 429 public void AttachObject(IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, LLQuaternion rot,
443 bool deadMethod) 430 bool deadMethod)
444 { 431 {
445 Console.WriteLine("Attaching object " + objectLocalID + " to " + AttachmentPt); 432 Console.WriteLine("Attaching object " + objectLocalID + " to " + AttachmentPt);
446 SceneObjectPart p = GetSceneObjectPart(objectLocalID); 433 SceneObjectPart p = GetSceneObjectPart(objectLocalID);
@@ -489,14 +476,14 @@ namespace OpenSim.Region.Environment.Scenes
489 objupdate.ObjectData[0].ParentID = 0; 476 objupdate.ObjectData[0].ParentID = 0;
490 objupdate.ObjectData[0].OwnerID = LLUUID.Zero; 477 objupdate.ObjectData[0].OwnerID = LLUUID.Zero;
491 objupdate.ObjectData[0].Scale = new LLVector3(1, 1, 1); 478 objupdate.ObjectData[0].Scale = new LLVector3(1, 1, 1);
492 objupdate.ObjectData[0].PCode = (byte)PCode.Avatar; 479 objupdate.ObjectData[0].PCode = (byte) PCode.Avatar;
493 objupdate.ObjectData[0].TextureEntry = ScenePresence.DefaultTexture; 480 objupdate.ObjectData[0].TextureEntry = ScenePresence.DefaultTexture;
494 481
495 objupdate.ObjectData[0].ID = av.LocalId; 482 objupdate.ObjectData[0].ID = av.LocalId;
496 objupdate.ObjectData[0].FullID = remoteClient.AgentId; 483 objupdate.ObjectData[0].FullID = remoteClient.AgentId;
497 objupdate.ObjectData[0].ParentID = 0; 484 objupdate.ObjectData[0].ParentID = 0;
498 objupdate.ObjectData[0].NameValue = 485 objupdate.ObjectData[0].NameValue =
499 Helpers.StringToField("FirstName STRING RW SV " + av.Firstname + "\nLastName STRING RW SV " + av.Lastname); 486 Helpers.StringToField("FirstName STRING RW SV " + av.Firstname + "\nLastName STRING RW SV " + av.Lastname);
500 LLVector3 pos2 = av.AbsolutePosition; 487 LLVector3 pos2 = av.AbsolutePosition;
501 // new LLVector3((float) Pos.X, (float) Pos.Y, (float) Pos.Z); 488 // new LLVector3((float) Pos.X, (float) Pos.Y, (float) Pos.Z);
502 byte[] pb = pos2.GetBytes(); 489 byte[] pb = pos2.GetBytes();
@@ -529,7 +516,7 @@ namespace OpenSim.Region.Environment.Scenes
529 516
530 objupdate.ObjectData[1].TextureEntry = primData.TextureEntry; 517 objupdate.ObjectData[1].TextureEntry = primData.TextureEntry;
531 objupdate.ObjectData[1].PCode = primData.PCode; 518 objupdate.ObjectData[1].PCode = primData.PCode;
532 objupdate.ObjectData[1].State = (byte)(((byte)AttachmentPt) << 4); 519 objupdate.ObjectData[1].State = (byte) (((byte) AttachmentPt) << 4);
533 objupdate.ObjectData[1].PathBegin = primData.PathBegin; 520 objupdate.ObjectData[1].PathBegin = primData.PathBegin;
534 objupdate.ObjectData[1].PathEnd = primData.PathEnd; 521 objupdate.ObjectData[1].PathEnd = primData.PathEnd;
535 objupdate.ObjectData[1].PathScaleX = primData.PathScaleX; 522 objupdate.ObjectData[1].PathScaleX = primData.PathScaleX;
@@ -566,8 +553,8 @@ namespace OpenSim.Region.Environment.Scenes
566 //objupdate.ObjectData[1].ClickAction = clickAction; 553 //objupdate.ObjectData[1].ClickAction = clickAction;
567 objupdate.ObjectData[1].Radius = 20; 554 objupdate.ObjectData[1].Radius = 20;
568 objupdate.ObjectData[1].NameValue = 555 objupdate.ObjectData[1].NameValue =
569 Helpers.StringToField("AttachItemID STRING RW SV " + p.UUID); 556 Helpers.StringToField("AttachItemID STRING RW SV " + p.UUID);
570 LLVector3 pos = new LLVector3((float)0.0, (float)0.0, (float)0.0); 557 LLVector3 pos = new LLVector3((float) 0.0, (float) 0.0, (float) 0.0);
571 558
572 pb = pos.GetBytes(); 559 pb = pos.GetBytes();
573 Array.Copy(pb, 0, objupdate.ObjectData[1].ObjectData, 0, pb.Length); 560 Array.Copy(pb, 0, objupdate.ObjectData[1].ObjectData, 0, pb.Length);
@@ -738,6 +725,7 @@ namespace OpenSim.Region.Environment.Scenes
738 m_scriptLPS = 0; 725 m_scriptLPS = 0;
739 return returnval; 726 return returnval;
740 } 727 }
728
741 #endregion 729 #endregion
742 730
743 #region Get Methods 731 #region Get Methods
@@ -765,7 +753,7 @@ namespace OpenSim.Region.Environment.Scenes
765 753
766 return result; 754 return result;
767 } 755 }
768 756
769 /// <summary> 757 /// <summary>
770 /// Get the controlling client for the given avatar, if there is one. 758 /// Get the controlling client for the given avatar, if there is one.
771 /// 759 ///
@@ -779,12 +767,12 @@ namespace OpenSim.Region.Environment.Scenes
779 public IClientAPI GetControllingClient(LLUUID agentId) 767 public IClientAPI GetControllingClient(LLUUID agentId)
780 { 768 {
781 ScenePresence presence = GetScenePresence(agentId); 769 ScenePresence presence = GetScenePresence(agentId);
782 770
783 if (presence != null) 771 if (presence != null)
784 { 772 {
785 return presence.ControllingClient; 773 return presence.ControllingClient;
786 } 774 }
787 775
788 return null; 776 return null;
789 } 777 }
790 778
@@ -819,7 +807,7 @@ namespace OpenSim.Region.Environment.Scenes
819 { 807 {
820 return ScenePresences[agentID]; 808 return ScenePresences[agentID];
821 } 809 }
822 810
823 return null; 811 return null;
824 } 812 }
825 813
@@ -831,8 +819,8 @@ namespace OpenSim.Region.Environment.Scenes
831 { 819 {
832 if (ent is SceneObjectGroup) 820 if (ent is SceneObjectGroup)
833 { 821 {
834 if (((SceneObjectGroup)ent).HasChildPrim(localID)) 822 if (((SceneObjectGroup) ent).HasChildPrim(localID))
835 return (SceneObjectGroup)ent; 823 return (SceneObjectGroup) ent;
836 } 824 }
837 } 825 }
838 return null; 826 return null;
@@ -846,8 +834,8 @@ namespace OpenSim.Region.Environment.Scenes
846 { 834 {
847 if (ent is SceneObjectGroup) 835 if (ent is SceneObjectGroup)
848 { 836 {
849 if (((SceneObjectGroup)ent).HasChildPrim(fullID)) 837 if (((SceneObjectGroup) ent).HasChildPrim(fullID))
850 return (SceneObjectGroup)ent; 838 return (SceneObjectGroup) ent;
851 } 839 }
852 } 840 }
853 return null; 841 return null;
@@ -862,7 +850,7 @@ namespace OpenSim.Region.Environment.Scenes
862 { 850 {
863 if (ent is SceneObjectGroup) 851 if (ent is SceneObjectGroup)
864 { 852 {
865 SceneObjectGroup reportingG = (SceneObjectGroup)ent; 853 SceneObjectGroup reportingG = (SceneObjectGroup) ent;
866 EntityIntersection result = reportingG.TestIntersection(hray, frontFacesOnly, faceCenters); 854 EntityIntersection result = reportingG.TestIntersection(hray, frontFacesOnly, faceCenters);
867 if (result.HitTF) 855 if (result.HitTF)
868 { 856 {
@@ -902,13 +890,13 @@ namespace OpenSim.Region.Environment.Scenes
902 { 890 {
903 if (!presence.IsChildAgent) 891 if (!presence.IsChildAgent)
904 { 892 {
905 avatar = presence; 893 avatar = presence;
906 return true; 894 return true;
907 } 895 }
908 else 896 else
909 { 897 {
910 m_log.WarnFormat( 898 m_log.WarnFormat(
911 "[INNER SCENE]: Requested avatar {0} could not be found in scene {1} since it is only registered as a child agent!", 899 "[INNER SCENE]: Requested avatar {0} could not be found in scene {1} since it is only registered as a child agent!",
912 avatarId, m_parentScene.RegionInfo.RegionName); 900 avatarId, m_parentScene.RegionInfo.RegionName);
913 } 901 }
914 } 902 }
@@ -987,8 +975,8 @@ namespace OpenSim.Region.Environment.Scenes
987 975
988 if (presence.IsChildAgent && m_parentScene.m_seeIntoRegionFromNeighbor) 976 if (presence.IsChildAgent && m_parentScene.m_seeIntoRegionFromNeighbor)
989 { 977 {
990 LLVector3 oLoc = ((SceneObjectGroup)ent).AbsolutePosition; 978 LLVector3 oLoc = (ent).AbsolutePosition;
991 float distResult = (float)Util.GetDistanceTo(presence.AbsolutePosition, oLoc); 979 float distResult = (float) Util.GetDistanceTo(presence.AbsolutePosition, oLoc);
992 980
993 //m_log.Info("[DISTANCE]: " + distResult.ToString()); 981 //m_log.Info("[DISTANCE]: " + distResult.ToString());
994 982
@@ -996,13 +984,13 @@ namespace OpenSim.Region.Environment.Scenes
996 { 984 {
997 // Send Only if we don't already know about it. 985 // Send Only if we don't already know about it.
998 // KnownPrim also makes the prim known when called. 986 // KnownPrim also makes the prim known when called.
999 if (!presence.KnownPrim(((SceneObjectGroup)ent).UUID)) 987 if (!presence.KnownPrim((ent).UUID))
1000 ((SceneObjectGroup)ent).ScheduleFullUpdateToAvatar(presence); 988 ((SceneObjectGroup) ent).ScheduleFullUpdateToAvatar(presence);
1001 } 989 }
1002 } 990 }
1003 else 991 else
1004 { 992 {
1005 ((SceneObjectGroup)ent).ScheduleFullUpdateToAvatar(presence); 993 ((SceneObjectGroup) ent).ScheduleFullUpdateToAvatar(presence);
1006 } 994 }
1007 } 995 }
1008 } 996 }
@@ -1037,6 +1025,7 @@ namespace OpenSim.Region.Environment.Scenes
1037 } 1025 }
1038 } 1026 }
1039 } 1027 }
1028
1040 public void UpdatePrimGroupScale(uint localID, LLVector3 scale, IClientAPI remoteClient) 1029 public void UpdatePrimGroupScale(uint localID, LLVector3 scale, IClientAPI remoteClient)
1041 { 1030 {
1042 SceneObjectGroup group = GetGroupByPrim(localID); 1031 SceneObjectGroup group = GetGroupByPrim(localID);
@@ -1151,13 +1140,12 @@ namespace OpenSim.Region.Environment.Scenes
1151 SceneObjectGroup group = GetGroupByPrim(localID); 1140 SceneObjectGroup group = GetGroupByPrim(localID);
1152 if (group != null) 1141 if (group != null)
1153 { 1142 {
1154
1155 LLVector3 oldPos = group.AbsolutePosition; 1143 LLVector3 oldPos = group.AbsolutePosition;
1156 if (group.RootPart.m_IsAttachment) 1144 if (group.RootPart.m_IsAttachment)
1157 { 1145 {
1158 group.UpdateGroupPosition(pos); 1146 group.UpdateGroupPosition(pos);
1159 } 1147 }
1160 else 1148 else
1161 { 1149 {
1162 if (!PermissionsMngr.CanObjectEntry(remoteClient.AgentId, oldPos, pos) && !group.RootPart.m_IsAttachment) 1150 if (!PermissionsMngr.CanObjectEntry(remoteClient.AgentId, oldPos, pos) && !group.RootPart.m_IsAttachment)
1163 { 1151 {
@@ -1203,7 +1191,7 @@ namespace OpenSim.Region.Environment.Scenes
1203 { 1191 {
1204 if (PermissionsMngr.CanEditObject(remoteClient.AgentId, group.UUID)) 1192 if (PermissionsMngr.CanEditObject(remoteClient.AgentId, group.UUID))
1205 { 1193 {
1206 group.UpdatePrimFlags(localID, (ushort)packet.Type, true, packet.ToBytes()); 1194 group.UpdatePrimFlags(localID, (ushort) packet.Type, true, packet.ToBytes());
1207 } 1195 }
1208 } 1196 }
1209 } 1197 }
@@ -1213,7 +1201,7 @@ namespace OpenSim.Region.Environment.Scenes
1213 SceneObjectGroup group = GetGroupByPrim(objectID); 1201 SceneObjectGroup group = GetGroupByPrim(objectID);
1214 if (group != null) 1202 if (group != null)
1215 { 1203 {
1216 if (PermissionsMngr.CanEditObjectPosition(remoteClient.AgentId, group.UUID))// && PermissionsMngr.) 1204 if (PermissionsMngr.CanEditObjectPosition(remoteClient.AgentId, group.UUID)) // && PermissionsMngr.)
1217 { 1205 {
1218 group.GrabMovement(offset, pos, remoteClient); 1206 group.GrabMovement(offset, pos, remoteClient);
1219 } 1207 }
@@ -1304,9 +1292,9 @@ namespace OpenSim.Region.Environment.Scenes
1304 { 1292 {
1305 if (ent is SceneObjectGroup) 1293 if (ent is SceneObjectGroup)
1306 { 1294 {
1307 if (((SceneObjectGroup)ent).LocalId == parentPrim) 1295 if ((ent).LocalId == parentPrim)
1308 { 1296 {
1309 parenPrim = (SceneObjectGroup)ent; 1297 parenPrim = (SceneObjectGroup) ent;
1310 break; 1298 break;
1311 } 1299 }
1312 } 1300 }
@@ -1321,9 +1309,9 @@ namespace OpenSim.Region.Environment.Scenes
1321 { 1309 {
1322 if (ent is SceneObjectGroup) 1310 if (ent is SceneObjectGroup)
1323 { 1311 {
1324 if (((SceneObjectGroup)ent).LocalId == childPrims[i]) 1312 if ((ent).LocalId == childPrims[i])
1325 { 1313 {
1326 children.Add((SceneObjectGroup)ent); 1314 children.Add((SceneObjectGroup) ent);
1327 } 1315 }
1328 } 1316 }
1329 } 1317 }
@@ -1334,7 +1322,7 @@ namespace OpenSim.Region.Environment.Scenes
1334 { 1322 {
1335 parenPrim.LinkToGroup(sceneObj); 1323 parenPrim.LinkToGroup(sceneObj);
1336 } 1324 }
1337 1325
1338 // We need to explicitly resend the newly link prim's object properties since no other actions 1326 // We need to explicitly resend the newly link prim's object properties since no other actions
1339 // occur on link to invoke this elsewhere (such as object selection) 1327 // occur on link to invoke this elsewhere (such as object selection)
1340 parenPrim.GetProperties(client); 1328 parenPrim.GetProperties(client);
@@ -1360,19 +1348,16 @@ namespace OpenSim.Region.Environment.Scenes
1360 { 1348 {
1361 if (ent is SceneObjectGroup) 1349 if (ent is SceneObjectGroup)
1362 { 1350 {
1363 SceneObjectGroup obj = (SceneObjectGroup)ent; 1351 SceneObjectGroup obj = (SceneObjectGroup) ent;
1364 sceneObjects.Add(obj.LocalId, obj); 1352 sceneObjects.Add(obj.LocalId, obj);
1365
1366 } 1353 }
1367 } 1354 }
1368 1355
1369 // Find the root prim among the prim ids we've been given 1356 // Find the root prim among the prim ids we've been given
1370 for (int i = 0; i < primIds.Count; i++) 1357 for (int i = 0; i < primIds.Count; i++)
1371 { 1358 {
1372
1373 if (sceneObjects.ContainsKey(primIds[i])) 1359 if (sceneObjects.ContainsKey(primIds[i]))
1374 { 1360 {
1375
1376 parenPrim = sceneObjects[primIds[i]]; 1361 parenPrim = sceneObjects[primIds[i]];
1377 primIds.RemoveAt(i); 1362 primIds.RemoveAt(i);
1378 break; 1363 break;
@@ -1402,14 +1387,13 @@ namespace OpenSim.Region.Environment.Scenes
1402 grp.DelinkFromGroup(primIds[i]); 1387 grp.DelinkFromGroup(primIds[i]);
1403 delinkedSomething = true; 1388 delinkedSomething = true;
1404 } 1389 }
1405
1406 } 1390 }
1407 } 1391 }
1408 if (!delinkedSomething) 1392 if (!delinkedSomething)
1409 { 1393 {
1410 m_log.InfoFormat("[SCENE]: " + 1394 m_log.InfoFormat("[SCENE]: " +
1411 "DelinkObjects(): Could not find a root prim out of {0} as given to a delink request!", 1395 "DelinkObjects(): Could not find a root prim out of {0} as given to a delink request!",
1412 primIds); 1396 primIds);
1413 } 1397 }
1414 } 1398 }
1415 } 1399 }
@@ -1425,7 +1409,7 @@ namespace OpenSim.Region.Environment.Scenes
1425 { 1409 {
1426 if (ent is SceneObjectGroup) 1410 if (ent is SceneObjectGroup)
1427 { 1411 {
1428 foreach (KeyValuePair<LLUUID, SceneObjectPart> subent in ((SceneObjectGroup)ent).Children) 1412 foreach (KeyValuePair<LLUUID, SceneObjectPart> subent in ((SceneObjectGroup) ent).Children)
1429 { 1413 {
1430 if (subent.Value.LocalId == localID) 1414 if (subent.Value.LocalId == localID)
1431 { 1415 {
@@ -1435,7 +1419,7 @@ namespace OpenSim.Region.Environment.Scenes
1435 } 1419 }
1436 } 1420 }
1437 } 1421 }
1438 1422
1439 //Protip: In my day, we didn't call them searchable objects, we called them limited point-to-point joints 1423 //Protip: In my day, we didn't call them searchable objects, we called them limited point-to-point joints
1440 //aka ObjectFlags.JointWheel = IncludeInSearch 1424 //aka ObjectFlags.JointWheel = IncludeInSearch
1441 1425
@@ -1467,7 +1451,7 @@ namespace OpenSim.Region.Environment.Scenes
1467 public void DuplicateObject(uint originalPrim, LLVector3 offset, uint flags, LLUUID AgentID, LLUUID GroupID) 1451 public void DuplicateObject(uint originalPrim, LLVector3 offset, uint flags, LLUUID AgentID, LLUUID GroupID)
1468 { 1452 {
1469 m_log.DebugFormat("[SCENE]: Duplication of object {0} at offset {1} requested by agent {2}", originalPrim, offset, AgentID); 1453 m_log.DebugFormat("[SCENE]: Duplication of object {0} at offset {1} requested by agent {2}", originalPrim, offset, AgentID);
1470 1454
1471 List<EntityBase> EntityList = GetEntities(); 1455 List<EntityBase> EntityList = GetEntities();
1472 1456
1473 SceneObjectGroup originPrim = null; 1457 SceneObjectGroup originPrim = null;
@@ -1475,9 +1459,9 @@ namespace OpenSim.Region.Environment.Scenes
1475 { 1459 {
1476 if (ent is SceneObjectGroup) 1460 if (ent is SceneObjectGroup)
1477 { 1461 {
1478 if (((SceneObjectGroup)ent).LocalId == originalPrim) 1462 if ((ent).LocalId == originalPrim)
1479 { 1463 {
1480 originPrim = (SceneObjectGroup)ent; 1464 originPrim = (SceneObjectGroup) ent;
1481 break; 1465 break;
1482 } 1466 }
1483 } 1467 }
@@ -1526,4 +1510,4 @@ namespace OpenSim.Region.Environment.Scenes
1526 1510
1527 #endregion 1511 #endregion
1528 } 1512 }
1529} 1513} \ 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 6bd5d1a..1e6ebf9 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
@@ -40,7 +40,7 @@ namespace OpenSim.Region.Environment.Scenes
40{ 40{
41 public partial class Scene 41 public partial class Scene
42 { 42 {
43 private static readonly ILog m_log 43 private static readonly ILog m_log
44 = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 44 = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
45 45
46 /// <summary> 46 /// <summary>
@@ -49,11 +49,11 @@ namespace OpenSim.Region.Environment.Scenes
49 public void StartScripts() 49 public void StartScripts()
50 { 50 {
51 m_log.Info("[PRIM INVENTORY]: Starting scripts in scene"); 51 m_log.Info("[PRIM INVENTORY]: Starting scripts in scene");
52 52
53 foreach (SceneObjectGroup group in Entities.Values) 53 foreach (SceneObjectGroup group in Entities.Values)
54 { 54 {
55 group.StartScripts(); 55 group.StartScripts();
56 } 56 }
57 } 57 }
58 58
59 /// <summary> 59 /// <summary>
@@ -64,9 +64,9 @@ namespace OpenSim.Region.Environment.Scenes
64 /// in which the item is to be placed.</param> 64 /// in which the item is to be placed.</param>
65 public void AddInventoryItem(IClientAPI remoteClient, InventoryItemBase item) 65 public void AddInventoryItem(IClientAPI remoteClient, InventoryItemBase item)
66 { 66 {
67 CachedUserInfo userInfo 67 CachedUserInfo userInfo
68 = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId); 68 = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId);
69 69
70 if (userInfo != null) 70 if (userInfo != null)
71 { 71 {
72 userInfo.AddItem(remoteClient.AgentId, item); 72 userInfo.AddItem(remoteClient.AgentId, item);
@@ -88,9 +88,9 @@ namespace OpenSim.Region.Environment.Scenes
88 m_log.ErrorFormat( 88 m_log.ErrorFormat(
89 "[AGENT INVENTORY]: Agent {0} {1} was not found for add of item {2} {3}", 89 "[AGENT INVENTORY]: Agent {0} {1} was not found for add of item {2} {3}",
90 remoteClient.Name, remoteClient.AgentId, item.Name, item.ID); 90 remoteClient.Name, remoteClient.AgentId, item.Name, item.ID);
91 91
92 return; 92 return;
93 } 93 }
94 } 94 }
95 95
96 /// <summary> 96 /// <summary>
@@ -190,7 +190,7 @@ namespace OpenSim.Region.Environment.Scenes
190 { 190 {
191 // Retrieve group 191 // Retrieve group
192 SceneObjectPart part = GetSceneObjectPart(primId); 192 SceneObjectPart part = GetSceneObjectPart(primId);
193 SceneObjectGroup group = part.ParentGroup; 193 SceneObjectGroup group = part.ParentGroup;
194 if (null == group) 194 if (null == group)
195 { 195 {
196 m_log.ErrorFormat( 196 m_log.ErrorFormat(
@@ -200,30 +200,30 @@ namespace OpenSim.Region.Environment.Scenes
200 200
201 return; 201 return;
202 } 202 }
203 203
204 // Retrieve item 204 // Retrieve item
205 TaskInventoryItem item = group.GetInventoryItem(part.LocalId, itemId); 205 TaskInventoryItem item = group.GetInventoryItem(part.LocalId, itemId);
206 if (null == item) 206 if (null == item)
207 { 207 {
208 return; 208 return;
209 } 209 }
210 210
211 // Create new asset 211 // Create new asset
212 // XXX Hardcoding the numbers is a temporary measure - need an enumeration for this 212 // XXX Hardcoding the numbers is a temporary measure - need an enumeration for this
213 // There may well be one in libsecondlife 213 // There may well be one in libsecondlife
214 AssetBase asset = CreateAsset(item.Name, item.Description, 10, 10, data); 214 AssetBase asset = CreateAsset(item.Name, item.Description, 10, 10, data);
215 AssetCache.AddAsset(asset); 215 AssetCache.AddAsset(asset);
216 216
217 // Update item with new asset 217 // Update item with new asset
218 item.AssetID = asset.FullID; 218 item.AssetID = asset.FullID;
219 group.UpdateInventoryItem(item); 219 group.UpdateInventoryItem(item);
220 group.GetProperties(remoteClient); 220 group.GetProperties(remoteClient);
221 221
222 // Trigger rerunning of script (use TriggerRezScript event, see RezScript) 222 // Trigger rerunning of script (use TriggerRezScript event, see RezScript)
223 if (isScriptRunning) 223 if (isScriptRunning)
224 { 224 {
225 group.StopScript(part.LocalId, item.ItemID); 225 group.StopScript(part.LocalId, item.ItemID);
226 group.StartScript(part.LocalId, item.ItemID); 226 group.StartScript(part.LocalId, item.ItemID);
227 } 227 }
228 } 228 }
229 229
@@ -272,7 +272,7 @@ namespace OpenSim.Region.Environment.Scenes
272 if (userInfo != null && userInfo.RootFolder != null) 272 if (userInfo != null && userInfo.RootFolder != null)
273 { 273 {
274 InventoryItemBase item = userInfo.RootFolder.HasItem(itemID); 274 InventoryItemBase item = userInfo.RootFolder.HasItem(itemID);
275 275
276 if (item != null) 276 if (item != null)
277 { 277 {
278 if (LLUUID.Zero == transactionID) 278 if (LLUUID.Zero == transactionID)
@@ -298,11 +298,11 @@ namespace OpenSim.Region.Environment.Scenes
298 } 298 }
299 else 299 else
300 { 300 {
301 IAgentAssetTransactions agentTransactions = this.RequestModuleInterface<IAgentAssetTransactions>(); 301 IAgentAssetTransactions agentTransactions = RequestModuleInterface<IAgentAssetTransactions>();
302 if (agentTransactions != null) 302 if (agentTransactions != null)
303 { 303 {
304 agentTransactions.HandleItemUpdateFromTransaction( 304 agentTransactions.HandleItemUpdateFromTransaction(
305 remoteClient, transactionID, item); 305 remoteClient, transactionID, item);
306 } 306 }
307 } 307 }
308 } 308 }
@@ -318,7 +318,7 @@ namespace OpenSim.Region.Environment.Scenes
318 "[AGENT INVENTORY]: Agent ID " + remoteClient.AgentId + " not found for an inventory item update."); 318 "[AGENT INVENTORY]: Agent ID " + remoteClient.AgentId + " not found for an inventory item update.");
319 } 319 }
320 } 320 }
321 321
322 /// <summary> 322 /// <summary>
323 /// Give an inventory item from one avatar to another 323 /// Give an inventory item from one avatar to another
324 /// </summary> 324 /// </summary>
@@ -328,13 +328,13 @@ namespace OpenSim.Region.Environment.Scenes
328 public void GiveInventoryItem(IClientAPI recipientClient, LLUUID senderId, LLUUID itemId) 328 public void GiveInventoryItem(IClientAPI recipientClient, LLUUID senderId, LLUUID itemId)
329 { 329 {
330 // Retrieve the item from the sender 330 // Retrieve the item from the sender
331 CachedUserInfo senderUserInfo = CommsManager.UserProfileCacheService.GetUserDetails(senderId); 331 CachedUserInfo senderUserInfo = CommsManager.UserProfileCacheService.GetUserDetails(senderId);
332 332
333 if (senderUserInfo == null) 333 if (senderUserInfo == null)
334 { 334 {
335 m_log.ErrorFormat( 335 m_log.ErrorFormat(
336 "[AGENT INVENTORY]: Failed to find sending user {0} for item {1}", senderId, itemId); 336 "[AGENT INVENTORY]: Failed to find sending user {0} for item {1}", senderId, itemId);
337 337
338 return; 338 return;
339 } 339 }
340 340
@@ -342,11 +342,11 @@ namespace OpenSim.Region.Environment.Scenes
342 { 342 {
343 InventoryItemBase item = senderUserInfo.RootFolder.HasItem(itemId); 343 InventoryItemBase item = senderUserInfo.RootFolder.HasItem(itemId);
344 if (item != null) 344 if (item != null)
345 { 345 {
346 // TODO get recipient's root folder 346 // TODO get recipient's root folder
347 CachedUserInfo recipientUserInfo 347 CachedUserInfo recipientUserInfo
348 = CommsManager.UserProfileCacheService.GetUserDetails(recipientClient.AgentId); 348 = CommsManager.UserProfileCacheService.GetUserDetails(recipientClient.AgentId);
349 349
350 if (recipientUserInfo != null) 350 if (recipientUserInfo != null)
351 { 351 {
352 // Insert a copy of the item into the recipient 352 // Insert a copy of the item into the recipient
@@ -373,15 +373,15 @@ namespace OpenSim.Region.Environment.Scenes
373 itemCopy.SaleType = item.SaleType; 373 itemCopy.SaleType = item.SaleType;
374 374
375 recipientUserInfo.AddItem(recipientClient.AgentId, itemCopy); 375 recipientUserInfo.AddItem(recipientClient.AgentId, itemCopy);
376 376
377 // Let the recipient client know about this new item 377 // Let the recipient client know about this new item
378 recipientClient.SendBulkUpdateInventory(itemCopy); 378 recipientClient.SendBulkUpdateInventory(itemCopy);
379 } 379 }
380 else 380 else
381 { 381 {
382 m_log.ErrorFormat( 382 m_log.ErrorFormat(
383 "[AGENT INVENTORY]: Could not find userinfo for recipient user {0}, {1} of item {2}, {3} from {4}", 383 "[AGENT INVENTORY]: Could not find userinfo for recipient user {0}, {1} of item {2}, {3} from {4}",
384 recipientClient.Name, recipientClient.AgentId, item.Name, 384 recipientClient.Name, recipientClient.AgentId, item.Name,
385 item.ID, senderId); 385 item.ID, senderId);
386 } 386 }
387 } 387 }
@@ -389,15 +389,15 @@ namespace OpenSim.Region.Environment.Scenes
389 { 389 {
390 m_log.ErrorFormat( 390 m_log.ErrorFormat(
391 "[AGENT INVENTORY]: Failed to find item {0} to give to {1}", itemId, senderId); 391 "[AGENT INVENTORY]: Failed to find item {0} to give to {1}", itemId, senderId);
392 392
393 return; 393 return;
394 } 394 }
395 } 395 }
396 else 396 else
397 { 397 {
398 m_log.Error("[AGENT INVENTORY]: Failed to find item " + itemId.ToString() + ", no root folder"); 398 m_log.Error("[AGENT INVENTORY]: Failed to find item " + itemId + ", no root folder");
399 return; 399 return;
400 } 400 }
401 } 401 }
402 402
403 public void CopyInventoryItem(IClientAPI remoteClient, uint callbackID, LLUUID oldAgentID, LLUUID oldItemID, 403 public void CopyInventoryItem(IClientAPI remoteClient, uint callbackID, LLUUID oldAgentID, LLUUID oldItemID,
@@ -406,14 +406,14 @@ namespace OpenSim.Region.Environment.Scenes
406 m_log.DebugFormat( 406 m_log.DebugFormat(
407 "[AGENT INVENTORY]: CopyInventoryItem received by {0} with oldAgentID {1}, oldItemID {2}, new FolderID {3}, newName {4}", 407 "[AGENT INVENTORY]: CopyInventoryItem received by {0} with oldAgentID {1}, oldItemID {2}, new FolderID {3}, newName {4}",
408 remoteClient.AgentId, oldAgentID, oldItemID, newFolderID, newName); 408 remoteClient.AgentId, oldAgentID, oldItemID, newFolderID, newName);
409 409
410 InventoryItemBase item = CommsManager.UserProfileCacheService.libraryRoot.HasItem(oldItemID); 410 InventoryItemBase item = CommsManager.UserProfileCacheService.libraryRoot.HasItem(oldItemID);
411 if (item == null) 411 if (item == null)
412 { 412 {
413 CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(oldAgentID); 413 CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(oldAgentID);
414 if (userInfo == null) 414 if (userInfo == null)
415 { 415 {
416 m_log.Error("[AGENT INVENTORY]: Failed to find user " + oldAgentID.ToString()); 416 m_log.Error("[AGENT INVENTORY]: Failed to find user " + oldAgentID);
417 return; 417 return;
418 } 418 }
419 419
@@ -422,20 +422,20 @@ namespace OpenSim.Region.Environment.Scenes
422 item = userInfo.RootFolder.HasItem(oldItemID); 422 item = userInfo.RootFolder.HasItem(oldItemID);
423 if (item == null) 423 if (item == null)
424 { 424 {
425 m_log.Error("[AGENT INVENTORY]: Failed to find item " + oldItemID.ToString()); 425 m_log.Error("[AGENT INVENTORY]: Failed to find item " + oldItemID);
426 return; 426 return;
427 } 427 }
428 } 428 }
429 else 429 else
430 { 430 {
431 m_log.Error("[AGENT INVENTORY]: Failed to find item " + oldItemID.ToString()); 431 m_log.Error("[AGENT INVENTORY]: Failed to find item " + oldItemID);
432 return; 432 return;
433 } 433 }
434 } 434 }
435 435
436 AssetBase asset 436 AssetBase asset
437 = AssetCache.GetAsset( 437 = AssetCache.GetAsset(
438 item.AssetID, (item.AssetType == (int)AssetType.Texture ? true : false)); 438 item.AssetID, (item.AssetType == (int) AssetType.Texture ? true : false));
439 439
440 if (asset != null) 440 if (asset != null)
441 { 441 {
@@ -447,7 +447,7 @@ namespace OpenSim.Region.Environment.Scenes
447 { 447 {
448 m_log.ErrorFormat( 448 m_log.ErrorFormat(
449 "[AGENT INVENTORY]: Could not copy item {0} since asset {1} could not be found", 449 "[AGENT INVENTORY]: Could not copy item {0} since asset {1} could not be found",
450 item.Name, item.AssetID); 450 item.Name, item.AssetID);
451 } 451 }
452 } 452 }
453 453
@@ -472,7 +472,7 @@ namespace OpenSim.Region.Environment.Scenes
472 CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId); 472 CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId);
473 if (userInfo == null) 473 if (userInfo == null)
474 { 474 {
475 m_log.Error("[AGENT INVENTORY]: Failed to find user " + remoteClient.AgentId.ToString()); 475 m_log.Error("[AGENT INVENTORY]: Failed to find user " + remoteClient.AgentId);
476 return; 476 return;
477 } 477 }
478 478
@@ -493,13 +493,13 @@ namespace OpenSim.Region.Environment.Scenes
493 } 493 }
494 else 494 else
495 { 495 {
496 m_log.Error("[AGENT INVENTORY]: Failed to find item " + itemID.ToString()); 496 m_log.Error("[AGENT INVENTORY]: Failed to find item " + itemID);
497 return; 497 return;
498 } 498 }
499 } 499 }
500 else 500 else
501 { 501 {
502 m_log.Error("[AGENT INVENTORY]: Failed to find item " + itemID.ToString() + ", no root folder"); 502 m_log.Error("[AGENT INVENTORY]: Failed to find item " + itemID + ", no root folder");
503 return; 503 return;
504 } 504 }
505 } 505 }
@@ -515,9 +515,9 @@ namespace OpenSim.Region.Environment.Scenes
515 private void CreateNewInventoryItem(IClientAPI remoteClient, LLUUID folderID, uint callbackID, 515 private void CreateNewInventoryItem(IClientAPI remoteClient, LLUUID folderID, uint callbackID,
516 AssetBase asset, uint nextOwnerMask) 516 AssetBase asset, uint nextOwnerMask)
517 { 517 {
518 CachedUserInfo userInfo 518 CachedUserInfo userInfo
519 = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId); 519 = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId);
520 520
521 if (userInfo != null) 521 if (userInfo != null)
522 { 522 {
523 InventoryItemBase item = new InventoryItemBase(); 523 InventoryItemBase item = new InventoryItemBase();
@@ -539,8 +539,8 @@ namespace OpenSim.Region.Environment.Scenes
539 else 539 else
540 { 540 {
541 m_log.WarnFormat( 541 m_log.WarnFormat(
542 "No user details associated with client {0} uuid {1} in CreateNewInventoryItem!", 542 "No user details associated with client {0} uuid {1} in CreateNewInventoryItem!",
543 remoteClient.Name, remoteClient.AgentId); 543 remoteClient.Name, remoteClient.AgentId);
544 } 544 }
545 } 545 }
546 546
@@ -564,25 +564,25 @@ namespace OpenSim.Region.Environment.Scenes
564 byte wearableType, uint nextOwnerMask) 564 byte wearableType, uint nextOwnerMask)
565 { 565 {
566// m_log.DebugFormat("[AGENT INVENTORY]: Received request to create inventory item {0} in folder {1}", name, folderID); 566// m_log.DebugFormat("[AGENT INVENTORY]: Received request to create inventory item {0} in folder {1}", name, folderID);
567 567
568 if (transactionID == LLUUID.Zero) 568 if (transactionID == LLUUID.Zero)
569 { 569 {
570 CachedUserInfo userInfo 570 CachedUserInfo userInfo
571 = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId); 571 = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId);
572 572
573 if (userInfo != null) 573 if (userInfo != null)
574 { 574 {
575 ScenePresence presence; 575 ScenePresence presence;
576 TryGetAvatar(remoteClient.AgentId, out presence); 576 TryGetAvatar(remoteClient.AgentId, out presence);
577 byte[] data = null; 577 byte[] data = null;
578 if(invType == 3 && presence != null) // libsecondlife.asset.assettype.landmark = 3 - needs to be turned into an enum 578 if (invType == 3 && presence != null) // libsecondlife.asset.assettype.landmark = 3 - needs to be turned into an enum
579 { 579 {
580 LLVector3 pos=presence.AbsolutePosition; 580 LLVector3 pos = presence.AbsolutePosition;
581 string strdata=String.Format("Landmark version 2\nregion_id {0}\nlocal_pos {1} {2} {3}\nregion_handle {4}\n", 581 string strdata = String.Format("Landmark version 2\nregion_id {0}\nlocal_pos {1} {2} {3}\nregion_handle {4}\n",
582 presence.Scene.RegionInfo.RegionID, 582 presence.Scene.RegionInfo.RegionID,
583 pos.X, pos.Y, pos.Z, 583 pos.X, pos.Y, pos.Z,
584 presence.RegionHandle); 584 presence.RegionHandle);
585 data=Encoding.ASCII.GetBytes(strdata); 585 data = Encoding.ASCII.GetBytes(strdata);
586 } 586 }
587 587
588 AssetBase asset = CreateAsset(name, description, invType, assetType, data); 588 AssetBase asset = CreateAsset(name, description, invType, assetType, data);
@@ -593,21 +593,19 @@ namespace OpenSim.Region.Environment.Scenes
593 else 593 else
594 { 594 {
595 m_log.ErrorFormat( 595 m_log.ErrorFormat(
596 "userInfo for agent uuid {0} unexpectedly null in CreateNewInventoryItem", 596 "userInfo for agent uuid {0} unexpectedly null in CreateNewInventoryItem",
597 remoteClient.AgentId); 597 remoteClient.AgentId);
598 } 598 }
599 } 599 }
600 else 600 else
601 { 601 {
602 IAgentAssetTransactions agentTransactions = this.RequestModuleInterface<IAgentAssetTransactions>(); 602 IAgentAssetTransactions agentTransactions = RequestModuleInterface<IAgentAssetTransactions>();
603 if (agentTransactions != null) 603 if (agentTransactions != null)
604 { 604 {
605 agentTransactions.HandleItemCreationFromTransaction( 605 agentTransactions.HandleItemCreationFromTransaction(
606 remoteClient, transactionID, folderID, callbackID, description, 606 remoteClient, transactionID, folderID, callbackID, description,
607 name, invType, assetType, wearableType, nextOwnerMask); 607 name, invType, assetType, wearableType, nextOwnerMask);
608 } 608 }
609
610
611 } 609 }
612 } 610 }
613 611
@@ -617,7 +615,7 @@ namespace OpenSim.Region.Environment.Scenes
617 = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId); 615 = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId);
618 if (userInfo == null) 616 if (userInfo == null)
619 { 617 {
620 m_log.Error("[AGENT INVENTORY]: Failed to find user " + remoteClient.AgentId.ToString()); 618 m_log.Error("[AGENT INVENTORY]: Failed to find user " + remoteClient.AgentId);
621 return; 619 return;
622 } 620 }
623 621
@@ -641,7 +639,7 @@ namespace OpenSim.Region.Environment.Scenes
641 = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId); 639 = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId);
642 if (userInfo == null) 640 if (userInfo == null)
643 { 641 {
644 m_log.Error("[AGENT INVENTORY]: Failed to find user " + remoteClient.AgentId.ToString()); 642 m_log.Error("[AGENT INVENTORY]: Failed to find user " + remoteClient.AgentId);
645 return; 643 return;
646 } 644 }
647 645
@@ -677,7 +675,7 @@ namespace OpenSim.Region.Environment.Scenes
677 /// <param name="remoteClient"></param> 675 /// <param name="remoteClient"></param>
678 /// <param name="primLocalID"></param> 676 /// <param name="primLocalID"></param>
679 public void RequestTaskInventory(IClientAPI remoteClient, uint primLocalID) 677 public void RequestTaskInventory(IClientAPI remoteClient, uint primLocalID)
680 { 678 {
681 SceneObjectGroup group = GetGroupByPrim(primLocalID); 679 SceneObjectGroup group = GetGroupByPrim(primLocalID);
682 if (group != null) 680 if (group != null)
683 { 681 {
@@ -725,7 +723,7 @@ namespace OpenSim.Region.Environment.Scenes
725 localID); 723 localID);
726 } 724 }
727 } 725 }
728 726
729 /// <summary> 727 /// <summary>
730 /// Move the given item in the given prim to a folder in the client's inventory 728 /// Move the given item in the given prim to a folder in the client's inventory
731 /// </summary> 729 /// </summary>
@@ -736,43 +734,43 @@ namespace OpenSim.Region.Environment.Scenes
736 public void MoveTaskInventoryItem(IClientAPI remoteClient, LLUUID folderId, uint primLocalId, LLUUID itemId) 734 public void MoveTaskInventoryItem(IClientAPI remoteClient, LLUUID folderId, uint primLocalId, LLUUID itemId)
737 { 735 {
738 SceneObjectGroup group = GetGroupByPrim(primLocalId); 736 SceneObjectGroup group = GetGroupByPrim(primLocalId);
739 737
740 if (null == group) 738 if (null == group)
741 { 739 {
742 m_log.WarnFormat( 740 m_log.WarnFormat(
743 "[PRIM INVENTORY]: " + 741 "[PRIM INVENTORY]: " +
744 "Move of inventory item {0} from prim with local id {1} failed because the prim could not be found", 742 "Move of inventory item {0} from prim with local id {1} failed because the prim could not be found",
745 itemId, primLocalId); 743 itemId, primLocalId);
746 744
747 return; 745 return;
748 } 746 }
749 747
750 TaskInventoryItem taskItem = group.GetInventoryItem(primLocalId, itemId); 748 TaskInventoryItem taskItem = group.GetInventoryItem(primLocalId, itemId);
751 749
752 if (null == taskItem) 750 if (null == taskItem)
753 { 751 {
754 // Console already notified of error in GetInventoryItem 752 // Console already notified of error in GetInventoryItem
755 return; 753 return;
756 } 754 }
757 755
758// bool permission; 756// bool permission;
759// permission = PermissionsMngr.CanCopyObject(remoteClient.AgentId, 757// permission = PermissionsMngr.CanCopyObject(remoteClient.AgentId,
760// ((SceneObjectGroup) selectedEnt).UUID); 758// ((SceneObjectGroup) selectedEnt).UUID);
761 759
762 // Pending resolving upstream problems with permissions, we just won't allow anybody who is not the owner 760 // Pending resolving upstream problems with permissions, we just won't allow anybody who is not the owner
763 // to copy 761 // to copy
764 if (remoteClient.AgentId != taskItem.OwnerID) 762 if (remoteClient.AgentId != taskItem.OwnerID)
765 { 763 {
766 m_log.InfoFormat( 764 m_log.InfoFormat(
767 "[PRIM INVENTORY]: Attempt made by {0} {1} to copy inventory item {2} {3} in prim {4} {5}," 765 "[PRIM INVENTORY]: Attempt made by {0} {1} to copy inventory item {2} {3} in prim {4} {5},"
768 + " but temporarily not allowed pending upstream bugfixes/feature implementation", 766 + " but temporarily not allowed pending upstream bugfixes/feature implementation",
769 remoteClient.Name, remoteClient.AgentId, taskItem.Name, taskItem.ItemID, group.Name, group.UUID); 767 remoteClient.Name, remoteClient.AgentId, taskItem.Name, taskItem.ItemID, group.Name, group.UUID);
770 768
771 return; 769 return;
772 } 770 }
773 771
774 InventoryItemBase agentItem = new InventoryItemBase(); 772 InventoryItemBase agentItem = new InventoryItemBase();
775 773
776 agentItem.ID = LLUUID.Random(); 774 agentItem.ID = LLUUID.Random();
777 agentItem.Creator = taskItem.CreatorID; 775 agentItem.Creator = taskItem.CreatorID;
778 agentItem.Owner = remoteClient.AgentId; 776 agentItem.Owner = remoteClient.AgentId;
@@ -783,8 +781,9 @@ namespace OpenSim.Region.Environment.Scenes
783 agentItem.InvType = taskItem.InvType; 781 agentItem.InvType = taskItem.InvType;
784 agentItem.Folder = folderId; 782 agentItem.Folder = folderId;
785 agentItem.EveryOnePermissions = taskItem.EveryoneMask; 783 agentItem.EveryOnePermissions = taskItem.EveryoneMask;
786 784
787 if (remoteClient.AgentId != taskItem.OwnerID) { 785 if (remoteClient.AgentId != taskItem.OwnerID)
786 {
788 agentItem.BasePermissions = taskItem.NextOwnerMask; 787 agentItem.BasePermissions = taskItem.NextOwnerMask;
789 agentItem.CurrentPermissions = taskItem.NextOwnerMask; 788 agentItem.CurrentPermissions = taskItem.NextOwnerMask;
790 agentItem.NextPermissions = taskItem.NextOwnerMask; 789 agentItem.NextPermissions = taskItem.NextOwnerMask;
@@ -793,9 +792,9 @@ namespace OpenSim.Region.Environment.Scenes
793 { 792 {
794 agentItem.BasePermissions = taskItem.BaseMask; 793 agentItem.BasePermissions = taskItem.BaseMask;
795 agentItem.CurrentPermissions = taskItem.OwnerMask; 794 agentItem.CurrentPermissions = taskItem.OwnerMask;
796 agentItem.NextPermissions = taskItem.NextOwnerMask; 795 agentItem.NextPermissions = taskItem.NextOwnerMask;
797 } 796 }
798 797
799 AddInventoryItem(remoteClient, agentItem); 798 AddInventoryItem(remoteClient, agentItem);
800 } 799 }
801 800
@@ -834,7 +833,7 @@ namespace OpenSim.Region.Environment.Scenes
834 { 833 {
835 group.AddInventoryItem(remoteClient, primLocalID, item, copyID); 834 group.AddInventoryItem(remoteClient, primLocalID, item, copyID);
836 m_log.InfoFormat( 835 m_log.InfoFormat(
837 "[PRIM INVENTORY]: Update with item {0} requested of prim {1} for {2}", 836 "[PRIM INVENTORY]: Update with item {0} requested of prim {1} for {2}",
838 item.Name, primLocalID, remoteClient.Name); 837 item.Name, primLocalID, remoteClient.Name);
839 group.GetProperties(remoteClient); 838 group.GetProperties(remoteClient);
840 } 839 }
@@ -865,22 +864,22 @@ namespace OpenSim.Region.Environment.Scenes
865 public void RezScript(IClientAPI remoteClient, LLUUID itemID, uint localID) 864 public void RezScript(IClientAPI remoteClient, LLUUID itemID, uint localID)
866 { 865 {
867 LLUUID copyID = LLUUID.Random(); 866 LLUUID copyID = LLUUID.Random();
868 867
869 if (itemID != LLUUID.Zero) 868 if (itemID != LLUUID.Zero)
870 { 869 {
871 CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId); 870 CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId);
872 871
873 if (userInfo != null && userInfo.RootFolder != null) 872 if (userInfo != null && userInfo.RootFolder != null)
874 { 873 {
875 InventoryItemBase item = userInfo.RootFolder.HasItem(itemID); 874 InventoryItemBase item = userInfo.RootFolder.HasItem(itemID);
876 875
877 // Try library 876 // Try library
878 // XXX clumsy, possibly should be one call 877 // XXX clumsy, possibly should be one call
879 if (null == item) 878 if (null == item)
880 { 879 {
881 item = CommsManager.UserProfileCacheService.libraryRoot.HasItem(itemID); 880 item = CommsManager.UserProfileCacheService.libraryRoot.HasItem(itemID);
882 } 881 }
883 882
884 if (item != null) 883 if (item != null)
885 { 884 {
886 SceneObjectGroup group = GetGroupByPrim(localID); 885 SceneObjectGroup group = GetGroupByPrim(localID);
@@ -889,10 +888,10 @@ namespace OpenSim.Region.Environment.Scenes
889 group.AddInventoryItem(remoteClient, localID, item, copyID); 888 group.AddInventoryItem(remoteClient, localID, item, copyID);
890 group.StartScript(localID, copyID); 889 group.StartScript(localID, copyID);
891 group.GetProperties(remoteClient); 890 group.GetProperties(remoteClient);
892 891
893 // m_log.InfoFormat("[PRIMINVENTORY]: " + 892 // m_log.InfoFormat("[PRIMINVENTORY]: " +
894 // "Rezzed script {0} into prim local ID {1} for user {2}", 893 // "Rezzed script {0} into prim local ID {1} for user {2}",
895 // item.inventoryName, localID, remoteClient.Name); 894 // item.inventoryName, localID, remoteClient.Name);
896 } 895 }
897 else 896 else
898 { 897 {
@@ -911,7 +910,7 @@ namespace OpenSim.Region.Environment.Scenes
911 } 910 }
912 } 911 }
913 } 912 }
914 else // If the itemID is zero then the script has been rezzed directly in an object's inventory 913 else // If the itemID is zero then the script has been rezzed directly in an object's inventory
915 { 914 {
916 // not yet implemented 915 // not yet implemented
917 // TODO Need to get more details from original RezScript packet 916 // TODO Need to get more details from original RezScript packet
@@ -927,7 +926,7 @@ namespace OpenSim.Region.Environment.Scenes
927 /// <param name="packet"></param> 926 /// <param name="packet"></param>
928 /// <param name="simClient"></param> 927 /// <param name="simClient"></param>
929 public virtual void DeRezObject(Packet packet, IClientAPI remoteClient) 928 public virtual void DeRezObject(Packet packet, IClientAPI remoteClient)
930 { 929 {
931 DeRezObjectPacket DeRezPacket = (DeRezObjectPacket) packet; 930 DeRezObjectPacket DeRezPacket = (DeRezObjectPacket) packet;
932 931
933 if (DeRezPacket.AgentBlock.DestinationID == LLUUID.Zero) 932 if (DeRezPacket.AgentBlock.DestinationID == LLUUID.Zero)
@@ -937,11 +936,11 @@ namespace OpenSim.Region.Environment.Scenes
937 else 936 else
938 { 937 {
939 foreach (DeRezObjectPacket.ObjectDataBlock Data in DeRezPacket.ObjectData) 938 foreach (DeRezObjectPacket.ObjectDataBlock Data in DeRezPacket.ObjectData)
940 { 939 {
941// m_log.DebugFormat( 940// m_log.DebugFormat(
942// "[AGENT INVENTORY]: Received request to derez {0} into folder {1}", 941// "[AGENT INVENTORY]: Received request to derez {0} into folder {1}",
943// Data.ObjectLocalID, DeRezPacket.AgentBlock.DestinationID); 942// Data.ObjectLocalID, DeRezPacket.AgentBlock.DestinationID);
944 943
945 EntityBase selectedEnt = null; 944 EntityBase selectedEnt = null;
946 //m_log.Info("[CLIENT]: LocalID:" + Data.ObjectLocalID.ToString()); 945 //m_log.Info("[CLIENT]: LocalID:" + Data.ObjectLocalID.ToString());
947 946
@@ -959,14 +958,16 @@ namespace OpenSim.Region.Environment.Scenes
959 { 958 {
960 bool permission; 959 bool permission;
961 if (DeRezPacket.AgentBlock.Destination == 1) 960 if (DeRezPacket.AgentBlock.Destination == 1)
962 { // Take Copy 961 {
963 permission = PermissionsMngr.CanCopyObject(remoteClient.AgentId, 962 // Take Copy
964 ((SceneObjectGroup) selectedEnt).UUID); 963 permission = PermissionsMngr.CanCopyObject(remoteClient.AgentId,
964 (selectedEnt).UUID);
965 } 965 }
966 else 966 else
967 { // Take 967 {
968 permission = PermissionsMngr.CanDeRezObject(remoteClient.AgentId, 968 // Take
969 ((SceneObjectGroup) selectedEnt).UUID); 969 permission = PermissionsMngr.CanDeRezObject(remoteClient.AgentId,
970 (selectedEnt).UUID);
970 } 971 }
971 972
972 if (permission) 973 if (permission)
@@ -997,7 +998,8 @@ namespace OpenSim.Region.Environment.Scenes
997 item.InvType = asset.InvType; 998 item.InvType = asset.InvType;
998 item.Folder = DeRezPacket.AgentBlock.DestinationID; 999 item.Folder = DeRezPacket.AgentBlock.DestinationID;
999 item.EveryOnePermissions = objectGroup.RootPart.EveryoneMask; 1000 item.EveryOnePermissions = objectGroup.RootPart.EveryoneMask;
1000 if (remoteClient.AgentId != objectGroup.RootPart.OwnerID) { 1001 if (remoteClient.AgentId != objectGroup.RootPart.OwnerID)
1002 {
1001 item.BasePermissions = objectGroup.RootPart.NextOwnerMask; 1003 item.BasePermissions = objectGroup.RootPart.NextOwnerMask;
1002 item.CurrentPermissions = objectGroup.RootPart.NextOwnerMask; 1004 item.CurrentPermissions = objectGroup.RootPart.NextOwnerMask;
1003 item.NextPermissions = objectGroup.RootPart.NextOwnerMask; 1005 item.NextPermissions = objectGroup.RootPart.NextOwnerMask;
@@ -1025,6 +1027,7 @@ namespace OpenSim.Region.Environment.Scenes
1025 } 1027 }
1026 } 1028 }
1027 } 1029 }
1030
1028 public void updateKnownAsset(IClientAPI remoteClient, SceneObjectGroup grp, LLUUID assetID, LLUUID agentID) 1031 public void updateKnownAsset(IClientAPI remoteClient, SceneObjectGroup grp, LLUUID assetID, LLUUID agentID)
1029 { 1032 {
1030 SceneObjectGroup objectGroup = grp; 1033 SceneObjectGroup objectGroup = grp;
@@ -1044,7 +1047,6 @@ namespace OpenSim.Region.Environment.Scenes
1044 // search through folders to find the asset. 1047 // search through folders to find the asset.
1045 while (searchfolders.Count > 0) 1048 while (searchfolders.Count > 0)
1046 { 1049 {
1047
1048 InventoryFolderImpl fld = searchfolders.Dequeue(); 1050 InventoryFolderImpl fld = searchfolders.Dequeue();
1049 lock (fld) 1051 lock (fld)
1050 { 1052 {
@@ -1069,8 +1071,8 @@ namespace OpenSim.Region.Environment.Scenes
1069 AssetBase asset = CreateAsset( 1071 AssetBase asset = CreateAsset(
1070 objectGroup.GetPartName(objectGroup.LocalId), 1072 objectGroup.GetPartName(objectGroup.LocalId),
1071 objectGroup.GetPartDescription(objectGroup.LocalId), 1073 objectGroup.GetPartDescription(objectGroup.LocalId),
1072 (sbyte)InventoryType.Object, 1074 (sbyte) InventoryType.Object,
1073 (sbyte)AssetType.Object, 1075 (sbyte) AssetType.Object,
1074 Helpers.StringToField(sceneObjectXml)); 1076 Helpers.StringToField(sceneObjectXml));
1075 AssetCache.AddAsset(asset); 1077 AssetCache.AddAsset(asset);
1076 1078
@@ -1086,7 +1088,7 @@ namespace OpenSim.Region.Environment.Scenes
1086 1088
1087 // Sticking it in root folder for now.. objects folder later? 1089 // Sticking it in root folder for now.. objects folder later?
1088 1090
1089 item.Folder = foundFolder;// DeRezPacket.AgentBlock.DestinationID; 1091 item.Folder = foundFolder; // DeRezPacket.AgentBlock.DestinationID;
1090 item.EveryOnePermissions = objectGroup.RootPart.EveryoneMask; 1092 item.EveryOnePermissions = objectGroup.RootPart.EveryoneMask;
1091 if (agentID != objectGroup.RootPart.OwnerID) 1093 if (agentID != objectGroup.RootPart.OwnerID)
1092 { 1094 {
@@ -1108,10 +1110,10 @@ namespace OpenSim.Region.Environment.Scenes
1108 { 1110 {
1109 remoteClient.SendInventoryItemCreateUpdate(item); 1111 remoteClient.SendInventoryItemCreateUpdate(item);
1110 } 1112 }
1111
1112 } 1113 }
1113 } 1114 }
1114 } 1115 }
1116
1115 public LLUUID attachObjectAssetStore(IClientAPI remoteClient, SceneObjectGroup grp, LLUUID AgentId) 1117 public LLUUID attachObjectAssetStore(IClientAPI remoteClient, SceneObjectGroup grp, LLUUID AgentId)
1116 { 1118 {
1117 SceneObjectGroup objectGroup = grp; 1119 SceneObjectGroup objectGroup = grp;
@@ -1126,8 +1128,8 @@ namespace OpenSim.Region.Environment.Scenes
1126 AssetBase asset = CreateAsset( 1128 AssetBase asset = CreateAsset(
1127 objectGroup.GetPartName(objectGroup.LocalId), 1129 objectGroup.GetPartName(objectGroup.LocalId),
1128 objectGroup.GetPartDescription(objectGroup.LocalId), 1130 objectGroup.GetPartDescription(objectGroup.LocalId),
1129 (sbyte)InventoryType.Object, 1131 (sbyte) InventoryType.Object,
1130 (sbyte)AssetType.Object, 1132 (sbyte) AssetType.Object,
1131 Helpers.StringToField(sceneObjectXml)); 1133 Helpers.StringToField(sceneObjectXml));
1132 AssetCache.AddAsset(asset); 1134 AssetCache.AddAsset(asset);
1133 1135
@@ -1140,10 +1142,10 @@ namespace OpenSim.Region.Environment.Scenes
1140 item.Name = asset.Name; 1142 item.Name = asset.Name;
1141 item.AssetType = asset.Type; 1143 item.AssetType = asset.Type;
1142 item.InvType = asset.InvType; 1144 item.InvType = asset.InvType;
1143 1145
1144 // Sticking it in root folder for now.. objects folder later? 1146 // Sticking it in root folder for now.. objects folder later?
1145 1147
1146 item.Folder = userInfo.RootFolder.ID;// DeRezPacket.AgentBlock.DestinationID; 1148 item.Folder = userInfo.RootFolder.ID; // DeRezPacket.AgentBlock.DestinationID;
1147 item.EveryOnePermissions = objectGroup.RootPart.EveryoneMask; 1149 item.EveryOnePermissions = objectGroup.RootPart.EveryoneMask;
1148 if (remoteClient.AgentId != objectGroup.RootPart.OwnerID) 1150 if (remoteClient.AgentId != objectGroup.RootPart.OwnerID)
1149 { 1151 {
@@ -1165,7 +1167,6 @@ namespace OpenSim.Region.Environment.Scenes
1165 return LLUUID.Zero; 1167 return LLUUID.Zero;
1166 } 1168 }
1167 return LLUUID.Zero; 1169 return LLUUID.Zero;
1168
1169 } 1170 }
1170 1171
1171 /// <summary> 1172 /// <summary>
@@ -1187,64 +1188,63 @@ namespace OpenSim.Region.Environment.Scenes
1187 /// <param name="RemoveItem"></param> 1188 /// <param name="RemoveItem"></param>
1188 /// <param name="fromTaskID"></param> 1189 /// <param name="fromTaskID"></param>
1189 public virtual void RezObject(IClientAPI remoteClient, LLUUID itemID, LLVector3 RayEnd, LLVector3 RayStart, 1190 public virtual void RezObject(IClientAPI remoteClient, LLUUID itemID, LLVector3 RayEnd, LLVector3 RayStart,
1190 LLUUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection, 1191 LLUUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection,
1191 uint EveryoneMask, uint GroupMask, uint NextOwnerMask, uint ItemFlags, 1192 uint EveryoneMask, uint GroupMask, uint NextOwnerMask, uint ItemFlags,
1192 bool RezSelected, bool RemoveItem, LLUUID fromTaskID) 1193 bool RezSelected, bool RemoveItem, LLUUID fromTaskID)
1193 { 1194 {
1194 SceneObjectGroup sog = RezObject(remoteClient, itemID, RayEnd, RayStart, 1195 SceneObjectGroup sog = RezObject(remoteClient, itemID, RayEnd, RayStart,
1195 RayTargetID, BypassRayCast, RayEndIsIntersection, 1196 RayTargetID, BypassRayCast, RayEndIsIntersection,
1196 EveryoneMask, GroupMask, NextOwnerMask, ItemFlags, 1197 EveryoneMask, GroupMask, NextOwnerMask, ItemFlags,
1197 RezSelected, RemoveItem, fromTaskID, false); 1198 RezSelected, RemoveItem, fromTaskID, false);
1198 } 1199 }
1199 1200
1200 1201
1201 1202 /// <summary>
1202 /// <summary> 1203 /// Returns SceneObjectGroup or null from asset request.
1203 /// Returns SceneObjectGroup or null from asset request. 1204 /// </summary>
1204 /// </summary> 1205 /// <param name="remoteClient"></param>
1205 /// <param name="remoteClient"></param> 1206 /// <param name="itemID"></param>
1206 /// <param name="itemID"></param> 1207 /// <param name="RayEnd"></param>
1207 /// <param name="RayEnd"></param> 1208 /// <param name="RayStart"></param>
1208 /// <param name="RayStart"></param> 1209 /// <param name="RayTargetID"></param>
1209 /// <param name="RayTargetID"></param> 1210 /// <param name="BypassRayCast"></param>
1210 /// <param name="BypassRayCast"></param> 1211 /// <param name="RayEndIsIntersection"></param>
1211 /// <param name="RayEndIsIntersection"></param> 1212 /// <param name="EveryoneMask"></param>
1212 /// <param name="EveryoneMask"></param> 1213 /// <param name="GroupMask"></param>
1213 /// <param name="GroupMask"></param> 1214 /// <param name="NextOwnerMask"></param>
1214 /// <param name="NextOwnerMask"></param> 1215 /// <param name="ItemFlags"></param>
1215 /// <param name="ItemFlags"></param> 1216 /// <param name="RezSelected"></param>
1216 /// <param name="RezSelected"></param> 1217 /// <param name="RemoveItem"></param>
1217 /// <param name="RemoveItem"></param> 1218 /// <param name="fromTaskID"></param>
1218 /// <param name="fromTaskID"></param> 1219 /// <param name="difference"></param>
1219 /// <param name="difference"></param> 1220 /// <returns></returns>
1220 /// <returns></returns>
1221 public virtual SceneObjectGroup RezObject(IClientAPI remoteClient, LLUUID itemID, LLVector3 RayEnd, LLVector3 RayStart, 1221 public virtual SceneObjectGroup RezObject(IClientAPI remoteClient, LLUUID itemID, LLVector3 RayEnd, LLVector3 RayStart,
1222 LLUUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection, 1222 LLUUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection,
1223 uint EveryoneMask, uint GroupMask, uint NextOwnerMask, uint ItemFlags, 1223 uint EveryoneMask, uint GroupMask, uint NextOwnerMask, uint ItemFlags,
1224 bool RezSelected, bool RemoveItem, LLUUID fromTaskID, bool attachment) 1224 bool RezSelected, bool RemoveItem, LLUUID fromTaskID, bool attachment)
1225 { 1225 {
1226 // Work out position details 1226 // Work out position details
1227 byte bRayEndIsIntersection = (byte)0; 1227 byte bRayEndIsIntersection = 0;
1228 1228
1229 if (RayEndIsIntersection) 1229 if (RayEndIsIntersection)
1230 { 1230 {
1231 bRayEndIsIntersection = (byte)1; 1231 bRayEndIsIntersection = 1;
1232 } 1232 }
1233 else 1233 else
1234 { 1234 {
1235 bRayEndIsIntersection = (byte)0; 1235 bRayEndIsIntersection = 0;
1236 } 1236 }
1237 1237
1238 LLVector3 scale = new LLVector3(0.5f, 0.5f, 0.5f); 1238 LLVector3 scale = new LLVector3(0.5f, 0.5f, 0.5f);
1239 1239
1240 1240
1241 LLVector3 pos = GetNewRezLocation( 1241 LLVector3 pos = GetNewRezLocation(
1242 RayStart, RayEnd, RayTargetID, new LLQuaternion(0, 0, 0, 1), 1242 RayStart, RayEnd, RayTargetID, new LLQuaternion(0, 0, 0, 1),
1243 BypassRayCast, bRayEndIsIntersection,true,scale, false); 1243 BypassRayCast, bRayEndIsIntersection, true, scale, false);
1244 1244
1245 if (!PermissionsMngr.CanRezObject(remoteClient.AgentId, pos) && !attachment) 1245 if (!PermissionsMngr.CanRezObject(remoteClient.AgentId, pos) && !attachment)
1246 { 1246 {
1247 return null; 1247 return null;
1248 } 1248 }
1249 1249
1250 // Rez object 1250 // Rez object
@@ -1260,7 +1260,7 @@ namespace OpenSim.Region.Environment.Scenes
1260 1260
1261 if (rezAsset != null) 1261 if (rezAsset != null)
1262 { 1262 {
1263 string xmlData = Helpers.FieldToUTF8String(rezAsset.Data); 1263 string xmlData = Helpers.FieldToUTF8String(rezAsset.Data);
1264 SceneObjectGroup group = new SceneObjectGroup(this, m_regionHandle, xmlData); 1264 SceneObjectGroup group = new SceneObjectGroup(this, m_regionHandle, xmlData);
1265 group.ResetIDs(); 1265 group.ResetIDs();
1266 AddEntity(group); 1266 AddEntity(group);
@@ -1270,8 +1270,8 @@ namespace OpenSim.Region.Environment.Scenes
1270 if (!attachment) 1270 if (!attachment)
1271 { 1271 {
1272 pos = GetNewRezLocation( 1272 pos = GetNewRezLocation(
1273 RayStart, RayEnd, RayTargetID, new LLQuaternion(0, 0, 0, 1), 1273 RayStart, RayEnd, RayTargetID, new LLQuaternion(0, 0, 0, 1),
1274 BypassRayCast, bRayEndIsIntersection, true, group.GroupScale(), false); 1274 BypassRayCast, bRayEndIsIntersection, true, group.GroupScale(), false);
1275 group.AbsolutePosition = pos; 1275 group.AbsolutePosition = pos;
1276 } 1276 }
1277 else 1277 else
@@ -1280,7 +1280,7 @@ namespace OpenSim.Region.Environment.Scenes
1280 } 1280 }
1281 1281
1282 SceneObjectPart rootPart = group.GetChildPart(group.UUID); 1282 SceneObjectPart rootPart = group.GetChildPart(group.UUID);
1283 1283
1284 // Since renaming the item in the inventory does not affect the name stored 1284 // Since renaming the item in the inventory does not affect the name stored
1285 // in the serialization, transfer the correct name from the inventory to the 1285 // in the serialization, transfer the correct name from the inventory to the
1286 // object itself before we rez. 1286 // object itself before we rez.
@@ -1301,22 +1301,22 @@ namespace OpenSim.Region.Environment.Scenes
1301 part.ChangeInventoryOwner(item.Owner); 1301 part.ChangeInventoryOwner(item.Owner);
1302 } 1302 }
1303 } 1303 }
1304 1304
1305 rootPart.TrimPermissions(); 1305 rootPart.TrimPermissions();
1306 1306
1307 if (!attachment) 1307 if (!attachment)
1308 { 1308 {
1309 if (group.RootPart.Shape.PCode == (byte)PCode.Prim) 1309 if (group.RootPart.Shape.PCode == (byte) PCode.Prim)
1310 { 1310 {
1311 group.ClearPartAttachmentData(); 1311 group.ClearPartAttachmentData();
1312 } 1312 }
1313 group.ApplyPhysics(m_physicalPrim); 1313 group.ApplyPhysics(m_physicalPrim);
1314 } 1314 }
1315 1315
1316 1316
1317 group.StartScripts(); 1317 group.StartScripts();
1318 1318
1319 1319
1320 if (!attachment) 1320 if (!attachment)
1321 rootPart.ScheduleFullUpdate(); 1321 rootPart.ScheduleFullUpdate();
1322 1322
@@ -1327,7 +1327,5 @@ namespace OpenSim.Region.Environment.Scenes
1327 } 1327 }
1328 return null; 1328 return null;
1329 } 1329 }
1330
1331
1332 } 1330 }
1333} 1331} \ 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 dccc09a..b052096 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs
@@ -78,11 +78,12 @@ namespace OpenSim.Region.Environment.Scenes
78 foreach (EntityBase ent in EntitieList) 78 foreach (EntityBase ent in EntitieList)
79 { 79 {
80 if (ent is SceneObjectGroup) 80 if (ent is SceneObjectGroup)
81 { 81 {
82 if (((SceneObjectGroup) ent).LocalId == primLocalID) 82 if ((ent).LocalId == primLocalID)
83 { 83 {
84 // A prim is only tainted if it's allowed to be edited by the person clicking it. 84 // A prim is only tainted if it's allowed to be edited by the person clicking it.
85 if (m_permissionManager.CanEditObjectPosition(remoteClient.AgentId, ((SceneObjectGroup)ent).UUID) || m_permissionManager.CanEditObject(remoteClient.AgentId, ((SceneObjectGroup)ent).UUID)) 85 if (m_permissionManager.CanEditObjectPosition(remoteClient.AgentId, (ent).UUID) ||
86 m_permissionManager.CanEditObject(remoteClient.AgentId, (ent).UUID))
86 { 87 {
87 ((SceneObjectGroup) ent).GetProperties(remoteClient); 88 ((SceneObjectGroup) ent).GetProperties(remoteClient);
88 ((SceneObjectGroup) ent).IsSelected = true; 89 ((SceneObjectGroup) ent).IsSelected = true;
@@ -107,9 +108,10 @@ namespace OpenSim.Region.Environment.Scenes
107 { 108 {
108 if (ent is SceneObjectGroup) 109 if (ent is SceneObjectGroup)
109 { 110 {
110 if (((SceneObjectGroup) ent).LocalId == primLocalID) 111 if ((ent).LocalId == primLocalID)
111 { 112 {
112 if (m_permissionManager.CanEditObjectPosition(remoteClient.AgentId, ((SceneObjectGroup)ent).UUID) || m_permissionManager.CanEditObject(remoteClient.AgentId, ((SceneObjectGroup)ent).UUID)) 113 if (m_permissionManager.CanEditObjectPosition(remoteClient.AgentId, (ent).UUID) ||
114 m_permissionManager.CanEditObject(remoteClient.AgentId, (ent).UUID))
113 { 115 {
114 ((SceneObjectGroup) ent).IsSelected = false; 116 ((SceneObjectGroup) ent).IsSelected = false;
115 LandChannel.setPrimsTainted(); 117 LandChannel.setPrimsTainted();
@@ -129,21 +131,20 @@ namespace OpenSim.Region.Environment.Scenes
129 } 131 }
130 132
131 public virtual void ProcessParcelBuy(LLUUID agentId, LLUUID groupId, bool final, bool groupOwned, 133 public virtual void ProcessParcelBuy(LLUUID agentId, LLUUID groupId, bool final, bool groupOwned,
132 bool removeContribution, int parcelLocalID, int parcelArea, int parcelPrice, bool authenticated) 134 bool removeContribution, int parcelLocalID, int parcelArea, int parcelPrice, bool authenticated)
133 { 135 {
134 EventManager.LandBuyArgs args = new EventManager.LandBuyArgs( 136 EventManager.LandBuyArgs args = new EventManager.LandBuyArgs(
135 agentId, groupId, final, groupOwned, removeContribution, parcelLocalID, parcelArea, parcelPrice, authenticated); 137 agentId, groupId, final, groupOwned, removeContribution, parcelLocalID, parcelArea, parcelPrice, authenticated);
136 138
137 // First, allow all validators a stab at it 139 // First, allow all validators a stab at it
138 m_eventManager.TriggerValidateLandBuy(this, args); 140 m_eventManager.TriggerValidateLandBuy(this, args);
139 141
140 // Then, check validation and transfer 142 // Then, check validation and transfer
141 m_eventManager.TriggerLandBuy(this, args); 143 m_eventManager.TriggerLandBuy(this, args);
142 } 144 }
143 145
144 public virtual void ProcessObjectGrab(uint localID, LLVector3 offsetPos, IClientAPI remoteClient) 146 public virtual void ProcessObjectGrab(uint localID, LLVector3 offsetPos, IClientAPI remoteClient)
145 { 147 {
146
147 List<EntityBase> EntitieList = GetEntities(); 148 List<EntityBase> EntitieList = GetEntities();
148 149
149 foreach (EntityBase ent in EntitieList) 150 foreach (EntityBase ent in EntitieList)
@@ -178,7 +179,6 @@ namespace OpenSim.Region.Environment.Scenes
178 179
179 public virtual void ProcessObjectDeGrab(uint localID, IClientAPI remoteClient) 180 public virtual void ProcessObjectDeGrab(uint localID, IClientAPI remoteClient)
180 { 181 {
181
182 List<EntityBase> EntitieList = GetEntities(); 182 List<EntityBase> EntitieList = GetEntities();
183 183
184 foreach (EntityBase ent in EntitieList) 184 foreach (EntityBase ent in EntitieList)
@@ -190,7 +190,7 @@ namespace OpenSim.Region.Environment.Scenes
190 // Is this prim part of the group 190 // Is this prim part of the group
191 if (obj.HasChildPrim(localID)) 191 if (obj.HasChildPrim(localID))
192 { 192 {
193 SceneObjectPart part=obj.GetChildPart(localID); 193 SceneObjectPart part = obj.GetChildPart(localID);
194 if (part != null) 194 if (part != null)
195 { 195 {
196 // If the touched prim handles touches, deliver it 196 // If the touched prim handles touches, deliver it
@@ -233,8 +233,8 @@ namespace OpenSim.Region.Environment.Scenes
233 LLUUID translatedIDtem = item.AvatarID; 233 LLUUID translatedIDtem = item.AvatarID;
234 searchData[i] = new AvatarPickerReplyPacket.DataBlock(); 234 searchData[i] = new AvatarPickerReplyPacket.DataBlock();
235 searchData[i].AvatarID = translatedIDtem; 235 searchData[i].AvatarID = translatedIDtem;
236 searchData[i].FirstName = Helpers.StringToField((string) item.firstName); 236 searchData[i].FirstName = Helpers.StringToField(item.firstName);
237 searchData[i].LastName = Helpers.StringToField((string) item.lastName); 237 searchData[i].LastName = Helpers.StringToField(item.lastName);
238 i++; 238 i++;
239 } 239 }
240 if (AvatarResponses.Count == 0) 240 if (AvatarResponses.Count == 0)
@@ -245,4 +245,4 @@ namespace OpenSim.Region.Environment.Scenes
245 client.SendAvatarPickerReply(replyPacket); 245 client.SendAvatarPickerReply(replyPacket);
246 } 246 }
247 } 247 }
248} 248} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs
index 3113831..6617995 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.cs
@@ -53,107 +53,99 @@ namespace OpenSim.Region.Environment.Scenes
53 53
54 public partial class Scene : SceneBase 54 public partial class Scene : SceneBase
55 { 55 {
56 public delegate void SynchronizeSceneHandler(Scene scene); 56 #region Delegates
57 public SynchronizeSceneHandler SynchronizeScene = null;
58 public int splitID = 0;
59
60 #region Fields
61 57
62 protected Timer m_heartbeatTimer = new Timer(); 58 public delegate void SynchronizeSceneHandler(Scene scene);
63 protected Timer m_restartWaitTimer = new Timer();
64 59
65 protected SimStatsReporter m_statsReporter; 60 #endregion
66 61
67 protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>(); 62 public int splitID;
68 protected List<RegionInfo> m_neighbours = new List<RegionInfo>(); 63 public SynchronizeSceneHandler SynchronizeScene;
69 64
70 public InnerScene m_innerScene; 65 #region Fields
71 66
72 private Random Rand = new Random();
73 private uint _primCount = 720000;
74 private readonly Mutex _primAllocateMutex = new Mutex(false); 67 private readonly Mutex _primAllocateMutex = new Mutex(false);
75 68
76 private int m_timePhase = 24;
77
78 private readonly Mutex updateLock;
79 public bool m_physicalPrim;
80 public bool m_seeIntoRegionFromNeighbor;
81 public int MaxUndoCount = 5;
82 private int m_RestartTimerCounter;
83 private readonly Timer m_restartTimer = new Timer(15000); // Wait before firing 69 private readonly Timer m_restartTimer = new Timer(15000); // Wait before firing
84 private int m_incrementsof15seconds = 0; 70 private readonly Mutex updateLock;
85 71 private uint _primCount = 720000;
86 public string m_simulatorVersion = "OpenSimulator 0.5";
87
88 protected ModuleLoader m_moduleLoader;
89 protected StorageManager m_storageManager;
90 protected AgentCircuitManager m_authenticateHandler;
91 public CommunicationsManager CommsManager; 72 public CommunicationsManager CommsManager;
73 private int frameMS;
74 protected AgentCircuitManager m_authenticateHandler;
92 // protected XferManager xferManager; 75 // protected XferManager xferManager;
93 protected SceneCommunicationService m_sceneGridService; 76 protected IAvatarFactory m_AvatarFactory;
94 protected SceneXmlLoader m_sceneXmlLoader;
95 77
96 /// <summary> 78 /// <summary>
97 /// Each agent has its own capabilities handler. 79 /// Each agent has its own capabilities handler.
98 /// </summary> 80 /// </summary>
99 protected Dictionary<LLUUID, Caps> m_capsHandlers = new Dictionary<LLUUID, Caps>(); 81 protected Dictionary<LLUUID, Caps> m_capsHandlers = new Dictionary<LLUUID, Caps>();
100
101 protected BaseHttpServer m_httpListener;
102
103 protected Dictionary<string, IRegionModule> Modules = new Dictionary<string, IRegionModule>();
104 public Dictionary<Type, object> ModuleInterfaces = new Dictionary<Type, object>();
105 protected Dictionary<string, object> ModuleAPIMethods = new Dictionary<string, object>();
106 public Dictionary<string, ICommander> m_moduleCommanders = new Dictionary<string, ICommander>();
107
108 //API module interfaces
109
110 public IXfer XferManager;
111
112 protected IHttpRequests m_httpRequestModule;
113 protected ISimChat m_simChatModule;
114 protected IXMLRPC m_xmlrpcModule;
115 protected IWorldComm m_worldCommModule;
116 protected IAvatarFactory m_AvatarFactory;
117 82
118 // Central Update Loop 83 // Central Update Loop
119 84
120 protected int m_fps = 10; 85 protected int m_fps = 10;
121 protected int m_frame = 0; 86 protected int m_frame;
122 protected float m_timespan = 0.089f; 87 protected Timer m_heartbeatTimer = new Timer();
88 protected BaseHttpServer m_httpListener;
89 protected IHttpRequests m_httpRequestModule;
90 private int m_incrementsof15seconds;
91 public InnerScene m_innerScene;
123 protected DateTime m_lastupdate = DateTime.Now; 92 protected DateTime m_lastupdate = DateTime.Now;
93 public Dictionary<string, ICommander> m_moduleCommanders = new Dictionary<string, ICommander>();
94 protected ModuleLoader m_moduleLoader;
95 protected List<RegionInfo> m_neighbours = new List<RegionInfo>();
96 public bool m_physicalPrim;
97 private bool m_physics_enabled = true;
98 protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>();
99 private int m_RestartTimerCounter;
100 protected Timer m_restartWaitTimer = new Timer();
101 protected SceneCommunicationService m_sceneGridService;
102 protected SceneXmlLoader m_sceneXmlLoader;
103 private bool m_scripts_enabled = true;
104 public bool m_seeIntoRegionFromNeighbor;
105 protected ISimChat m_simChatModule;
106 public string m_simulatorVersion = "OpenSimulator 0.5";
107 protected SimStatsReporter m_statsReporter;
108 protected StorageManager m_storageManager;
124 109
125 protected float m_timedilation = 1.0f; 110 protected float m_timedilation = 1.0f;
111 private int m_timePhase = 24;
112 protected float m_timespan = 0.089f;
113 private int m_update_backup = 200;
126 114
127 private int m_update_physics = 1;
128 private int m_update_entitymovement = 1;
129 private int m_update_entities = 1; // Run through all objects checking for updates 115 private int m_update_entities = 1; // Run through all objects checking for updates
130 private int m_update_entitiesquick = 200; // Run through objects that have scheduled updates checking for updates 116 private int m_update_entitiesquick = 200; // Run through objects that have scheduled updates checking for updates
131 private int m_update_presences = 1; // Update scene presence movements 117 private int m_update_entitymovement = 1;
132 private int m_update_events = 1; 118 private int m_update_events = 1;
133 private int m_update_backup = 200;
134 private int m_update_terrain = 50;
135 private int m_update_land = 1; 119 private int m_update_land = 1;
120 private int m_update_physics = 1;
121 private int m_update_presences = 1; // Update scene presence movements
122 private int m_update_terrain = 50;
123 protected IWorldComm m_worldCommModule;
124 protected IXMLRPC m_xmlrpcModule;
125 public int MaxUndoCount = 5;
126 protected Dictionary<string, object> ModuleAPIMethods = new Dictionary<string, object>();
127 public Dictionary<Type, object> ModuleInterfaces = new Dictionary<Type, object>();
128 protected Dictionary<string, IRegionModule> Modules = new Dictionary<string, IRegionModule>();
136 129
137 private int frameMS = 0; 130 private int otherMS;
138 private int physicsMS2 = 0; 131 private int physicsMS;
139 private int physicsMS = 0; 132 private int physicsMS2;
140 private int otherMS = 0; 133 private Random Rand = new Random();
141 134 public IXfer XferManager;
142 private bool m_physics_enabled = true;
143 private bool m_scripts_enabled = true;
144
145
146 135
147 #endregion 136 #endregion
148 137
149 #region Properties 138 #region Properties
150 139
140 protected readonly EstateManager m_estateManager;
141 protected readonly PermissionManager m_permissionManager;
142 public int objectCapacity = 45000;
143
151 public AgentCircuitManager AuthenticateHandler 144 public AgentCircuitManager AuthenticateHandler
152 { 145 {
153 get { return m_authenticateHandler; } 146 get { return m_authenticateHandler; }
154 } 147 }
155 148
156 protected readonly EstateManager m_estateManager;
157 // an instance to the physics plugin's Scene object. 149 // an instance to the physics plugin's Scene object.
158 public PhysicsScene PhysicsScene 150 public PhysicsScene PhysicsScene
159 { 151 {
@@ -177,7 +169,6 @@ namespace OpenSim.Region.Environment.Scenes
177 get { return m_timedilation; } 169 get { return m_timedilation; }
178 } 170 }
179 171
180 protected readonly PermissionManager m_permissionManager;
181 // This is the instance to the permissions manager. 172 // This is the instance to the permissions manager.
182 // This manages permissions to clients on in world objects 173 // This manages permissions to clients on in world objects
183 174
@@ -215,14 +206,13 @@ namespace OpenSim.Region.Environment.Scenes
215 get { return m_innerScene.Entities; } 206 get { return m_innerScene.Entities; }
216 set { m_innerScene.Entities = value; } 207 set { m_innerScene.Entities = value; }
217 } 208 }
209
218 public Dictionary<LLUUID, ScenePresence> m_restorePresences 210 public Dictionary<LLUUID, ScenePresence> m_restorePresences
219 { 211 {
220 get { return m_innerScene.RestorePresences; } 212 get { return m_innerScene.RestorePresences; }
221 set { m_innerScene.RestorePresences = value; } 213 set { m_innerScene.RestorePresences = value; }
222 } 214 }
223 215
224 public int objectCapacity = 45000;
225
226 #endregion 216 #endregion
227 217
228 #region Constructors 218 #region Constructors
@@ -252,9 +242,9 @@ namespace OpenSim.Region.Environment.Scenes
252 242
253 //Bind Storage Manager functions to some land manager functions for this scene 243 //Bind Storage Manager functions to some land manager functions for this scene
254 EventManager.OnLandObjectAdded += 244 EventManager.OnLandObjectAdded +=
255 new EventManager.LandObjectAdded(m_storageManager.DataStore.StoreLandObject); 245 m_storageManager.DataStore.StoreLandObject;
256 EventManager.OnLandObjectRemoved += 246 EventManager.OnLandObjectRemoved +=
257 new EventManager.LandObjectRemoved(m_storageManager.DataStore.RemoveLandObject); 247 m_storageManager.DataStore.RemoveLandObject;
258 248
259 m_estateManager = new EstateManager(this, m_regInfo); 249 m_estateManager = new EstateManager(this, m_regInfo);
260 250
@@ -321,7 +311,7 @@ namespace OpenSim.Region.Environment.Scenes
321 OSString = OSString.Substring(0, 45); 311 OSString = OSString.Substring(0, 45);
322 } 312 }
323 313
324 m_simulatorVersion = "OpenSimulator v0.5-SVN on " + OSString + " ChilTasks:" + m_seeIntoRegionFromNeighbor.ToString() + " PhysPrim:" + m_physicalPrim.ToString(); 314 m_simulatorVersion = "OpenSimulator v0.5-SVN on " + OSString + " ChilTasks:" + m_seeIntoRegionFromNeighbor + " PhysPrim:" + m_physicalPrim;
325 } 315 }
326 316
327 #endregion 317 #endregion
@@ -382,23 +372,23 @@ namespace OpenSim.Region.Environment.Scenes
382 } 372 }
383 // If these are cast to INT because long + negative values + abs returns invalid data 373 // If these are cast to INT because long + negative values + abs returns invalid data
384 374
385 int resultX = Math.Abs((int)otherRegion.RegionLocX - (int)RegionInfo.RegionLocX); 375 int resultX = Math.Abs((int) otherRegion.RegionLocX - (int) RegionInfo.RegionLocX);
386 int resultY = Math.Abs((int)otherRegion.RegionLocY - (int)RegionInfo.RegionLocY); 376 int resultY = Math.Abs((int) otherRegion.RegionLocY - (int) RegionInfo.RegionLocY);
387 if ((resultX <= 1) && 377 if ((resultX <= 1) &&
388 (resultY <= 1)) 378 (resultY <= 1))
389 { 379 {
390 try 380 try
391 { 381 {
392 ForEachScenePresence(delegate(ScenePresence agent) 382 ForEachScenePresence(delegate(ScenePresence agent)
393 {
394 // If agent is a root agent.
395 if (!agent.IsChildAgent)
396 { 383 {
397 //agent.ControllingClient.new 384 // If agent is a root agent.
398 //this.CommsManager.InterRegion.InformRegionOfChildAgent(otherRegion.RegionHandle, agent.ControllingClient.RequestClientInfo()); 385 if (!agent.IsChildAgent)
399 InformClientOfNeighbor(agent, otherRegion); 386 {
387 //agent.ControllingClient.new
388 //this.CommsManager.InterRegion.InformRegionOfChildAgent(otherRegion.RegionHandle, agent.ControllingClient.RequestClientInfo());
389 InformClientOfNeighbor(agent, otherRegion);
390 }
400 } 391 }
401 }
402 ); 392 );
403 } 393 }
404 catch (NullReferenceException) 394 catch (NullReferenceException)
@@ -410,9 +400,9 @@ namespace OpenSim.Region.Environment.Scenes
410 } 400 }
411 else 401 else
412 { 402 {
413 m_log.Info("[INTERGRID]: Got notice about far away Region: " + otherRegion.RegionName.ToString() + 403 m_log.Info("[INTERGRID]: Got notice about far away Region: " + otherRegion.RegionName +
414 " at (" + otherRegion.RegionLocX.ToString() + ", " + 404 " at (" + otherRegion.RegionLocX + ", " +
415 otherRegion.RegionLocY.ToString() + ")"); 405 otherRegion.RegionLocY + ")");
416 } 406 }
417 } 407 }
418 return true; 408 return true;
@@ -436,10 +426,10 @@ namespace OpenSim.Region.Environment.Scenes
436 { 426 {
437 // Now we figure out what to set the timer to that does the notifications and calls, RestartNow() 427 // Now we figure out what to set the timer to that does the notifications and calls, RestartNow()
438 m_restartTimer.Interval = 15000; 428 m_restartTimer.Interval = 15000;
439 m_incrementsof15seconds = (int)seconds / 15; 429 m_incrementsof15seconds = (int) seconds / 15;
440 m_RestartTimerCounter = 0; 430 m_RestartTimerCounter = 0;
441 m_restartTimer.AutoReset = true; 431 m_restartTimer.AutoReset = true;
442 m_restartTimer.Elapsed += new ElapsedEventHandler(RestartTimer_Elapsed); 432 m_restartTimer.Elapsed += RestartTimer_Elapsed;
443 m_log.Error("[REGION]: Restarting Region in " + (seconds / 60) + " minutes"); 433 m_log.Error("[REGION]: Restarting Region in " + (seconds / 60) + " minutes");
444 m_restartTimer.Start(); 434 m_restartTimer.Start();
445 SendRegionMessageFromEstateTools(LLUUID.Random(), LLUUID.Random(), String.Empty, RegionInfo.RegionName + ": Restarting in 2 Minutes"); 435 SendRegionMessageFromEstateTools(LLUUID.Random(), LLUUID.Random(), String.Empty, RegionInfo.RegionName + ": Restarting in 2 Minutes");
@@ -458,7 +448,7 @@ namespace OpenSim.Region.Environment.Scenes
458 { 448 {
459 if (m_RestartTimerCounter == 4 || m_RestartTimerCounter == 6 || m_RestartTimerCounter == 7) 449 if (m_RestartTimerCounter == 4 || m_RestartTimerCounter == 6 || m_RestartTimerCounter == 7)
460 SendRegionMessageFromEstateTools(LLUUID.Random(), LLUUID.Random(), String.Empty, RegionInfo.RegionName + ": Restarting in " + 450 SendRegionMessageFromEstateTools(LLUUID.Random(), LLUUID.Random(), String.Empty, RegionInfo.RegionName + ": Restarting in " +
461 ((8 - m_RestartTimerCounter) * 15) + " seconds"); 451 ((8 - m_RestartTimerCounter) * 15) + " seconds");
462 452
463 // SendGeneralAlert(RegionInfo.RegionName + ": Restarting in " + ((8 - m_RestartTimerCounter)*15) + 453 // SendGeneralAlert(RegionInfo.RegionName + ": Restarting in " + ((8 - m_RestartTimerCounter)*15) +
464 //" seconds"); 454 //" seconds");
@@ -500,15 +490,15 @@ namespace OpenSim.Region.Environment.Scenes
500 try 490 try
501 { 491 {
502 ForEachScenePresence(delegate(ScenePresence agent) 492 ForEachScenePresence(delegate(ScenePresence agent)
503 {
504 // If agent is a root agent.
505 if (!agent.IsChildAgent)
506 { 493 {
507 //agent.ControllingClient.new 494 // If agent is a root agent.
508 //this.CommsManager.InterRegion.InformRegionOfChildAgent(otherRegion.RegionHandle, agent.ControllingClient.RequestClientInfo()); 495 if (!agent.IsChildAgent)
509 InformClientOfNeighbor(agent, region); 496 {
497 //agent.ControllingClient.new
498 //this.CommsManager.InterRegion.InformRegionOfChildAgent(otherRegion.RegionHandle, agent.ControllingClient.RequestClientInfo());
499 InformClientOfNeighbor(agent, region);
500 }
510 } 501 }
511 }
512 ); 502 );
513 } 503 }
514 catch (NullReferenceException) 504 catch (NullReferenceException)
@@ -537,7 +527,7 @@ namespace OpenSim.Region.Environment.Scenes
537 { 527 {
538 if (ent is SceneObjectGroup) 528 if (ent is SceneObjectGroup)
539 { 529 {
540 ((SceneObjectGroup)ent).StopScripts(); 530 ((SceneObjectGroup) ent).StopScripts();
541 } 531 }
542 } 532 }
543 } 533 }
@@ -551,12 +541,10 @@ namespace OpenSim.Region.Environment.Scenes
551 { 541 {
552 if (ent is SceneObjectGroup) 542 if (ent is SceneObjectGroup)
553 { 543 {
554 ((SceneObjectGroup)ent).StartScripts(); 544 ((SceneObjectGroup) ent).StartScripts();
555 } 545 }
556 } 546 }
557 } 547 }
558
559
560 } 548 }
561 m_scripts_enabled = !ScriptEngine; 549 m_scripts_enabled = !ScriptEngine;
562 m_log.Info("[TOTEDD]: Here is the method to trigger disabling of the scripting engine"); 550 m_log.Info("[TOTEDD]: Here is the method to trigger disabling of the scripting engine");
@@ -564,9 +552,7 @@ namespace OpenSim.Region.Environment.Scenes
564 if (m_physics_enabled != !PhysicsEngine) 552 if (m_physics_enabled != !PhysicsEngine)
565 { 553 {
566 m_physics_enabled = !PhysicsEngine; 554 m_physics_enabled = !PhysicsEngine;
567
568 } 555 }
569
570 } 556 }
571 557
572 // This is the method that shuts down the scene. 558 // This is the method that shuts down the scene.
@@ -575,16 +561,16 @@ namespace OpenSim.Region.Environment.Scenes
575 m_log.Warn("[SCENE]: Closing down the single simulator: " + RegionInfo.RegionName); 561 m_log.Warn("[SCENE]: Closing down the single simulator: " + RegionInfo.RegionName);
576 // Kick all ROOT agents with the message, 'The simulator is going down' 562 // Kick all ROOT agents with the message, 'The simulator is going down'
577 ForEachScenePresence(delegate(ScenePresence avatar) 563 ForEachScenePresence(delegate(ScenePresence avatar)
578 { 564 {
579 if (avatar.KnownChildRegions.Contains(RegionInfo.RegionHandle)) 565 if (avatar.KnownChildRegions.Contains(RegionInfo.RegionHandle))
580 avatar.KnownChildRegions.Remove(RegionInfo.RegionHandle); 566 avatar.KnownChildRegions.Remove(RegionInfo.RegionHandle);
581 567
582 if (!avatar.IsChildAgent) 568 if (!avatar.IsChildAgent)
583 avatar.ControllingClient.Kick("The simulator is going down."); 569 avatar.ControllingClient.Kick("The simulator is going down.");
584 570
585 avatar.ControllingClient.OutPacket(PacketPool.Instance.GetPacket(PacketType.DisableSimulator), 571 avatar.ControllingClient.OutPacket(PacketPool.Instance.GetPacket(PacketType.DisableSimulator),
586 ThrottleOutPacketType.Task); 572 ThrottleOutPacketType.Task);
587 }); 573 });
588 574
589 // Wait here, or the kick messages won't actually get to the agents before the scene terminates. 575 // Wait here, or the kick messages won't actually get to the agents before the scene terminates.
590 Thread.Sleep(500); 576 Thread.Sleep(500);
@@ -619,8 +605,8 @@ namespace OpenSim.Region.Environment.Scenes
619 { 605 {
620 m_log.Debug("[SCENE]: Starting timer"); 606 m_log.Debug("[SCENE]: Starting timer");
621 m_heartbeatTimer.Enabled = true; 607 m_heartbeatTimer.Enabled = true;
622 m_heartbeatTimer.Interval = (int)(m_timespan * 1000); 608 m_heartbeatTimer.Interval = (int) (m_timespan * 1000);
623 m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); 609 m_heartbeatTimer.Elapsed += Heartbeat;
624 } 610 }
625 611
626 public void SetModuleInterfaces() 612 public void SetModuleInterfaces()
@@ -722,13 +708,13 @@ namespace OpenSim.Region.Environment.Scenes
722 { 708 {
723 if (m_frame % m_update_events == 0) 709 if (m_frame % m_update_events == 0)
724 UpdateEvents(); 710 UpdateEvents();
725 711
726 if (m_frame % m_update_backup == 0) 712 if (m_frame % m_update_backup == 0)
727 UpdateStorageBackup(); 713 UpdateStorageBackup();
728 714
729 if (m_frame % m_update_terrain == 0) 715 if (m_frame % m_update_terrain == 0)
730 UpdateTerrain(); 716 UpdateTerrain();
731 717
732 if (m_frame % m_update_land == 0) 718 if (m_frame % m_update_land == 0)
733 UpdateLand(); 719 UpdateLand();
734 otherMS = System.Environment.TickCount - otherMS; 720 otherMS = System.Environment.TickCount - otherMS;
@@ -756,28 +742,25 @@ namespace OpenSim.Region.Environment.Scenes
756 } 742 }
757 catch (AccessViolationException e) 743 catch (AccessViolationException e)
758 { 744 {
759 m_log.Error("[Scene]: Failed with exception " + e.ToString() + " On Region: " + RegionInfo.RegionName); 745 m_log.Error("[Scene]: Failed with exception " + e + " On Region: " + RegionInfo.RegionName);
760
761 } 746 }
762 catch (NullReferenceException e) 747 catch (NullReferenceException e)
763 { 748 {
764 m_log.Error("[Scene]: Failed with exception " + e.ToString() + " On Region: " + RegionInfo.RegionName); 749 m_log.Error("[Scene]: Failed with exception " + e + " On Region: " + RegionInfo.RegionName);
765
766 } 750 }
767 catch (InvalidOperationException e) 751 catch (InvalidOperationException e)
768 { 752 {
769 m_log.Error("[Scene]: Failed with exception " + e.ToString() + " On Region: " + RegionInfo.RegionName); 753 m_log.Error("[Scene]: Failed with exception " + e + " On Region: " + RegionInfo.RegionName);
770
771 } 754 }
772 catch (Exception e) 755 catch (Exception e)
773 { 756 {
774 m_log.Error("[Scene]: Failed with exception " + e.ToString() + " On Region: " + RegionInfo.RegionName); 757 m_log.Error("[Scene]: Failed with exception " + e + " On Region: " + RegionInfo.RegionName);
775 } 758 }
776 finally 759 finally
777 { 760 {
778 updateLock.ReleaseMutex(); 761 updateLock.ReleaseMutex();
779 // Get actual time dilation 762 // Get actual time dilation
780 float tmpval = (m_timespan / (float)SinceLastFrame.TotalSeconds); 763 float tmpval = (m_timespan / (float) SinceLastFrame.TotalSeconds);
781 764
782 // If actual time dilation is greater then one, we're catching up, so subtract 765 // If actual time dilation is greater then one, we're catching up, so subtract
783 // the amount that's greater then 1 from the time dilation 766 // the amount that's greater then 1 from the time dilation
@@ -786,7 +769,7 @@ namespace OpenSim.Region.Environment.Scenes
786 tmpval = tmpval - (tmpval - 1.0f); 769 tmpval = tmpval - (tmpval - 1.0f);
787 } 770 }
788 m_timedilation = tmpval; 771 m_timedilation = tmpval;
789 772
790 m_lastupdate = DateTime.Now; 773 m_lastupdate = DateTime.Now;
791 } 774 }
792 } 775 }
@@ -856,10 +839,10 @@ namespace OpenSim.Region.Environment.Scenes
856 public void ExportWorldMap(string fileName) 839 public void ExportWorldMap(string fileName)
857 { 840 {
858 List<MapBlockData> mapBlocks = 841 List<MapBlockData> mapBlocks =
859 m_sceneGridService.RequestNeighbourMapBlocks((int)(RegionInfo.RegionLocX - 9), 842 m_sceneGridService.RequestNeighbourMapBlocks((int) (RegionInfo.RegionLocX - 9),
860 (int)(RegionInfo.RegionLocY - 9), 843 (int) (RegionInfo.RegionLocY - 9),
861 (int)(RegionInfo.RegionLocX + 9), 844 (int) (RegionInfo.RegionLocX + 9),
862 (int)(RegionInfo.RegionLocY + 9)); 845 (int) (RegionInfo.RegionLocY + 9));
863 List<AssetBase> textures = new List<AssetBase>(); 846 List<AssetBase> textures = new List<AssetBase>();
864 List<Image> bitImages = new List<Image>(); 847 List<Image> bitImages = new List<Image>();
865 848
@@ -894,8 +877,8 @@ namespace OpenSim.Region.Environment.Scenes
894 877
895 for (int i = 0; i < mapBlocks.Count; i++) 878 for (int i = 0; i < mapBlocks.Count; i++)
896 { 879 {
897 ushort x = (ushort)((mapBlocks[i].X - RegionInfo.RegionLocX) + 10); 880 ushort x = (ushort) ((mapBlocks[i].X - RegionInfo.RegionLocX) + 10);
898 ushort y = (ushort)((mapBlocks[i].Y - RegionInfo.RegionLocY) + 10); 881 ushort y = (ushort) ((mapBlocks[i].Y - RegionInfo.RegionLocY) + 10);
899 g.DrawImage(bitImages[i], (x * 128), (y * 128), 128, 128); 882 g.DrawImage(bitImages[i], (x * 128), (y * 128), 128, 128);
900 } 883 }
901 mapTexture.Save(fileName, ImageFormat.Jpeg); 884 mapTexture.Save(fileName, ImageFormat.Jpeg);
@@ -926,11 +909,10 @@ namespace OpenSim.Region.Environment.Scenes
926 { 909 {
927 Heightmap = new TerrainChannel(map); 910 Heightmap = new TerrainChannel(map);
928 } 911 }
929
930 } 912 }
931 catch (Exception e) 913 catch (Exception e)
932 { 914 {
933 m_log.Warn("[terrain]: Scene.cs: LoadWorldMap() - Failed with exception " + e.ToString()); 915 m_log.Warn("[terrain]: Scene.cs: LoadWorldMap() - Failed with exception " + e);
934 } 916 }
935 } 917 }
936 918
@@ -991,7 +973,7 @@ namespace OpenSim.Region.Environment.Scenes
991 { 973 {
992 for (int y = 0; y < 256; y++) 974 for (int y = 0; y < 256; y++)
993 { 975 {
994 float hmval = (float)hm[x, y]; 976 float hmval = (float) hm[x, y];
995 if (hmval < low) 977 if (hmval < low)
996 low = hmval; 978 low = hmval;
997 if (hmval > high) 979 if (hmval > high)
@@ -1021,10 +1003,10 @@ namespace OpenSim.Region.Environment.Scenes
1021 //} 1003 //}
1022 //else 1004 //else
1023 //{ 1005 //{
1024 float tmpval = (float)hm[x, y]; 1006 float tmpval = (float) hm[x, y];
1025 heightvalue = (float)hm[x, y]; 1007 heightvalue = (float) hm[x, y];
1026 1008
1027 if ((float)heightvalue > m_regInfo.EstateSettings.waterHeight) 1009 if (heightvalue > m_regInfo.EstateSettings.waterHeight)
1028 { 1010 {
1029 // scale height value 1011 // scale height value
1030 heightvalue = low + mid * (heightvalue - low) / mid; 1012 heightvalue = low + mid * (heightvalue - low) / mid;
@@ -1036,7 +1018,7 @@ namespace OpenSim.Region.Environment.Scenes
1036 heightvalue = 0; 1018 heightvalue = 0;
1037 1019
1038 1020
1039 Color green = Color.FromArgb((int)heightvalue, 100, (int)heightvalue); 1021 Color green = Color.FromArgb((int) heightvalue, 100, (int) heightvalue);
1040 1022
1041 // Y flip the cordinates 1023 // Y flip the cordinates
1042 mapbmp.SetPixel(x, (256 - y) - 1, green); 1024 mapbmp.SetPixel(x, (256 - y) - 1, green);
@@ -1058,12 +1040,10 @@ namespace OpenSim.Region.Environment.Scenes
1058 if (heightvalue < 0) 1040 if (heightvalue < 0)
1059 heightvalue = 0; 1041 heightvalue = 0;
1060 1042
1061 Color water = Color.FromArgb((int)heightvalue, (int)heightvalue, 255); 1043 Color water = Color.FromArgb((int) heightvalue, (int) heightvalue, 255);
1062 mapbmp.SetPixel(x, (256 - y) - 1, water); 1044 mapbmp.SetPixel(x, (256 - y) - 1, water);
1063 } 1045 }
1064 //} 1046 //}
1065
1066
1067 } 1047 }
1068 //tc = System.Environment.TickCount - tc; 1048 //tc = System.Environment.TickCount - tc;
1069 //m_log.Info("[MAPTILE]: Completed One row in " + tc + " ms"); 1049 //m_log.Info("[MAPTILE]: Completed One row in " + tc + " ms");
@@ -1087,7 +1067,6 @@ namespace OpenSim.Region.Environment.Scenes
1087 asset.Type = 0; 1067 asset.Type = 0;
1088 asset.Temporary = temporary; 1068 asset.Temporary = temporary;
1089 AssetCache.AddAsset(asset); 1069 AssetCache.AddAsset(asset);
1090
1091 } 1070 }
1092 else 1071 else
1093 { 1072 {
@@ -1105,7 +1084,6 @@ namespace OpenSim.Region.Environment.Scenes
1105 AssetCache.AddAsset(asset); 1084 AssetCache.AddAsset(asset);
1106 } 1085 }
1107 } 1086 }
1108
1109 } 1087 }
1110 1088
1111 #endregion 1089 #endregion
@@ -1143,14 +1121,14 @@ namespace OpenSim.Region.Environment.Scenes
1143 { 1121 {
1144 AddEntityFromStorage(group); 1122 AddEntityFromStorage(group);
1145 SceneObjectPart rootPart = group.GetChildPart(group.UUID); 1123 SceneObjectPart rootPart = group.GetChildPart(group.UUID);
1146 rootPart.ObjectFlags &= ~(uint)LLObject.ObjectFlags.Scripted; 1124 rootPart.ObjectFlags &= ~(uint) LLObject.ObjectFlags.Scripted;
1147 rootPart.TrimPermissions(); 1125 rootPart.TrimPermissions();
1148 1126
1149 group.ApplyPhysics(m_physicalPrim); 1127 group.ApplyPhysics(m_physicalPrim);
1150 //rootPart.DoPhysicsPropertyUpdate(UsePhysics, true); 1128 //rootPart.DoPhysicsPropertyUpdate(UsePhysics, true);
1151 } 1129 }
1152 1130
1153 m_log.Info("[SCENE]: Loaded " + PrimsFromDB.Count.ToString() + " SceneObject(s)"); 1131 m_log.Info("[SCENE]: Loaded " + PrimsFromDB.Count + " SceneObject(s)");
1154 } 1132 }
1155 1133
1156 /// <summary> 1134 /// <summary>
@@ -1169,10 +1147,11 @@ namespace OpenSim.Region.Environment.Scenes
1169 return myID; 1147 return myID;
1170 } 1148 }
1171 1149
1172 public LLVector3 GetNewRezLocation(LLVector3 RayStart, LLVector3 RayEnd, LLUUID RayTargetID, LLQuaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, LLVector3 scale, bool FaceCenter) 1150 public LLVector3 GetNewRezLocation(LLVector3 RayStart, LLVector3 RayEnd, LLUUID RayTargetID, LLQuaternion rot, byte bypassRayCast,
1151 byte RayEndIsIntersection, bool frontFacesOnly, LLVector3 scale, bool FaceCenter)
1173 { 1152 {
1174 LLVector3 pos = LLVector3.Zero; 1153 LLVector3 pos = LLVector3.Zero;
1175 if (RayEndIsIntersection == (byte)1) 1154 if (RayEndIsIntersection == 1)
1176 { 1155 {
1177 pos = RayEnd; 1156 pos = RayEnd;
1178 return pos; 1157 return pos;
@@ -1180,7 +1159,7 @@ namespace OpenSim.Region.Environment.Scenes
1180 if (RayTargetID != LLUUID.Zero) 1159 if (RayTargetID != LLUUID.Zero)
1181 { 1160 {
1182 SceneObjectPart target = GetSceneObjectPart(RayTargetID); 1161 SceneObjectPart target = GetSceneObjectPart(RayTargetID);
1183 1162
1184 LLVector3 direction = LLVector3.Norm(RayEnd - RayStart); 1163 LLVector3 direction = LLVector3.Norm(RayEnd - RayStart);
1185 Vector3 AXOrigin = new Vector3(RayStart.X, RayStart.Y, RayStart.Z); 1164 Vector3 AXOrigin = new Vector3(RayStart.X, RayStart.Y, RayStart.Z);
1186 Vector3 AXdirection = new Vector3(direction.X, direction.Y, direction.Z); 1165 Vector3 AXdirection = new Vector3(direction.X, direction.Y, direction.Z);
@@ -1189,17 +1168,17 @@ namespace OpenSim.Region.Environment.Scenes
1189 { 1168 {
1190 pos = target.AbsolutePosition; 1169 pos = target.AbsolutePosition;
1191 //m_log.Info("[OBJECT_REZ]: TargetPos: " + pos.ToString() + ", RayStart: " + RayStart.ToString() + ", RayEnd: " + RayEnd.ToString() + ", Volume: " + Util.GetDistanceTo(RayStart,RayEnd).ToString() + ", mag1: " + Util.GetMagnitude(RayStart).ToString() + ", mag2: " + Util.GetMagnitude(RayEnd).ToString()); 1170 //m_log.Info("[OBJECT_REZ]: TargetPos: " + pos.ToString() + ", RayStart: " + RayStart.ToString() + ", RayEnd: " + RayEnd.ToString() + ", Volume: " + Util.GetDistanceTo(RayStart,RayEnd).ToString() + ", mag1: " + Util.GetMagnitude(RayStart).ToString() + ", mag2: " + Util.GetMagnitude(RayEnd).ToString());
1192 1171
1193 // TODO: Raytrace better here 1172 // TODO: Raytrace better here
1194 1173
1195 //EntityIntersection ei = m_innerScene.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection)); 1174 //EntityIntersection ei = m_innerScene.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection));
1196 Ray NewRay = new Ray(AXOrigin, AXdirection); 1175 Ray NewRay = new Ray(AXOrigin, AXdirection);
1197 1176
1198 // Ray Trace against target here 1177 // Ray Trace against target here
1199 EntityIntersection ei = target.TestIntersectionOBB(NewRay, new Quaternion(1,0,0,0), frontFacesOnly, FaceCenter); 1178 EntityIntersection ei = target.TestIntersectionOBB(NewRay, new Quaternion(1, 0, 0, 0), frontFacesOnly, FaceCenter);
1200 1179
1201 // Un-comment out the following line to Get Raytrace results printed to the console. 1180 // Un-comment out the following line to Get Raytrace results printed to the console.
1202 // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); 1181 // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString());
1203 float ScaleOffset = 0.5f; 1182 float ScaleOffset = 0.5f;
1204 1183
1205 // If we hit something 1184 // If we hit something
@@ -1215,13 +1194,12 @@ namespace OpenSim.Region.Environment.Scenes
1215 // Set the position to the intersection point 1194 // Set the position to the intersection point
1216 LLVector3 offset = (normal * (ScaleOffset / 2f)); 1195 LLVector3 offset = (normal * (ScaleOffset / 2f));
1217 pos = (intersectionpoint + offset); 1196 pos = (intersectionpoint + offset);
1218 1197
1219 // Un-offset the prim (it gets offset later by the consumer method) 1198 // Un-offset the prim (it gets offset later by the consumer method)
1220 pos.Z -= 0.25F; 1199 pos.Z -= 0.25F;
1221 1200 }
1222 } 1201
1223 1202
1224
1225 return pos; 1203 return pos;
1226 } 1204 }
1227 else 1205 else
@@ -1236,8 +1214,8 @@ namespace OpenSim.Region.Environment.Scenes
1236 if (ei.HitTF) 1214 if (ei.HitTF)
1237 { 1215 {
1238 pos = new LLVector3(ei.ipoint.x, ei.ipoint.y, ei.ipoint.z); 1216 pos = new LLVector3(ei.ipoint.x, ei.ipoint.y, ei.ipoint.z);
1239 } 1217 }
1240 1218
1241 return pos; 1219 return pos;
1242 } 1220 }
1243 } 1221 }
@@ -1253,8 +1231,8 @@ namespace OpenSim.Region.Environment.Scenes
1253 byte bypassRaycast, LLVector3 RayStart, LLUUID RayTargetID, 1231 byte bypassRaycast, LLVector3 RayStart, LLUUID RayTargetID,
1254 byte RayEndIsIntersection) 1232 byte RayEndIsIntersection)
1255 { 1233 {
1256 1234 LLVector3 pos = GetNewRezLocation(RayStart, RayEnd, RayTargetID, rot, bypassRaycast, RayEndIsIntersection, true, new LLVector3(0.5f, 0.5f, 0.5f),
1257 LLVector3 pos = GetNewRezLocation(RayStart, RayEnd, RayTargetID, rot, bypassRaycast, RayEndIsIntersection, true, new LLVector3(0.5f,0.5f,0.5f), false); 1235 false);
1258 1236
1259 if (PermissionsMngr.CanRezObject(ownerID, pos)) 1237 if (PermissionsMngr.CanRezObject(ownerID, pos))
1260 { 1238 {
@@ -1274,7 +1252,7 @@ namespace OpenSim.Region.Environment.Scenes
1274 SceneObjectPart rootPart = sceneOb.GetChildPart(sceneOb.UUID); 1252 SceneObjectPart rootPart = sceneOb.GetChildPart(sceneOb.UUID);
1275 // if grass or tree, make phantom 1253 // if grass or tree, make phantom
1276 //rootPart.TrimPermissions(); 1254 //rootPart.TrimPermissions();
1277 if ((rootPart.Shape.PCode == (byte)PCode.Grass) || (rootPart.Shape.PCode == (byte)PCode.Tree) || (rootPart.Shape.PCode == (byte)PCode.NewTree)) 1255 if ((rootPart.Shape.PCode == (byte) PCode.Grass) || (rootPart.Shape.PCode == (byte) PCode.Tree) || (rootPart.Shape.PCode == (byte) PCode.NewTree))
1278 { 1256 {
1279 rootPart.AddFlag(LLObject.ObjectFlags.Phantom); 1257 rootPart.AddFlag(LLObject.ObjectFlags.Phantom);
1280 //rootPart.ObjectFlags += (uint)LLObject.ObjectFlags.Phantom; 1258 //rootPart.ObjectFlags += (uint)LLObject.ObjectFlags.Phantom;
@@ -1289,13 +1267,13 @@ namespace OpenSim.Region.Environment.Scenes
1289 public SceneObjectGroup AddTree(LLVector3 scale, LLQuaternion rotation, LLVector3 position, 1267 public SceneObjectGroup AddTree(LLVector3 scale, LLQuaternion rotation, LLVector3 position,
1290 Tree treeType, bool newTree) 1268 Tree treeType, bool newTree)
1291 { 1269 {
1292 LLUUID uuid = this.RegionInfo.MasterAvatarAssignedUUID; 1270 LLUUID uuid = RegionInfo.MasterAvatarAssignedUUID;
1293 PrimitiveBaseShape treeShape = new PrimitiveBaseShape(); 1271 PrimitiveBaseShape treeShape = new PrimitiveBaseShape();
1294 treeShape.PathCurve = 16; 1272 treeShape.PathCurve = 16;
1295 treeShape.PathEnd = 49900; 1273 treeShape.PathEnd = 49900;
1296 treeShape.PCode = newTree ? (byte)PCode.NewTree : (byte)PCode.Tree; 1274 treeShape.PCode = newTree ? (byte) PCode.NewTree : (byte) PCode.Tree;
1297 treeShape.Scale = scale; 1275 treeShape.Scale = scale;
1298 treeShape.State = (byte)treeType; 1276 treeShape.State = (byte) treeType;
1299 return AddNewPrim(uuid, position, rotation, treeShape); 1277 return AddNewPrim(uuid, position, rotation, treeShape);
1300 } 1278 }
1301 1279
@@ -1360,12 +1338,11 @@ namespace OpenSim.Region.Environment.Scenes
1360 /// </summary> 1338 /// </summary>
1361 /// <param name="position">current position of Group</param> 1339 /// <param name="position">current position of Group</param>
1362 /// <param name="grp">Scene Object Group that we're crossing</param> 1340 /// <param name="grp">Scene Object Group that we're crossing</param>
1363
1364 public void CrossPrimGroupIntoNewRegion(LLVector3 position, SceneObjectGroup grp) 1341 public void CrossPrimGroupIntoNewRegion(LLVector3 position, SceneObjectGroup grp)
1365 { 1342 {
1366 m_log.Warn("Prim crossing: " + grp.UUID.ToString()); 1343 m_log.Warn("Prim crossing: " + grp.UUID);
1367 int thisx = (int)RegionInfo.RegionLocX; 1344 int thisx = (int) RegionInfo.RegionLocX;
1368 int thisy = (int)RegionInfo.RegionLocY; 1345 int thisy = (int) RegionInfo.RegionLocY;
1369 1346
1370 ulong newRegionHandle = 0; 1347 ulong newRegionHandle = 0;
1371 LLVector3 pos = position; 1348 LLVector3 pos = position;
@@ -1374,43 +1351,44 @@ namespace OpenSim.Region.Environment.Scenes
1374 { 1351 {
1375 pos.X = ((pos.X - Constants.RegionSize)); 1352 pos.X = ((pos.X - Constants.RegionSize));
1376 1353
1377 newRegionHandle = Util.UIntsToLong((uint)((thisx + 1) * Constants.RegionSize), (uint)(thisy * Constants.RegionSize)); 1354 newRegionHandle = Util.UIntsToLong((uint) ((thisx + 1) * Constants.RegionSize), (uint) (thisy * Constants.RegionSize));
1378 1355
1379 // x + 1 1356 // x + 1
1380 } 1357 }
1381 else if (position.X < -0.1f) 1358 else if (position.X < -0.1f)
1382 { 1359 {
1383 pos.X = ((pos.X + Constants.RegionSize)); 1360 pos.X = ((pos.X + Constants.RegionSize));
1384 newRegionHandle = Util.UIntsToLong((uint)((thisx - 1) * Constants.RegionSize), (uint)(thisy * Constants.RegionSize)); 1361 newRegionHandle = Util.UIntsToLong((uint) ((thisx - 1) * Constants.RegionSize), (uint) (thisy * Constants.RegionSize));
1385 // x - 1 1362 // x - 1
1386 } 1363 }
1387 1364
1388 if (position.Y > Constants.RegionSize + 0.1f) 1365 if (position.Y > Constants.RegionSize + 0.1f)
1389 { 1366 {
1390 pos.Y = ((pos.Y - Constants.RegionSize)); 1367 pos.Y = ((pos.Y - Constants.RegionSize));
1391 newRegionHandle = Util.UIntsToLong((uint)(thisx * Constants.RegionSize), (uint)((thisy + 1) * Constants.RegionSize)); 1368 newRegionHandle = Util.UIntsToLong((uint) (thisx * Constants.RegionSize), (uint) ((thisy + 1) * Constants.RegionSize));
1392 // y + 1 1369 // y + 1
1393 } 1370 }
1394 else if (position.Y < -1f) 1371 else if (position.Y < -1f)
1395 { 1372 {
1396 pos.Y = ((pos.Y + Constants.RegionSize)); 1373 pos.Y = ((pos.Y + Constants.RegionSize));
1397 newRegionHandle = Util.UIntsToLong((uint)(thisx * Constants.RegionSize), (uint)((thisy - 1) * Constants.RegionSize)); 1374 newRegionHandle = Util.UIntsToLong((uint) (thisx * Constants.RegionSize), (uint) ((thisy - 1) * Constants.RegionSize));
1398 // y - 1 1375 // y - 1
1399 } 1376 }
1400 1377
1401 // Offset the positions for the new region across the border 1378 // Offset the positions for the new region across the border
1402 grp.OffsetForNewRegion(pos); 1379 grp.OffsetForNewRegion(pos);
1403
1404 CrossPrimGroupIntoNewRegion(newRegionHandle, grp);
1405 1380
1381 CrossPrimGroupIntoNewRegion(newRegionHandle, grp);
1406 } 1382 }
1383
1407 public void CrossPrimGroupIntoNewRegion(ulong newRegionHandle, SceneObjectGroup grp) 1384 public void CrossPrimGroupIntoNewRegion(ulong newRegionHandle, SceneObjectGroup grp)
1408 { 1385 {
1409 int primcrossingXMLmethod = 0; 1386 int primcrossingXMLmethod = 0;
1410 if (newRegionHandle != 0) 1387 if (newRegionHandle != 0)
1411 { 1388 {
1412 bool successYN = false; 1389 bool successYN = false;
1413 successYN = m_sceneGridService.PrimCrossToNeighboringRegion(newRegionHandle, grp.UUID, m_sceneXmlLoader.SavePrimGroupToXML2String(grp), primcrossingXMLmethod); 1390 successYN = m_sceneGridService.PrimCrossToNeighboringRegion(newRegionHandle, grp.UUID, m_sceneXmlLoader.SavePrimGroupToXML2String(grp),
1391 primcrossingXMLmethod);
1414 if (successYN) 1392 if (successYN)
1415 { 1393 {
1416 // We remove the object here 1394 // We remove the object here
@@ -1446,7 +1424,7 @@ namespace OpenSim.Region.Environment.Scenes
1446 SceneObjectPart RootPrim = GetSceneObjectPart(primID); 1424 SceneObjectPart RootPrim = GetSceneObjectPart(primID);
1447 if (RootPrim != null) 1425 if (RootPrim != null)
1448 { 1426 {
1449 if (RootPrim.Shape.PCode == (byte)PCode.Prim) 1427 if (RootPrim.Shape.PCode == (byte) PCode.Prim)
1450 { 1428 {
1451 SceneObjectGroup grp = RootPrim.ParentGroup; 1429 SceneObjectGroup grp = RootPrim.ParentGroup;
1452 if (grp != null) 1430 if (grp != null)
@@ -1462,12 +1440,10 @@ namespace OpenSim.Region.Environment.Scenes
1462 // with the deeded object, it goes back to them 1440 // with the deeded object, it goes back to them
1463 1441
1464 grp.SetFromAssetID(grp.RootPart.LastOwnerID); 1442 grp.SetFromAssetID(grp.RootPart.LastOwnerID);
1465 m_innerScene.AttachObject(sp.ControllingClient, grp.LocalId, (uint)0, grp.GroupRotation, grp.AbsolutePosition); 1443 m_innerScene.AttachObject(sp.ControllingClient, grp.LocalId, 0, grp.GroupRotation, grp.AbsolutePosition);
1466 } 1444 }
1467 } 1445 }
1468 } 1446 }
1469
1470
1471 } 1447 }
1472 } 1448 }
1473 return true; 1449 return true;
@@ -1476,7 +1452,6 @@ namespace OpenSim.Region.Environment.Scenes
1476 { 1452 {
1477 return false; 1453 return false;
1478 } 1454 }
1479
1480 } 1455 }
1481 1456
1482 #endregion 1457 #endregion
@@ -1491,9 +1466,9 @@ namespace OpenSim.Region.Environment.Scenes
1491 public override void AddNewClient(IClientAPI client, bool child) 1466 public override void AddNewClient(IClientAPI client, bool child)
1492 { 1467 {
1493 m_log.DebugFormat( 1468 m_log.DebugFormat(
1494 "[CONNECTION DEBUGGING]: Creating new client for {0} at {1}", 1469 "[CONNECTION DEBUGGING]: Creating new client for {0} at {1}",
1495 client.AgentId, RegionInfo.RegionName); 1470 client.AgentId, RegionInfo.RegionName);
1496 1471
1497 SubscribeToClientEvents(client); 1472 SubscribeToClientEvents(client);
1498 ScenePresence presence = null; 1473 ScenePresence presence = null;
1499 1474
@@ -1563,19 +1538,19 @@ namespace OpenSim.Region.Environment.Scenes
1563 client.OnObjectDuplicateOnRay += doObjectDuplicateOnRay; 1538 client.OnObjectDuplicateOnRay += doObjectDuplicateOnRay;
1564 client.OnUpdatePrimFlags += m_innerScene.UpdatePrimFlags; 1539 client.OnUpdatePrimFlags += m_innerScene.UpdatePrimFlags;
1565 client.OnRequestObjectPropertiesFamily += m_innerScene.RequestObjectPropertiesFamily; 1540 client.OnRequestObjectPropertiesFamily += m_innerScene.RequestObjectPropertiesFamily;
1566 client.OnParcelPropertiesRequest += new ParcelPropertiesRequest(LandChannel.handleParcelPropertiesRequest); 1541 client.OnParcelPropertiesRequest += LandChannel.handleParcelPropertiesRequest;
1567 client.OnParcelDivideRequest += new ParcelDivideRequest(LandChannel.handleParcelDivideRequest); 1542 client.OnParcelDivideRequest += LandChannel.handleParcelDivideRequest;
1568 client.OnParcelJoinRequest += new ParcelJoinRequest(LandChannel.handleParcelJoinRequest); 1543 client.OnParcelJoinRequest += LandChannel.handleParcelJoinRequest;
1569 client.OnParcelPropertiesUpdateRequest += 1544 client.OnParcelPropertiesUpdateRequest +=
1570 new ParcelPropertiesUpdateRequest(LandChannel.handleParcelPropertiesUpdateRequest); 1545 LandChannel.handleParcelPropertiesUpdateRequest;
1571 client.OnParcelSelectObjects += new ParcelSelectObjects(LandChannel.handleParcelSelectObjectsRequest); 1546 client.OnParcelSelectObjects += LandChannel.handleParcelSelectObjectsRequest;
1572 client.OnParcelObjectOwnerRequest += 1547 client.OnParcelObjectOwnerRequest +=
1573 new ParcelObjectOwnerRequest(LandChannel.handleParcelObjectOwnersRequest); 1548 LandChannel.handleParcelObjectOwnersRequest;
1574 client.OnParcelAccessListRequest += new ParcelAccessListRequest(LandChannel.handleParcelAccessRequest); 1549 client.OnParcelAccessListRequest += LandChannel.handleParcelAccessRequest;
1575 client.OnParcelAccessListUpdateRequest += 1550 client.OnParcelAccessListUpdateRequest +=
1576 new ParcelAccessListUpdateRequest(LandChannel.handleParcelAccessUpdateRequest); 1551 LandChannel.handleParcelAccessUpdateRequest;
1577 1552
1578 client.OnEstateOwnerMessage += new EstateOwnerMessageRequest(m_estateManager.handleEstateOwnerMessage); 1553 client.OnEstateOwnerMessage += m_estateManager.handleEstateOwnerMessage;
1579 client.OnRegionInfoRequest += m_estateManager.HandleRegionInfoRequest; 1554 client.OnRegionInfoRequest += m_estateManager.HandleRegionInfoRequest;
1580 client.OnEstateCovenantRequest += m_estateManager.HandleEstateCovenantRequest; 1555 client.OnEstateCovenantRequest += m_estateManager.HandleEstateCovenantRequest;
1581 client.OnRequestGodlikePowers += handleRequestGodlikePowers; 1556 client.OnRequestGodlikePowers += handleRequestGodlikePowers;
@@ -1616,41 +1591,38 @@ namespace OpenSim.Region.Environment.Scenes
1616 1591
1617 client.OnSetStartLocationRequest += SetHomeRezPoint; 1592 client.OnSetStartLocationRequest += SetHomeRezPoint;
1618 client.OnUndo += m_innerScene.HandleUndo; 1593 client.OnUndo += m_innerScene.HandleUndo;
1619 1594
1620 EventManager.TriggerOnNewClient(client); 1595 EventManager.TriggerOnNewClient(client);
1621 } 1596 }
1597
1622 public virtual void TeleportClientHome(LLUUID AgentId, IClientAPI client) 1598 public virtual void TeleportClientHome(LLUUID AgentId, IClientAPI client)
1623 { 1599 {
1624 UserProfileData UserProfile = CommsManager.UserService.GetUserProfile(AgentId); 1600 UserProfileData UserProfile = CommsManager.UserService.GetUserProfile(AgentId);
1625 if (UserProfile != null) 1601 if (UserProfile != null)
1626 { 1602 {
1627 ulong homeRegion = UserProfile.HomeRegion; 1603 ulong homeRegion = UserProfile.HomeRegion;
1628 LLVector3 homePostion = new LLVector3(UserProfile.HomeLocationX,UserProfile.HomeLocationY,UserProfile.HomeLocationZ); 1604 LLVector3 homePostion = new LLVector3(UserProfile.HomeLocationX, UserProfile.HomeLocationY, UserProfile.HomeLocationZ);
1629 LLVector3 homeLookat = new LLVector3(UserProfile.HomeLookAt); 1605 LLVector3 homeLookat = new LLVector3(UserProfile.HomeLookAt);
1630 RequestTeleportLocation(client, homeRegion, homePostion,homeLookat,(uint)0); 1606 RequestTeleportLocation(client, homeRegion, homePostion, homeLookat, 0);
1631
1632 } 1607 }
1633
1634
1635 } 1608 }
1609
1636 public void doObjectDuplicateOnRay(uint localID, uint dupeFlags, LLUUID AgentID, LLUUID GroupID, 1610 public void doObjectDuplicateOnRay(uint localID, uint dupeFlags, LLUUID AgentID, LLUUID GroupID,
1637 LLUUID RayTargetObj, LLVector3 RayEnd, LLVector3 RayStart, 1611 LLUUID RayTargetObj, LLVector3 RayEnd, LLVector3 RayStart,
1638 bool BypassRaycast, bool RayEndIsIntersection, bool CopyCenters, bool CopyRotates) 1612 bool BypassRaycast, bool RayEndIsIntersection, bool CopyCenters, bool CopyRotates)
1639 { 1613 {
1640
1641 LLVector3 pos = LLVector3.Zero; 1614 LLVector3 pos = LLVector3.Zero;
1642 bool frontFacesOnly = true; 1615 bool frontFacesOnly = true;
1643 1616
1644 SceneObjectPart target = GetSceneObjectPart(localID); 1617 SceneObjectPart target = GetSceneObjectPart(localID);
1645 1618
1646 if (target != null) 1619 if (target != null)
1647 { 1620 {
1648
1649 LLVector3 direction = LLVector3.Norm(RayEnd - RayStart); 1621 LLVector3 direction = LLVector3.Norm(RayEnd - RayStart);
1650 Vector3 AXOrigin = new Vector3(RayStart.X, RayStart.Y, RayStart.Z); 1622 Vector3 AXOrigin = new Vector3(RayStart.X, RayStart.Y, RayStart.Z);
1651 Vector3 AXdirection = new Vector3(direction.X, direction.Y, direction.Z); 1623 Vector3 AXdirection = new Vector3(direction.X, direction.Y, direction.Z);
1652 1624
1653 1625
1654 if (target != null) 1626 if (target != null)
1655 { 1627 {
1656 if (target.ParentGroup != null) 1628 if (target.ParentGroup != null)
@@ -1680,9 +1652,8 @@ namespace OpenSim.Region.Environment.Scenes
1680 if (scaleComponent.Z != 0) ScaleOffset = scale.Z; 1652 if (scaleComponent.Z != 0) ScaleOffset = scale.Z;
1681 ScaleOffset = Math.Abs(ScaleOffset); 1653 ScaleOffset = Math.Abs(ScaleOffset);
1682 LLVector3 intersectionpoint = new LLVector3(ei.ipoint.x, ei.ipoint.y, ei.ipoint.z); 1654 LLVector3 intersectionpoint = new LLVector3(ei.ipoint.x, ei.ipoint.y, ei.ipoint.z);
1683 1655
1684 1656
1685
1686 if (CopyCenters) 1657 if (CopyCenters)
1687 { 1658 {
1688 // now we cast a ray from inside the prim(absolute position) to one of it's faces along the face normal. 1659 // now we cast a ray from inside the prim(absolute position) to one of it's faces along the face normal.
@@ -1694,7 +1665,7 @@ namespace OpenSim.Region.Environment.Scenes
1694 if (ei2.HitTF) 1665 if (ei2.HitTF)
1695 { 1666 {
1696 //m_log.Info("[RAYTRACERESULTS]: Hit:" + ei2.HitTF.ToString() + " Point: " + ei2.ipoint.ToString() + " Normal: " + ei2.normal.ToString()); 1667 //m_log.Info("[RAYTRACERESULTS]: Hit:" + ei2.HitTF.ToString() + " Point: " + ei2.ipoint.ToString() + " Normal: " + ei2.normal.ToString());
1697 pos = new LLVector3(ei2.ipoint.x,ei2.ipoint.y,ei2.ipoint.z); 1668 pos = new LLVector3(ei2.ipoint.x, ei2.ipoint.y, ei2.ipoint.z);
1698 } 1669 }
1699 } 1670 }
1700 LLVector3 normal = new LLVector3(ei.normal.x, ei.normal.y, ei.normal.z); 1671 LLVector3 normal = new LLVector3(ei.normal.x, ei.normal.y, ei.normal.z);
@@ -1707,18 +1678,14 @@ namespace OpenSim.Region.Environment.Scenes
1707 m_innerScene.DuplicateObject(target.ParentGroup.LocalId, pos, target.GetEffectiveObjectFlags(), AgentID, GroupID); 1678 m_innerScene.DuplicateObject(target.ParentGroup.LocalId, pos, target.GetEffectiveObjectFlags(), AgentID, GroupID);
1708 } 1679 }
1709 1680
1710 1681
1711 return; 1682 return;
1712 } 1683 }
1713 return; 1684 return;
1714 } 1685 }
1715
1716 } 1686 }
1717
1718
1719
1720
1721 } 1687 }
1688
1722 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, LLVector3 position, LLVector3 lookAt, uint flags) 1689 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, LLVector3 position, LLVector3 lookAt, uint flags)
1723 { 1690 {
1724 UserProfileData UserProfile = CommsManager.UserService.GetUserProfile(remoteClient.AgentId); 1691 UserProfileData UserProfile = CommsManager.UserService.GetUserProfile(remoteClient.AgentId);
@@ -1731,22 +1698,22 @@ namespace OpenSim.Region.Environment.Scenes
1731 // We cast these to an int so as not to cause a breaking change with old regions 1698 // We cast these to an int so as not to cause a breaking change with old regions
1732 // Newer regions treat this as a float on the ExpectUser method.. so we need to wait a few 1699 // Newer regions treat this as a float on the ExpectUser method.. so we need to wait a few
1733 // releases before setting these to floats. (r4257) 1700 // releases before setting these to floats. (r4257)
1734 UserProfile.HomeLocationX = (int)position.X; 1701 UserProfile.HomeLocationX = (int) position.X;
1735 UserProfile.HomeLocationY = (int)position.Y; 1702 UserProfile.HomeLocationY = (int) position.Y;
1736 UserProfile.HomeLocationZ = (int)position.Z; 1703 UserProfile.HomeLocationZ = (int) position.Z;
1737 UserProfile.HomeLookAtX = (int)lookAt.X; 1704 UserProfile.HomeLookAtX = (int) lookAt.X;
1738 UserProfile.HomeLookAtY = (int)lookAt.Y; 1705 UserProfile.HomeLookAtY = (int) lookAt.Y;
1739 UserProfile.HomeLookAtZ = (int)lookAt.Z; 1706 UserProfile.HomeLookAtZ = (int) lookAt.Z;
1740 CommsManager.UserService.UpdateUserProfileProperties(UserProfile); 1707 CommsManager.UserService.UpdateUserProfileProperties(UserProfile);
1741 1708
1742 remoteClient.SendAgentAlertMessage("Set home to here if supported by login service",false); 1709 remoteClient.SendAgentAlertMessage("Set home to here if supported by login service", false);
1743 } 1710 }
1744 else 1711 else
1745 { 1712 {
1746 remoteClient.SendAgentAlertMessage("Set Home request Failed",false); 1713 remoteClient.SendAgentAlertMessage("Set Home request Failed", false);
1747 } 1714 }
1748
1749 } 1715 }
1716
1750 protected virtual ScenePresence CreateAndAddScenePresence(IClientAPI client, bool child) 1717 protected virtual ScenePresence CreateAndAddScenePresence(IClientAPI client, bool child)
1751 { 1718 {
1752 ScenePresence avatar = null; 1719 ScenePresence avatar = null;
@@ -1812,7 +1779,7 @@ namespace OpenSim.Region.Environment.Scenes
1812 m_sceneGridService.SendCloseChildAgentConnections(agentID, childknownRegions); 1779 m_sceneGridService.SendCloseChildAgentConnections(agentID, childknownRegions);
1813 1780
1814 RemoveCapsHandler(agentID); 1781 RemoveCapsHandler(agentID);
1815 1782
1816 CommsManager.UserProfileCacheService.RemoveUser(agentID); 1783 CommsManager.UserProfileCacheService.RemoveUser(agentID);
1817 } 1784 }
1818 1785
@@ -1825,21 +1792,21 @@ namespace OpenSim.Region.Environment.Scenes
1825 } 1792 }
1826 m_eventManager.TriggerOnRemovePresence(agentID); 1793 m_eventManager.TriggerOnRemovePresence(agentID);
1827 Broadcast(delegate(IClientAPI client) 1794 Broadcast(delegate(IClientAPI client)
1828 {
1829 try
1830 {
1831 client.SendKillObject(avatar.RegionHandle, avatar.LocalId);
1832 }
1833 catch (NullReferenceException)
1834 { 1795 {
1835 //We can safely ignore null reference exceptions. It means the avatar are dead and cleaned up anyway. 1796 try
1836 } 1797 {
1837 }); 1798 client.SendKillObject(avatar.RegionHandle, avatar.LocalId);
1799 }
1800 catch (NullReferenceException)
1801 {
1802 //We can safely ignore null reference exceptions. It means the avatar are dead and cleaned up anyway.
1803 }
1804 });
1838 1805
1839 ForEachScenePresence( 1806 ForEachScenePresence(
1840 delegate(ScenePresence presence) { presence.CoarseLocationChange(); }); 1807 delegate(ScenePresence presence) { presence.CoarseLocationChange(); });
1841 1808
1842 IAgentAssetTransactions agentTransactions = this.RequestModuleInterface<IAgentAssetTransactions>(); 1809 IAgentAssetTransactions agentTransactions = RequestModuleInterface<IAgentAssetTransactions>();
1843 if (agentTransactions != null) 1810 if (agentTransactions != null)
1844 { 1811 {
1845 agentTransactions.RemoveAgentAssetTransactions(agentID); 1812 agentTransactions.RemoveAgentAssetTransactions(agentID);
@@ -1879,7 +1846,7 @@ namespace OpenSim.Region.Environment.Scenes
1879 } 1846 }
1880 catch (Exception e) 1847 catch (Exception e)
1881 { 1848 {
1882 m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString()); 1849 m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e);
1883 } 1850 }
1884 1851
1885 // Remove client agent from profile, so new logins will work 1852 // Remove client agent from profile, so new logins will work
@@ -1899,14 +1866,12 @@ namespace OpenSim.Region.Environment.Scenes
1899 { 1866 {
1900 lock (av) 1867 lock (av)
1901 { 1868 {
1902
1903 for (int i = 0; i < regionslst.Count; i++) 1869 for (int i = 0; i < regionslst.Count; i++)
1904 { 1870 {
1905 av.KnownChildRegions.Remove(regionslst[i]); 1871 av.KnownChildRegions.Remove(regionslst[i]);
1906 } 1872 }
1907 } 1873 }
1908 } 1874 }
1909
1910 } 1875 }
1911 1876
1912 public override void CloseAllAgents(uint circuitcode) 1877 public override void CloseAllAgents(uint circuitcode)
@@ -1994,7 +1959,7 @@ namespace OpenSim.Region.Environment.Scenes
1994 if (regionHandle == m_regInfo.RegionHandle) 1959 if (regionHandle == m_regInfo.RegionHandle)
1995 { 1960 {
1996 capsPaths[agent.AgentID] = agent.CapsPath; 1961 capsPaths[agent.AgentID] = agent.CapsPath;
1997 1962
1998 if (!agent.child) 1963 if (!agent.child)
1999 { 1964 {
2000 AddCapsHandler(agent.AgentID); 1965 AddCapsHandler(agent.AgentID);
@@ -2003,26 +1968,26 @@ namespace OpenSim.Region.Environment.Scenes
2003 ILandObject land = LandChannel.getLandObject(agent.startpos.X, agent.startpos.Y); 1968 ILandObject land = LandChannel.getLandObject(agent.startpos.X, agent.startpos.Y);
2004 if (land != null) 1969 if (land != null)
2005 { 1970 {
2006 if (land.landData.landingType == (byte)1 && land.landData.userLocation != LLVector3.Zero) 1971 if (land.landData.landingType == 1 && land.landData.userLocation != LLVector3.Zero)
2007 { 1972 {
2008 agent.startpos = land.landData.userLocation; 1973 agent.startpos = land.landData.userLocation;
2009 } 1974 }
2010 } 1975 }
2011 } 1976 }
2012 1977
2013 m_log.DebugFormat( 1978 m_log.DebugFormat(
2014 "[CONNECTION DEBUGGING]: Creating new circuit code ({0}) for avatar {1} at {2}", 1979 "[CONNECTION DEBUGGING]: Creating new circuit code ({0}) for avatar {1} at {2}",
2015 agent.circuitcode, agent.AgentID, RegionInfo.RegionName); 1980 agent.circuitcode, agent.AgentID, RegionInfo.RegionName);
2016 1981
2017 m_authenticateHandler.AddNewCircuit(agent.circuitcode, agent); 1982 m_authenticateHandler.AddNewCircuit(agent.circuitcode, agent);
2018 } 1983 }
2019 else 1984 else
2020 { 1985 {
2021 m_log.WarnFormat( 1986 m_log.WarnFormat(
2022 "[CONNECTION DEBUGGING]: Skipping this region for welcoming avatar {0} [{1}] at {2}", 1987 "[CONNECTION DEBUGGING]: Skipping this region for welcoming avatar {0} [{1}] at {2}",
2023 agent.AgentID, regionHandle, RegionInfo.RegionName); 1988 agent.AgentID, regionHandle, RegionInfo.RegionName);
2024 } 1989 }
2025 } 1990 }
2026 1991
2027 /// <summary> 1992 /// <summary>
2028 /// Add a caps handler for the given agent. If the CAPS handler already exists for this agent, 1993 /// Add a caps handler for the given agent. If the CAPS handler already exists for this agent,
@@ -2035,18 +2000,18 @@ namespace OpenSim.Region.Environment.Scenes
2035 /// <param name="agentId"></param> 2000 /// <param name="agentId"></param>
2036 /// <param name="capsObjectPath"></param> 2001 /// <param name="capsObjectPath"></param>
2037 public void AddCapsHandler(LLUUID agentId) 2002 public void AddCapsHandler(LLUUID agentId)
2038 { 2003 {
2039 String capsObjectPath = GetCapsPath(agentId); 2004 String capsObjectPath = GetCapsPath(agentId);
2040 2005
2041 m_log.DebugFormat( 2006 m_log.DebugFormat(
2042 "[CAPS]: Setting up CAPS handler for root agent {0} in {1}", 2007 "[CAPS]: Setting up CAPS handler for root agent {0} in {1}",
2043 agentId, RegionInfo.RegionName); 2008 agentId, RegionInfo.RegionName);
2044 2009
2045 Caps cap = 2010 Caps cap =
2046 new Caps(AssetCache, m_httpListener, m_regInfo.ExternalHostName, m_httpListener.Port, 2011 new Caps(AssetCache, m_httpListener, m_regInfo.ExternalHostName, m_httpListener.Port,
2047 capsObjectPath, agentId, m_dumpAssetsToFile, RegionInfo.RegionName); 2012 capsObjectPath, agentId, m_dumpAssetsToFile, RegionInfo.RegionName);
2048 cap.RegisterHandlers(); 2013 cap.RegisterHandlers();
2049 2014
2050 EventManager.TriggerOnRegisterCaps(agentId, cap); 2015 EventManager.TriggerOnRegisterCaps(agentId, cap);
2051 2016
2052 cap.AddNewInventoryItem = AddInventoryItem; 2017 cap.AddNewInventoryItem = AddInventoryItem;
@@ -2055,7 +2020,7 @@ namespace OpenSim.Region.Environment.Scenes
2055 cap.CAPSFetchInventoryDescendents = CommsManager.UserProfileCacheService.HandleFetchInventoryDescendentsCAPS; 2020 cap.CAPSFetchInventoryDescendents = CommsManager.UserProfileCacheService.HandleFetchInventoryDescendentsCAPS;
2056 cap.GetClient = m_innerScene.GetControllingClient; 2021 cap.GetClient = m_innerScene.GetControllingClient;
2057 m_capsHandlers[agentId] = cap; 2022 m_capsHandlers[agentId] = cap;
2058 } 2023 }
2059 2024
2060 /// <summary> 2025 /// <summary>
2061 /// Remove the caps handler for a given agent. 2026 /// Remove the caps handler for a given agent.
@@ -2068,9 +2033,9 @@ namespace OpenSim.Region.Environment.Scenes
2068 if (m_capsHandlers.ContainsKey(agentId)) 2033 if (m_capsHandlers.ContainsKey(agentId))
2069 { 2034 {
2070 m_log.DebugFormat( 2035 m_log.DebugFormat(
2071 "[CAPS]: Removing CAPS handler for root agent {0} in {1}", 2036 "[CAPS]: Removing CAPS handler for root agent {0} in {1}",
2072 agentId, RegionInfo.RegionName); 2037 agentId, RegionInfo.RegionName);
2073 2038
2074 m_capsHandlers[agentId].DeregisterHandlers(); 2039 m_capsHandlers[agentId].DeregisterHandlers();
2075 EventManager.TriggerOnDeregisterCaps(agentId, m_capsHandlers[agentId]); 2040 EventManager.TriggerOnDeregisterCaps(agentId, m_capsHandlers[agentId]);
2076 2041
@@ -2105,7 +2070,7 @@ namespace OpenSim.Region.Environment.Scenes
2105 catch (Exception e) 2070 catch (Exception e)
2106 { 2071 {
2107 m_log.Info("[SCENE]: Unable to do Agent Crossing."); 2072 m_log.Info("[SCENE]: Unable to do Agent Crossing.");
2108 m_log.Debug("[SCENE]: " + e.ToString()); 2073 m_log.Debug("[SCENE]: " + e);
2109 } 2074 }
2110 //m_innerScene.SwapRootChildAgent(false); 2075 //m_innerScene.SwapRootChildAgent(false);
2111 } 2076 }
@@ -2121,15 +2086,14 @@ namespace OpenSim.Region.Environment.Scenes
2121 // however to avoid a race condition crossing borders.. 2086 // however to avoid a race condition crossing borders..
2122 if (childAgentUpdate.IsChildAgent) 2087 if (childAgentUpdate.IsChildAgent)
2123 { 2088 {
2124 uint rRegionX = (uint)(cAgentData.regionHandle >> 40); 2089 uint rRegionX = (uint) (cAgentData.regionHandle >> 40);
2125 uint rRegionY = (((uint)(cAgentData.regionHandle)) >> 8); 2090 uint rRegionY = (((uint) (cAgentData.regionHandle)) >> 8);
2126 uint tRegionX = RegionInfo.RegionLocX; 2091 uint tRegionX = RegionInfo.RegionLocX;
2127 uint tRegionY = RegionInfo.RegionLocY; 2092 uint tRegionY = RegionInfo.RegionLocY;
2128 //Send Data to ScenePresence 2093 //Send Data to ScenePresence
2129 childAgentUpdate.ChildAgentDataUpdate(cAgentData, tRegionX, tRegionY, rRegionX, rRegionY); 2094 childAgentUpdate.ChildAgentDataUpdate(cAgentData, tRegionX, tRegionY, rRegionX, rRegionY);
2130 // Not Implemented: 2095 // Not Implemented:
2131 //TODO: Do we need to pass the message on to one of our neighbors? 2096 //TODO: Do we need to pass the message on to one of our neighbors?
2132
2133 } 2097 }
2134 return true; 2098 return true;
2135 } 2099 }
@@ -2157,7 +2121,7 @@ namespace OpenSim.Region.Environment.Scenes
2157 m_innerScene.removeUserCount(true); 2121 m_innerScene.removeUserCount(true);
2158 } 2122 }
2159 // Tell a single agent to disconnect from the region. 2123 // Tell a single agent to disconnect from the region.
2160 DisableSimulatorPacket disable = (DisableSimulatorPacket)PacketPool.Instance.GetPacket(PacketType.DisableSimulator); 2124 DisableSimulatorPacket disable = (DisableSimulatorPacket) PacketPool.Instance.GetPacket(PacketType.DisableSimulator);
2161 presence.ControllingClient.OutPacket(disable, ThrottleOutPacketType.Unknown); 2125 presence.ControllingClient.OutPacket(disable, ThrottleOutPacketType.Unknown);
2162 presence.ControllingClient.Close(true); 2126 presence.ControllingClient.Close(true);
2163 } 2127 }
@@ -2307,9 +2271,9 @@ namespace OpenSim.Region.Environment.Scenes
2307 /// <param name="mod"></param> 2271 /// <param name="mod"></param>
2308 public void RegisterModuleInterface<M>(M mod) 2272 public void RegisterModuleInterface<M>(M mod)
2309 { 2273 {
2310 if (!ModuleInterfaces.ContainsKey(typeof(M))) 2274 if (!ModuleInterfaces.ContainsKey(typeof (M)))
2311 { 2275 {
2312 ModuleInterfaces.Add(typeof(M), mod); 2276 ModuleInterfaces.Add(typeof (M), mod);
2313 } 2277 }
2314 } 2278 }
2315 2279
@@ -2319,9 +2283,9 @@ namespace OpenSim.Region.Environment.Scenes
2319 /// <returns></returns> 2283 /// <returns></returns>
2320 public T RequestModuleInterface<T>() 2284 public T RequestModuleInterface<T>()
2321 { 2285 {
2322 if (ModuleInterfaces.ContainsKey(typeof(T))) 2286 if (ModuleInterfaces.ContainsKey(typeof (T)))
2323 { 2287 {
2324 return (T)ModuleInterfaces[typeof(T)]; 2288 return (T) ModuleInterfaces[typeof (T)];
2325 } 2289 }
2326 else 2290 else
2327 { 2291 {
@@ -2336,14 +2300,12 @@ namespace OpenSim.Region.Environment.Scenes
2336 m_statsReporter.SetObjectCapacity(objects); 2300 m_statsReporter.SetObjectCapacity(objects);
2337 } 2301 }
2338 objectCapacity = objects; 2302 objectCapacity = objects;
2339
2340 } 2303 }
2341 2304
2342 public List<FriendListItem> GetFriendList(LLUUID avatarID) 2305 public List<FriendListItem> GetFriendList(LLUUID avatarID)
2343 { 2306 {
2344 return CommsManager.GetUserFriendList(avatarID); 2307 return CommsManager.GetUserFriendList(avatarID);
2345 } 2308 }
2346
2347 2309
2348 #endregion 2310 #endregion
2349 2311
@@ -2378,7 +2340,8 @@ namespace OpenSim.Region.Environment.Scenes
2378 } 2340 }
2379 } 2341 }
2380 2342
2381 public void SendDialogToUser(LLUUID avatarID, string objectName, LLUUID objectID, LLUUID ownerID, string message, LLUUID TextureID, int ch, string[] buttonlabels) 2343 public void SendDialogToUser(LLUUID avatarID, string objectName, LLUUID objectID, LLUUID ownerID, string message, LLUUID TextureID, int ch,
2344 string[] buttonlabels)
2382 { 2345 {
2383 if (m_scenePresences.ContainsKey(avatarID)) 2346 if (m_scenePresences.ContainsKey(avatarID))
2384 { 2347 {
@@ -2401,7 +2364,7 @@ namespace OpenSim.Region.Environment.Scenes
2401 } 2364 }
2402 return LLUUID.Zero; 2365 return LLUUID.Zero;
2403 } 2366 }
2404 2367
2405 2368
2406 /// <summary> 2369 /// <summary>
2407 /// This method is a way for the Friends Module to create an instant 2370 /// This method is a way for the Friends Module to create an instant
@@ -2436,6 +2399,7 @@ namespace OpenSim.Region.Environment.Scenes
2436 // TODO: m_sceneGridService.DoStuff; 2399 // TODO: m_sceneGridService.DoStuff;
2437 m_sceneGridService.RemoveUserFriend(ownerID, ExfriendID); 2400 m_sceneGridService.RemoveUserFriend(ownerID, ExfriendID);
2438 } 2401 }
2402
2439 public virtual List<FriendListItem> StoreGetFriendsForUser(LLUUID ownerID) 2403 public virtual List<FriendListItem> StoreGetFriendsForUser(LLUUID ownerID)
2440 { 2404 {
2441 // TODO: m_sceneGridService.DoStuff; 2405 // TODO: m_sceneGridService.DoStuff;
@@ -2448,11 +2412,13 @@ namespace OpenSim.Region.Environment.Scenes
2448 m_statsReporter.AddOutPackets(outPackets); 2412 m_statsReporter.AddOutPackets(outPackets);
2449 m_statsReporter.AddunAckedBytes(unAckedBytes); 2413 m_statsReporter.AddunAckedBytes(unAckedBytes);
2450 } 2414 }
2415
2451 public void AddAgentTime(int ms) 2416 public void AddAgentTime(int ms)
2452 { 2417 {
2453 m_statsReporter.addFrameMS(ms); 2418 m_statsReporter.addFrameMS(ms);
2454 m_statsReporter.addAgentMS(ms); 2419 m_statsReporter.addAgentMS(ms);
2455 } 2420 }
2421
2456 public void AddAgentUpdates(int count) 2422 public void AddAgentUpdates(int count)
2457 { 2423 {
2458 m_statsReporter.AddAgentUpdates(count); 2424 m_statsReporter.AddAgentUpdates(count);
@@ -2546,7 +2512,6 @@ namespace OpenSim.Region.Environment.Scenes
2546 /// <param name="Message">The Message being sent to the user</param> 2512 /// <param name="Message">The Message being sent to the user</param>
2547 public void SendRegionMessageFromEstateTools(LLUUID FromAvatarID, LLUUID fromSessionID, String FromAvatarName, String Message) 2513 public void SendRegionMessageFromEstateTools(LLUUID FromAvatarID, LLUUID fromSessionID, String FromAvatarName, String Message)
2548 { 2514 {
2549
2550 List<ScenePresence> presenceList = GetScenePresences(); 2515 List<ScenePresence> presenceList = GetScenePresences();
2551 2516
2552 foreach (ScenePresence presence in presenceList) 2517 foreach (ScenePresence presence in presenceList)
@@ -2566,11 +2531,7 @@ namespace OpenSim.Region.Environment.Scenes
2566 /// <param name="Message">The Message being sent to the user</param> 2531 /// <param name="Message">The Message being sent to the user</param>
2567 public void SendEstateMessageFromEstateTools(LLUUID FromAvatarID, LLUUID fromSessionID, String FromAvatarName, String Message) 2532 public void SendEstateMessageFromEstateTools(LLUUID FromAvatarID, LLUUID fromSessionID, String FromAvatarName, String Message)
2568 { 2533 {
2569 2534 ClientManager.ForEachClient(delegate(IClientAPI controller) { controller.SendBlueBoxMessage(FromAvatarID, fromSessionID, FromAvatarName, Message); }
2570 ClientManager.ForEachClient(delegate(IClientAPI controller)
2571 {
2572 controller.SendBlueBoxMessage(FromAvatarID, fromSessionID, FromAvatarName, Message);
2573 }
2574 ); 2535 );
2575 } 2536 }
2576 2537
@@ -2596,27 +2557,24 @@ namespace OpenSim.Region.Environment.Scenes
2596 if (agentID == kickUserID) 2557 if (agentID == kickUserID)
2597 { 2558 {
2598 ClientManager.ForEachClient(delegate(IClientAPI controller) 2559 ClientManager.ForEachClient(delegate(IClientAPI controller)
2599 { 2560 {
2600 if (controller.AgentId != godID) 2561 if (controller.AgentId != godID)
2601 controller.Kick(Helpers.FieldToUTF8String(reason)); 2562 controller.Kick(Helpers.FieldToUTF8String(reason));
2602 2563 }
2603
2604
2605 }
2606 ); 2564 );
2607 // This is a bit crude. It seems the client will be null before it actually stops the thread 2565 // This is a bit crude. It seems the client will be null before it actually stops the thread
2608 // The thread will kill itself eventually :/ 2566 // The thread will kill itself eventually :/
2609 // Is there another way to make sure *all* clients get this 'inter region' message? 2567 // Is there another way to make sure *all* clients get this 'inter region' message?
2610 ClientManager.ForEachClient(delegate(IClientAPI controller) 2568 ClientManager.ForEachClient(delegate(IClientAPI controller)
2611 {
2612 ScenePresence p = GetScenePresence(controller.AgentId);
2613 bool childagent = !p.Equals(null) && p.IsChildAgent;
2614 if (controller.AgentId != godID && !childagent)
2615 // Do we really want to kick the initiator of this madness?
2616 { 2569 {
2617 controller.Close(true); 2570 ScenePresence p = GetScenePresence(controller.AgentId);
2571 bool childagent = !p.Equals(null) && p.IsChildAgent;
2572 if (controller.AgentId != godID && !childagent)
2573 // Do we really want to kick the initiator of this madness?
2574 {
2575 controller.Close(true);
2576 }
2618 } 2577 }
2619 }
2620 ); 2578 );
2621 } 2579 }
2622 else 2580 else
@@ -2647,7 +2605,6 @@ namespace OpenSim.Region.Environment.Scenes
2647 // Check for spoofing.. since this is permissions we're talking about here! 2605 // Check for spoofing.. since this is permissions we're talking about here!
2648 if ((controller.SessionId == sessionID) && (controller.AgentId == agentID)) 2606 if ((controller.SessionId == sessionID) && (controller.AgentId == agentID))
2649 { 2607 {
2650
2651 // Tell the object to do permission update 2608 // Tell the object to do permission update
2652 if (localId != 0) 2609 if (localId != 0)
2653 { 2610 {
@@ -2657,7 +2614,6 @@ namespace OpenSim.Region.Environment.Scenes
2657 chObjectGroup.UpdatePermissions(agentID, field, localId, mask, set); 2614 chObjectGroup.UpdatePermissions(agentID, field, localId, mask, set);
2658 } 2615 }
2659 } 2616 }
2660
2661 } 2617 }
2662 } 2618 }
2663 2619
@@ -2723,7 +2679,7 @@ namespace OpenSim.Region.Environment.Scenes
2723 { 2679 {
2724 if (ent is SceneObjectGroup) 2680 if (ent is SceneObjectGroup)
2725 { 2681 {
2726 ((SceneObjectGroup)ent).ScheduleGroupForFullUpdate(); 2682 ((SceneObjectGroup) ent).ScheduleGroupForFullUpdate();
2727 } 2683 }
2728 } 2684 }
2729 } 2685 }
@@ -2743,7 +2699,7 @@ namespace OpenSim.Region.Environment.Scenes
2743 { 2699 {
2744 if (ent is SceneObjectGroup) 2700 if (ent is SceneObjectGroup)
2745 { 2701 {
2746 SceneObjectPart part = ((SceneObjectGroup)ent).GetChildPart(((SceneObjectGroup)ent).UUID); 2702 SceneObjectPart part = ((SceneObjectGroup) ent).GetChildPart((ent).UUID);
2747 if (part != null) 2703 if (part != null)
2748 { 2704 {
2749 if (part.Name == cmdparams[0]) 2705 if (part.Name == cmdparams[0])
@@ -2867,8 +2823,8 @@ namespace OpenSim.Region.Environment.Scenes
2867 2823
2868 #region Script Engine 2824 #region Script Engine
2869 2825
2870 private List<ScriptEngineInterface> ScriptEngines = new List<ScriptEngineInterface>(); 2826 private readonly bool m_dumpAssetsToFile;
2871 private bool m_dumpAssetsToFile; 2827 private readonly List<ScriptEngineInterface> ScriptEngines = new List<ScriptEngineInterface>();
2872 2828
2873 /// <summary> 2829 /// <summary>
2874 /// 2830 ///
@@ -2882,13 +2838,11 @@ namespace OpenSim.Region.Environment.Scenes
2882 2838
2883 public void TriggerObjectChanged(uint localID, uint change) 2839 public void TriggerObjectChanged(uint localID, uint change)
2884 { 2840 {
2885
2886 m_eventManager.TriggerOnScriptChangedEvent(localID, change); 2841 m_eventManager.TriggerOnScriptChangedEvent(localID, change);
2887 } 2842 }
2888 2843
2889 public void TriggerAtTargetEvent(uint localID, uint handle, LLVector3 targetpos, LLVector3 currentpos) 2844 public void TriggerAtTargetEvent(uint localID, uint handle, LLVector3 targetpos, LLVector3 currentpos)
2890 { 2845 {
2891
2892 m_eventManager.TriggerAtTargetEvent(localID, handle, targetpos, currentpos); 2846 m_eventManager.TriggerAtTargetEvent(localID, handle, targetpos, currentpos);
2893 } 2847 }
2894 2848
@@ -2897,20 +2851,21 @@ namespace OpenSim.Region.Environment.Scenes
2897 m_eventManager.TriggerNotAtTargetEvent(localID); 2851 m_eventManager.TriggerNotAtTargetEvent(localID);
2898 } 2852 }
2899 2853
2900 private bool scriptDanger(SceneObjectPart part,LLVector3 pos) 2854 private bool scriptDanger(SceneObjectPart part, LLVector3 pos)
2901 { 2855 {
2902 ILandObject parcel = LandChannel.getLandObject(pos.X, pos.Y); 2856 ILandObject parcel = LandChannel.getLandObject(pos.X, pos.Y);
2903 if (part != null) 2857 if (part != null)
2904 { 2858 {
2905 if (parcel != null) 2859 if (parcel != null)
2906 { 2860 {
2907 if ((parcel.landData.landFlags & (uint)Parcel.ParcelFlags.AllowOtherScripts) != 0) 2861 if ((parcel.landData.landFlags & (uint) Parcel.ParcelFlags.AllowOtherScripts) != 0)
2908 { 2862 {
2909 return true; 2863 return true;
2910 } 2864 }
2911 else if ((parcel.landData.landFlags & (uint)Parcel.ParcelFlags.AllowGroupScripts) != 0) 2865 else if ((parcel.landData.landFlags & (uint) Parcel.ParcelFlags.AllowGroupScripts) != 0)
2912 { 2866 {
2913 if (part.OwnerID == parcel.landData.ownerID || (parcel.landData.isGroupOwned && part.GroupID == parcel.landData.groupID) || PermissionsMngr.GenericEstatePermission(part.OwnerID)) 2867 if (part.OwnerID == parcel.landData.ownerID || (parcel.landData.isGroupOwned && part.GroupID == parcel.landData.groupID) ||
2868 PermissionsMngr.GenericEstatePermission(part.OwnerID))
2914 { 2869 {
2915 return true; 2870 return true;
2916 } 2871 }
@@ -2918,7 +2873,7 @@ namespace OpenSim.Region.Environment.Scenes
2918 { 2873 {
2919 return false; 2874 return false;
2920 } 2875 }
2921 } 2876 }
2922 else 2877 else
2923 { 2878 {
2924 if (part.OwnerID == parcel.landData.ownerID) 2879 if (part.OwnerID == parcel.landData.ownerID)
@@ -2933,7 +2888,6 @@ namespace OpenSim.Region.Environment.Scenes
2933 } 2888 }
2934 else 2889 else
2935 { 2890 {
2936
2937 if (pos.X > 0f && pos.X < Constants.RegionSize && pos.Y > 0f && pos.Y < Constants.RegionSize) 2891 if (pos.X > 0f && pos.X < Constants.RegionSize && pos.Y > 0f && pos.Y < Constants.RegionSize)
2938 { 2892 {
2939 // The only time parcel != null when an object is inside a region is when 2893 // The only time parcel != null when an object is inside a region is when
@@ -2952,6 +2906,7 @@ namespace OpenSim.Region.Environment.Scenes
2952 return false; 2906 return false;
2953 } 2907 }
2954 } 2908 }
2909
2955 public bool scriptDanger(uint localID, LLVector3 pos) 2910 public bool scriptDanger(uint localID, LLVector3 pos)
2956 { 2911 {
2957 SceneObjectPart part = GetSceneObjectPart(localID); 2912 SceneObjectPart part = GetSceneObjectPart(localID);
@@ -2967,13 +2922,11 @@ namespace OpenSim.Region.Environment.Scenes
2967 2922
2968 public bool pipeEventsForScript(uint localID) 2923 public bool pipeEventsForScript(uint localID)
2969 { 2924 {
2970
2971 SceneObjectPart part = GetSceneObjectPart(localID); 2925 SceneObjectPart part = GetSceneObjectPart(localID);
2972 if (part != null) 2926 if (part != null)
2973 { 2927 {
2974 LLVector3 pos = part.GetWorldPosition(); 2928 LLVector3 pos = part.GetWorldPosition();
2975 return scriptDanger(part, pos); 2929 return scriptDanger(part, pos);
2976
2977 } 2930 }
2978 else 2931 else
2979 { 2932 {
@@ -3090,17 +3043,17 @@ namespace OpenSim.Region.Environment.Scenes
3090 } 3043 }
3091 catch (Exception e) 3044 catch (Exception e)
3092 { 3045 {
3093 m_log.Info("[BUG]: " + e.ToString()); 3046 m_log.Info("[BUG]: " + e);
3094 } 3047 }
3095 } 3048 }
3096 } 3049 }
3097 3050
3098 /// <summary> 3051 /// <summary>
3099 /// Delete this object from the scene. 3052 /// Delete this object from the scene.
3100 /// </summary> 3053 /// </summary>
3101 /// <param name="group"></param> 3054 /// <param name="group"></param>
3102 public void DeleteSceneObjectGroup(SceneObjectGroup group) 3055 public void DeleteSceneObjectGroup(SceneObjectGroup group)
3103 { 3056 {
3104 SceneObjectPart rootPart = (group).GetChildPart(group.UUID); 3057 SceneObjectPart rootPart = (group).GetChildPart(group.UUID);
3105 if (rootPart.PhysActor != null) 3058 if (rootPart.PhysActor != null)
3106 { 3059 {
@@ -3117,15 +3070,15 @@ namespace OpenSim.Region.Environment.Scenes
3117 m_innerScene.RemoveAPrimCount(); 3070 m_innerScene.RemoveAPrimCount();
3118 } 3071 }
3119 group.DeleteParts(); 3072 group.DeleteParts();
3120 3073
3121 // In case anybody else retains a reference to this group, signal deletion by changing the name 3074 // In case anybody else retains a reference to this group, signal deletion by changing the name
3122 // to null. We can't zero out the UUID because this is taken from the root part, which has already 3075 // to null. We can't zero out the UUID because this is taken from the root part, which has already
3123 // been removed. 3076 // been removed.
3124 // FIXME: This is a really poor temporary solution, since it still leaves plenty of scope for race 3077 // FIXME: This is a really poor temporary solution, since it still leaves plenty of scope for race
3125 // conditions where a user deletes an entity while it is being stored. Really, the update 3078 // conditions where a user deletes an entity while it is being stored. Really, the update
3126 // code needs a redesign. 3079 // code needs a redesign.
3127 group.Name = null; 3080 group.Name = null;
3128 } 3081 }
3129 3082
3130 /// <summary> 3083 /// <summary>
3131 /// 3084 ///
@@ -3145,7 +3098,6 @@ namespace OpenSim.Region.Environment.Scenes
3145 // action(presence); 3098 // action(presence);
3146 // } 3099 // }
3147 // } 3100 // }
3148
3149 /// <summary> 3101 /// <summary>
3150 /// 3102 ///
3151 /// </summary> 3103 /// </summary>
@@ -3235,6 +3187,7 @@ namespace OpenSim.Region.Environment.Scenes
3235 } 3187 }
3236 return visualParams; 3188 return visualParams;
3237 } 3189 }
3190
3238 #endregion 3191 #endregion
3239 } 3192 }
3240} 3193} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Scenes/SceneBase.cs b/OpenSim/Region/Environment/Scenes/SceneBase.cs
index d9dc1da..435dc8b 100644
--- a/OpenSim/Region/Environment/Scenes/SceneBase.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneBase.cs
@@ -40,6 +40,11 @@ namespace OpenSim.Region.Environment.Scenes
40 { 40 {
41 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 41 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
42 42
43 /// <summary>
44 /// XXX These two methods are very temporary
45 /// </summary>
46 protected Dictionary<LLUUID, string> capsPaths = new Dictionary<LLUUID, string>();
47
43 #region Events 48 #region Events
44 49
45 public event restart OnRestart; 50 public event restart OnRestart;
@@ -50,41 +55,38 @@ namespace OpenSim.Region.Environment.Scenes
50 55
51 private readonly ClientManager m_clientManager = new ClientManager(); 56 private readonly ClientManager m_clientManager = new ClientManager();
52 57
53 public ClientManager ClientManager
54 {
55 get { return m_clientManager; }
56 }
57
58 protected ulong m_regionHandle;
59 protected string m_regionName;
60 protected RegionInfo m_regInfo;
61
62 //public TerrainEngine Terrain; 58 //public TerrainEngine Terrain;
63 public ITerrainChannel Heightmap; 59 public ITerrainChannel Heightmap;
64 60
65 public ILandChannel LandChannel; 61 public ILandChannel LandChannel;
62 private AssetCache m_assetCache;
66 63
64
65 protected string m_datastore;
67 protected EventManager m_eventManager; 66 protected EventManager m_eventManager;
68 67
68 private uint m_nextLocalId = 8880000;
69 protected RegionInfo m_regInfo;
70 protected ulong m_regionHandle;
71 protected string m_regionName;
72
73 protected RegionStatus m_regStatus;
74
69 public EventManager EventManager 75 public EventManager EventManager
70 { 76 {
71 get { return m_eventManager; } 77 get { return m_eventManager; }
72 } 78 }
73 79
74
75 protected string m_datastore;
76
77 private uint m_nextLocalId = 8880000;
78
79 private AssetCache m_assetCache;
80
81 public AssetCache AssetCache 80 public AssetCache AssetCache
82 { 81 {
83 get { return m_assetCache; } 82 get { return m_assetCache; }
84 set { m_assetCache = value; } 83 set { m_assetCache = value; }
85 } 84 }
86 85
87 protected RegionStatus m_regStatus; 86 public ClientManager ClientManager
87 {
88 get { return m_clientManager; }
89 }
88 90
89 public RegionStatus Region_Status 91 public RegionStatus Region_Status
90 { 92 {
@@ -141,6 +143,8 @@ namespace OpenSim.Region.Environment.Scenes
141 143
142 #endregion 144 #endregion
143 145
146 #region IScene Members
147
144 /// <summary> 148 /// <summary>
145 /// 149 ///
146 /// </summary> 150 /// </summary>
@@ -155,6 +159,18 @@ namespace OpenSim.Region.Environment.Scenes
155 get { return m_nextLocalId++; } 159 get { return m_nextLocalId++; }
156 } 160 }
157 161
162 public string GetCapsPath(LLUUID agentId)
163 {
164 if (capsPaths.ContainsKey(agentId))
165 {
166 return capsPaths[agentId];
167 }
168
169 return null;
170 }
171
172 #endregion
173
158 #region admin stuff 174 #region admin stuff
159 175
160 /// <summary> 176 /// <summary>
@@ -173,6 +189,7 @@ namespace OpenSim.Region.Environment.Scenes
173 { 189 {
174 return false; 190 return false;
175 } 191 }
192
176 public abstract bool OtherRegionUp(RegionInfo thisRegion); 193 public abstract bool OtherRegionUp(RegionInfo thisRegion);
177 194
178 public virtual string GetSimulatorVersion() 195 public virtual string GetSimulatorVersion()
@@ -195,24 +212,10 @@ namespace OpenSim.Region.Environment.Scenes
195 } 212 }
196 catch (Exception e) 213 catch (Exception e)
197 { 214 {
198 m_log.Error("[SCENE]: SceneBase.cs: Close() - Failed with exception " + e.ToString()); 215 m_log.Error("[SCENE]: SceneBase.cs: Close() - Failed with exception " + e);
199 } 216 }
200 } 217 }
201 218
202 #endregion 219 #endregion
203
204 /// <summary>
205 /// XXX These two methods are very temporary
206 /// </summary>
207 protected Dictionary<LLUUID, string> capsPaths = new Dictionary<LLUUID, string>();
208 public string GetCapsPath(LLUUID agentId)
209 {
210 if (capsPaths.ContainsKey(agentId))
211 {
212 return capsPaths[agentId];
213 }
214
215 return null;
216 }
217 } 220 }
218} 221} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs
index 91bbdb7..b44847b 100644
--- a/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs
@@ -43,13 +43,47 @@ namespace OpenSim.Region.Environment.Scenes
43 43
44 public class SceneCommunicationService //one instance per region 44 public class SceneCommunicationService //one instance per region
45 { 45 {
46 #region Delegates
47
48 public delegate void InformNeighbourThatRegionUpDelegate(RegionInfo region, ulong regionhandle);
49
50 public delegate void SendChildAgentDataUpdateDelegate(ChildAgentDataUpdate cAgentData, ScenePresence presence);
51
52 public delegate void SendCloseChildAgentDelegate(LLUUID agentID, List<ulong> regionlst);
53
54 #endregion
55
46 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 56 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
57 public string _debugRegionName = String.Empty;
58 private AgentCrossing handlerAvatarCrossingIntoRegion; // OnAvatarCrossingIntoRegion;
59 private ChildAgentUpdate handlerChildAgentUpdate; // OnChildAgentUpdate;
60 private CloseAgentConnection handlerCloseAgentConnection; // OnCloseAgentConnection;
61 private ExpectPrimDelegate handlerExpectPrim; // OnExpectPrim;
62 private ExpectUserDelegate handlerExpectUser; // OnExpectUser;
63 private PrimCrossing handlerPrimCrossingIntoRegion; // OnPrimCrossingIntoRegion;
64 private RegionUp handlerRegionUp; // OnRegionUp;
65 private RemoveKnownRegionsFromAvatarList handlerRemoveKnownRegionFromAvatar; // OnRemoveKnownRegionFromAvatar;
66
67 public KillObjectDelegate KillObject;
47 68
48 protected CommunicationsManager m_commsProvider; 69 protected CommunicationsManager m_commsProvider;
49 protected RegionInfo m_regionInfo; 70 protected RegionInfo m_regionInfo;
50 71
51 protected RegionCommsListener regionCommsHost; 72 protected RegionCommsListener regionCommsHost;
52 73
74 public SceneCommunicationService(CommunicationsManager commsMan)
75 {
76 m_commsProvider = commsMan;
77 m_commsProvider.GridService.gdebugRegionName = _debugRegionName;
78 m_commsProvider.InterRegion.rdebugRegionName = _debugRegionName;
79 }
80
81 public string debugRegionName
82 {
83 get { return _debugRegionName; }
84 set { _debugRegionName = value; }
85 }
86
53 public event AgentCrossing OnAvatarCrossingIntoRegion; 87 public event AgentCrossing OnAvatarCrossingIntoRegion;
54 public event ExpectUserDelegate OnExpectUser; 88 public event ExpectUserDelegate OnExpectUser;
55 public event ExpectPrimDelegate OnExpectPrim; 89 public event ExpectPrimDelegate OnExpectPrim;
@@ -59,31 +93,6 @@ namespace OpenSim.Region.Environment.Scenes
59 public event ChildAgentUpdate OnChildAgentUpdate; 93 public event ChildAgentUpdate OnChildAgentUpdate;
60 public event RemoveKnownRegionsFromAvatarList OnRemoveKnownRegionFromAvatar; 94 public event RemoveKnownRegionsFromAvatarList OnRemoveKnownRegionFromAvatar;
61 95
62 private AgentCrossing handlerAvatarCrossingIntoRegion = null; // OnAvatarCrossingIntoRegion;
63 private ExpectUserDelegate handlerExpectUser = null; // OnExpectUser;
64 private ExpectPrimDelegate handlerExpectPrim = null; // OnExpectPrim;
65 private CloseAgentConnection handlerCloseAgentConnection = null; // OnCloseAgentConnection;
66 private PrimCrossing handlerPrimCrossingIntoRegion = null; // OnPrimCrossingIntoRegion;
67 private RegionUp handlerRegionUp = null; // OnRegionUp;
68 private ChildAgentUpdate handlerChildAgentUpdate = null; // OnChildAgentUpdate;
69 private RemoveKnownRegionsFromAvatarList handlerRemoveKnownRegionFromAvatar = null; // OnRemoveKnownRegionFromAvatar;
70
71 public KillObjectDelegate KillObject;
72 public string _debugRegionName = String.Empty;
73
74 public string debugRegionName
75 {
76 get { return _debugRegionName; }
77 set { _debugRegionName = value; }
78 }
79
80 public SceneCommunicationService(CommunicationsManager commsMan)
81 {
82 m_commsProvider = commsMan;
83 m_commsProvider.GridService.gdebugRegionName = _debugRegionName;
84 m_commsProvider.InterRegion.rdebugRegionName = _debugRegionName;
85 }
86
87 public void RegisterRegion(RegionInfo regionInfos) 96 public void RegisterRegion(RegionInfo regionInfos)
88 { 97 {
89 m_regionInfo = regionInfos; 98 m_regionInfo = regionInfos;
@@ -99,7 +108,7 @@ namespace OpenSim.Region.Environment.Scenes
99 regionCommsHost.OnAvatarCrossingIntoRegion += AgentCrossing; 108 regionCommsHost.OnAvatarCrossingIntoRegion += AgentCrossing;
100 regionCommsHost.OnCloseAgentConnection += CloseConnection; 109 regionCommsHost.OnCloseAgentConnection += CloseConnection;
101 regionCommsHost.OnRegionUp += newRegionUp; 110 regionCommsHost.OnRegionUp += newRegionUp;
102 regionCommsHost.OnChildAgentUpdate += ChildAgentUpdate; 111 regionCommsHost.OnChildAgentUpdate += ChildAgentUpdate;
103 } 112 }
104 else 113 else
105 { 114 {
@@ -122,218 +131,6 @@ namespace OpenSim.Region.Environment.Scenes
122 } 131 }
123 } 132 }
124 133
125 #region CommsManager Event handlers
126
127 /// <summary>
128 ///
129 /// </summary>
130 /// <param name="regionHandle"></param>
131 /// <param name="agent"></param>
132 ///
133 protected void NewUserConnection(ulong regionHandle, AgentCircuitData agent)
134 {
135 handlerExpectUser = OnExpectUser;
136 if (handlerExpectUser != null)
137 {
138 //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: OnExpectUser Fired for User:" + agent.firstname + " " + agent.lastname);
139 handlerExpectUser(regionHandle, agent);
140 }
141 }
142
143 protected bool newRegionUp(RegionInfo region)
144 {
145 handlerRegionUp = OnRegionUp;
146 if (handlerRegionUp != null)
147 {
148 //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: newRegionUp Fired for User:" + region.RegionName);
149 handlerRegionUp(region);
150 }
151 return true;
152 }
153
154 protected bool ChildAgentUpdate(ulong regionHandle, ChildAgentDataUpdate cAgentData)
155 {
156 handlerChildAgentUpdate = OnChildAgentUpdate;
157 if (handlerChildAgentUpdate != null)
158 handlerChildAgentUpdate(regionHandle, cAgentData);
159
160
161 return true;
162 }
163
164 protected void AgentCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position, bool isFlying)
165 {
166 handlerAvatarCrossingIntoRegion = OnAvatarCrossingIntoRegion;
167 if (handlerAvatarCrossingIntoRegion != null)
168 {
169 handlerAvatarCrossingIntoRegion(regionHandle, agentID, position, isFlying);
170 }
171 }
172
173 protected bool IncomingPrimCrossing(ulong regionHandle, LLUUID primID, String objXMLData, int XMLMethod)
174 {
175 handlerExpectPrim = OnExpectPrim;
176 if (handlerExpectPrim != null)
177 {
178 return handlerExpectPrim(regionHandle, primID, objXMLData, XMLMethod);
179 }
180 else
181 {
182 return false;
183 }
184
185 }
186
187 protected void PrimCrossing(ulong regionHandle, LLUUID primID, LLVector3 position, bool isPhysical)
188 {
189 handlerPrimCrossingIntoRegion = OnPrimCrossingIntoRegion;
190 if (handlerPrimCrossingIntoRegion != null)
191 {
192 handlerPrimCrossingIntoRegion(regionHandle, primID, position, isPhysical);
193 }
194 }
195
196 protected bool CloseConnection(ulong regionHandle, LLUUID agentID)
197 {
198 m_log.Info("[INTERREGION]: Incoming Agent Close Request for agent: " + agentID.ToString());
199 handlerCloseAgentConnection = OnCloseAgentConnection;
200 if (handlerCloseAgentConnection != null)
201 {
202 return handlerCloseAgentConnection(regionHandle, agentID);
203 }
204 return false;
205 }
206
207 #endregion
208
209 #region Inform Client of Neighbours
210
211 private delegate void InformClientOfNeighbourDelegate(
212 ScenePresence avatar, AgentCircuitData a, ulong regionHandle, IPEndPoint endPoint);
213
214 private void InformClientOfNeighbourCompleted(IAsyncResult iar)
215 {
216 InformClientOfNeighbourDelegate icon = (InformClientOfNeighbourDelegate) iar.AsyncState;
217 icon.EndInvoke(iar);
218 }
219
220 /// <summary>
221 /// Async compnent for informing client of which neighbours exists
222 /// </summary>
223 /// <remarks>
224 /// This needs to run asynchronesously, as a network timeout may block the thread for a long while
225 /// </remarks>
226 /// <param name="remoteClient"></param>
227 /// <param name="a"></param>
228 /// <param name="regionHandle"></param>
229 /// <param name="endPoint"></param>
230 private void InformClientOfNeighbourAsync(ScenePresence avatar, AgentCircuitData a, ulong regionHandle,
231 IPEndPoint endPoint)
232 {
233 m_log.Info("[INTERGRID]: Starting to inform client about neighbours");
234 bool regionAccepted = m_commsProvider.InterRegion.InformRegionOfChildAgent(regionHandle, a);
235
236 if (regionAccepted)
237 {
238 avatar.ControllingClient.InformClientOfNeighbour(regionHandle, endPoint);
239 avatar.AddNeighbourRegion(regionHandle);
240 m_log.Info("[INTERGRID]: Completed inform client about neighbours");
241 }
242 }
243
244 public void RequestNeighbors(RegionInfo region)
245 {
246 List<SimpleRegionInfo> neighbours =
247 m_commsProvider.GridService.RequestNeighbours(m_regionInfo.RegionLocX, m_regionInfo.RegionLocY);
248 //IPEndPoint blah = new IPEndPoint();
249
250 //blah.Address = region.RemotingAddress;
251 //blah.Port = region.RemotingPort;
252 }
253
254 /// <summary>
255 /// This informs all neighboring regions about agent "avatar".
256 /// Calls an asynchronous method to do so.. so it doesn't lag the sim.
257 /// </summary>
258 public void EnableNeighbourChildAgents(ScenePresence avatar, List<RegionInfo> lstneighbours)
259 {
260 List<SimpleRegionInfo> neighbours = new List<SimpleRegionInfo>();
261
262 //m_commsProvider.GridService.RequestNeighbours(m_regionInfo.RegionLocX, m_regionInfo.RegionLocY);
263 for (int i = 0; i < lstneighbours.Count; i++)
264 {
265 // We don't want to keep sending to regions that consistently fail on comms.
266 if (!(lstneighbours[i].commFailTF))
267 {
268 neighbours.Add(new SimpleRegionInfo(lstneighbours[i]));
269 }
270 }
271 // we're going to be using the above code once neighbour cache is correct. Currently it doesn't appear to be
272 // So we're temporarily going back to the old method of grabbing it from the Grid Server Every time :/
273 neighbours =
274 m_commsProvider.GridService.RequestNeighbours(m_regionInfo.RegionLocX, m_regionInfo.RegionLocY);
275
276 if (neighbours != null)
277 {
278 for (int i = 0; i < neighbours.Count; i++)
279 {
280 AgentCircuitData agent = avatar.ControllingClient.RequestClientInfo();
281 agent.BaseFolder = LLUUID.Zero;
282 agent.InventoryFolder = LLUUID.Zero;
283 agent.startpos = new LLVector3(128, 128, 70);
284 agent.child = true;
285
286 InformClientOfNeighbourDelegate d = InformClientOfNeighbourAsync;
287
288 try
289 {
290 d.BeginInvoke(avatar, agent, neighbours[i].RegionHandle, neighbours[i].ExternalEndPoint,
291 InformClientOfNeighbourCompleted,
292 d);
293 }
294 catch (Exception e)
295 {
296 m_log.ErrorFormat(
297 "[REGIONINFO]: Could not resolve external hostname {0} for region {1} ({2}, {3}). {4}",
298 neighbours[i].ExternalHostName,
299 neighbours[i].RegionHandle,
300 neighbours[i].RegionLocX,
301 neighbours[i].RegionLocY,
302 e);
303
304 // FIXME: Okay, even though we've failed, we're still going to throw the exception on,
305 // since I don't know what will happen if we just let the client continue
306
307 // XXX: Well, decided to swallow the exception instead for now. Let us see how that goes.
308 // throw e;
309
310 }
311 }
312 }
313 }
314
315 /// <summary>
316 /// This informs a single neighboring region about agent "avatar".
317 /// Calls an asynchronous method to do so.. so it doesn't lag the sim.
318 /// </summary>
319 public void InformNeighborChildAgent(ScenePresence avatar, RegionInfo region, List<RegionInfo> neighbours)
320 {
321 AgentCircuitData agent = avatar.ControllingClient.RequestClientInfo();
322 agent.BaseFolder = LLUUID.Zero;
323 agent.InventoryFolder = LLUUID.Zero;
324 agent.startpos = new LLVector3(128, 128, 70);
325 agent.child = true;
326
327 InformClientOfNeighbourDelegate d = InformClientOfNeighbourAsync;
328 d.BeginInvoke(avatar, agent, region.RegionHandle, region.ExternalEndPoint,
329 InformClientOfNeighbourCompleted,
330 d);
331 }
332
333 #endregion
334
335 public delegate void InformNeighbourThatRegionUpDelegate(RegionInfo region, ulong regionhandle);
336
337 private void InformNeighborsThatRegionisUpCompleted(IAsyncResult iar) 134 private void InformNeighborsThatRegionisUpCompleted(IAsyncResult iar)
338 { 135 {
339 InformNeighbourThatRegionUpDelegate icon = (InformNeighbourThatRegionUpDelegate) iar.AsyncState; 136 InformNeighbourThatRegionUpDelegate icon = (InformNeighbourThatRegionUpDelegate) iar.AsyncState;
@@ -390,8 +187,6 @@ namespace OpenSim.Region.Environment.Scenes
390 //bool val = m_commsProvider.InterRegion.RegionUp(new SearializableRegionInfo(region)); 187 //bool val = m_commsProvider.InterRegion.RegionUp(new SearializableRegionInfo(region));
391 } 188 }
392 189
393 public delegate void SendChildAgentDataUpdateDelegate(ChildAgentDataUpdate cAgentData, ScenePresence presence);
394
395 /// <summary> 190 /// <summary>
396 /// This informs all neighboring regions about the settings of it's child agent. 191 /// This informs all neighboring regions about the settings of it's child agent.
397 /// Calls an asynchronous method to do so.. so it doesn't lag the sim. 192 /// Calls an asynchronous method to do so.. so it doesn't lag the sim.
@@ -422,7 +217,6 @@ namespace OpenSim.Region.Environment.Scenes
422 { 217 {
423 // We're ignoring a collection was modified error because this data gets old and outdated fast. 218 // We're ignoring a collection was modified error because this data gets old and outdated fast.
424 } 219 }
425
426 } 220 }
427 221
428 private void SendChildAgentDataUpdateCompleted(IAsyncResult iar) 222 private void SendChildAgentDataUpdateCompleted(IAsyncResult iar)
@@ -435,20 +229,17 @@ namespace OpenSim.Region.Environment.Scenes
435 { 229 {
436 // This assumes that we know what our neighbors are. 230 // This assumes that we know what our neighbors are.
437 SendChildAgentDataUpdateDelegate d = SendChildAgentDataUpdateAsync; 231 SendChildAgentDataUpdateDelegate d = SendChildAgentDataUpdateAsync;
438 d.BeginInvoke(cAgentData,presence, 232 d.BeginInvoke(cAgentData, presence,
439 SendChildAgentDataUpdateCompleted, 233 SendChildAgentDataUpdateCompleted,
440 d); 234 d);
441 } 235 }
442 236
443 public delegate void SendCloseChildAgentDelegate( LLUUID agentID, List<ulong> regionlst);
444
445 /// <summary> 237 /// <summary>
446 /// This Closes child agents on neighboring regions 238 /// This Closes child agents on neighboring regions
447 /// Calls an asynchronous method to do so.. so it doesn't lag the sim. 239 /// Calls an asynchronous method to do so.. so it doesn't lag the sim.
448 /// </summary> 240 /// </summary>
449 private void SendCloseChildAgentAsync(LLUUID agentID, List<ulong> regionlst) 241 private void SendCloseChildAgentAsync(LLUUID agentID, List<ulong> regionlst)
450 { 242 {
451
452 foreach (ulong regionHandle in regionlst) 243 foreach (ulong regionHandle in regionlst)
453 { 244 {
454 bool regionAccepted = m_commsProvider.InterRegion.TellRegionToCloseChildConnection(regionHandle, agentID); 245 bool regionAccepted = m_commsProvider.InterRegion.TellRegionToCloseChildConnection(regionHandle, agentID);
@@ -456,14 +247,11 @@ namespace OpenSim.Region.Environment.Scenes
456 if (regionAccepted) 247 if (regionAccepted)
457 { 248 {
458 m_log.Info("[INTERGRID]: Completed sending agent Close agent Request to neighbor"); 249 m_log.Info("[INTERGRID]: Completed sending agent Close agent Request to neighbor");
459
460 } 250 }
461 else 251 else
462 { 252 {
463 m_log.Info("[INTERGRID]: Failed sending agent Close agent Request to neighbor"); 253 m_log.Info("[INTERGRID]: Failed sending agent Close agent Request to neighbor");
464
465 } 254 }
466
467 } 255 }
468 // We remove the list of known regions from the agent's known region list through an event 256 // We remove the list of known regions from the agent's known region list through an event
469 // to scene, because, if an agent logged of, it's likely that there will be no scene presence 257 // to scene, because, if an agent logged of, it's likely that there will be no scene presence
@@ -477,7 +265,7 @@ namespace OpenSim.Region.Environment.Scenes
477 265
478 private void SendCloseChildAgentCompleted(IAsyncResult iar) 266 private void SendCloseChildAgentCompleted(IAsyncResult iar)
479 { 267 {
480 SendCloseChildAgentDelegate icon = (SendCloseChildAgentDelegate)iar.AsyncState; 268 SendCloseChildAgentDelegate icon = (SendCloseChildAgentDelegate) iar.AsyncState;
481 icon.EndInvoke(iar); 269 icon.EndInvoke(iar);
482 } 270 }
483 271
@@ -556,28 +344,28 @@ namespace OpenSim.Region.Environment.Scenes
556 // assume local regions are always up 344 // assume local regions are always up
557 destRegionUp = true; 345 destRegionUp = true;
558 } 346 }
559 if(destRegionUp) 347 if (destRegionUp)
560 { 348 {
561 avatar.Close(); 349 avatar.Close();
562 350
563 // Compared to ScenePresence.CrossToNewRegion(), there's no obvious code to handle a teleport 351 // Compared to ScenePresence.CrossToNewRegion(), there's no obvious code to handle a teleport
564 // failure at this point (unlike a border crossing failure). So perhaps this can never fail 352 // failure at this point (unlike a border crossing failure). So perhaps this can never fail
565 // once we reach here... 353 // once we reach here...
566 avatar.Scene.RemoveCapsHandler(avatar.UUID); 354 avatar.Scene.RemoveCapsHandler(avatar.UUID);
567 355
568 m_commsProvider.InterRegion.InformRegionOfChildAgent(regionHandle, agent); 356 m_commsProvider.InterRegion.InformRegionOfChildAgent(regionHandle, agent);
569 m_commsProvider.InterRegion.ExpectAvatarCrossing(regionHandle, avatar.ControllingClient.AgentId, 357 m_commsProvider.InterRegion.ExpectAvatarCrossing(regionHandle, avatar.ControllingClient.AgentId,
570 position, false); 358 position, false);
571 AgentCircuitData circuitdata = avatar.ControllingClient.RequestClientInfo(); 359 AgentCircuitData circuitdata = avatar.ControllingClient.RequestClientInfo();
572 360
573 // TODO Should construct this behind a method 361 // TODO Should construct this behind a method
574 string capsPath = 362 string capsPath =
575 "http://" + reg.ExternalHostName + ":" + reg.HttpPort 363 "http://" + reg.ExternalHostName + ":" + reg.HttpPort
576 + "/CAPS/" + circuitdata.CapsPath + "0000/"; 364 + "/CAPS/" + circuitdata.CapsPath + "0000/";
577 365
578 m_log.DebugFormat( 366 m_log.DebugFormat(
579 "[CAPS]: Sending new CAPS seed url {0} to client {1}", capsPath, avatar.UUID); 367 "[CAPS]: Sending new CAPS seed url {0} to client {1}", capsPath, avatar.UUID);
580 368
581 avatar.ControllingClient.SendRegionTeleport(regionHandle, 13, reg.ExternalEndPoint, 4, (1 << 4), 369 avatar.ControllingClient.SendRegionTeleport(regionHandle, 13, reg.ExternalEndPoint, 4, (1 << 4),
582 capsPath); 370 capsPath);
583 avatar.MakeChildAgent(); 371 avatar.MakeChildAgent();
@@ -587,13 +375,13 @@ namespace OpenSim.Region.Environment.Scenes
587 { 375 {
588 KillObject(avatar.LocalId); 376 KillObject(avatar.LocalId);
589 } 377 }
590 uint newRegionX = (uint)(regionHandle >> 40); 378 uint newRegionX = (uint) (regionHandle >> 40);
591 uint newRegionY = (((uint)(regionHandle)) >> 8); 379 uint newRegionY = (((uint) (regionHandle)) >> 8);
592 uint oldRegionX = (uint)(m_regionInfo.RegionHandle >> 40); 380 uint oldRegionX = (uint) (m_regionInfo.RegionHandle >> 40);
593 uint oldRegionY = (((uint)(m_regionInfo.RegionHandle)) >> 8); 381 uint oldRegionY = (((uint) (m_regionInfo.RegionHandle)) >> 8);
594 if (Util.fast_distance2d((int)(newRegionX - oldRegionX), (int)(newRegionY - oldRegionY)) > 3) 382 if (Util.fast_distance2d((int) (newRegionX - oldRegionX), (int) (newRegionY - oldRegionY)) > 3)
595 { 383 {
596 SendCloseChildAgentConnections(avatar.UUID,avatar.GetKnownRegionList()); 384 SendCloseChildAgentConnections(avatar.UUID, avatar.GetKnownRegionList());
597 } 385 }
598 } 386 }
599 else 387 else
@@ -628,7 +416,7 @@ namespace OpenSim.Region.Environment.Scenes
628 416
629 public void LogOffUser(LLUUID userid, LLUUID regionid, ulong regionhandle, float posx, float posy, float posz) 417 public void LogOffUser(LLUUID userid, LLUUID regionid, ulong regionhandle, float posx, float posy, float posz)
630 { 418 {
631 m_commsProvider.LogOffUser(userid, regionid, regionhandle, posx, posy, posz); 419 m_commsProvider.LogOffUser(userid, regionid, regionhandle, posx, posy, posz);
632 } 420 }
633 421
634 public void ClearUserAgent(LLUUID avatarID) 422 public void ClearUserAgent(LLUUID avatarID)
@@ -656,7 +444,7 @@ namespace OpenSim.Region.Environment.Scenes
656 return m_commsProvider.GetUserFriendList(friendlistowner); 444 return m_commsProvider.GetUserFriendList(friendlistowner);
657 } 445 }
658 446
659 public List<MapBlockData> RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY) 447 public List<MapBlockData> RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY)
660 { 448 {
661 return m_commsProvider.GridService.RequestNeighbourMapBlocks(minX, minY, maxX, maxY); 449 return m_commsProvider.GridService.RequestNeighbourMapBlocks(minX, minY, maxX, maxY);
662 } 450 }
@@ -665,5 +453,213 @@ namespace OpenSim.Region.Environment.Scenes
665 { 453 {
666 return m_commsProvider.GenerateAgentPickerRequestResponse(queryID, query); 454 return m_commsProvider.GenerateAgentPickerRequestResponse(queryID, query);
667 } 455 }
456
457 #region CommsManager Event handlers
458
459 /// <summary>
460 ///
461 /// </summary>
462 /// <param name="regionHandle"></param>
463 /// <param name="agent"></param>
464 ///
465 protected void NewUserConnection(ulong regionHandle, AgentCircuitData agent)
466 {
467 handlerExpectUser = OnExpectUser;
468 if (handlerExpectUser != null)
469 {
470 //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: OnExpectUser Fired for User:" + agent.firstname + " " + agent.lastname);
471 handlerExpectUser(regionHandle, agent);
472 }
473 }
474
475 protected bool newRegionUp(RegionInfo region)
476 {
477 handlerRegionUp = OnRegionUp;
478 if (handlerRegionUp != null)
479 {
480 //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: newRegionUp Fired for User:" + region.RegionName);
481 handlerRegionUp(region);
482 }
483 return true;
484 }
485
486 protected bool ChildAgentUpdate(ulong regionHandle, ChildAgentDataUpdate cAgentData)
487 {
488 handlerChildAgentUpdate = OnChildAgentUpdate;
489 if (handlerChildAgentUpdate != null)
490 handlerChildAgentUpdate(regionHandle, cAgentData);
491
492
493 return true;
494 }
495
496 protected void AgentCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position, bool isFlying)
497 {
498 handlerAvatarCrossingIntoRegion = OnAvatarCrossingIntoRegion;
499 if (handlerAvatarCrossingIntoRegion != null)
500 {
501 handlerAvatarCrossingIntoRegion(regionHandle, agentID, position, isFlying);
502 }
503 }
504
505 protected bool IncomingPrimCrossing(ulong regionHandle, LLUUID primID, String objXMLData, int XMLMethod)
506 {
507 handlerExpectPrim = OnExpectPrim;
508 if (handlerExpectPrim != null)
509 {
510 return handlerExpectPrim(regionHandle, primID, objXMLData, XMLMethod);
511 }
512 else
513 {
514 return false;
515 }
516 }
517
518 protected void PrimCrossing(ulong regionHandle, LLUUID primID, LLVector3 position, bool isPhysical)
519 {
520 handlerPrimCrossingIntoRegion = OnPrimCrossingIntoRegion;
521 if (handlerPrimCrossingIntoRegion != null)
522 {
523 handlerPrimCrossingIntoRegion(regionHandle, primID, position, isPhysical);
524 }
525 }
526
527 protected bool CloseConnection(ulong regionHandle, LLUUID agentID)
528 {
529 m_log.Info("[INTERREGION]: Incoming Agent Close Request for agent: " + agentID);
530 handlerCloseAgentConnection = OnCloseAgentConnection;
531 if (handlerCloseAgentConnection != null)
532 {
533 return handlerCloseAgentConnection(regionHandle, agentID);
534 }
535 return false;
536 }
537
538 #endregion
539
540 #region Inform Client of Neighbours
541
542 private void InformClientOfNeighbourCompleted(IAsyncResult iar)
543 {
544 InformClientOfNeighbourDelegate icon = (InformClientOfNeighbourDelegate) iar.AsyncState;
545 icon.EndInvoke(iar);
546 }
547
548 /// <summary>
549 /// Async compnent for informing client of which neighbours exists
550 /// </summary>
551 /// <remarks>
552 /// This needs to run asynchronesously, as a network timeout may block the thread for a long while
553 /// </remarks>
554 /// <param name="remoteClient"></param>
555 /// <param name="a"></param>
556 /// <param name="regionHandle"></param>
557 /// <param name="endPoint"></param>
558 private void InformClientOfNeighbourAsync(ScenePresence avatar, AgentCircuitData a, ulong regionHandle,
559 IPEndPoint endPoint)
560 {
561 m_log.Info("[INTERGRID]: Starting to inform client about neighbours");
562 bool regionAccepted = m_commsProvider.InterRegion.InformRegionOfChildAgent(regionHandle, a);
563
564 if (regionAccepted)
565 {
566 avatar.ControllingClient.InformClientOfNeighbour(regionHandle, endPoint);
567 avatar.AddNeighbourRegion(regionHandle);
568 m_log.Info("[INTERGRID]: Completed inform client about neighbours");
569 }
570 }
571
572 public void RequestNeighbors(RegionInfo region)
573 {
574 List<SimpleRegionInfo> neighbours =
575 m_commsProvider.GridService.RequestNeighbours(m_regionInfo.RegionLocX, m_regionInfo.RegionLocY);
576 //IPEndPoint blah = new IPEndPoint();
577
578 //blah.Address = region.RemotingAddress;
579 //blah.Port = region.RemotingPort;
580 }
581
582 /// <summary>
583 /// This informs all neighboring regions about agent "avatar".
584 /// Calls an asynchronous method to do so.. so it doesn't lag the sim.
585 /// </summary>
586 public void EnableNeighbourChildAgents(ScenePresence avatar, List<RegionInfo> lstneighbours)
587 {
588 List<SimpleRegionInfo> neighbours = new List<SimpleRegionInfo>();
589
590 //m_commsProvider.GridService.RequestNeighbours(m_regionInfo.RegionLocX, m_regionInfo.RegionLocY);
591 for (int i = 0; i < lstneighbours.Count; i++)
592 {
593 // We don't want to keep sending to regions that consistently fail on comms.
594 if (!(lstneighbours[i].commFailTF))
595 {
596 neighbours.Add(new SimpleRegionInfo(lstneighbours[i]));
597 }
598 }
599 // we're going to be using the above code once neighbour cache is correct. Currently it doesn't appear to be
600 // So we're temporarily going back to the old method of grabbing it from the Grid Server Every time :/
601 neighbours =
602 m_commsProvider.GridService.RequestNeighbours(m_regionInfo.RegionLocX, m_regionInfo.RegionLocY);
603
604 if (neighbours != null)
605 {
606 for (int i = 0; i < neighbours.Count; i++)
607 {
608 AgentCircuitData agent = avatar.ControllingClient.RequestClientInfo();
609 agent.BaseFolder = LLUUID.Zero;
610 agent.InventoryFolder = LLUUID.Zero;
611 agent.startpos = new LLVector3(128, 128, 70);
612 agent.child = true;
613
614 InformClientOfNeighbourDelegate d = InformClientOfNeighbourAsync;
615
616 try
617 {
618 d.BeginInvoke(avatar, agent, neighbours[i].RegionHandle, neighbours[i].ExternalEndPoint,
619 InformClientOfNeighbourCompleted,
620 d);
621 }
622 catch (Exception e)
623 {
624 m_log.ErrorFormat(
625 "[REGIONINFO]: Could not resolve external hostname {0} for region {1} ({2}, {3}). {4}",
626 neighbours[i].ExternalHostName,
627 neighbours[i].RegionHandle,
628 neighbours[i].RegionLocX,
629 neighbours[i].RegionLocY,
630 e);
631
632 // FIXME: Okay, even though we've failed, we're still going to throw the exception on,
633 // since I don't know what will happen if we just let the client continue
634
635 // XXX: Well, decided to swallow the exception instead for now. Let us see how that goes.
636 // throw e;
637 }
638 }
639 }
640 }
641
642 /// <summary>
643 /// This informs a single neighboring region about agent "avatar".
644 /// Calls an asynchronous method to do so.. so it doesn't lag the sim.
645 /// </summary>
646 public void InformNeighborChildAgent(ScenePresence avatar, RegionInfo region, List<RegionInfo> neighbours)
647 {
648 AgentCircuitData agent = avatar.ControllingClient.RequestClientInfo();
649 agent.BaseFolder = LLUUID.Zero;
650 agent.InventoryFolder = LLUUID.Zero;
651 agent.startpos = new LLVector3(128, 128, 70);
652 agent.child = true;
653
654 InformClientOfNeighbourDelegate d = InformClientOfNeighbourAsync;
655 d.BeginInvoke(avatar, agent, region.RegionHandle, region.ExternalEndPoint,
656 InformClientOfNeighbourCompleted,
657 d);
658 }
659
660 private delegate void InformClientOfNeighbourDelegate(
661 ScenePresence avatar, AgentCircuitData a, ulong regionHandle, IPEndPoint endPoint);
662
663 #endregion
668 } 664 }
669} 665} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Scenes/SceneEvents.cs b/OpenSim/Region/Environment/Scenes/SceneEvents.cs
index 002fc5d..297d796 100644
--- a/OpenSim/Region/Environment/Scenes/SceneEvents.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneEvents.cs
@@ -38,194 +38,179 @@ namespace OpenSim.Region.Environment.Scenes
38 /// </summary> 38 /// </summary>
39 public class EventManager 39 public class EventManager
40 { 40 {
41 public delegate void OnFrameDelegate(); 41 #region Delegates
42 42
43 public event OnFrameDelegate OnFrame; 43 public delegate void AvatarEnteringNewParcel(ScenePresence avatar, int localLandID, LLUUID regionID);
44
45 public delegate void ClientClosed(LLUUID clientID);
44 46
45 public delegate void ClientMovement(ScenePresence client); 47 public delegate void ClientMovement(ScenePresence client);
46 48
47 public event ClientMovement OnClientMovement; 49 /// <summary>
50 /// DeregisterCapsEvent is called by Scene when the caps
51 /// handler for an agent are removed.
52 /// </summary>
53 public delegate void DeregisterCapsEvent(LLUUID agentID, Caps caps);
48 54
49 public delegate void OnTerrainTickDelegate(); 55 public delegate void LandBuy(Object sender, LandBuyArgs e);
50 56
51 public event OnTerrainTickDelegate OnTerrainTick; 57 public delegate void LandObjectAdded(ILandObject newParcel);
52 58
53 public delegate void OnBackupDelegate(IRegionDataStore datastore); 59 public delegate void LandObjectRemoved(LLUUID globalID);
54 60
55 public event OnBackupDelegate OnBackup; 61 public delegate void MoneyTransferEvent(Object sender, MoneyTransferArgs e);
56 62
57 public delegate void OnNewClientDelegate(IClientAPI client); 63 public delegate void NewGridInstantMessage(GridInstantMessage message);
58 64
59 public event OnNewClientDelegate OnNewClient; 65 public delegate void NewInventoryItemUploadComplete(LLUUID avatarID, LLUUID assetID, string name, int userlevel);
60 66
61 public delegate void OnNewPresenceDelegate(ScenePresence presence); 67 public delegate void NewRezScript(uint localID, LLUUID itemID, string script);
62 68
63 public event OnNewPresenceDelegate OnNewPresence; 69 public delegate void ObjectDeGrabDelegate(uint localID, IClientAPI remoteClient);
64 70
65 public delegate void OnRemovePresenceDelegate(LLUUID agentId); 71 public delegate void ObjectGrabDelegate(uint localID, LLVector3 offsetPos, IClientAPI remoteClient);
66 72
67 public event OnRemovePresenceDelegate OnRemovePresence; 73 public delegate void OnBackupDelegate(IRegionDataStore datastore);
68 74
69 public delegate void OnParcelPrimCountUpdateDelegate(); 75 public delegate void OnFrameDelegate();
70 76
71 public event OnParcelPrimCountUpdateDelegate OnParcelPrimCountUpdate; 77 public delegate void OnNewClientDelegate(IClientAPI client);
78
79 public delegate void OnNewPresenceDelegate(ScenePresence presence);
72 80
73 public delegate void OnParcelPrimCountAddDelegate(SceneObjectGroup obj); 81 public delegate void OnParcelPrimCountAddDelegate(SceneObjectGroup obj);
74 82
75 public event OnParcelPrimCountAddDelegate OnParcelPrimCountAdd; 83 public delegate void OnParcelPrimCountUpdateDelegate();
84
85 public delegate void OnPermissionErrorDelegate(LLUUID user, string reason);
76 86
77 public delegate void OnPluginConsoleDelegate(string[] args); 87 public delegate void OnPluginConsoleDelegate(string[] args);
78 88
79 public event OnPluginConsoleDelegate OnPluginConsole; 89 public delegate void OnRemovePresenceDelegate(LLUUID agentId);
80 90
81 public delegate void OnShutdownDelegate(); 91 public delegate void OnShutdownDelegate();
82 92
83 public event OnShutdownDelegate OnShutdown; 93 public delegate void OnTerrainTickDelegate();
84 94
85 public delegate void ObjectGrabDelegate(uint localID, LLVector3 offsetPos, IClientAPI remoteClient); 95 /// <summary>
86 public delegate void ObjectDeGrabDelegate(uint localID, IClientAPI remoteClient); 96 /// RegisterCapsEvent is called by Scene after the Caps object
97 /// has been instantiated and before it is return to the
98 /// client and provides region modules to add their caps.
99 /// </summary>
100 public delegate void RegisterCapsEvent(LLUUID agentID, Caps caps);
87 101
88 public delegate void OnPermissionErrorDelegate(LLUUID user, string reason); 102 public delegate void RemoveScript(uint localID, LLUUID itemID);
103
104 public delegate void SceneGroupGrabed(LLUUID groupID, LLVector3 offset, LLUUID userID);
105
106 public delegate bool SceneGroupMoved(LLUUID groupID, LLVector3 delta);
107
108 public delegate void ScriptAtTargetEvent(uint localID, uint handle, LLVector3 targetpos, LLVector3 atpos);
109
110 public delegate void ScriptChangedEvent(uint localID, uint change);
111
112 public delegate void ScriptNotAtTargetEvent(uint localID);
113
114 #endregion
115
116 private AvatarEnteringNewParcel handlerAvatarEnteringNewParcel; //OnAvatarEnteringNewParcel;
117 private OnBackupDelegate handlerBackup; //OnBackup;
118 private ClientClosed handlerClientClosed; //OnClientClosed;
119 private ClientMovement handlerClientMovement; //OnClientMovement;
120 private DeregisterCapsEvent handlerDeregisterCaps; // OnDeregisterCaps;
121 private OnFrameDelegate handlerFrame; //OnFrame;
122 private NewGridInstantMessage handlerGridInstantMessageToFriends; //OnGridInstantMessageToFriendsModule;
123 private NewGridInstantMessage handlerGridInstantMessageToIM; //OnGridInstantMessageToIMModule;
124 private LandBuy handlerLandBuy;
125 private LandObjectAdded handlerLandObjectAdded; //OnLandObjectAdded;
126 private LandObjectRemoved handlerLandObjectRemoved; //OnLandObjectRemoved;
127 private OnNewPresenceDelegate handlerMakeChildAgent; //OnMakeChildAgent;
128 private MoneyTransferEvent handlerMoneyTransfer; //OnMoneyTransfer;
129 private OnNewClientDelegate handlerNewClient; //OnNewClient;
130 private NewInventoryItemUploadComplete handlerNewInventoryItemUpdateComplete;
131 private OnNewPresenceDelegate handlerNewPresence; //OnNewPresence;
132 private ObjectDeGrabDelegate handlerObjectDeGrab; //OnObjectDeGrab;
133 private ObjectGrabDelegate handlerObjectGrab; //OnObjectGrab;
134 private OnParcelPrimCountAddDelegate handlerParcelPrimCountAdd; //OnParcelPrimCountAdd;
135 private OnParcelPrimCountUpdateDelegate handlerParcelPrimCountUpdate; //OnParcelPrimCountUpdate;
136 private OnPermissionErrorDelegate handlerPermissionError; //OnPermissionError;
137 private OnPluginConsoleDelegate handlerPluginConsole; //OnPluginConsole;
138 private RegisterCapsEvent handlerRegisterCaps; // OnRegisterCaps;
139 private OnRemovePresenceDelegate handlerRemovePresence; //OnRemovePresence;
140 private RemoveScript handlerRemoveScript; //OnRemoveScript;
141 private NewRezScript handlerRezScript; //OnRezScript;
142 private SceneGroupGrabed handlerSceneGroupGrab; //OnSceneGroupGrab;
143 private SceneGroupMoved handlerSceneGroupMove; //OnSceneGroupMove;
144 private ScriptAtTargetEvent handlerScriptAtTargetEvent;
145 private ScriptChangedEvent handlerScriptChangedEvent; //OnScriptChangedEvent;
146 private ScriptNotAtTargetEvent handlerScriptNotAtTargetEvent;
147 private OnShutdownDelegate handlerShutdown; //OnShutdown;
148 private OnTerrainTickDelegate handlerTerrainTick; // OnTerainTick;
149 private LandBuy handlerValidateLandBuy;
150
151 public event OnFrameDelegate OnFrame;
152
153 public event ClientMovement OnClientMovement;
154
155 public event OnTerrainTickDelegate OnTerrainTick;
156
157 public event OnBackupDelegate OnBackup;
158
159 public event OnNewClientDelegate OnNewClient;
160
161 public event OnNewPresenceDelegate OnNewPresence;
162
163 public event OnRemovePresenceDelegate OnRemovePresence;
164
165 public event OnParcelPrimCountUpdateDelegate OnParcelPrimCountUpdate;
166
167 public event OnParcelPrimCountAddDelegate OnParcelPrimCountAdd;
168
169 public event OnPluginConsoleDelegate OnPluginConsole;
170
171 public event OnShutdownDelegate OnShutdown;
89 172
90 public event ObjectGrabDelegate OnObjectGrab; 173 public event ObjectGrabDelegate OnObjectGrab;
91 public event ObjectDeGrabDelegate OnObjectDeGrab; 174 public event ObjectDeGrabDelegate OnObjectDeGrab;
92 175
93 public event OnPermissionErrorDelegate OnPermissionError; 176 public event OnPermissionErrorDelegate OnPermissionError;
94 177
95 public delegate void NewRezScript(uint localID, LLUUID itemID, string script);
96
97 public event NewRezScript OnRezScript; 178 public event NewRezScript OnRezScript;
98 179
99 public delegate void RemoveScript(uint localID, LLUUID itemID);
100
101 public event RemoveScript OnRemoveScript; 180 public event RemoveScript OnRemoveScript;
102 181
103 public delegate bool SceneGroupMoved(LLUUID groupID, LLVector3 delta);
104
105 public event SceneGroupMoved OnSceneGroupMove; 182 public event SceneGroupMoved OnSceneGroupMove;
106 183
107 public delegate void SceneGroupGrabed(LLUUID groupID, LLVector3 offset, LLUUID userID);
108
109 public event SceneGroupGrabed OnSceneGroupGrab; 184 public event SceneGroupGrabed OnSceneGroupGrab;
110 185
111 public delegate void LandObjectAdded(ILandObject newParcel);
112
113 public event LandObjectAdded OnLandObjectAdded; 186 public event LandObjectAdded OnLandObjectAdded;
114 187
115 public delegate void LandObjectRemoved(LLUUID globalID);
116
117 public event LandObjectRemoved OnLandObjectRemoved; 188 public event LandObjectRemoved OnLandObjectRemoved;
118 189
119 public delegate void AvatarEnteringNewParcel(ScenePresence avatar, int localLandID, LLUUID regionID);
120
121 public event AvatarEnteringNewParcel OnAvatarEnteringNewParcel; 190 public event AvatarEnteringNewParcel OnAvatarEnteringNewParcel;
122 191
123 192
124 public delegate void NewGridInstantMessage(GridInstantMessage message);
125
126 public event NewGridInstantMessage OnGridInstantMessageToIMModule; 193 public event NewGridInstantMessage OnGridInstantMessageToIMModule;
127 194
128 public event NewGridInstantMessage OnGridInstantMessageToFriendsModule; 195 public event NewGridInstantMessage OnGridInstantMessageToFriendsModule;
129 196
130 public event NewGridInstantMessage OnGridInstantMessageToGroupsModule; 197 public event NewGridInstantMessage OnGridInstantMessageToGroupsModule;
131 198
132 public delegate void ClientClosed(LLUUID clientID);
133
134 public event ClientClosed OnClientClosed; 199 public event ClientClosed OnClientClosed;
135 200
136 public delegate void ScriptChangedEvent(uint localID, uint change);
137
138 public event ScriptChangedEvent OnScriptChangedEvent; 201 public event ScriptChangedEvent OnScriptChangedEvent;
139 202
140 public delegate void ScriptAtTargetEvent(uint localID, uint handle, LLVector3 targetpos, LLVector3 atpos);
141
142 public event ScriptAtTargetEvent OnScriptAtTargetEvent; 203 public event ScriptAtTargetEvent OnScriptAtTargetEvent;
143 204
144 public delegate void ScriptNotAtTargetEvent(uint localID);
145
146 public event ScriptNotAtTargetEvent OnScriptNotAtTargetEvent; 205 public event ScriptNotAtTargetEvent OnScriptNotAtTargetEvent;
147 206
148 public event OnNewPresenceDelegate OnMakeChildAgent; 207 public event OnNewPresenceDelegate OnMakeChildAgent;
149 208
150 public delegate void NewInventoryItemUploadComplete(LLUUID avatarID, LLUUID assetID, string name, int userlevel);
151
152 public event NewInventoryItemUploadComplete OnNewInventoryItemUploadComplete; 209 public event NewInventoryItemUploadComplete OnNewInventoryItemUploadComplete;
153 210
154 /// <summary>
155 /// RegisterCapsEvent is called by Scene after the Caps object
156 /// has been instantiated and before it is return to the
157 /// client and provides region modules to add their caps.
158 /// </summary>
159 public delegate void RegisterCapsEvent(LLUUID agentID, Caps caps);
160 public event RegisterCapsEvent OnRegisterCaps; 211 public event RegisterCapsEvent OnRegisterCaps;
161 /// <summary>
162 /// DeregisterCapsEvent is called by Scene when the caps
163 /// handler for an agent are removed.
164 /// </summary>
165 public delegate void DeregisterCapsEvent(LLUUID agentID, Caps caps);
166 public event DeregisterCapsEvent OnDeregisterCaps;
167
168 public class MoneyTransferArgs : EventArgs
169 {
170 public LLUUID sender;
171 public LLUUID receiver;
172
173 // Always false. The SL protocol sucks.
174 public bool authenticated = false;
175
176 public int amount;
177 public int transactiontype;
178 public string description;
179
180 public MoneyTransferArgs(LLUUID asender, LLUUID areceiver, int aamount, int atransactiontype, string adescription) {
181 sender = asender;
182 receiver = areceiver;
183 amount = aamount;
184 transactiontype = atransactiontype;
185 description = adescription;
186 }
187 }
188
189 public class LandBuyArgs : EventArgs
190 {
191 public LLUUID agentId = LLUUID.Zero;
192
193 public LLUUID groupId = LLUUID.Zero;
194
195 public LLUUID parcelOwnerID = LLUUID.Zero;
196
197 public bool final = false;
198 public bool groupOwned = false;
199 public bool removeContribution = false;
200 public int parcelLocalID = 0;
201 public int parcelArea = 0;
202 public int parcelPrice = 0;
203 public bool authenticated = false;
204 public bool landValidated = false;
205 public bool economyValidated = false;
206 public int transactionID = 0;
207 public int amountDebited = 0;
208
209
210 public LandBuyArgs(LLUUID pagentId, LLUUID pgroupId, bool pfinal, bool pgroupOwned,
211 bool premoveContribution, int pparcelLocalID, int pparcelArea, int pparcelPrice,
212 bool pauthenticated)
213 {
214 agentId = pagentId;
215 groupId = pgroupId;
216 final = pfinal;
217 groupOwned = pgroupOwned;
218 removeContribution = premoveContribution;
219 parcelLocalID = pparcelLocalID;
220 parcelArea = pparcelArea;
221 parcelPrice = pparcelPrice;
222 authenticated = pauthenticated;
223 }
224 }
225
226 public delegate void MoneyTransferEvent(Object sender, MoneyTransferArgs e);
227 212
228 public delegate void LandBuy(Object sender, LandBuyArgs e); 213 public event DeregisterCapsEvent OnDeregisterCaps;
229 214
230 public event MoneyTransferEvent OnMoneyTransfer; 215 public event MoneyTransferEvent OnMoneyTransfer;
231 public event LandBuy OnLandBuy; 216 public event LandBuy OnLandBuy;
@@ -233,41 +218,6 @@ namespace OpenSim.Region.Environment.Scenes
233 218
234 /* Designated Event Deletage Instances */ 219 /* Designated Event Deletage Instances */
235 220
236 private ScriptChangedEvent handlerScriptChangedEvent = null; //OnScriptChangedEvent;
237 private ScriptAtTargetEvent handlerScriptAtTargetEvent = null;
238 private ScriptNotAtTargetEvent handlerScriptNotAtTargetEvent = null;
239 private ClientMovement handlerClientMovement = null; //OnClientMovement;
240 private OnPermissionErrorDelegate handlerPermissionError = null; //OnPermissionError;
241 private OnPluginConsoleDelegate handlerPluginConsole = null; //OnPluginConsole;
242 private OnFrameDelegate handlerFrame = null; //OnFrame;
243 private OnNewClientDelegate handlerNewClient = null; //OnNewClient;
244 private OnNewPresenceDelegate handlerNewPresence = null; //OnNewPresence;
245 private OnRemovePresenceDelegate handlerRemovePresence = null; //OnRemovePresence;
246 private OnBackupDelegate handlerBackup = null; //OnBackup;
247 private OnParcelPrimCountUpdateDelegate handlerParcelPrimCountUpdate = null; //OnParcelPrimCountUpdate;
248 private MoneyTransferEvent handlerMoneyTransfer = null; //OnMoneyTransfer;
249 private OnParcelPrimCountAddDelegate handlerParcelPrimCountAdd = null; //OnParcelPrimCountAdd;
250 private OnShutdownDelegate handlerShutdown = null; //OnShutdown;
251 private ObjectGrabDelegate handlerObjectGrab = null; //OnObjectGrab;
252 private ObjectDeGrabDelegate handlerObjectDeGrab = null; //OnObjectDeGrab;
253 private NewRezScript handlerRezScript = null; //OnRezScript;
254 private RemoveScript handlerRemoveScript = null; //OnRemoveScript;
255 private SceneGroupMoved handlerSceneGroupMove = null; //OnSceneGroupMove;
256 private SceneGroupGrabed handlerSceneGroupGrab = null; //OnSceneGroupGrab;
257 private LandObjectAdded handlerLandObjectAdded = null; //OnLandObjectAdded;
258 private LandObjectRemoved handlerLandObjectRemoved = null; //OnLandObjectRemoved;
259 private AvatarEnteringNewParcel handlerAvatarEnteringNewParcel = null; //OnAvatarEnteringNewParcel;
260 private NewGridInstantMessage handlerGridInstantMessageToIM = null; //OnGridInstantMessageToIMModule;
261 private NewGridInstantMessage handlerGridInstantMessageToFriends = null; //OnGridInstantMessageToFriendsModule;
262 private ClientClosed handlerClientClosed = null; //OnClientClosed;
263 private OnNewPresenceDelegate handlerMakeChildAgent = null; //OnMakeChildAgent;
264 private OnTerrainTickDelegate handlerTerrainTick = null; // OnTerainTick;
265 private RegisterCapsEvent handlerRegisterCaps = null; // OnRegisterCaps;
266 private DeregisterCapsEvent handlerDeregisterCaps = null; // OnDeregisterCaps;
267 private NewInventoryItemUploadComplete handlerNewInventoryItemUpdateComplete = null;
268 private LandBuy handlerLandBuy = null;
269 private LandBuy handlerValidateLandBuy = null;
270
271 public void TriggerOnScriptChangedEvent(uint localID, uint change) 221 public void TriggerOnScriptChangedEvent(uint localID, uint change)
272 { 222 {
273 handlerScriptChangedEvent = OnScriptChangedEvent; 223 handlerScriptChangedEvent = OnScriptChangedEvent;
@@ -343,7 +293,7 @@ namespace OpenSim.Region.Environment.Scenes
343 if (handlerParcelPrimCountUpdate != null) 293 if (handlerParcelPrimCountUpdate != null)
344 { 294 {
345 handlerParcelPrimCountUpdate(); 295 handlerParcelPrimCountUpdate();
346 } 296 }
347 } 297 }
348 298
349 public void TriggerMoneyTransfer(Object sender, MoneyTransferArgs e) 299 public void TriggerMoneyTransfer(Object sender, MoneyTransferArgs e)
@@ -492,7 +442,6 @@ namespace OpenSim.Region.Environment.Scenes
492 { 442 {
493 handlerGridInstantMessageToFriends(message); 443 handlerGridInstantMessageToFriends(message);
494 } 444 }
495
496 } 445 }
497 } 446 }
498 447
@@ -514,7 +463,7 @@ namespace OpenSim.Region.Environment.Scenes
514 } 463 }
515 } 464 }
516 465
517 public void TriggerOnRegisterCaps(LLUUID agentID, Caps caps) 466 public void TriggerOnRegisterCaps(LLUUID agentID, Caps caps)
518 { 467 {
519 handlerRegisterCaps = OnRegisterCaps; 468 handlerRegisterCaps = OnRegisterCaps;
520 if (handlerRegisterCaps != null) 469 if (handlerRegisterCaps != null)
@@ -523,7 +472,7 @@ namespace OpenSim.Region.Environment.Scenes
523 } 472 }
524 } 473 }
525 474
526 public void TriggerOnDeregisterCaps(LLUUID agentID, Caps caps) 475 public void TriggerOnDeregisterCaps(LLUUID agentID, Caps caps)
527 { 476 {
528 handlerDeregisterCaps = OnDeregisterCaps; 477 handlerDeregisterCaps = OnDeregisterCaps;
529 if (handlerDeregisterCaps != null) 478 if (handlerDeregisterCaps != null)
@@ -540,7 +489,8 @@ namespace OpenSim.Region.Environment.Scenes
540 handlerNewInventoryItemUpdateComplete(agentID, AssetID, AssetName, userlevel); 489 handlerNewInventoryItemUpdateComplete(agentID, AssetID, AssetName, userlevel);
541 } 490 }
542 } 491 }
543 public void TriggerLandBuy (Object sender, LandBuyArgs e) 492
493 public void TriggerLandBuy(Object sender, LandBuyArgs e)
544 { 494 {
545 handlerLandBuy = OnLandBuy; 495 handlerLandBuy = OnLandBuy;
546 if (handlerLandBuy != null) 496 if (handlerLandBuy != null)
@@ -548,6 +498,7 @@ namespace OpenSim.Region.Environment.Scenes
548 handlerLandBuy(sender, e); 498 handlerLandBuy(sender, e);
549 } 499 }
550 } 500 }
501
551 public void TriggerValidateLandBuy(Object sender, LandBuyArgs e) 502 public void TriggerValidateLandBuy(Object sender, LandBuyArgs e)
552 { 503 {
553 handlerValidateLandBuy = OnValidateLandBuy; 504 handlerValidateLandBuy = OnValidateLandBuy;
@@ -556,7 +507,7 @@ namespace OpenSim.Region.Environment.Scenes
556 handlerValidateLandBuy(sender, e); 507 handlerValidateLandBuy(sender, e);
557 } 508 }
558 } 509 }
559 510
560 public void TriggerAtTargetEvent(uint localID, uint handle, LLVector3 targetpos, LLVector3 currentpos) 511 public void TriggerAtTargetEvent(uint localID, uint handle, LLVector3 targetpos, LLVector3 currentpos)
561 { 512 {
562 handlerScriptAtTargetEvent = OnScriptAtTargetEvent; 513 handlerScriptAtTargetEvent = OnScriptAtTargetEvent;
@@ -574,5 +525,67 @@ namespace OpenSim.Region.Environment.Scenes
574 handlerScriptNotAtTargetEvent(localID); 525 handlerScriptNotAtTargetEvent(localID);
575 } 526 }
576 } 527 }
528
529 #region Nested type: LandBuyArgs
530
531 public class LandBuyArgs : EventArgs
532 {
533 public LLUUID agentId = LLUUID.Zero;
534 public int amountDebited;
535 public bool authenticated;
536 public bool economyValidated;
537
538 public bool final;
539 public LLUUID groupId = LLUUID.Zero;
540 public bool groupOwned;
541 public bool landValidated;
542 public int parcelArea;
543 public int parcelLocalID;
544 public LLUUID parcelOwnerID = LLUUID.Zero;
545 public int parcelPrice;
546 public bool removeContribution;
547 public int transactionID;
548
549
550 public LandBuyArgs(LLUUID pagentId, LLUUID pgroupId, bool pfinal, bool pgroupOwned,
551 bool premoveContribution, int pparcelLocalID, int pparcelArea, int pparcelPrice,
552 bool pauthenticated)
553 {
554 agentId = pagentId;
555 groupId = pgroupId;
556 final = pfinal;
557 groupOwned = pgroupOwned;
558 removeContribution = premoveContribution;
559 parcelLocalID = pparcelLocalID;
560 parcelArea = pparcelArea;
561 parcelPrice = pparcelPrice;
562 authenticated = pauthenticated;
563 }
564 }
565
566 #endregion
567
568 #region Nested type: MoneyTransferArgs
569
570 public class MoneyTransferArgs : EventArgs
571 {
572 public int amount;
573 public bool authenticated;
574 public string description;
575 public LLUUID receiver;
576 public LLUUID sender;
577 public int transactiontype;
578
579 public MoneyTransferArgs(LLUUID asender, LLUUID areceiver, int aamount, int atransactiontype, string adescription)
580 {
581 sender = asender;
582 receiver = areceiver;
583 amount = aamount;
584 transactiontype = atransactiontype;
585 description = adescription;
586 }
587 }
588
589 #endregion
577 } 590 }
578} 591} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Scenes/SceneManager.cs b/OpenSim/Region/Environment/Scenes/SceneManager.cs
index 2dfea2a..2325ed4 100644
--- a/OpenSim/Region/Environment/Scenes/SceneManager.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneManager.cs
@@ -41,10 +41,13 @@ namespace OpenSim.Region.Environment.Scenes
41 { 41 {
42 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 42 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
43 43
44 public event RestartSim OnRestartSim;
45
46 private readonly List<Scene> m_localScenes; 44 private readonly List<Scene> m_localScenes;
47 private Scene m_currentScene = null; 45 private Scene m_currentScene;
46
47 public SceneManager()
48 {
49 m_localScenes = new List<Scene>();
50 }
48 51
49 public List<Scene> Scenes 52 public List<Scene> Scenes
50 { 53 {
@@ -71,10 +74,7 @@ namespace OpenSim.Region.Environment.Scenes
71 } 74 }
72 } 75 }
73 76
74 public SceneManager() 77 public event RestartSim OnRestartSim;
75 {
76 m_localScenes = new List<Scene>();
77 }
78 78
79 public void Close() 79 public void Close()
80 { 80 {
@@ -180,7 +180,7 @@ namespace OpenSim.Region.Environment.Scenes
180 [Obsolete("TODO: Remove this warning by 0.7")] 180 [Obsolete("TODO: Remove this warning by 0.7")]
181 public bool RunTerrainCmdOnCurrentScene(string[] cmdparams, ref string result) 181 public bool RunTerrainCmdOnCurrentScene(string[] cmdparams, ref string result)
182 { 182 {
183 m_log.Warn("DEPRECIATED: The terrain engine has been replaced with a new terrain plugin module. Please type 'plugin terrain help' for new commands."); 183 m_log.Warn("DEPRECIATED: The terrain engine has been replaced with a new terrain plugin module. Please type 'plugin terrain help' for new commands.");
184 return false; 184 return false;
185 } 185 }
186 186
@@ -252,8 +252,8 @@ namespace OpenSim.Region.Environment.Scenes
252 252
253 public bool TrySetCurrentScene(LLUUID regionID) 253 public bool TrySetCurrentScene(LLUUID regionID)
254 { 254 {
255 Console.WriteLine("Searching for Region: '{0}'", regionID.ToString()); 255 Console.WriteLine("Searching for Region: '{0}'", regionID);
256 256
257 foreach (Scene scene in m_localScenes) 257 foreach (Scene scene in m_localScenes)
258 { 258 {
259 if (scene.RegionInfo.RegionID == regionID) 259 if (scene.RegionInfo.RegionID == regionID)
@@ -262,7 +262,7 @@ namespace OpenSim.Region.Environment.Scenes
262 return true; 262 return true;
263 } 263 }
264 } 264 }
265 265
266 return false; 266 return false;
267 } 267 }
268 268
@@ -313,7 +313,7 @@ namespace OpenSim.Region.Environment.Scenes
313 { 313 {
314 foreach (Scene mscene in m_localScenes) 314 foreach (Scene mscene in m_localScenes)
315 { 315 {
316 if((mscene.RegionInfo.InternalEndPoint.Equals(ipEndPoint.Address)) && 316 if ((mscene.RegionInfo.InternalEndPoint.Equals(ipEndPoint.Address)) &&
317 (mscene.RegionInfo.InternalEndPoint.Port == ipEndPoint.Port)) 317 (mscene.RegionInfo.InternalEndPoint.Port == ipEndPoint.Port))
318 { 318 {
319 scene = mscene; 319 scene = mscene;
@@ -327,22 +327,22 @@ namespace OpenSim.Region.Environment.Scenes
327 public void SetDebugPacketOnCurrentScene(int newDebug) 327 public void SetDebugPacketOnCurrentScene(int newDebug)
328 { 328 {
329 ForEachCurrentScene(delegate(Scene scene) 329 ForEachCurrentScene(delegate(Scene scene)
330 {
331 List<ScenePresence> scenePresences = scene.GetScenePresences();
332
333 foreach (ScenePresence scenePresence in scenePresences)
334 { 330 {
335 if (!scenePresence.IsChildAgent) 331 List<ScenePresence> scenePresences = scene.GetScenePresences();
336 {
337 m_log.ErrorFormat("Packet debug for {0} {1} set to {2}",
338 scenePresence.Firstname,
339 scenePresence.Lastname,
340 newDebug);
341 332
342 scenePresence.ControllingClient.SetDebug(newDebug); 333 foreach (ScenePresence scenePresence in scenePresences)
334 {
335 if (!scenePresence.IsChildAgent)
336 {
337 m_log.ErrorFormat("Packet debug for {0} {1} set to {2}",
338 scenePresence.Firstname,
339 scenePresence.Lastname,
340 newDebug);
341
342 scenePresence.ControllingClient.SetDebug(newDebug);
343 }
343 } 344 }
344 } 345 });
345 });
346 } 346 }
347 347
348 public List<ScenePresence> GetCurrentSceneAvatars() 348 public List<ScenePresence> GetCurrentSceneAvatars()
@@ -350,17 +350,17 @@ namespace OpenSim.Region.Environment.Scenes
350 List<ScenePresence> avatars = new List<ScenePresence>(); 350 List<ScenePresence> avatars = new List<ScenePresence>();
351 351
352 ForEachCurrentScene(delegate(Scene scene) 352 ForEachCurrentScene(delegate(Scene scene)
353 { 353 {
354 List<ScenePresence> scenePresences = scene.GetScenePresences(); 354 List<ScenePresence> scenePresences = scene.GetScenePresences();
355 355
356 foreach (ScenePresence scenePresence in scenePresences) 356 foreach (ScenePresence scenePresence in scenePresences)
357 { 357 {
358 if (!scenePresence.IsChildAgent) 358 if (!scenePresence.IsChildAgent)
359 { 359 {
360 avatars.Add(scenePresence); 360 avatars.Add(scenePresence);
361 } 361 }
362 } 362 }
363 }); 363 });
364 364
365 return avatars; 365 return avatars;
366 } 366 }
@@ -381,11 +381,11 @@ namespace OpenSim.Region.Environment.Scenes
381 public void SetCurrentSceneTimePhase(int timePhase) 381 public void SetCurrentSceneTimePhase(int timePhase)
382 { 382 {
383 ForEachCurrentScene(delegate(Scene scene) 383 ForEachCurrentScene(delegate(Scene scene)
384 { 384 {
385 scene.SetTimePhase( 385 scene.SetTimePhase(
386 timePhase) 386 timePhase)
387 ; 387 ;
388 }); 388 });
389 } 389 }
390 390
391 public void ForceCurrentSceneClientUpdate() 391 public void ForceCurrentSceneClientUpdate()
@@ -453,4 +453,4 @@ namespace OpenSim.Region.Environment.Scenes
453 m_localScenes.ForEach(action); 453 m_localScenes.ForEach(action);
454 } 454 }
455 } 455 }
456} 456} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.Inventory.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.Inventory.cs
index 824a536..d051ed9 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.Inventory.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.Inventory.cs
@@ -49,7 +49,6 @@ namespace OpenSim.Region.Environment.Scenes
49 if (part != null) 49 if (part != null)
50 { 50 {
51 part.StartScript(itemID); 51 part.StartScript(itemID);
52
53 } 52 }
54 else 53 else
55 { 54 {
@@ -57,9 +56,9 @@ namespace OpenSim.Region.Environment.Scenes
57 "[PRIMINVENTORY]: " + 56 "[PRIMINVENTORY]: " +
58 "Couldn't find part {0} in object group {1}, {2} to start script with ID {3}", 57 "Couldn't find part {0} in object group {1}, {2} to start script with ID {3}",
59 localID, Name, UUID, itemID); 58 localID, Name, UUID, itemID);
60 } 59 }
61 } 60 }
62 61
63// /// Start a given script. 62// /// Start a given script.
64// /// </summary> 63// /// </summary>
65// /// <param name="localID"> 64// /// <param name="localID">
@@ -80,7 +79,7 @@ namespace OpenSim.Region.Environment.Scenes
80// localID, Name, UUID, itemID); 79// localID, Name, UUID, itemID);
81// } 80// }
82// } 81// }
83 82
84 /// <summary> 83 /// <summary>
85 /// Start the scripts contained in all the prims in this group. 84 /// Start the scripts contained in all the prims in this group.
86 /// </summary> 85 /// </summary>
@@ -106,7 +105,7 @@ namespace OpenSim.Region.Environment.Scenes
106 } 105 }
107 } 106 }
108 } 107 }
109 108
110 /// Start a given script. 109 /// Start a given script.
111 /// </summary> 110 /// </summary>
112 /// <param name="localID"> 111 /// <param name="localID">
@@ -126,9 +125,9 @@ namespace OpenSim.Region.Environment.Scenes
126 "[PRIMINVENTORY]: " + 125 "[PRIMINVENTORY]: " +
127 "Couldn't find part {0} in object group {1}, {2} to stop script with ID {3}", 126 "Couldn't find part {0} in object group {1}, {2} to stop script with ID {3}",
128 partID, Name, UUID, itemID); 127 partID, Name, UUID, itemID);
129 } 128 }
130 } 129 }
131 130
132 /// <summary> 131 /// <summary>
133 /// 132 ///
134 /// </summary> 133 /// </summary>
@@ -171,7 +170,7 @@ namespace OpenSim.Region.Environment.Scenes
171 localID, Name, UUID); 170 localID, Name, UUID);
172 } 171 }
173 } 172 }
174 173
175 /// <summary> 174 /// <summary>
176 /// Add an inventory item to a prim in this group. 175 /// Add an inventory item to a prim in this group.
177 /// </summary> 176 /// </summary>
@@ -180,7 +179,7 @@ namespace OpenSim.Region.Environment.Scenes
180 /// <param name="item"></param> 179 /// <param name="item"></param>
181 /// <param name="copyItemID">The item UUID that should be used by the new item.</param> 180 /// <param name="copyItemID">The item UUID that should be used by the new item.</param>
182 /// <returns></returns> 181 /// <returns></returns>
183 public bool AddInventoryItem(IClientAPI remoteClient, uint localID, 182 public bool AddInventoryItem(IClientAPI remoteClient, uint localID,
184 InventoryItemBase item, LLUUID copyItemID) 183 InventoryItemBase item, LLUUID copyItemID)
185 { 184 {
186 LLUUID newItemId = (copyItemID != LLUUID.Zero) ? copyItemID : item.ID; 185 LLUUID newItemId = (copyItemID != LLUUID.Zero) ? copyItemID : item.ID;
@@ -189,8 +188,8 @@ namespace OpenSim.Region.Environment.Scenes
189 if (part != null) 188 if (part != null)
190 { 189 {
191 TaskInventoryItem taskItem = new TaskInventoryItem(); 190 TaskInventoryItem taskItem = new TaskInventoryItem();
192 191
193 taskItem.ItemID = newItemId; 192 taskItem.ItemID = newItemId;
194 taskItem.AssetID = item.AssetID; 193 taskItem.AssetID = item.AssetID;
195 taskItem.Name = item.Name; 194 taskItem.Name = item.Name;
196 taskItem.Description = item.Description; 195 taskItem.Description = item.Description;
@@ -198,15 +197,15 @@ namespace OpenSim.Region.Environment.Scenes
198 taskItem.CreatorID = item.Creator; 197 taskItem.CreatorID = item.Creator;
199 taskItem.Type = item.AssetType; 198 taskItem.Type = item.AssetType;
200 taskItem.InvType = item.InvType; 199 taskItem.InvType = item.InvType;
201 200
202 taskItem.BaseMask = item.BasePermissions; 201 taskItem.BaseMask = item.BasePermissions;
203 taskItem.OwnerMask = item.CurrentPermissions; 202 taskItem.OwnerMask = item.CurrentPermissions;
204 // FIXME: ignoring group permissions for now as they aren't stored in item 203 // FIXME: ignoring group permissions for now as they aren't stored in item
205 taskItem.EveryoneMask = item.EveryOnePermissions; 204 taskItem.EveryoneMask = item.EveryOnePermissions;
206 taskItem.NextOwnerMask = item.NextPermissions; 205 taskItem.NextOwnerMask = item.NextPermissions;
207 206
208 part.AddInventoryItem(taskItem); 207 part.AddInventoryItem(taskItem);
209 208
210 return true; 209 return true;
211 } 210 }
212 else 211 else
@@ -219,7 +218,7 @@ namespace OpenSim.Region.Environment.Scenes
219 218
220 return false; 219 return false;
221 } 220 }
222 221
223 /// <summary> 222 /// <summary>
224 /// Returns an existing inventory item. Returns the original, so any changes will be live. 223 /// Returns an existing inventory item. Returns the original, so any changes will be live.
225 /// </summary> 224 /// </summary>
@@ -239,11 +238,11 @@ namespace OpenSim.Region.Environment.Scenes
239 "[PRIMINVENTORY]: " + 238 "[PRIMINVENTORY]: " +
240 "Couldn't find prim local ID {0} in prim {1}, {2} to get inventory item ID {3}", 239 "Couldn't find prim local ID {0} in prim {1}, {2} to get inventory item ID {3}",
241 primID, part.Name, part.UUID, itemID); 240 primID, part.Name, part.UUID, itemID);
242 } 241 }
243 242
244 return null; 243 return null;
245 } 244 }
246 245
247 /// <summary> 246 /// <summary>
248 /// Update an existing inventory item. 247 /// Update an existing inventory item.
249 /// </summary> 248 /// </summary>
@@ -255,8 +254,8 @@ namespace OpenSim.Region.Environment.Scenes
255 SceneObjectPart part = GetChildPart(item.ParentPartID); 254 SceneObjectPart part = GetChildPart(item.ParentPartID);
256 if (part != null) 255 if (part != null)
257 { 256 {
258 part.UpdateInventoryItem(item); 257 part.UpdateInventoryItem(item);
259 258
260 return true; 259 return true;
261 } 260 }
262 else 261 else
@@ -265,22 +264,22 @@ namespace OpenSim.Region.Environment.Scenes
265 "[PRIMINVENTORY]: " + 264 "[PRIMINVENTORY]: " +
266 "Couldn't find prim ID {0} to update item {1}, {2}", 265 "Couldn't find prim ID {0} to update item {1}, {2}",
267 item.ParentPartID, item.Name, item.ItemID); 266 item.ParentPartID, item.Name, item.ItemID);
268 } 267 }
269 268
270 return false; 269 return false;
271 } 270 }
272 271
273 public int RemoveInventoryItem(uint localID, LLUUID itemID) 272 public int RemoveInventoryItem(uint localID, LLUUID itemID)
274 { 273 {
275 SceneObjectPart part = GetChildPart(localID); 274 SceneObjectPart part = GetChildPart(localID);
276 if (part != null) 275 if (part != null)
277 { 276 {
278 int type = part.RemoveInventoryItem(itemID); 277 int type = part.RemoveInventoryItem(itemID);
279 278
280 return type; 279 return type;
281 } 280 }
282 281
283 return -1; 282 return -1;
284 } 283 }
285 } 284 }
286} 285} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
index 5d39790..1ea2f24 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
@@ -72,7 +72,7 @@ namespace OpenSim.Region.Environment.Scenes
72 object_rez = 4194304 72 object_rez = 4194304
73 } 73 }
74 74
75 struct scriptPosTarget 75 internal struct scriptPosTarget
76 { 76 {
77 public LLVector3 targetPos; 77 public LLVector3 targetPos;
78 public float tolerance; 78 public float tolerance;
@@ -82,14 +82,14 @@ namespace OpenSim.Region.Environment.Scenes
82 82
83 public partial class SceneObjectGroup : EntityBase 83 public partial class SceneObjectGroup : EntityBase
84 { 84 {
85 private PrimCountTaintedDelegate handlerPrimCountTainted = null; 85 private readonly Dictionary<uint, scriptPosTarget> m_targets = new Dictionary<uint, scriptPosTarget>();
86 private PrimCountTaintedDelegate handlerPrimCountTainted;
86 87
87 /// <summary> 88 /// <summary>
88 /// Signal whether the non-inventory attributes of any prims in the group have changed 89 /// Signal whether the non-inventory attributes of any prims in the group have changed
89 /// since the group's last persistent backup 90 /// since the group's last persistent backup
90 /// </summary> 91 /// </summary>
91 public bool HasGroupChanged = false; 92 public bool HasGroupChanged;
92
93 93
94 94
95 private LLVector3 lastPhysGroupPos; 95 private LLVector3 lastPhysGroupPos;
@@ -104,11 +104,8 @@ namespace OpenSim.Region.Environment.Scenes
104 protected SceneObjectPart m_rootPart; 104 protected SceneObjectPart m_rootPart;
105 private Dictionary<LLUUID, scriptEvents> m_scriptEvents = new Dictionary<LLUUID, scriptEvents>(); 105 private Dictionary<LLUUID, scriptEvents> m_scriptEvents = new Dictionary<LLUUID, scriptEvents>();
106 106
107 private Dictionary<uint, scriptPosTarget> m_targets = new Dictionary<uint, scriptPosTarget>(); 107 private bool m_scriptListens_atTarget;
108 108 private bool m_scriptListens_notAtTarget;
109 private bool m_scriptListens_atTarget = false;
110 private bool m_scriptListens_notAtTarget = false;
111
112 109
113 #region Properties 110 #region Properties
114 111
@@ -119,7 +116,7 @@ namespace OpenSim.Region.Environment.Scenes
119 /// think really there should be a list (or whatever) in each scenepresence 116 /// think really there should be a list (or whatever) in each scenepresence
120 /// saying what prim(s) that user has selected. 117 /// saying what prim(s) that user has selected.
121 /// </summary> 118 /// </summary>
122 protected bool m_isSelected = false; 119 protected bool m_isSelected;
123 120
124 /// <summary> 121 /// <summary>
125 /// 122 ///
@@ -186,7 +183,6 @@ namespace OpenSim.Region.Environment.Scenes
186 string.Format("[SCENE OBJECT GROUP]: Object {0} has no root part.", m_uuid)); 183 string.Format("[SCENE OBJECT GROUP]: Object {0} has no root part.", m_uuid));
187 } 184 }
188 185
189
190 186
191 return m_rootPart.GroupPosition; 187 return m_rootPart.GroupPosition;
192 } 188 }
@@ -206,7 +202,7 @@ namespace OpenSim.Region.Environment.Scenes
206 part.GroupPosition = val; 202 part.GroupPosition = val;
207 } 203 }
208 } 204 }
209 205
210 //if (m_rootPart.PhysActor != null) 206 //if (m_rootPart.PhysActor != null)
211 //{ 207 //{
212 //m_rootPart.PhysActor.Position = 208 //m_rootPart.PhysActor.Position =
@@ -216,7 +212,7 @@ namespace OpenSim.Region.Environment.Scenes
216 //} 212 //}
217 } 213 }
218 } 214 }
219 215
220 public override uint LocalId 216 public override uint LocalId
221 { 217 {
222 get 218 get
@@ -515,10 +511,11 @@ namespace OpenSim.Region.Environment.Scenes
515 m_scene.EventManager.OnBackup += ProcessBackup; 511 m_scene.EventManager.OnBackup += ProcessBackup;
516 } 512 }
517 } 513 }
514
518 public LLVector3 GroupScale() 515 public LLVector3 GroupScale()
519 { 516 {
520 LLVector3 minScale = new LLVector3(Constants.RegionSize,Constants.RegionSize,Constants.RegionSize); 517 LLVector3 minScale = new LLVector3(Constants.RegionSize, Constants.RegionSize, Constants.RegionSize);
521 LLVector3 maxScale = new LLVector3(0f,0f,0f); 518 LLVector3 maxScale = new LLVector3(0f, 0f, 0f);
522 LLVector3 finalScale = new LLVector3(0.5f, 0.5f, 0.5f); 519 LLVector3 finalScale = new LLVector3(0.5f, 0.5f, 0.5f);
523 520
524 lock (m_parts) 521 lock (m_parts)
@@ -541,8 +538,8 @@ namespace OpenSim.Region.Environment.Scenes
541 finalScale.Y = (minScale.Y > maxScale.Y) ? minScale.Y : maxScale.Y; 538 finalScale.Y = (minScale.Y > maxScale.Y) ? minScale.Y : maxScale.Y;
542 finalScale.Z = (minScale.Z > maxScale.Z) ? minScale.Z : maxScale.Z; 539 finalScale.Z = (minScale.Z > maxScale.Z) ? minScale.Z : maxScale.Z;
543 return finalScale; 540 return finalScale;
544
545 } 541 }
542
546 public EntityIntersection TestIntersection(Ray hRay, bool frontFacesOnly, bool faceCenters) 543 public EntityIntersection TestIntersection(Ray hRay, bool frontFacesOnly, bool faceCenters)
547 { 544 {
548 // We got a request from the inner_scene to raytrace along the Ray hRay 545 // We got a request from the inner_scene to raytrace along the Ray hRay
@@ -565,7 +562,7 @@ namespace OpenSim.Region.Environment.Scenes
565 // Telling the prim to raytrace. 562 // Telling the prim to raytrace.
566 //EntityIntersection inter = part.TestIntersection(hRay, parentrotation); 563 //EntityIntersection inter = part.TestIntersection(hRay, parentrotation);
567 564
568 EntityIntersection inter = part.TestIntersectionOBB(hRay, parentrotation,frontFacesOnly, faceCenters); 565 EntityIntersection inter = part.TestIntersectionOBB(hRay, parentrotation, frontFacesOnly, faceCenters);
569 566
570 // This may need to be updated to the maximum draw distance possible.. 567 // This may need to be updated to the maximum draw distance possible..
571 // We might (and probably will) be checking for prim creation from other sims 568 // We might (and probably will) be checking for prim creation from other sims
@@ -684,12 +681,11 @@ namespace OpenSim.Region.Environment.Scenes
684 DetachFromBackup(this); 681 DetachFromBackup(this);
685 m_rootPart.m_attachedAvatar = agentID; 682 m_rootPart.m_attachedAvatar = agentID;
686 683
687 684
688 if (m_rootPart.PhysActor != null) 685 if (m_rootPart.PhysActor != null)
689 { 686 {
690 m_scene.PhysicsScene.RemovePrim(m_rootPart.PhysActor); 687 m_scene.PhysicsScene.RemovePrim(m_rootPart.PhysActor);
691 m_rootPart.PhysActor = null; 688 m_rootPart.PhysActor = null;
692
693 } 689 }
694 690
695 AbsolutePosition = AttachOffset; 691 AbsolutePosition = AttachOffset;
@@ -709,27 +705,28 @@ namespace OpenSim.Region.Environment.Scenes
709 m_rootPart.ScheduleFullUpdate(); 705 m_rootPart.ScheduleFullUpdate();
710 } 706 }
711 } 707 }
708
712 public byte GetAttachmentPoint() 709 public byte GetAttachmentPoint()
713 { 710 {
714 if (m_rootPart != null) 711 if (m_rootPart != null)
715 { 712 {
716 return m_rootPart.Shape.State; 713 return m_rootPart.Shape.State;
717 } 714 }
718 return (byte)0; 715 return 0;
719 } 716 }
720 717
721 public void ClearPartAttachmentData() 718 public void ClearPartAttachmentData()
722 { 719 {
723 foreach (SceneObjectPart part in m_parts.Values) 720 foreach (SceneObjectPart part in m_parts.Values)
724 { 721 {
725 part.SetAttachmentPoint((Byte)0); 722 part.SetAttachmentPoint(0);
726 } 723 }
727 } 724 }
728 725
729 public void DetachToGround() 726 public void DetachToGround()
730 { 727 {
731 ScenePresence avatar = m_scene.GetScenePresence(m_rootPart.m_attachedAvatar); 728 ScenePresence avatar = m_scene.GetScenePresence(m_rootPart.m_attachedAvatar);
732 LLVector3 detachedpos = new LLVector3(127f,127f,127f); 729 LLVector3 detachedpos = new LLVector3(127f, 127f, 127f);
733 if (avatar != null) 730 if (avatar != null)
734 { 731 {
735 detachedpos = avatar.AbsolutePosition; 732 detachedpos = avatar.AbsolutePosition;
@@ -738,14 +735,14 @@ namespace OpenSim.Region.Environment.Scenes
738 AbsolutePosition = detachedpos; 735 AbsolutePosition = detachedpos;
739 m_rootPart.m_attachedAvatar = LLUUID.Zero; 736 m_rootPart.m_attachedAvatar = LLUUID.Zero;
740 m_rootPart.SetParentLocalId(0); 737 m_rootPart.SetParentLocalId(0);
741 m_rootPart.SetAttachmentPoint((byte)0); 738 m_rootPart.SetAttachmentPoint(0);
742 m_rootPart.m_IsAttachment = false; 739 m_rootPart.m_IsAttachment = false;
743 m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_scene.m_physicalPrim); 740 m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_scene.m_physicalPrim);
744 AttachToBackup(); 741 AttachToBackup();
745 m_rootPart.ScheduleFullUpdate(); 742 m_rootPart.ScheduleFullUpdate();
746 m_rootPart.ClearUndoState(); 743 m_rootPart.ClearUndoState();
747
748 } 744 }
745
749 public void DetachToInventoryPrep() 746 public void DetachToInventoryPrep()
750 { 747 {
751 ScenePresence avatar = m_scene.GetScenePresence(m_rootPart.m_attachedAvatar); 748 ScenePresence avatar = m_scene.GetScenePresence(m_rootPart.m_attachedAvatar);
@@ -755,7 +752,7 @@ namespace OpenSim.Region.Environment.Scenes
755 //detachedpos = avatar.AbsolutePosition; 752 //detachedpos = avatar.AbsolutePosition;
756 avatar.RemoveAttachment(this); 753 avatar.RemoveAttachment(this);
757 } 754 }
758 755
759 m_rootPart.m_attachedAvatar = LLUUID.Zero; 756 m_rootPart.m_attachedAvatar = LLUUID.Zero;
760 m_rootPart.SetParentLocalId(0); 757 m_rootPart.SetParentLocalId(0);
761 //m_rootPart.SetAttachmentPoint((byte)0); 758 //m_rootPart.SetAttachmentPoint((byte)0);
@@ -764,8 +761,8 @@ namespace OpenSim.Region.Environment.Scenes
764 //m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_scene.m_physicalPrim); 761 //m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_scene.m_physicalPrim);
765 //AttachToBackup(); 762 //AttachToBackup();
766 //m_rootPart.ScheduleFullUpdate(); 763 //m_rootPart.ScheduleFullUpdate();
767
768 } 764 }
765
769 /// <summary> 766 /// <summary>
770 /// 767 ///
771 /// </summary> 768 /// </summary>
@@ -826,7 +823,6 @@ namespace OpenSim.Region.Environment.Scenes
826 try 823 try
827 { 824 {
828 m_parts.Add(part.UUID, part); 825 m_parts.Add(part.UUID, part);
829
830 } 826 }
831 catch (Exception e) 827 catch (Exception e)
832 { 828 {
@@ -847,7 +843,6 @@ namespace OpenSim.Region.Environment.Scenes
847 if (part.UUID != m_rootPart.UUID) 843 if (part.UUID != m_rootPart.UUID)
848 { 844 {
849 part.ParentID = m_rootPart.LocalId; 845 part.ParentID = m_rootPart.LocalId;
850
851 } 846 }
852 } 847 }
853 } 848 }
@@ -860,10 +855,10 @@ namespace OpenSim.Region.Environment.Scenes
860 foreach (SceneObjectPart part in m_parts.Values) 855 foreach (SceneObjectPart part in m_parts.Values)
861 { 856 {
862 part.UUID = LLUUID.Random(); 857 part.UUID = LLUUID.Random();
863
864 } 858 }
865 } 859 }
866 } 860 }
861
867 // helper provided for parts. 862 // helper provided for parts.
868 public int GetSceneMaxUndo() 863 public int GetSceneMaxUndo()
869 { 864 {
@@ -871,6 +866,7 @@ namespace OpenSim.Region.Environment.Scenes
871 return m_scene.MaxUndoCount; 866 return m_scene.MaxUndoCount;
872 return 5; 867 return 5;
873 } 868 }
869
874 public void ResetChildPrimPhysicsPositions() 870 public void ResetChildPrimPhysicsPositions()
875 { 871 {
876 AbsolutePosition = AbsolutePosition; 872 AbsolutePosition = AbsolutePosition;
@@ -897,7 +893,6 @@ namespace OpenSim.Region.Environment.Scenes
897 { 893 {
898 SceneObjectPart part = GetChildPart(localId); 894 SceneObjectPart part = GetChildPart(localId);
899 OnGrabPart(part, offsetPos, remoteClient); 895 OnGrabPart(part, offsetPos, remoteClient);
900
901 } 896 }
902 } 897 }
903 898
@@ -905,7 +900,6 @@ namespace OpenSim.Region.Environment.Scenes
905 { 900 {
906 part.StoreUndoState(); 901 part.StoreUndoState();
907 part.OnGrab(offsetPos, remoteClient); 902 part.OnGrab(offsetPos, remoteClient);
908
909 } 903 }
910 904
911 public virtual void OnGrabGroup(LLVector3 offsetPos, IClientAPI remoteClient) 905 public virtual void OnGrabGroup(LLVector3 offsetPos, IClientAPI remoteClient)
@@ -969,19 +963,19 @@ namespace OpenSim.Region.Environment.Scenes
969 963
970 public void aggregateScriptEvents() 964 public void aggregateScriptEvents()
971 { 965 {
972 uint objectflagupdate=(uint)RootPart.GetEffectiveObjectFlags(); 966 uint objectflagupdate = RootPart.GetEffectiveObjectFlags();
973 967
974 scriptEvents aggregateScriptEvents=0; 968 scriptEvents aggregateScriptEvents = 0;
975 969
976 lock (m_parts) 970 lock (m_parts)
977 { 971 {
978 foreach (SceneObjectPart part in m_parts.Values) 972 foreach (SceneObjectPart part in m_parts.Values)
979 { 973 {
980 if(part == null) 974 if (part == null)
981 continue; 975 continue;
982 if(part != RootPart) 976 if (part != RootPart)
983 part.ObjectFlags = objectflagupdate; 977 part.ObjectFlags = objectflagupdate;
984 aggregateScriptEvents |= part.m_aggregateScriptEvents; 978 aggregateScriptEvents |= part.m_aggregateScriptEvents;
985 } 979 }
986 } 980 }
987 981
@@ -1065,6 +1059,139 @@ namespace OpenSim.Region.Environment.Scenes
1065 } 1059 }
1066 } 1060 }
1067 1061
1062 internal void SetAxisRotation(int axis, int rotate10)
1063 {
1064 bool setX = false;
1065 bool setY = false;
1066 bool setZ = false;
1067
1068 int xaxis = 2;
1069 int yaxis = 4;
1070 int zaxis = 8;
1071
1072 if (m_rootPart != null)
1073 {
1074 setX = ((axis & xaxis) != 0) ? true : false;
1075 setY = ((axis & yaxis) != 0) ? true : false;
1076 setZ = ((axis & zaxis) != 0) ? true : false;
1077
1078 float setval = (rotate10 > 0) ? 1f : 0f;
1079
1080 if (setX)
1081 m_rootPart.m_rotationAxis.X = setval;
1082 if (setY)
1083 m_rootPart.m_rotationAxis.Y = setval;
1084 if (setZ)
1085 m_rootPart.m_rotationAxis.Z = setval;
1086
1087 if (setX || setY || setZ)
1088 {
1089 m_rootPart.SetPhysicsAxisRotation();
1090 }
1091 }
1092 }
1093
1094 public int registerTargetWaypoint(LLVector3 target, float tolerance)
1095 {
1096 scriptPosTarget waypoint = new scriptPosTarget();
1097 waypoint.targetPos = target;
1098 waypoint.tolerance = tolerance;
1099 uint handle = m_scene.PrimIDAllocate();
1100 lock (m_targets)
1101 {
1102 m_targets.Add(handle, waypoint);
1103 }
1104 return (int) handle;
1105 }
1106
1107 public void unregisterTargetWaypoint(int handle)
1108 {
1109 lock (m_targets)
1110 {
1111 if (m_targets.ContainsKey((uint) handle))
1112 m_targets.Remove((uint) handle);
1113 }
1114 }
1115
1116 private void checkAtTargets()
1117 {
1118 if (m_scriptListens_atTarget || m_scriptListens_notAtTarget)
1119 {
1120 if (m_targets.Count > 0)
1121 {
1122 bool at_target = false;
1123 //LLVector3 targetPos;
1124 //uint targetHandle;
1125 Dictionary<uint, scriptPosTarget> atTargets = new Dictionary<uint, scriptPosTarget>();
1126 lock (m_targets)
1127 {
1128 foreach (uint idx in m_targets.Keys)
1129 {
1130 scriptPosTarget target = m_targets[idx];
1131 if (Util.GetDistanceTo(target.targetPos, m_rootPart.GroupPosition) <= target.tolerance)
1132 {
1133 // trigger at_target
1134 if (m_scriptListens_atTarget)
1135 {
1136 // Reusing att.tolerance to hold the index of the target in the targets dictionary
1137 // to avoid deadlocking the sim.
1138 at_target = true;
1139 scriptPosTarget att = new scriptPosTarget();
1140 att.targetPos = target.targetPos;
1141 att.tolerance = idx;
1142 atTargets.Add(idx, att);
1143 }
1144 }
1145 }
1146 }
1147 if (atTargets.Count > 0)
1148 {
1149 uint[] localids = new uint[0];
1150 lock (m_parts)
1151 {
1152 localids = new uint[m_parts.Count];
1153 int cntr = 0;
1154 foreach (SceneObjectPart part in m_parts.Values)
1155 {
1156 localids[cntr] = part.LocalId;
1157 cntr++;
1158 }
1159 }
1160 for (int ctr = 0; ctr < localids.Length; ctr++)
1161 {
1162 foreach (uint target in atTargets.Keys)
1163 {
1164 scriptPosTarget att = atTargets[target];
1165 // Reusing att.tolerance to hold the index of the target in the targets dictionary
1166 // to avoid deadlocking the sim.
1167 m_scene.TriggerAtTargetEvent(localids[ctr], (uint) att.tolerance, att.targetPos, m_rootPart.GroupPosition);
1168 }
1169 }
1170 return;
1171 }
1172 if (m_scriptListens_notAtTarget && !at_target)
1173 {
1174 //trigger not_at_target
1175 uint[] localids = new uint[0];
1176 lock (m_parts)
1177 {
1178 localids = new uint[m_parts.Count];
1179 int cntr = 0;
1180 foreach (SceneObjectPart part in m_parts.Values)
1181 {
1182 localids[cntr] = part.LocalId;
1183 cntr++;
1184 }
1185 }
1186 for (int ctr = 0; ctr < localids.Length; ctr++)
1187 {
1188 m_scene.TriggerNotAtTargetEvent(localids[ctr]);
1189 }
1190 }
1191 }
1192 }
1193 }
1194
1068 #region Events 1195 #region Events
1069 1196
1070 /// <summary> 1197 /// <summary>
@@ -1362,9 +1489,8 @@ namespace OpenSim.Region.Environment.Scenes
1362 { 1489 {
1363 m_parts.Add(newPart.UUID, newPart); 1490 m_parts.Add(newPart.UUID, newPart);
1364 } 1491 }
1365 1492
1366 SetPartAsNonRoot(newPart); 1493 SetPartAsNonRoot(newPart);
1367
1368 } 1494 }
1369 1495
1370 /// <summary> 1496 /// <summary>
@@ -1434,32 +1560,30 @@ namespace OpenSim.Region.Environment.Scenes
1434 /// </summary> 1560 /// </summary>
1435 public override void Update() 1561 public override void Update()
1436 { 1562 {
1437
1438 lock (m_parts) 1563 lock (m_parts)
1439 { 1564 {
1440 //if (m_rootPart.m_IsAttachment) 1565 //if (m_rootPart.m_IsAttachment)
1441 //{ 1566 //{
1442 //foreach (SceneObjectPart part in m_parts.Values) 1567 //foreach (SceneObjectPart part in m_parts.Values)
1443 //{ 1568 //{
1444 //part.SendScheduledUpdates(); 1569 //part.SendScheduledUpdates();
1445 //}
1446 //return;
1447 //} 1570 //}
1448 1571 //return;
1572 //}
1573
1449 if (Util.GetDistanceTo(lastPhysGroupPos, AbsolutePosition) > 0.02) 1574 if (Util.GetDistanceTo(lastPhysGroupPos, AbsolutePosition) > 0.02)
1450 { 1575 {
1451 m_rootPart.UpdateFlag = 1; 1576 m_rootPart.UpdateFlag = 1;
1452 lastPhysGroupPos = AbsolutePosition; 1577 lastPhysGroupPos = AbsolutePosition;
1453 } 1578 }
1454 //foreach (SceneObjectPart part in m_parts.Values) 1579 //foreach (SceneObjectPart part in m_parts.Values)
1455 //{ 1580 //{
1456 //if (part.UpdateFlag == 0) part.UpdateFlag = 1; 1581 //if (part.UpdateFlag == 0) part.UpdateFlag = 1;
1457 //} 1582 //}
1583
1584
1585 checkAtTargets();
1458 1586
1459
1460
1461 checkAtTargets();
1462
1463 1587
1464 if ((Math.Abs(lastPhysGroupRot.W - GroupRotation.W) > 0.1) 1588 if ((Math.Abs(lastPhysGroupRot.W - GroupRotation.W) > 0.1)
1465 || (Math.Abs(lastPhysGroupRot.X - GroupRotation.X) > 0.1) 1589 || (Math.Abs(lastPhysGroupRot.X - GroupRotation.X) > 0.1)
@@ -1763,7 +1887,7 @@ namespace OpenSim.Region.Environment.Scenes
1763 public void DelinkFromGroup(uint partID) 1887 public void DelinkFromGroup(uint partID)
1764 { 1888 {
1765 SceneObjectPart linkPart = GetChildPart(partID); 1889 SceneObjectPart linkPart = GetChildPart(partID);
1766 1890
1767 if (null != linkPart) 1891 if (null != linkPart)
1768 { 1892 {
1769 linkPart.ClearUndoState(); 1893 linkPart.ClearUndoState();
@@ -1948,10 +2072,10 @@ namespace OpenSim.Region.Environment.Scenes
1948 proper.ObjectData[0].FromTaskID = LLUUID.Zero; 2072 proper.ObjectData[0].FromTaskID = LLUUID.Zero;
1949 proper.ObjectData[0].GroupID = LLUUID.Zero; 2073 proper.ObjectData[0].GroupID = LLUUID.Zero;
1950 proper.ObjectData[0].InventorySerial = (short) m_rootPart.InventorySerial; 2074 proper.ObjectData[0].InventorySerial = (short) m_rootPart.InventorySerial;
1951 2075
1952 proper.ObjectData[0].LastOwnerID = m_rootPart.LastOwnerID; 2076 proper.ObjectData[0].LastOwnerID = m_rootPart.LastOwnerID;
1953// proper.ObjectData[0].LastOwnerID = LLUUID.Zero; 2077// proper.ObjectData[0].LastOwnerID = LLUUID.Zero;
1954 2078
1955 proper.ObjectData[0].ObjectID = UUID; 2079 proper.ObjectData[0].ObjectID = UUID;
1956 proper.ObjectData[0].OwnerID = m_rootPart.OwnerID; 2080 proper.ObjectData[0].OwnerID = m_rootPart.OwnerID;
1957 proper.ObjectData[0].TouchName = Helpers.StringToField(m_rootPart.TouchName); 2081 proper.ObjectData[0].TouchName = Helpers.StringToField(m_rootPart.TouchName);
@@ -2391,140 +2515,5 @@ namespace OpenSim.Region.Environment.Scenes
2391 } 2515 }
2392 2516
2393 #endregion 2517 #endregion
2394
2395 internal void SetAxisRotation(int axis, int rotate10)
2396 {
2397 bool setX = false;
2398 bool setY = false;
2399 bool setZ = false;
2400
2401 int xaxis = 2;
2402 int yaxis = 4;
2403 int zaxis = 8;
2404
2405 if (m_rootPart != null)
2406 {
2407 setX = ((axis & xaxis) != 0) ? true : false;
2408 setY = ((axis & yaxis) != 0) ? true : false;
2409 setZ = ((axis & zaxis) != 0) ? true : false;
2410
2411 float setval = (rotate10 > 0) ? 1f : 0f;
2412
2413 if (setX)
2414 m_rootPart.m_rotationAxis.X = setval;
2415 if (setY)
2416 m_rootPart.m_rotationAxis.Y = setval;
2417 if (setZ)
2418 m_rootPart.m_rotationAxis.Z = setval;
2419
2420 if (setX || setY || setZ)
2421 {
2422 m_rootPart.SetPhysicsAxisRotation();
2423 }
2424
2425 }
2426 }
2427
2428 public int registerTargetWaypoint(LLVector3 target, float tolerance)
2429 {
2430 scriptPosTarget waypoint = new scriptPosTarget();
2431 waypoint.targetPos = target;
2432 waypoint.tolerance = tolerance;
2433 uint handle = m_scene.PrimIDAllocate();
2434 lock (m_targets)
2435 {
2436 m_targets.Add(handle, waypoint);
2437 }
2438 return (int)handle;
2439 }
2440 public void unregisterTargetWaypoint(int handle)
2441 {
2442 lock (m_targets)
2443 {
2444 if (m_targets.ContainsKey((uint)handle))
2445 m_targets.Remove((uint)handle);
2446 }
2447 }
2448
2449 private void checkAtTargets()
2450 {
2451 if (m_scriptListens_atTarget || m_scriptListens_notAtTarget)
2452 {
2453 if (m_targets.Count > 0)
2454 {
2455 bool at_target = false;
2456 //LLVector3 targetPos;
2457 //uint targetHandle;
2458 Dictionary<uint, scriptPosTarget> atTargets = new Dictionary<uint, scriptPosTarget>();
2459 lock (m_targets)
2460 {
2461 foreach (uint idx in m_targets.Keys)
2462 {
2463 scriptPosTarget target = m_targets[idx];
2464 if (Util.GetDistanceTo(target.targetPos, m_rootPart.GroupPosition) <= target.tolerance)
2465 {
2466 // trigger at_target
2467 if (m_scriptListens_atTarget)
2468 {
2469 // Reusing att.tolerance to hold the index of the target in the targets dictionary
2470 // to avoid deadlocking the sim.
2471 at_target = true;
2472 scriptPosTarget att = new scriptPosTarget();
2473 att.targetPos = target.targetPos;
2474 att.tolerance = (float)idx;
2475 atTargets.Add(idx, att);
2476 }
2477 }
2478 }
2479 }
2480 if (atTargets.Count > 0)
2481 {
2482 uint[] localids = new uint[0];
2483 lock (m_parts)
2484 {
2485 localids = new uint[m_parts.Count];
2486 int cntr = 0;
2487 foreach (SceneObjectPart part in m_parts.Values)
2488 {
2489 localids[cntr] = part.LocalId;
2490 cntr++;
2491 }
2492 }
2493 for (int ctr = 0; ctr < localids.Length; ctr++)
2494 {
2495 foreach (uint target in atTargets.Keys)
2496 {
2497 scriptPosTarget att = atTargets[target];
2498 // Reusing att.tolerance to hold the index of the target in the targets dictionary
2499 // to avoid deadlocking the sim.
2500 m_scene.TriggerAtTargetEvent(localids[ctr], (uint)att.tolerance, att.targetPos, m_rootPart.GroupPosition);
2501
2502
2503 }
2504 }
2505 return;
2506 }
2507 if (m_scriptListens_notAtTarget && !at_target)
2508 {
2509 //trigger not_at_target
2510 uint[] localids = new uint[0];
2511 lock (m_parts)
2512 {
2513 localids = new uint[m_parts.Count];
2514 int cntr = 0;
2515 foreach (SceneObjectPart part in m_parts.Values)
2516 {
2517 localids[cntr] = part.LocalId;
2518 cntr++;
2519 }
2520 }
2521 for (int ctr = 0; ctr < localids.Length; ctr++)
2522 {
2523 m_scene.TriggerNotAtTargetEvent(localids[ctr]);
2524 }
2525 }
2526 }
2527 }
2528 }
2529 } 2518 }
2530} 2519} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs
index 0215cec..c8a8f95 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs
@@ -41,7 +41,12 @@ namespace OpenSim.Region.Environment.Scenes
41 { 41 {
42 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 42 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
43 43
44 private string m_inventoryFileName = String.Empty; 44 private readonly string m_inventoryFileName = String.Empty;
45
46 /// <summary>
47 /// Tracks whether inventory has changed since the last persistent backup
48 /// </summary>
49 private bool HasInventoryChanged;
45 50
46 /// <summary> 51 /// <summary>
47 /// The inventory folder for this prim 52 /// The inventory folder for this prim
@@ -49,6 +54,17 @@ namespace OpenSim.Region.Environment.Scenes
49 private LLUUID m_folderID = LLUUID.Zero; 54 private LLUUID m_folderID = LLUUID.Zero;
50 55
51 /// <summary> 56 /// <summary>
57 /// Serial count for inventory file , used to tell if inventory has changed
58 /// no need for this to be part of Database backup
59 /// </summary>
60 protected uint m_inventorySerial;
61
62 /// <summary>
63 /// Holds in memory prim inventory
64 /// </summary>
65 protected TaskInventoryDictionary m_taskInventory = new TaskInventoryDictionary();
66
67 /// <summary>
52 /// Exposing this is not particularly good, but it's one of the least evils at the moment to see 68 /// Exposing this is not particularly good, but it's one of the least evils at the moment to see
53 /// folder id from prim inventory item data, since it's not (yet) actually stored with the prim. 69 /// folder id from prim inventory item data, since it's not (yet) actually stored with the prim.
54 /// </summary> 70 /// </summary>
@@ -58,23 +74,12 @@ namespace OpenSim.Region.Environment.Scenes
58 set { m_folderID = value; } 74 set { m_folderID = value; }
59 } 75 }
60 76
61 /// <summary>
62 /// Serial count for inventory file , used to tell if inventory has changed
63 /// no need for this to be part of Database backup
64 /// </summary>
65 protected uint m_inventorySerial = 0;
66
67 public uint InventorySerial 77 public uint InventorySerial
68 { 78 {
69 get { return m_inventorySerial; } 79 get { return m_inventorySerial; }
70 set { m_inventorySerial = value; } 80 set { m_inventorySerial = value; }
71 } 81 }
72 82
73 /// <summary>
74 /// Holds in memory prim inventory
75 /// </summary>
76 protected TaskInventoryDictionary m_taskInventory = new TaskInventoryDictionary();
77
78 public TaskInventoryDictionary TaskInventory 83 public TaskInventoryDictionary TaskInventory
79 { 84 {
80 get { return m_taskInventory; } 85 get { return m_taskInventory; }
@@ -82,11 +87,6 @@ namespace OpenSim.Region.Environment.Scenes
82 } 87 }
83 88
84 /// <summary> 89 /// <summary>
85 /// Tracks whether inventory has changed since the last persistent backup
86 /// </summary>
87 private bool HasInventoryChanged;
88
89 /// <summary>
90 /// Reset LLUUIDs for all the items in the prim's inventory. This involves either generating 90 /// Reset LLUUIDs for all the items in the prim's inventory. This involves either generating
91 /// new ones or setting existing UUIDs to the correct parent UUIDs. 91 /// new ones or setting existing UUIDs to the correct parent UUIDs.
92 /// 92 ///
@@ -96,14 +96,14 @@ namespace OpenSim.Region.Environment.Scenes
96 public void ResetInventoryIDs() 96 public void ResetInventoryIDs()
97 { 97 {
98 lock (TaskInventory) 98 lock (TaskInventory)
99 { 99 {
100 if (0 == TaskInventory.Count) 100 if (0 == TaskInventory.Count)
101 { 101 {
102 return; 102 return;
103 } 103 }
104 104
105 HasInventoryChanged = true; 105 HasInventoryChanged = true;
106 106
107 IList<TaskInventoryItem> items = new List<TaskInventoryItem>(TaskInventory.Values); 107 IList<TaskInventoryItem> items = new List<TaskInventoryItem>(TaskInventory.Values);
108 TaskInventory.Clear(); 108 TaskInventory.Clear();
109 109
@@ -132,9 +132,9 @@ namespace OpenSim.Region.Environment.Scenes
132 if (ownerId != item.OwnerID) 132 if (ownerId != item.OwnerID)
133 { 133 {
134 item.LastOwnerID = item.OwnerID; 134 item.LastOwnerID = item.OwnerID;
135 item.OwnerID = ownerId; 135 item.OwnerID = ownerId;
136 item.BaseMask = item.NextOwnerMask & (uint)PermissionMask.All; 136 item.BaseMask = item.NextOwnerMask & (uint) PermissionMask.All;
137 item.OwnerMask = item.NextOwnerMask & (uint)PermissionMask.All; 137 item.OwnerMask = item.NextOwnerMask & (uint) PermissionMask.All;
138 } 138 }
139 } 139 }
140 } 140 }
@@ -194,22 +194,22 @@ namespace OpenSim.Region.Environment.Scenes
194 AssetCache cache = m_parentGroup.Scene.AssetCache; 194 AssetCache cache = m_parentGroup.Scene.AssetCache;
195 195
196 cache.GetAsset(item.AssetID, delegate(LLUUID assetID, AssetBase asset) 196 cache.GetAsset(item.AssetID, delegate(LLUUID assetID, AssetBase asset)
197 { 197 {
198 if (null == asset) 198 if (null == asset)
199 { 199 {
200 m_log.ErrorFormat( 200 m_log.ErrorFormat(
201 "[PRIMINVENTORY]: " + 201 "[PRIMINVENTORY]: " +
202 "Couldn't start script {0}, {1} since asset ID {2} could not be found", 202 "Couldn't start script {0}, {1} since asset ID {2} could not be found",
203 item.Name, item.ItemID, item.AssetID); 203 item.Name, item.ItemID, item.AssetID);
204 } 204 }
205 else 205 else
206 { 206 {
207 string script = Helpers.FieldToUTF8String(asset.Data); 207 string script = Helpers.FieldToUTF8String(asset.Data);
208 m_parentGroup.Scene.EventManager.TriggerRezScript(LocalId,item.ItemID,script); 208 m_parentGroup.Scene.EventManager.TriggerRezScript(LocalId, item.ItemID, script);
209 m_parentGroup.AddActiveScriptCount(1); 209 m_parentGroup.AddActiveScriptCount(1);
210 ScheduleFullUpdate(); 210 ScheduleFullUpdate();
211 } 211 }
212 }, false); 212 }, false);
213 } 213 }
214 } 214 }
215 215
@@ -226,7 +226,6 @@ namespace OpenSim.Region.Environment.Scenes
226 if (m_taskInventory.ContainsKey(itemId)) 226 if (m_taskInventory.ContainsKey(itemId))
227 { 227 {
228 StartScript(m_taskInventory[itemId]); 228 StartScript(m_taskInventory[itemId]);
229
230 } 229 }
231 else 230 else
232 { 231 {
@@ -263,7 +262,7 @@ namespace OpenSim.Region.Environment.Scenes
263 { 262 {
264 foreach (TaskInventoryItem item in m_taskInventory.Values) 263 foreach (TaskInventoryItem item in m_taskInventory.Values)
265 { 264 {
266 if(item.Name == name) 265 if (item.Name == name)
267 return true; 266 return true;
268 } 267 }
269 return false; 268 return false;
@@ -271,14 +270,14 @@ namespace OpenSim.Region.Environment.Scenes
271 270
272 private string FindAvailableInventoryName(string name) 271 private string FindAvailableInventoryName(string name)
273 { 272 {
274 if(!InventoryContainsName(name)) 273 if (!InventoryContainsName(name))
275 return name; 274 return name;
276 275
277 int suffix=1; 276 int suffix = 1;
278 while(suffix < 256) 277 while (suffix < 256)
279 { 278 {
280 string tryName=String.Format("{0} {1}", name, suffix); 279 string tryName = String.Format("{0} {1}", name, suffix);
281 if(!InventoryContainsName(tryName)) 280 if (!InventoryContainsName(tryName))
282 return tryName; 281 return tryName;
283 suffix++; 282 suffix++;
284 } 283 }
@@ -295,11 +294,11 @@ namespace OpenSim.Region.Environment.Scenes
295 item.CreationDate = 1000; 294 item.CreationDate = 1000;
296 item.ParentPartID = UUID; 295 item.ParentPartID = UUID;
297 296
298 string name=FindAvailableInventoryName(item.Name); 297 string name = FindAvailableInventoryName(item.Name);
299 if(name == String.Empty) 298 if (name == String.Empty)
300 return; 299 return;
301 300
302 item.Name=name; 301 item.Name = name;
303 302
304 lock (m_taskInventory) 303 lock (m_taskInventory)
305 { 304 {
@@ -347,7 +346,7 @@ namespace OpenSim.Region.Environment.Scenes
347// m_log.DebugFormat( 346// m_log.DebugFormat(
348// "[PRIM INVENTORY]: Retrieved task inventory item {0}, {1} from prim {2}, {3}", 347// "[PRIM INVENTORY]: Retrieved task inventory item {0}, {1} from prim {2}, {3}",
349// m_taskInventory[itemID].Name, itemID, Name, UUID); 348// m_taskInventory[itemID].Name, itemID, Name, UUID);
350 349
351 return m_taskInventory[itemID]; 350 return m_taskInventory[itemID];
352 } 351 }
353 else 352 else
@@ -428,7 +427,6 @@ namespace OpenSim.Region.Environment.Scenes
428 scriptcount++; 427 scriptcount++;
429 } 428 }
430 } 429 }
431
432 } 430 }
433 if (scriptcount <= 0) 431 if (scriptcount <= 0)
434 { 432 {
@@ -457,14 +455,14 @@ namespace OpenSim.Region.Environment.Scenes
457 /// <param name="client"></param> 455 /// <param name="client"></param>
458 /// <param name="localID"></param> 456 /// <param name="localID"></param>
459 public bool GetInventoryFileName(IClientAPI client, uint localID) 457 public bool GetInventoryFileName(IClientAPI client, uint localID)
460 { 458 {
461// m_log.DebugFormat( 459// m_log.DebugFormat(
462// "[PRIM INVENTORY]: Received request from client {0} for inventory file name of {1}, {2}", 460// "[PRIM INVENTORY]: Received request from client {0} for inventory file name of {1}, {2}",
463// client.AgentId, Name, UUID); 461// client.AgentId, Name, UUID);
464 462
465 if (m_inventorySerial > 0) 463 if (m_inventorySerial > 0)
466 { 464 {
467 client.SendTaskInventory(m_uuid, (short)m_inventorySerial, 465 client.SendTaskInventory(m_uuid, (short) m_inventorySerial,
468 Helpers.StringToField(m_inventoryFileName)); 466 Helpers.StringToField(m_inventoryFileName));
469 return true; 467 return true;
470 } 468 }
@@ -480,9 +478,9 @@ namespace OpenSim.Region.Environment.Scenes
480 /// </summary> 478 /// </summary>
481 /// <param name="xferManager"></param> 479 /// <param name="xferManager"></param>
482 public void RequestInventoryFile(IXfer xferManager) 480 public void RequestInventoryFile(IXfer xferManager)
483 { 481 {
484 byte[] fileData = new byte[0]; 482 byte[] fileData = new byte[0];
485 483
486 // Confusingly, the folder item has to be the object id, while the 'parent id' has to be zero. This matches 484 // Confusingly, the folder item has to be the object id, while the 'parent id' has to be zero. This matches
487 // what appears to happen in the Second Life protocol. If this isn't the case. then various functionality 485 // what appears to happen in the Second Life protocol. If this isn't the case. then various functionality
488 // isn't available (such as drag from prim inventory to agent inventory) 486 // isn't available (such as drag from prim inventory to agent inventory)
@@ -493,53 +491,53 @@ namespace OpenSim.Region.Environment.Scenes
493 foreach (TaskInventoryItem item in m_taskInventory.Values) 491 foreach (TaskInventoryItem item in m_taskInventory.Values)
494 { 492 {
495 invString.AddItemStart(); 493 invString.AddItemStart();
496 invString.AddNameValueLine("item_id", item.ItemID.ToString()); 494 invString.AddNameValueLine("item_id", item.ItemID.ToString());
497 invString.AddNameValueLine("parent_id", m_folderID.ToString()); 495 invString.AddNameValueLine("parent_id", m_folderID.ToString());
498 496
499 invString.AddPermissionsStart(); 497 invString.AddPermissionsStart();
500 498
501 // FIXME: Temporary until permissions are properly sorted. 499 // FIXME: Temporary until permissions are properly sorted.
502 invString.AddNameValueLine("base_mask", "7fffffff"); 500 invString.AddNameValueLine("base_mask", "7fffffff");
503 invString.AddNameValueLine("owner_mask", "7fffffff"); 501 invString.AddNameValueLine("owner_mask", "7fffffff");
504 invString.AddNameValueLine("group_mask", "7fffffff"); 502 invString.AddNameValueLine("group_mask", "7fffffff");
505 invString.AddNameValueLine("everyone_mask", "7fffffff"); 503 invString.AddNameValueLine("everyone_mask", "7fffffff");
506 invString.AddNameValueLine("next_owner_mask", "7fffffff"); 504 invString.AddNameValueLine("next_owner_mask", "7fffffff");
507 505
508// invString.AddNameValueLine("group_mask", "00000000"); 506// invString.AddNameValueLine("group_mask", "00000000");
509// invString.AddNameValueLine("everyone_mask", "00000000"); 507// invString.AddNameValueLine("everyone_mask", "00000000");
510// invString.AddNameValueLine("next_owner_mask", "00086000"); 508// invString.AddNameValueLine("next_owner_mask", "00086000");
511 509
512// invString.AddNameValueLine("base_mask", Helpers.UIntToHexString(item.BaseMask)); 510// invString.AddNameValueLine("base_mask", Helpers.UIntToHexString(item.BaseMask));
513// invString.AddNameValueLine("owner_mask", Helpers.UIntToHexString(item.OwnerMask)); 511// invString.AddNameValueLine("owner_mask", Helpers.UIntToHexString(item.OwnerMask));
514// invString.AddNameValueLine("group_mask", Helpers.UIntToHexString(item.GroupMask)); 512// invString.AddNameValueLine("group_mask", Helpers.UIntToHexString(item.GroupMask));
515// invString.AddNameValueLine("everyone_mask", Helpers.UIntToHexString(item.EveryoneMask)); 513// invString.AddNameValueLine("everyone_mask", Helpers.UIntToHexString(item.EveryoneMask));
516// invString.AddNameValueLine("next_owner_mask", Helpers.UIntToHexString(item.NextOwnerMask)); 514// invString.AddNameValueLine("next_owner_mask", Helpers.UIntToHexString(item.NextOwnerMask));
517 515
518 invString.AddNameValueLine("creator_id", item.CreatorID.ToString()); 516 invString.AddNameValueLine("creator_id", item.CreatorID.ToString());
519 invString.AddNameValueLine("owner_id", item.OwnerID.ToString()); 517 invString.AddNameValueLine("owner_id", item.OwnerID.ToString());
520 518
521 invString.AddNameValueLine("last_owner_id", item.LastOwnerID.ToString()); 519 invString.AddNameValueLine("last_owner_id", item.LastOwnerID.ToString());
522// invString.AddNameValueLine("last_owner_id", item.OwnerID.ToString()); 520// invString.AddNameValueLine("last_owner_id", item.OwnerID.ToString());
523 521
524 invString.AddNameValueLine("group_id", item.GroupID.ToString()); 522 invString.AddNameValueLine("group_id", item.GroupID.ToString());
525 invString.AddSectionEnd(); 523 invString.AddSectionEnd();
526 524
527 invString.AddNameValueLine("asset_id", item.AssetID.ToString()); 525 invString.AddNameValueLine("asset_id", item.AssetID.ToString());
528 invString.AddNameValueLine("type", TaskInventoryItem.Types[item.Type]); 526 invString.AddNameValueLine("type", TaskInventoryItem.Types[item.Type]);
529 invString.AddNameValueLine("inv_type", TaskInventoryItem.InvTypes[item.InvType]); 527 invString.AddNameValueLine("inv_type", TaskInventoryItem.InvTypes[item.InvType]);
530 invString.AddNameValueLine("flags", "00000000"); 528 invString.AddNameValueLine("flags", "00000000");
531 529
532 invString.AddSaleStart(); 530 invString.AddSaleStart();
533 invString.AddNameValueLine("sale_type", "not"); 531 invString.AddNameValueLine("sale_type", "not");
534 invString.AddNameValueLine("sale_price", "0"); 532 invString.AddNameValueLine("sale_price", "0");
535 invString.AddSectionEnd(); 533 invString.AddSectionEnd();
536 534
537 invString.AddNameValueLine("name", item.Name + "|"); 535 invString.AddNameValueLine("name", item.Name + "|");
538 invString.AddNameValueLine("desc", item.Description + "|"); 536 invString.AddNameValueLine("desc", item.Description + "|");
539 537
540 invString.AddNameValueLine("creation_date", item.CreationDate.ToString()); 538 invString.AddNameValueLine("creation_date", item.CreationDate.ToString());
541// invString.AddNameValueLine("creation_date", "1209151453"); 539// invString.AddNameValueLine("creation_date", "1209151453");
542 540
543 invString.AddSectionEnd(); 541 invString.AddSectionEnd();
544 } 542 }
545 } 543 }
@@ -571,6 +569,8 @@ namespace OpenSim.Region.Environment.Scenes
571 } 569 }
572 } 570 }
573 571
572 #region Nested type: InventoryStringBuilder
573
574 public class InventoryStringBuilder 574 public class InventoryStringBuilder
575 { 575 {
576 public string BuildString = String.Empty; 576 public string BuildString = String.Empty;
@@ -596,13 +596,13 @@ namespace OpenSim.Region.Environment.Scenes
596 BuildString += "\tpermissions 0\n"; 596 BuildString += "\tpermissions 0\n";
597 AddSectionStart(); 597 AddSectionStart();
598 } 598 }
599 599
600 public void AddSaleStart() 600 public void AddSaleStart()
601 { 601 {
602 BuildString += "\tsale_info\t0\n"; 602 BuildString += "\tsale_info\t0\n";
603 AddSectionStart(); 603 AddSectionStart();
604 } 604 }
605 605
606 protected void AddSectionStart() 606 protected void AddSectionStart()
607 { 607 {
608 BuildString += "\t{\n"; 608 BuildString += "\t{\n";
@@ -629,5 +629,7 @@ namespace OpenSim.Region.Environment.Scenes
629 { 629 {
630 } 630 }
631 } 631 }
632
633 #endregion
632 } 634 }
633} 635} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
index 3dbd809..3a9e1c2 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
@@ -56,6 +56,7 @@ namespace OpenSim.Region.Environment.Scenes
56 Something5 = 64, 56 Something5 = 64,
57 Something6 = 128 57 Something6 = 128
58 } 58 }
59
59 [Flags] 60 [Flags]
60 public enum Changed : uint 61 public enum Changed : uint
61 { 62 {
@@ -68,6 +69,7 @@ namespace OpenSim.Region.Environment.Scenes
68 ALLOWED_DROP = 64, 69 ALLOWED_DROP = 64,
69 OWNER = 128 70 OWNER = 128
70 } 71 }
72
71 [Flags] 73 [Flags]
72 public enum TextureAnimFlags : byte 74 public enum TextureAnimFlags : byte
73 { 75 {
@@ -81,70 +83,36 @@ namespace OpenSim.Region.Environment.Scenes
81 SCALE = 0x40 83 SCALE = 0x40
82 } 84 }
83 85
84 86
85 [Serializable] 87 [Serializable]
86 public partial class SceneObjectPart : IScriptHost, ISerializable 88 public partial class SceneObjectPart : IScriptHost, ISerializable
87 { 89 {
88
89 [XmlIgnore] public PhysicsActor PhysActor = null;
90
91 public LLUUID LastOwnerID;
92 public LLUUID OwnerID;
93 public LLUUID GroupID;
94 public int OwnershipCost;
95 public byte ObjectSaleType;
96 public int SalePrice;
97 public uint Category; 90 public uint Category;
98 91 public Int32 CreationDate;
92 [XmlIgnore] public LLUUID fromAssetID = LLUUID.Zero;
93 public LLUUID GroupID;
94 public LLUUID LastOwnerID;
95
99 // TODO: This needs to be persisted in next XML version update! 96 // TODO: This needs to be persisted in next XML version update!
100 [XmlIgnore] public int[] PayPrice = {-2,-2,-2,-2,-2};
101 [XmlIgnore] private Dictionary<LLUUID, scriptEvents> m_scriptEvents = new Dictionary<LLUUID, scriptEvents>();
102 [XmlIgnore] public scriptEvents m_aggregateScriptEvents=0;
103 [XmlIgnore] private LLObject.ObjectFlags LocalFlags = LLObject.ObjectFlags.None; 97 [XmlIgnore] private LLObject.ObjectFlags LocalFlags = LLObject.ObjectFlags.None;
98 [XmlIgnore] public scriptEvents m_aggregateScriptEvents = 0;
104 99
105 100
106 [XmlIgnore] public bool m_IsAttachment = false;
107 [XmlIgnore] public uint m_attachmentPoint = (byte)0;
108 [XmlIgnore] public LLUUID m_attachedAvatar = LLUUID.Zero; 101 [XmlIgnore] public LLUUID m_attachedAvatar = LLUUID.Zero;
109 [XmlIgnore] public LLVector3 m_attachedPos = LLVector3.Zero; 102 [XmlIgnore] public LLVector3 m_attachedPos = LLVector3.Zero;
110 [XmlIgnore] public LLUUID fromAssetID = LLUUID.Zero; 103 [XmlIgnore] public uint m_attachmentPoint = 0;
111 104 [XmlIgnore] public bool m_IsAttachment;
112 [XmlIgnore] public bool m_undoing = false;
113
114 public Int32 CreationDate;
115 public uint ParentID = 0;
116 105
117 private PhysicsVector m_lastRotationalVelocity = PhysicsVector.Zero; 106 private PhysicsVector m_lastRotationalVelocity = PhysicsVector.Zero;
118 private Vector3 m_sitTargetPosition = new Vector3(0, 0, 0); 107 protected SceneObjectGroup m_parentGroup;
119 private Quaternion m_sitTargetOrientation = new Quaternion(0, 0, 0, 1);
120 public LLUUID m_sitTargetAvatar = LLUUID.Zero;
121 [XmlIgnore] public PhysicsVector m_rotationAxis = new PhysicsVector(1f,1f,1f);
122
123 #region Permissions
124
125 public uint BaseMask = (uint)PermissionMask.All;
126 public uint OwnerMask = (uint)PermissionMask.All;
127 public uint GroupMask = (uint)PermissionMask.None;
128 public uint EveryoneMask = (uint)PermissionMask.None;
129 public uint NextOwnerMask = (uint)PermissionMask.All;
130
131 private UndoStack<UndoState> m_undo = new UndoStack<UndoState>(5);
132
133 public LLObject.ObjectFlags Flags = LLObject.ObjectFlags.None;
134
135 public uint ObjectFlags
136 {
137 get { return (uint)Flags; }
138 set { Flags = (LLObject.ObjectFlags)value; }
139 }
140
141 #endregion
142 108
143 protected byte[] m_particleSystem = new byte[0]; 109 protected byte[] m_particleSystem = new byte[0];
144 110 [XmlIgnore] public PhysicsVector m_rotationAxis = new PhysicsVector(1f, 1f, 1f);
145 [XmlIgnore] public uint TimeStampFull = 0; 111 [XmlIgnore] private Dictionary<LLUUID, scriptEvents> m_scriptEvents = new Dictionary<LLUUID, scriptEvents>();
146 [XmlIgnore] public uint TimeStampTerse = 0; 112 public LLUUID m_sitTargetAvatar = LLUUID.Zero;
147 [XmlIgnore] public uint TimeStampLastActivity = 0; // Will be used for AutoReturn 113 private Quaternion m_sitTargetOrientation = new Quaternion(0, 0, 0, 1);
114 private Vector3 m_sitTargetPosition = new Vector3(0, 0, 0);
115 [XmlIgnore] public bool m_undoing;
148 116
149 /// <summary> 117 /// <summary>
150 /// Only used internally to schedule client updates. 118 /// Only used internally to schedule client updates.
@@ -156,24 +124,44 @@ namespace OpenSim.Region.Environment.Scenes
156 /// </summary> 124 /// </summary>
157 private byte m_updateFlag; 125 private byte m_updateFlag;
158 126
159 #region Properties 127 public byte ObjectSaleType;
160 128 public LLUUID OwnerID;
161 public LLUUID CreatorID; 129 public int OwnershipCost;
130 public uint ParentID;
131 [XmlIgnore] public int[] PayPrice = {-2, -2, -2, -2, -2};
132 [XmlIgnore] public PhysicsActor PhysActor;
133 public int SalePrice;
162 134
163 public LLUUID ObjectCreator 135 [XmlIgnore] public uint TimeStampFull;
164 { 136 [XmlIgnore] public uint TimeStampLastActivity; // Will be used for AutoReturn
165 get { return CreatorID; } 137 [XmlIgnore] public uint TimeStampTerse;
166 }
167 138
168 protected LLUUID m_uuid; 139 #region Properties
169 140
170 public LLUUID UUID 141 public LLUUID CreatorID;
171 { 142 protected LLVector3 m_acceleration;
172 get { return m_uuid; } 143 protected LLVector3 m_angularVelocity;
173 set { m_uuid = value; } 144 private byte m_clickAction;
174 } 145 private Color m_color = Color.Black;
146 private string m_description = String.Empty;
147 protected LLVector3 m_groupPosition;
148 private int m_linkNum;
175 149
176 protected uint m_localId; 150 protected uint m_localId;
151 protected LLObject.MaterialType m_material = 0;
152
153 protected string m_name;
154 protected LLVector3 m_offsetPosition;
155 protected ulong m_regionHandle;
156 protected LLVector3 m_rotationalvelocity;
157 protected LLQuaternion m_rotationOffset;
158 protected PrimitiveBaseShape m_shape;
159 private string m_sitName = String.Empty;
160 private string m_text = String.Empty;
161 private byte[] m_TextureAnimation;
162 private string m_touchName = String.Empty;
163 protected LLUUID m_uuid;
164 protected LLVector3 m_velocity;
177 165
178 public uint LocalId 166 public uint LocalId
179 { 167 {
@@ -181,145 +169,23 @@ namespace OpenSim.Region.Environment.Scenes
181 set { m_localId = value; } 169 set { m_localId = value; }
182 } 170 }
183 171
184 protected string m_name; 172 public scriptEvents ScriptEvents
185
186 public virtual string Name
187 { 173 {
188 get { return m_name; } 174 get { return m_aggregateScriptEvents; }
189 set { m_name = value; }
190 } 175 }
191 176
192 public scriptEvents ScriptEvents
193 {
194 get { return m_aggregateScriptEvents; }
195 }
196
197 protected LLObject.MaterialType m_material = 0;
198
199 public byte Material 177 public byte Material
200 { 178 {
201 get { return (byte) m_material; } 179 get { return (byte) m_material; }
202 set { m_material = (LLObject.MaterialType) value; } 180 set { m_material = (LLObject.MaterialType) value; }
203 } 181 }
204 182
205 protected ulong m_regionHandle;
206
207 public ulong RegionHandle 183 public ulong RegionHandle
208 { 184 {
209 get { return m_regionHandle; } 185 get { return m_regionHandle; }
210 set { m_regionHandle = value; } 186 set { m_regionHandle = value; }
211 } 187 }
212 188
213 public uint GetEffectiveObjectFlags()
214 {
215 LLObject.ObjectFlags f=Flags;
216 if(m_parentGroup == null || m_parentGroup.RootPart == this)
217 f &= ~(LLObject.ObjectFlags.Touch | LLObject.ObjectFlags.Money);
218
219 return (uint)Flags | (uint)LocalFlags;
220 }
221
222 //unkown if this will be kept, added as a way of removing the group position from the group class
223 protected LLVector3 m_groupPosition;
224
225 /// <summary>
226 /// Method for a prim to get it's world position from the group.
227 /// Remember, the Group Position simply gives the position of the group itself
228 /// </summary>
229 /// <returns>A Linked Child Prim objects position in world</returns>
230 public LLVector3 GetWorldPosition()
231 {
232
233 Quaternion parentRot = new Quaternion(
234 ParentGroup.RootPart.RotationOffset.W,
235 ParentGroup.RootPart.RotationOffset.X,
236 ParentGroup.RootPart.RotationOffset.Y,
237 ParentGroup.RootPart.RotationOffset.Z);
238
239 Vector3 axPos
240 = new Vector3(
241 OffsetPosition.X,
242 OffsetPosition.Y,
243 OffsetPosition.Z);
244
245 axPos = parentRot * axPos;
246 LLVector3 translationOffsetPosition = new LLVector3(axPos.x, axPos.y, axPos.z);
247 return GroupPosition + translationOffsetPosition;
248
249 //return (new LLVector3(axiomPos.x, axiomPos.y, axiomPos.z) + AbsolutePosition);
250 }
251
252 /// <summary>
253 /// Gets the rotation of this prim offset by the group rotation
254 /// </summary>
255 /// <returns></returns>
256 public LLQuaternion GetWorldRotation()
257 {
258
259 Quaternion newRot;
260
261 if (this.LinkNum == 0)
262 {
263 newRot = new Quaternion(RotationOffset.W,RotationOffset.X,RotationOffset.Y,RotationOffset.Z);
264
265 }
266 else
267 {
268 Quaternion parentRot = new Quaternion(
269 ParentGroup.RootPart.RotationOffset.W,
270 ParentGroup.RootPart.RotationOffset.X,
271 ParentGroup.RootPart.RotationOffset.Y,
272 ParentGroup.RootPart.RotationOffset.Z);
273
274 Quaternion oldRot
275 = new Quaternion(
276 RotationOffset.W,
277 RotationOffset.X,
278 RotationOffset.Y,
279 RotationOffset.Z);
280
281 newRot = parentRot * oldRot;
282 }
283 return new LLQuaternion(newRot.x, newRot.y, newRot.z, newRot.w);
284
285 //return new LLQuaternion(axiomPartRotation.x, axiomPartRotation.y, axiomPartRotation.z, axiomPartRotation.w);
286
287 }
288
289 public void StoreUndoState()
290 {
291 if (!m_undoing)
292 {
293 if (m_parentGroup != null)
294 {
295 if (m_undo.Count > 0)
296 {
297 UndoState last = m_undo.Peek();
298 if (last != null)
299 {
300 if (last.Compare(this))
301 return;
302 }
303 }
304
305
306 if (m_parentGroup.GetSceneMaxUndo() > 0)
307 {
308 UndoState nUndo = new UndoState(this);
309
310 m_undo.Push(nUndo);
311
312 }
313 }
314 }
315 }
316
317 public void ClearUndoState()
318 {
319 m_undo.Clear();
320 StoreUndoState();
321 }
322
323 public LLVector3 GroupPosition 189 public LLVector3 GroupPosition
324 { 190 {
325 get 191 get
@@ -352,16 +218,13 @@ namespace OpenSim.Region.Environment.Scenes
352 { 218 {
353 try 219 try
354 { 220 {
355
356 // Root prim actually goes at Position 221 // Root prim actually goes at Position
357 if (ParentID == 0) 222 if (ParentID == 0)
358 { 223 {
359 PhysActor.Position = new PhysicsVector(value.X, value.Y, value.Z); 224 PhysActor.Position = new PhysicsVector(value.X, value.Y, value.Z);
360
361 } 225 }
362 else 226 else
363 { 227 {
364
365 // To move the child prim in respect to the group position and rotation we have to calculate 228 // To move the child prim in respect to the group position and rotation we have to calculate
366 229
367 LLVector3 resultingposition = GetWorldPosition(); 230 LLVector3 resultingposition = GetWorldPosition();
@@ -369,7 +232,7 @@ namespace OpenSim.Region.Environment.Scenes
369 LLQuaternion resultingrot = GetWorldRotation(); 232 LLQuaternion resultingrot = GetWorldRotation();
370 PhysActor.Orientation = new Quaternion(resultingrot.W, resultingrot.X, resultingrot.Y, resultingrot.Z); 233 PhysActor.Orientation = new Quaternion(resultingrot.W, resultingrot.X, resultingrot.Y, resultingrot.Z);
371 } 234 }
372 235
373 // Tell the physics engines that this prim changed. 236 // Tell the physics engines that this prim changed.
374 m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor); 237 m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor);
375 } 238 }
@@ -378,14 +241,9 @@ namespace OpenSim.Region.Environment.Scenes
378 Console.WriteLine(e.Message); 241 Console.WriteLine(e.Message);
379 } 242 }
380 } 243 }
381
382 } 244 }
383 } 245 }
384 246
385 private byte[] m_TextureAnimation;
386
387 protected LLVector3 m_offsetPosition;
388
389 public LLVector3 OffsetPosition 247 public LLVector3 OffsetPosition
390 { 248 {
391 get { return m_offsetPosition; } 249 get { return m_offsetPosition; }
@@ -393,31 +251,19 @@ namespace OpenSim.Region.Environment.Scenes
393 { 251 {
394 StoreUndoState(); 252 StoreUndoState();
395 m_offsetPosition = value; 253 m_offsetPosition = value;
396 try 254 try
397 { 255 {
398 // Hack to get the child prim to update world positions in the physics engine 256 // Hack to get the child prim to update world positions in the physics engine
399 ParentGroup.ResetChildPrimPhysicsPositions(); 257 ParentGroup.ResetChildPrimPhysicsPositions();
400 258 }
401 } 259 catch (NullReferenceException)
402 catch (NullReferenceException) 260 {
403 { 261 // Ignore, and skip over.
404 // Ignore, and skip over. 262 }
405 } 263 //m_log.Info("[PART]: OFFSET:" + m_offsetPosition.ToString());
406 //m_log.Info("[PART]: OFFSET:" + m_offsetPosition.ToString());
407 } 264 }
408 } 265 }
409 266
410 public LLVector3 AbsolutePosition
411 {
412 get {
413 if (m_IsAttachment)
414 return GroupPosition;
415
416 return m_offsetPosition + m_groupPosition; }
417 }
418
419 protected LLQuaternion m_rotationOffset;
420
421 public LLQuaternion RotationOffset 267 public LLQuaternion RotationOffset
422 { 268 {
423 get 269 get
@@ -466,13 +312,9 @@ namespace OpenSim.Region.Environment.Scenes
466 Console.WriteLine(ex.Message); 312 Console.WriteLine(ex.Message);
467 } 313 }
468 } 314 }
469
470 } 315 }
471 } 316 }
472 317
473 protected LLVector3 m_velocity;
474 protected LLVector3 m_rotationalvelocity;
475
476 /// <summary></summary> 318 /// <summary></summary>
477 public LLVector3 Velocity 319 public LLVector3 Velocity
478 { 320 {
@@ -493,8 +335,8 @@ namespace OpenSim.Region.Environment.Scenes
493 335
494 return m_velocity; 336 return m_velocity;
495 } 337 }
496 set { 338 set
497 339 {
498 m_velocity = value; 340 m_velocity = value;
499 if (PhysActor != null) 341 if (PhysActor != null)
500 { 342 {
@@ -504,7 +346,6 @@ namespace OpenSim.Region.Environment.Scenes
504 m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor); 346 m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor);
505 } 347 }
506 } 348 }
507
508 } 349 }
509 } 350 }
510 351
@@ -519,7 +360,7 @@ namespace OpenSim.Region.Environment.Scenes
519 { 360 {
520 if (PhysActor.IsPhysical) 361 if (PhysActor.IsPhysical)
521 { 362 {
522 m_rotationalvelocity.FromBytes(PhysActor.RotationalVelocity.GetBytes(),0); 363 m_rotationalvelocity.FromBytes(PhysActor.RotationalVelocity.GetBytes(), 0);
523 } 364 }
524 } 365 }
525 366
@@ -529,8 +370,6 @@ namespace OpenSim.Region.Environment.Scenes
529 } 370 }
530 371
531 372
532 protected LLVector3 m_angularVelocity;
533
534 /// <summary></summary> 373 /// <summary></summary>
535 public LLVector3 AngularVelocity 374 public LLVector3 AngularVelocity
536 { 375 {
@@ -538,8 +377,6 @@ namespace OpenSim.Region.Environment.Scenes
538 set { m_angularVelocity = value; } 377 set { m_angularVelocity = value; }
539 } 378 }
540 379
541 protected LLVector3 m_acceleration;
542
543 /// <summary></summary> 380 /// <summary></summary>
544 public LLVector3 Acceleration 381 public LLVector3 Acceleration
545 { 382 {
@@ -547,16 +384,6 @@ namespace OpenSim.Region.Environment.Scenes
547 set { m_acceleration = value; } 384 set { m_acceleration = value; }
548 } 385 }
549 386
550 private string m_description = String.Empty;
551
552 public string Description
553 {
554 get { return m_description; }
555 set { m_description = value; }
556 }
557
558 private Color m_color = Color.Black;
559
560 public Color Color 387 public Color Color
561 { 388 {
562 get { return m_color; } 389 get { return m_color; }
@@ -564,7 +391,7 @@ namespace OpenSim.Region.Environment.Scenes
564 { 391 {
565 m_color = value; 392 m_color = value;
566 TriggerScriptChangedEvent(Changed.COLOR); 393 TriggerScriptChangedEvent(Changed.COLOR);
567 394
568 /* ScheduleFullUpdate() need not be called b/c after 395 /* ScheduleFullUpdate() need not be called b/c after
569 * setting the color, the text will be set, so then 396 * setting the color, the text will be set, so then
570 * ScheduleFullUpdate() will be called. */ 397 * ScheduleFullUpdate() will be called. */
@@ -572,8 +399,6 @@ namespace OpenSim.Region.Environment.Scenes
572 } 399 }
573 } 400 }
574 401
575 private string m_text = String.Empty;
576
577 public Vector3 SitTargetPosition 402 public Vector3 SitTargetPosition
578 { 403 {
579 get { return m_sitTargetPosition; } 404 get { return m_sitTargetPosition; }
@@ -587,13 +412,93 @@ namespace OpenSim.Region.Environment.Scenes
587 public string Text 412 public string Text
588 { 413 {
589 get { return m_text; } 414 get { return m_text; }
415 set { m_text = value; }
416 }
417
418 public int LinkNum
419 {
420 get { return m_linkNum; }
590 set 421 set
591 { 422 {
592 m_text = value; 423 m_linkNum = value;
424 TriggerScriptChangedEvent(Changed.LINK);
593 } 425 }
594 } 426 }
595 427
596 private string m_sitName = String.Empty; 428 public byte ClickAction
429 {
430 get { return m_clickAction; }
431 set { m_clickAction = value; }
432 }
433
434 public PrimitiveBaseShape Shape
435 {
436 get { return m_shape; }
437 set
438 {
439 m_shape = value;
440 TriggerScriptChangedEvent(Changed.SHAPE);
441 }
442 }
443
444 public LLVector3 Scale
445 {
446 get { return m_shape.Scale; }
447 set
448 {
449 StoreUndoState();
450 m_shape.Scale = value;
451 TriggerScriptChangedEvent(Changed.SCALE);
452 }
453 }
454
455 public bool Stopped
456 {
457 get
458 {
459 double threshold = 0.02;
460 return (Math.Abs(Velocity.X) < threshold &&
461 Math.Abs(Velocity.Y) < threshold &&
462 Math.Abs(Velocity.Z) < threshold &&
463 Math.Abs(AngularVelocity.X) < threshold &&
464 Math.Abs(AngularVelocity.Y) < threshold &&
465 Math.Abs(AngularVelocity.Z) < threshold);
466 }
467 }
468
469 public LLUUID ObjectCreator
470 {
471 get { return CreatorID; }
472 }
473
474 public LLUUID UUID
475 {
476 get { return m_uuid; }
477 set { m_uuid = value; }
478 }
479
480 public virtual string Name
481 {
482 get { return m_name; }
483 set { m_name = value; }
484 }
485
486 public LLVector3 AbsolutePosition
487 {
488 get
489 {
490 if (m_IsAttachment)
491 return GroupPosition;
492
493 return m_offsetPosition + m_groupPosition;
494 }
495 }
496
497 public string Description
498 {
499 get { return m_description; }
500 set { m_description = value; }
501 }
597 502
598 public string SitName 503 public string SitName
599 { 504 {
@@ -601,39 +506,113 @@ namespace OpenSim.Region.Environment.Scenes
601 set { m_sitName = value; } 506 set { m_sitName = value; }
602 } 507 }
603 508
604 private string m_touchName = String.Empty;
605
606 public string TouchName 509 public string TouchName
607 { 510 {
608 get { return m_touchName; } 511 get { return m_touchName; }
609 set { m_touchName = value; } 512 set { m_touchName = value; }
610 } 513 }
611 514
612 private int m_linkNum = 0; 515 public uint GetEffectiveObjectFlags()
516 {
517 LLObject.ObjectFlags f = Flags;
518 if (m_parentGroup == null || m_parentGroup.RootPart == this)
519 f &= ~(LLObject.ObjectFlags.Touch | LLObject.ObjectFlags.Money);
613 520
614 public int LinkNum 521 return (uint) Flags | (uint) LocalFlags;
522 }
523
524 /// <summary>
525 /// Method for a prim to get it's world position from the group.
526 /// Remember, the Group Position simply gives the position of the group itself
527 /// </summary>
528 /// <returns>A Linked Child Prim objects position in world</returns>
529 public LLVector3 GetWorldPosition()
615 { 530 {
616 get { return m_linkNum; } 531 Quaternion parentRot = new Quaternion(
617 set 532 ParentGroup.RootPart.RotationOffset.W,
618 { 533 ParentGroup.RootPart.RotationOffset.X,
619 m_linkNum = value; 534 ParentGroup.RootPart.RotationOffset.Y,
620 TriggerScriptChangedEvent(Changed.LINK); 535 ParentGroup.RootPart.RotationOffset.Z);
621 536
622 } 537 Vector3 axPos
538 = new Vector3(
539 OffsetPosition.X,
540 OffsetPosition.Y,
541 OffsetPosition.Z);
542
543 axPos = parentRot * axPos;
544 LLVector3 translationOffsetPosition = new LLVector3(axPos.x, axPos.y, axPos.z);
545 return GroupPosition + translationOffsetPosition;
546
547 //return (new LLVector3(axiomPos.x, axiomPos.y, axiomPos.z) + AbsolutePosition);
623 } 548 }
624 549
625 private byte m_clickAction = 0; 550 /// <summary>
551 /// Gets the rotation of this prim offset by the group rotation
552 /// </summary>
553 /// <returns></returns>
554 public LLQuaternion GetWorldRotation()
555 {
556 Quaternion newRot;
626 557
627 public byte ClickAction 558 if (LinkNum == 0)
559 {
560 newRot = new Quaternion(RotationOffset.W, RotationOffset.X, RotationOffset.Y, RotationOffset.Z);
561 }
562 else
563 {
564 Quaternion parentRot = new Quaternion(
565 ParentGroup.RootPart.RotationOffset.W,
566 ParentGroup.RootPart.RotationOffset.X,
567 ParentGroup.RootPart.RotationOffset.Y,
568 ParentGroup.RootPart.RotationOffset.Z);
569
570 Quaternion oldRot
571 = new Quaternion(
572 RotationOffset.W,
573 RotationOffset.X,
574 RotationOffset.Y,
575 RotationOffset.Z);
576
577 newRot = parentRot * oldRot;
578 }
579 return new LLQuaternion(newRot.x, newRot.y, newRot.z, newRot.w);
580
581 //return new LLQuaternion(axiomPartRotation.x, axiomPartRotation.y, axiomPartRotation.z, axiomPartRotation.w);
582 }
583
584 public void StoreUndoState()
628 { 585 {
629 get { return m_clickAction; } 586 if (!m_undoing)
630 set
631 { 587 {
632 m_clickAction = value; 588 if (m_parentGroup != null)
589 {
590 if (m_undo.Count > 0)
591 {
592 UndoState last = m_undo.Peek();
593 if (last != null)
594 {
595 if (last.Compare(this))
596 return;
597 }
598 }
599
600
601 if (m_parentGroup.GetSceneMaxUndo() > 0)
602 {
603 UndoState nUndo = new UndoState(this);
604
605 m_undo.Push(nUndo);
606 }
607 }
633 } 608 }
634 } 609 }
635 610
636 protected PrimitiveBaseShape m_shape; 611 public void ClearUndoState()
612 {
613 m_undo.Clear();
614 StoreUndoState();
615 }
637 616
638 /// <summary> 617 /// <summary>
639 /// hook to the physics scene to apply impulse 618 /// hook to the physics scene to apply impulse
@@ -645,20 +624,17 @@ namespace OpenSim.Region.Environment.Scenes
645 public void ApplyImpulse(LLVector3 impulsei, bool localGlobalTF) 624 public void ApplyImpulse(LLVector3 impulsei, bool localGlobalTF)
646 { 625 {
647 PhysicsVector impulse = new PhysicsVector(impulsei.X, impulsei.Y, impulsei.Z); 626 PhysicsVector impulse = new PhysicsVector(impulsei.X, impulsei.Y, impulsei.Z);
648 627
649 if (localGlobalTF) 628 if (localGlobalTF)
650 { 629 {
651
652 LLQuaternion grot = GetWorldRotation(); 630 LLQuaternion grot = GetWorldRotation();
653 Quaternion AXgrot = new Quaternion(grot.W,grot.X,grot.Y,grot.Z); 631 Quaternion AXgrot = new Quaternion(grot.W, grot.X, grot.Y, grot.Z);
654 Vector3 AXimpulsei = new Vector3(impulsei.X, impulsei.Y, impulsei.Z); 632 Vector3 AXimpulsei = new Vector3(impulsei.X, impulsei.Y, impulsei.Z);
655 Vector3 newimpulse = AXgrot * AXimpulsei; 633 Vector3 newimpulse = AXgrot * AXimpulsei;
656 impulse = new PhysicsVector(newimpulse.x, newimpulse.y, newimpulse.z); 634 impulse = new PhysicsVector(newimpulse.x, newimpulse.y, newimpulse.z);
657
658 } 635 }
659 else 636 else
660 { 637 {
661
662 if (m_parentGroup != null) 638 if (m_parentGroup != null)
663 { 639 {
664 m_parentGroup.applyImpulse(impulse); 640 m_parentGroup.applyImpulse(impulse);
@@ -676,7 +652,6 @@ namespace OpenSim.Region.Environment.Scenes
676 { 652 {
677 StopMoveToTarget(); 653 StopMoveToTarget();
678 } 654 }
679
680 } 655 }
681 656
682 public void StopMoveToTarget() 657 public void StopMoveToTarget()
@@ -689,56 +664,48 @@ namespace OpenSim.Region.Environment.Scenes
689 if (m_parentGroup != null) 664 if (m_parentGroup != null)
690 { 665 {
691 if (m_parentGroup.Scene != null) 666 if (m_parentGroup.Scene != null)
692 m_parentGroup.Scene.TriggerObjectChanged(LocalId, (uint)val); 667 m_parentGroup.Scene.TriggerObjectChanged(LocalId, (uint) val);
693 } 668 }
694
695 } 669 }
696 670
697 public PrimitiveBaseShape Shape 671 #endregion
672
673 #region Permissions
674
675 private readonly UndoStack<UndoState> m_undo = new UndoStack<UndoState>(5);
676 public uint BaseMask = (uint) PermissionMask.All;
677 public uint EveryoneMask = (uint) PermissionMask.None;
678
679 public LLObject.ObjectFlags Flags = LLObject.ObjectFlags.None;
680 public uint GroupMask = (uint) PermissionMask.None;
681 public uint NextOwnerMask = (uint) PermissionMask.All;
682 public uint OwnerMask = (uint) PermissionMask.All;
683
684 public uint ObjectFlags
698 { 685 {
699 get { return m_shape; } 686 get { return (uint) Flags; }
700 set 687 set { Flags = (LLObject.ObjectFlags) value; }
701 {
702
703 m_shape = value;
704 TriggerScriptChangedEvent(Changed.SHAPE);
705 }
706 } 688 }
707 689
708 public LLVector3 Scale 690 #endregion
691
692 protected SceneObjectPart(SerializationInfo info, StreamingContext context)
709 { 693 {
710 get { return m_shape.Scale; } 694 //System.Console.WriteLine("SceneObjectPart Deserialize BGN");
711 set 695
696 if (info == null)
712 { 697 {
713 StoreUndoState(); 698 throw new ArgumentNullException("info");
714 m_shape.Scale = value;
715 TriggerScriptChangedEvent(Changed.SCALE);
716 } 699 }
717 }
718 700
719 public bool Stopped 701 /*
720 { 702 m_queue = (Queue<SceneObjectPart>)info.GetValue("m_queue", typeof(Queue<SceneObjectPart>));
721 get { 703 m_ids = (List<LLUUID>)info.GetValue("m_ids", typeof(List<LLUUID>));
722 double threshold = 0.02; 704 */
723 return (Math.Abs(Velocity.X) < threshold &&
724 Math.Abs(Velocity.Y) < threshold &&
725 Math.Abs(Velocity.Z) < threshold &&
726 Math.Abs(AngularVelocity.X) < threshold &&
727 Math.Abs(AngularVelocity.Y) < threshold &&
728 Math.Abs(AngularVelocity.Z) < threshold);
729 }
730 }
731 705
732 #endregion 706 //System.Console.WriteLine("SceneObjectPart Deserialize END");
733
734 public LLUUID ObjectOwner
735 {
736 get { return OwnerID; }
737 } 707 }
738 708
739 // FIXME, TODO, ERROR: 'ParentGroup' can't be in here, move it out.
740 protected SceneObjectGroup m_parentGroup;
741
742 public SceneObjectGroup ParentGroup 709 public SceneObjectGroup ParentGroup
743 { 710 {
744 get { return m_parentGroup; } 711 get { return m_parentGroup; }
@@ -758,7 +725,7 @@ namespace OpenSim.Region.Environment.Scenes
758 public SceneObjectPart() 725 public SceneObjectPart()
759 { 726 {
760 // It's not necessary to persist this 727 // It's not necessary to persist this
761 m_inventoryFileName = "inventory_" + LLUUID.Random().ToString() + ".tmp"; 728 m_inventoryFileName = "inventory_" + LLUUID.Random() + ".tmp";
762 m_TextureAnimation = new byte[0]; 729 m_TextureAnimation = new byte[0];
763 } 730 }
764 731
@@ -790,13 +757,13 @@ namespace OpenSim.Region.Environment.Scenes
790 CreatorID = OwnerID; 757 CreatorID = OwnerID;
791 LastOwnerID = LLUUID.Zero; 758 LastOwnerID = LLUUID.Zero;
792 UUID = LLUUID.Random(); 759 UUID = LLUUID.Random();
793 LocalId = (uint) (localID); 760 LocalId = (localID);
794 Shape = shape; 761 Shape = shape;
795 // Todo: Add More Object Parameter from above! 762 // Todo: Add More Object Parameter from above!
796 OwnershipCost = 0; 763 OwnershipCost = 0;
797 ObjectSaleType = (byte) 0; 764 ObjectSaleType = 0;
798 SalePrice = 0; 765 SalePrice = 0;
799 Category = (uint) 0; 766 Category = 0;
800 LastOwnerID = CreatorID; 767 LastOwnerID = CreatorID;
801 // End Todo: /// 768 // End Todo: ///
802 GroupPosition = groupPosition; 769 GroupPosition = groupPosition;
@@ -807,20 +774,20 @@ namespace OpenSim.Region.Environment.Scenes
807 AngularVelocity = new LLVector3(0, 0, 0); 774 AngularVelocity = new LLVector3(0, 0, 0);
808 Acceleration = new LLVector3(0, 0, 0); 775 Acceleration = new LLVector3(0, 0, 0);
809 m_TextureAnimation = new byte[0]; 776 m_TextureAnimation = new byte[0];
810 m_inventoryFileName = "inventory_" + LLUUID.Random().ToString() + ".tmp"; 777 m_inventoryFileName = "inventory_" + LLUUID.Random() + ".tmp";
811 778
812 // Prims currently only contain a single folder (Contents). From looking at the Second Life protocol, 779 // Prims currently only contain a single folder (Contents). From looking at the Second Life protocol,
813 // this appears to have the same UUID (!) as the prim. If this isn't the case, one can't drag items from 780 // this appears to have the same UUID (!) as the prim. If this isn't the case, one can't drag items from
814 // the prim into an agent inventory (Linden client reports that the "Object not found for drop" in its log 781 // the prim into an agent inventory (Linden client reports that the "Object not found for drop" in its log
815 m_folderID = UUID; 782 m_folderID = UUID;
816 783
817 Flags = 0; 784 Flags = 0;
818 Flags |= LLObject.ObjectFlags.AllowInventoryDrop | 785 Flags |= LLObject.ObjectFlags.AllowInventoryDrop |
819 LLObject.ObjectFlags.CreateSelected; 786 LLObject.ObjectFlags.CreateSelected;
820 787
821 TrimPermissions(); 788 TrimPermissions();
822 //m_undo = new UndoStack<UndoState>(ParentGroup.GetSceneMaxUndo()); 789 //m_undo = new UndoStack<UndoState>(ParentGroup.GetSceneMaxUndo());
823 790
824 ScheduleFullUpdate(); 791 ScheduleFullUpdate();
825 } 792 }
826 793
@@ -846,29 +813,149 @@ namespace OpenSim.Region.Environment.Scenes
846 CreatorID = creatorID; 813 CreatorID = creatorID;
847 LastOwnerID = lastOwnerID; 814 LastOwnerID = lastOwnerID;
848 UUID = LLUUID.Random(); 815 UUID = LLUUID.Random();
849 LocalId = (uint) (localID); 816 LocalId = (localID);
850 Shape = shape; 817 Shape = shape;
851 OwnershipCost = 0; 818 OwnershipCost = 0;
852 ObjectSaleType = (byte) 0; 819 ObjectSaleType = 0;
853 SalePrice = 0; 820 SalePrice = 0;
854 Category = (uint) 0; 821 Category = 0;
855 LastOwnerID = CreatorID; 822 LastOwnerID = CreatorID;
856 OffsetPosition = position; 823 OffsetPosition = position;
857 RotationOffset = rotation; 824 RotationOffset = rotation;
858 ObjectFlags = flags; 825 ObjectFlags = flags;
859 826
860 // Since we don't store script state, this is only a 'temporary' objectflag now 827 // Since we don't store script state, this is only a 'temporary' objectflag now
861 // If the object is scripted, the script will get loaded and this will be set again 828 // If the object is scripted, the script will get loaded and this will be set again
862 ObjectFlags &= ~(uint)(LLObject.ObjectFlags.Scripted | LLObject.ObjectFlags.Touch); 829 ObjectFlags &= ~(uint) (LLObject.ObjectFlags.Scripted | LLObject.ObjectFlags.Touch);
863 830
864 TrimPermissions(); 831 TrimPermissions();
865 // ApplyPhysics(); 832 // ApplyPhysics();
866 833
867 ScheduleFullUpdate(); 834 ScheduleFullUpdate();
868 } 835 }
869 836
870 #endregion 837 #endregion
871 838
839 #region IScriptHost Members
840
841 public LLUUID ObjectOwner
842 {
843 get { return OwnerID; }
844 }
845
846 public void SetText(string text, Vector3 color, double alpha)
847 {
848 Color = Color.FromArgb(0xff - (int) (alpha * 0xff),
849 (int) (color.x * 0xff),
850 (int) (color.y * 0xff),
851 (int) (color.z * 0xff));
852 SetText(text);
853 }
854
855 #endregion
856
857 #region ISerializable Members
858
859 [SecurityPermission(SecurityAction.LinkDemand,
860 Flags = SecurityPermissionFlag.SerializationFormatter)]
861 public virtual void GetObjectData(
862 SerializationInfo info, StreamingContext context)
863 {
864 if (info == null)
865 {
866 throw new ArgumentNullException("info");
867 }
868
869 info.AddValue("m_inventoryFileName", m_inventoryFileName);
870 info.AddValue("m_folderID", m_folderID.UUID);
871 info.AddValue("PhysActor", PhysActor);
872
873 Dictionary<Guid, TaskInventoryItem> TaskInventory_work = new Dictionary<Guid, TaskInventoryItem>();
874
875 foreach (LLUUID id in TaskInventory.Keys)
876 {
877 TaskInventory_work.Add(id.UUID, TaskInventory[id]);
878 }
879
880 info.AddValue("TaskInventory", TaskInventory_work);
881
882 info.AddValue("LastOwnerID", LastOwnerID.UUID);
883 info.AddValue("OwnerID", OwnerID.UUID);
884 info.AddValue("GroupID", GroupID.UUID);
885
886 info.AddValue("OwnershipCost", OwnershipCost);
887 info.AddValue("ObjectSaleType", ObjectSaleType);
888 info.AddValue("SalePrice", SalePrice);
889 info.AddValue("Category", Category);
890
891 info.AddValue("CreationDate", CreationDate);
892 info.AddValue("ParentID", ParentID);
893
894 info.AddValue("OwnerMask", OwnerMask);
895 info.AddValue("NextOwnerMask", NextOwnerMask);
896 info.AddValue("GroupMask", GroupMask);
897 info.AddValue("EveryoneMask", EveryoneMask);
898 info.AddValue("BaseMask", BaseMask);
899
900 info.AddValue("m_particleSystem", m_particleSystem);
901
902 info.AddValue("TimeStampFull", TimeStampFull);
903 info.AddValue("TimeStampTerse", TimeStampTerse);
904 info.AddValue("TimeStampLastActivity", TimeStampLastActivity);
905
906 info.AddValue("m_updateFlag", m_updateFlag);
907 info.AddValue("CreatorID", CreatorID.UUID);
908
909 info.AddValue("m_inventorySerial", m_inventorySerial);
910 info.AddValue("m_uuid", m_uuid.UUID);
911 info.AddValue("m_localID", m_localId);
912 info.AddValue("m_name", m_name);
913 info.AddValue("m_flags", Flags);
914 info.AddValue("m_material", m_material);
915 info.AddValue("m_regionHandle", m_regionHandle);
916
917 info.AddValue("m_groupPosition.X", m_groupPosition.X);
918 info.AddValue("m_groupPosition.Y", m_groupPosition.Y);
919 info.AddValue("m_groupPosition.Z", m_groupPosition.Z);
920
921 info.AddValue("m_offsetPosition.X", m_offsetPosition.X);
922 info.AddValue("m_offsetPosition.Y", m_offsetPosition.Y);
923 info.AddValue("m_offsetPosition.Z", m_offsetPosition.Z);
924
925 info.AddValue("m_rotationOffset.W", m_rotationOffset.W);
926 info.AddValue("m_rotationOffset.X", m_rotationOffset.X);
927 info.AddValue("m_rotationOffset.Y", m_rotationOffset.Y);
928 info.AddValue("m_rotationOffset.Z", m_rotationOffset.Z);
929
930 info.AddValue("m_velocity.X", m_velocity.X);
931 info.AddValue("m_velocity.Y", m_velocity.Y);
932 info.AddValue("m_velocity.Z", m_velocity.Z);
933
934 info.AddValue("m_rotationalvelocity.X", m_rotationalvelocity.X);
935 info.AddValue("m_rotationalvelocity.Y", m_rotationalvelocity.Y);
936 info.AddValue("m_rotationalvelocity.Z", m_rotationalvelocity.Z);
937
938 info.AddValue("m_angularVelocity.X", m_angularVelocity.X);
939 info.AddValue("m_angularVelocity.Y", m_angularVelocity.Y);
940 info.AddValue("m_angularVelocity.Z", m_angularVelocity.Z);
941
942 info.AddValue("m_acceleration.X", m_acceleration.X);
943 info.AddValue("m_acceleration.Y", m_acceleration.Y);
944 info.AddValue("m_acceleration.Z", m_acceleration.Z);
945
946 info.AddValue("m_description", m_description);
947 info.AddValue("m_color", m_color);
948 info.AddValue("m_text", m_text);
949 info.AddValue("m_sitName", m_sitName);
950 info.AddValue("m_touchName", m_touchName);
951 info.AddValue("m_clickAction", m_clickAction);
952 info.AddValue("m_shape", m_shape);
953 info.AddValue("m_parentGroup", m_parentGroup);
954 info.AddValue("PayPrice", PayPrice);
955 }
956
957 #endregion
958
872 /// <summary> 959 /// <summary>
873 /// Restore this part from the serialized xml representation. 960 /// Restore this part from the serialized xml representation.
874 /// </summary> 961 /// </summary>
@@ -881,10 +968,9 @@ namespace OpenSim.Region.Environment.Scenes
881 968
882 return newobject; 969 return newobject;
883 } 970 }
884 971
885 public void ApplyPhysics(uint rootObjectFlags, bool m_physicalPrim) 972 public void ApplyPhysics(uint rootObjectFlags, bool m_physicalPrim)
886 { 973 {
887
888 bool isPhysical = (((rootObjectFlags & (uint) LLObject.ObjectFlags.Physics) != 0) && m_physicalPrim); 974 bool isPhysical = (((rootObjectFlags & (uint) LLObject.ObjectFlags.Physics) != 0) && m_physicalPrim);
889 bool isPhantom = ((rootObjectFlags & (uint) LLObject.ObjectFlags.Phantom) != 0); 975 bool isPhantom = ((rootObjectFlags & (uint) LLObject.ObjectFlags.Phantom) != 0);
890 976
@@ -902,7 +988,7 @@ namespace OpenSim.Region.Environment.Scenes
902 new PhysicsVector(Scale.X, Scale.Y, Scale.Z), 988 new PhysicsVector(Scale.X, Scale.Y, Scale.Z),
903 new Quaternion(RotationOffset.W, RotationOffset.X, 989 new Quaternion(RotationOffset.W, RotationOffset.X,
904 RotationOffset.Y, RotationOffset.Z), RigidBody); 990 RotationOffset.Y, RotationOffset.Z), RigidBody);
905 991
906 // Basic Physics returns null.. joy joy joy. 992 // Basic Physics returns null.. joy joy joy.
907 if (PhysActor != null) 993 if (PhysActor != null)
908 { 994 {
@@ -918,18 +1004,15 @@ namespace OpenSim.Region.Environment.Scenes
918 OwnerMask = NextOwnerMask; 1004 OwnerMask = NextOwnerMask;
919 1005
920 TriggerScriptChangedEvent(Changed.OWNER); 1006 TriggerScriptChangedEvent(Changed.OWNER);
921
922 } 1007 }
923 1008
924 public void TrimPermissions() 1009 public void TrimPermissions()
925 { 1010 {
926 1011 BaseMask &= (uint) PermissionMask.All;
927 BaseMask &= (uint)PermissionMask.All; 1012 OwnerMask &= (uint) PermissionMask.All;
928 OwnerMask &= (uint)PermissionMask.All; 1013 GroupMask &= (uint) PermissionMask.All;
929 GroupMask &= (uint)PermissionMask.All; 1014 EveryoneMask &= (uint) PermissionMask.All;
930 EveryoneMask &= (uint)PermissionMask.All; 1015 NextOwnerMask &= (uint) PermissionMask.All;
931 NextOwnerMask &= (uint)PermissionMask.All;
932
933 } 1016 }
934 1017
935 /// <summary> 1018 /// <summary>
@@ -963,25 +1046,24 @@ namespace OpenSim.Region.Environment.Scenes
963 Vector3 rOrigin = iray.Origin; 1046 Vector3 rOrigin = iray.Origin;
964 Vector3 rDirection = iray.Direction; 1047 Vector3 rDirection = iray.Direction;
965 1048
966
967 1049
968 //rDirection = rDirection.Normalize(); 1050 //rDirection = rDirection.Normalize();
969 // Buidling the first part of the Quadratic equation 1051 // Buidling the first part of the Quadratic equation
970 Vector3 r2ndDirection = rDirection*rDirection; 1052 Vector3 r2ndDirection = rDirection * rDirection;
971 float itestPart1 = r2ndDirection.x + r2ndDirection.y + r2ndDirection.z; 1053 float itestPart1 = r2ndDirection.x + r2ndDirection.y + r2ndDirection.z;
972 1054
973 // Buidling the second part of the Quadratic equation 1055 // Buidling the second part of the Quadratic equation
974 Vector3 tmVal2 = rOrigin - vAbsolutePosition; 1056 Vector3 tmVal2 = rOrigin - vAbsolutePosition;
975 Vector3 r2Direction = rDirection*2.0f; 1057 Vector3 r2Direction = rDirection * 2.0f;
976 Vector3 tmVal3 = r2Direction*tmVal2; 1058 Vector3 tmVal3 = r2Direction * tmVal2;
977 1059
978 float itestPart2 = tmVal3.x + tmVal3.y + tmVal3.z; 1060 float itestPart2 = tmVal3.x + tmVal3.y + tmVal3.z;
979 1061
980 // Buidling the third part of the Quadratic equation 1062 // Buidling the third part of the Quadratic equation
981 Vector3 tmVal4 = rOrigin*rOrigin; 1063 Vector3 tmVal4 = rOrigin * rOrigin;
982 Vector3 tmVal5 = vAbsolutePosition*vAbsolutePosition; 1064 Vector3 tmVal5 = vAbsolutePosition * vAbsolutePosition;
983 1065
984 Vector3 tmVal6 = vAbsolutePosition*rOrigin; 1066 Vector3 tmVal6 = vAbsolutePosition * rOrigin;
985 1067
986 1068
987 // Set Radius to the largest dimention of the prim 1069 // Set Radius to the largest dimention of the prim
@@ -1003,21 +1085,21 @@ namespace OpenSim.Region.Environment.Scenes
1003 //radius = radius; 1085 //radius = radius;
1004 1086
1005 float itestPart3 = tmVal4.x + tmVal4.y + tmVal4.z + tmVal5.x + tmVal5.y + tmVal5.z - 1087 float itestPart3 = tmVal4.x + tmVal4.y + tmVal4.z + tmVal5.x + tmVal5.y + tmVal5.z -
1006 (2.0f*(tmVal6.x + tmVal6.y + tmVal6.z + (radius*radius))); 1088 (2.0f * (tmVal6.x + tmVal6.y + tmVal6.z + (radius * radius)));
1007 1089
1008 // Yuk Quadradrics.. Solve first 1090 // Yuk Quadradrics.. Solve first
1009 float rootsqr = (itestPart2*itestPart2) - (4.0f*itestPart1*itestPart3); 1091 float rootsqr = (itestPart2 * itestPart2) - (4.0f * itestPart1 * itestPart3);
1010 if (rootsqr < 0.0f) 1092 if (rootsqr < 0.0f)
1011 { 1093 {
1012 // No intersection 1094 // No intersection
1013 return returnresult; 1095 return returnresult;
1014 } 1096 }
1015 float root = ((-itestPart2) - (float) Math.Sqrt((double) rootsqr))/(itestPart1*2.0f); 1097 float root = ((-itestPart2) - (float) Math.Sqrt(rootsqr)) / (itestPart1 * 2.0f);
1016 1098
1017 if (root < 0.0f) 1099 if (root < 0.0f)
1018 { 1100 {
1019 // perform second quadratic root solution 1101 // perform second quadratic root solution
1020 root = ((-itestPart2) + (float) Math.Sqrt((double) rootsqr))/(itestPart1*2.0f); 1102 root = ((-itestPart2) + (float) Math.Sqrt(rootsqr)) / (itestPart1 * 2.0f);
1021 1103
1022 // is there any intersection? 1104 // is there any intersection?
1023 if (root < 0.0f) 1105 if (root < 0.0f)
@@ -1030,8 +1112,8 @@ namespace OpenSim.Region.Environment.Scenes
1030 // We got an intersection. putting together an EntityIntersection object with the 1112 // We got an intersection. putting together an EntityIntersection object with the
1031 // intersection information 1113 // intersection information
1032 Vector3 ipoint = 1114 Vector3 ipoint =
1033 new Vector3(iray.Origin.x + (iray.Direction.x*root), iray.Origin.y + (iray.Direction.y*root), 1115 new Vector3(iray.Origin.x + (iray.Direction.x * root), iray.Origin.y + (iray.Direction.y * root),
1034 iray.Origin.z + (iray.Direction.z*root)); 1116 iray.Origin.z + (iray.Direction.z * root));
1035 1117
1036 returnresult.HitTF = true; 1118 returnresult.HitTF = true;
1037 returnresult.ipoint = ipoint; 1119 returnresult.ipoint = ipoint;
@@ -1092,7 +1174,7 @@ namespace OpenSim.Region.Environment.Scenes
1092 1174
1093 // Variables prefixed with AX are Axiom.Math copies of the LL variety. 1175 // Variables prefixed with AX are Axiom.Math copies of the LL variety.
1094 1176
1095 Quaternion AXrot = new Quaternion(rot.W,rot.X,rot.Y,rot.Z); 1177 Quaternion AXrot = new Quaternion(rot.W, rot.X, rot.Y, rot.Z);
1096 AXrot.Normalize(); 1178 AXrot.Normalize();
1097 1179
1098 Vector3 AXpos = new Vector3(pos.X, pos.Y, pos.Z); 1180 Vector3 AXpos = new Vector3(pos.X, pos.Y, pos.Z);
@@ -1101,31 +1183,33 @@ namespace OpenSim.Region.Environment.Scenes
1101 // it's different for each vertex because we've got to rotate it 1183 // it's different for each vertex because we've got to rotate it
1102 // to get the world position of the vertex to produce the Oriented Bounding Box 1184 // to get the world position of the vertex to produce the Oriented Bounding Box
1103 1185
1104 Vector3 tScale = new Vector3(); 1186 Vector3 tScale = new Vector3();
1105 1187
1106 Vector3 AXscale = new Vector3(m_shape.Scale.X * 0.5f, m_shape.Scale.Y * 0.5f, m_shape.Scale.Z * 0.5f); 1188 Vector3 AXscale = new Vector3(m_shape.Scale.X * 0.5f, m_shape.Scale.Y * 0.5f, m_shape.Scale.Z * 0.5f);
1107 1189
1108 //Vector3 pScale = (AXscale) - (AXrot.Inverse() * (AXscale)); 1190 //Vector3 pScale = (AXscale) - (AXrot.Inverse() * (AXscale));
1109 //Vector3 nScale = (AXscale * -1) - (AXrot.Inverse() * (AXscale * -1)); 1191 //Vector3 nScale = (AXscale * -1) - (AXrot.Inverse() * (AXscale * -1));
1110 1192
1111 // rScale is the rotated offset to find a vertex based on the scale and the world rotation. 1193 // rScale is the rotated offset to find a vertex based on the scale and the world rotation.
1112 Vector3 rScale = new Vector3(); 1194 Vector3 rScale = new Vector3();
1113 1195
1114 // Get Vertexes for Faces Stick them into ABCD for each Face 1196 // Get Vertexes for Faces Stick them into ABCD for each Face
1115 // Form: Face<vertex>[face] that corresponds to the below diagram 1197 // Form: Face<vertex>[face] that corresponds to the below diagram
1198
1116 #region ABCD Face Vertex Map Comment Diagram 1199 #region ABCD Face Vertex Map Comment Diagram
1200
1117 // A _________ B 1201 // A _________ B
1118 // | | 1202 // | |
1119 // | 4 top | 1203 // | 4 top |
1120 // |_________| 1204 // |_________|
1121 // C D 1205 // C D
1122 1206
1123 // A _________ B 1207 // A _________ B
1124 // | Back | 1208 // | Back |
1125 // | 3 | 1209 // | 3 |
1126 // |_________| 1210 // |_________|
1127 // C D 1211 // C D
1128 1212
1129 // A _________ B B _________ A 1213 // A _________ B B _________ A
1130 // | Left | | Right | 1214 // | Left | | Right |
1131 // | 0 | | 2 | 1215 // | 0 | | 2 |
@@ -1143,13 +1227,15 @@ namespace OpenSim.Region.Environment.Scenes
1143 // | 5 bot | 1227 // | 5 bot |
1144 // |_________| 1228 // |_________|
1145 // A B 1229 // A B
1230
1146 #endregion 1231 #endregion
1147 1232
1148 #region Plane Decomposition of Oriented Bounding Box 1233 #region Plane Decomposition of Oriented Bounding Box
1234
1149 tScale = new Vector3(AXscale.x, -AXscale.y, AXscale.z); 1235 tScale = new Vector3(AXscale.x, -AXscale.y, AXscale.z);
1150 rScale = ((AXrot * tScale)); 1236 rScale = ((AXrot * tScale));
1151 vertexes[0] = (new Vector3((pos.X + rScale.x), (pos.Y + rScale.y), (pos.Z + rScale.z))); 1237 vertexes[0] = (new Vector3((pos.X + rScale.x), (pos.Y + rScale.y), (pos.Z + rScale.z)));
1152 // vertexes[0].x = pos.X + vertexes[0].x; 1238 // vertexes[0].x = pos.X + vertexes[0].x;
1153 //vertexes[0].y = pos.Y + vertexes[0].y; 1239 //vertexes[0].y = pos.Y + vertexes[0].y;
1154 //vertexes[0].z = pos.Z + vertexes[0].z; 1240 //vertexes[0].z = pos.Z + vertexes[0].z;
1155 1241
@@ -1161,8 +1247,8 @@ namespace OpenSim.Region.Environment.Scenes
1161 rScale = ((AXrot * tScale)); 1247 rScale = ((AXrot * tScale));
1162 vertexes[1] = (new Vector3((pos.X + rScale.x), (pos.Y + rScale.y), (pos.Z + rScale.z))); 1248 vertexes[1] = (new Vector3((pos.X + rScale.x), (pos.Y + rScale.y), (pos.Z + rScale.z)));
1163 1249
1164 // vertexes[1].x = pos.X + vertexes[1].x; 1250 // vertexes[1].x = pos.X + vertexes[1].x;
1165 // vertexes[1].y = pos.Y + vertexes[1].y; 1251 // vertexes[1].y = pos.Y + vertexes[1].y;
1166 //vertexes[1].z = pos.Z + vertexes[1].z; 1252 //vertexes[1].z = pos.Z + vertexes[1].z;
1167 1253
1168 FaceB[0] = vertexes[1]; 1254 FaceB[0] = vertexes[1];
@@ -1187,8 +1273,8 @@ namespace OpenSim.Region.Environment.Scenes
1187 vertexes[3] = (new Vector3((pos.X + rScale.x), (pos.Y + rScale.y), (pos.Z + rScale.z))); 1273 vertexes[3] = (new Vector3((pos.X + rScale.x), (pos.Y + rScale.y), (pos.Z + rScale.z)));
1188 1274
1189 //vertexes[3].x = pos.X + vertexes[3].x; 1275 //vertexes[3].x = pos.X + vertexes[3].x;
1190 // vertexes[3].y = pos.Y + vertexes[3].y; 1276 // vertexes[3].y = pos.Y + vertexes[3].y;
1191 // vertexes[3].z = pos.Z + vertexes[3].z; 1277 // vertexes[3].z = pos.Z + vertexes[3].z;
1192 1278
1193 FaceD[0] = vertexes[3]; 1279 FaceD[0] = vertexes[3];
1194 FaceC[1] = vertexes[3]; 1280 FaceC[1] = vertexes[3];
@@ -1198,9 +1284,9 @@ namespace OpenSim.Region.Environment.Scenes
1198 rScale = ((AXrot * tScale)); 1284 rScale = ((AXrot * tScale));
1199 vertexes[4] = (new Vector3((pos.X + rScale.x), (pos.Y + rScale.y), (pos.Z + rScale.z))); 1285 vertexes[4] = (new Vector3((pos.X + rScale.x), (pos.Y + rScale.y), (pos.Z + rScale.z)));
1200 1286
1201 // vertexes[4].x = pos.X + vertexes[4].x; 1287 // vertexes[4].x = pos.X + vertexes[4].x;
1202 // vertexes[4].y = pos.Y + vertexes[4].y; 1288 // vertexes[4].y = pos.Y + vertexes[4].y;
1203 // vertexes[4].z = pos.Z + vertexes[4].z; 1289 // vertexes[4].z = pos.Z + vertexes[4].z;
1204 1290
1205 FaceB[1] = vertexes[4]; 1291 FaceB[1] = vertexes[4];
1206 FaceA[2] = vertexes[4]; 1292 FaceA[2] = vertexes[4];
@@ -1210,9 +1296,9 @@ namespace OpenSim.Region.Environment.Scenes
1210 rScale = ((AXrot * tScale)); 1296 rScale = ((AXrot * tScale));
1211 vertexes[5] = (new Vector3((pos.X + rScale.x), (pos.Y + rScale.y), (pos.Z + rScale.z))); 1297 vertexes[5] = (new Vector3((pos.X + rScale.x), (pos.Y + rScale.y), (pos.Z + rScale.z)));
1212 1298
1213 // vertexes[5].x = pos.X + vertexes[5].x; 1299 // vertexes[5].x = pos.X + vertexes[5].x;
1214 // vertexes[5].y = pos.Y + vertexes[5].y; 1300 // vertexes[5].y = pos.Y + vertexes[5].y;
1215 // vertexes[5].z = pos.Z + vertexes[5].z; 1301 // vertexes[5].z = pos.Z + vertexes[5].z;
1216 1302
1217 FaceD[1] = vertexes[5]; 1303 FaceD[1] = vertexes[5];
1218 FaceC[2] = vertexes[5]; 1304 FaceC[2] = vertexes[5];
@@ -1222,9 +1308,9 @@ namespace OpenSim.Region.Environment.Scenes
1222 rScale = ((AXrot * tScale)); 1308 rScale = ((AXrot * tScale));
1223 vertexes[6] = (new Vector3((pos.X + rScale.x), (pos.Y + rScale.y), (pos.Z + rScale.z))); 1309 vertexes[6] = (new Vector3((pos.X + rScale.x), (pos.Y + rScale.y), (pos.Z + rScale.z)));
1224 1310
1225 // vertexes[6].x = pos.X + vertexes[6].x; 1311 // vertexes[6].x = pos.X + vertexes[6].x;
1226 // vertexes[6].y = pos.Y + vertexes[6].y; 1312 // vertexes[6].y = pos.Y + vertexes[6].y;
1227 // vertexes[6].z = pos.Z + vertexes[6].z; 1313 // vertexes[6].z = pos.Z + vertexes[6].z;
1228 1314
1229 FaceB[2] = vertexes[6]; 1315 FaceB[2] = vertexes[6];
1230 FaceA[3] = vertexes[6]; 1316 FaceA[3] = vertexes[6];
@@ -1234,35 +1320,36 @@ namespace OpenSim.Region.Environment.Scenes
1234 rScale = ((AXrot * tScale)); 1320 rScale = ((AXrot * tScale));
1235 vertexes[7] = (new Vector3((pos.X + rScale.x), (pos.Y + rScale.y), (pos.Z + rScale.z))); 1321 vertexes[7] = (new Vector3((pos.X + rScale.x), (pos.Y + rScale.y), (pos.Z + rScale.z)));
1236 1322
1237 // vertexes[7].x = pos.X + vertexes[7].x; 1323 // vertexes[7].x = pos.X + vertexes[7].x;
1238 // vertexes[7].y = pos.Y + vertexes[7].y; 1324 // vertexes[7].y = pos.Y + vertexes[7].y;
1239 // vertexes[7].z = pos.Z + vertexes[7].z; 1325 // vertexes[7].z = pos.Z + vertexes[7].z;
1240 1326
1241 FaceD[2] = vertexes[7]; 1327 FaceD[2] = vertexes[7];
1242 FaceC[3] = vertexes[7]; 1328 FaceC[3] = vertexes[7];
1243 FaceD[5] = vertexes[7]; 1329 FaceD[5] = vertexes[7];
1330
1244 #endregion 1331 #endregion
1245 1332
1246 // Get our plane normals 1333 // Get our plane normals
1247 for (int i = 0; i < 6; i++) 1334 for (int i = 0; i < 6; i++)
1248 { 1335 {
1249 //m_log.Info("[FACECALCULATION]: FaceA[" + i + "]=" + FaceA[i] + " FaceB[" + i + "]=" + FaceB[i] + " FaceC[" + i + "]=" + FaceC[i] + " FaceD[" + i + "]=" + FaceD[i]); 1336 //m_log.Info("[FACECALCULATION]: FaceA[" + i + "]=" + FaceA[i] + " FaceB[" + i + "]=" + FaceB[i] + " FaceC[" + i + "]=" + FaceC[i] + " FaceD[" + i + "]=" + FaceD[i]);
1250 1337
1251 // Our Plane direction 1338 // Our Plane direction
1252 AmBa = FaceA[i] - FaceB[i]; 1339 AmBa = FaceA[i] - FaceB[i];
1253 AmBb = FaceB[i] - FaceC[i]; 1340 AmBb = FaceB[i] - FaceC[i];
1254 1341
1255 cross = AmBb.Cross(AmBa); 1342 cross = AmBb.Cross(AmBa);
1256 1343
1257 // normalize the cross product to get the normal. 1344 // normalize the cross product to get the normal.
1258 normals[i] = cross / cross.Length; 1345 normals[i] = cross / cross.Length;
1259 1346
1260 //m_log.Info("[NORMALS]: normals[ " + i + "]" + normals[i].ToString()); 1347 //m_log.Info("[NORMALS]: normals[ " + i + "]" + normals[i].ToString());
1261 //distance[i] = (normals[i].x * AmBa.x + normals[i].y * AmBa.y + normals[i].z * AmBa.z) * -1; 1348 //distance[i] = (normals[i].x * AmBa.x + normals[i].y * AmBa.y + normals[i].z * AmBa.z) * -1;
1262 } 1349 }
1263 1350
1264 EntityIntersection returnresult = new EntityIntersection(); 1351 EntityIntersection returnresult = new EntityIntersection();
1265 1352
1266 returnresult.distance = 1024; 1353 returnresult.distance = 1024;
1267 float c = 0; 1354 float c = 0;
1268 float a = 0; 1355 float a = 0;
@@ -1270,57 +1357,59 @@ namespace OpenSim.Region.Environment.Scenes
1270 Vector3 q = new Vector3(); 1357 Vector3 q = new Vector3();
1271 1358
1272 #region OBB Version 2 Experiment 1359 #region OBB Version 2 Experiment
1360
1273 //float fmin = 999999; 1361 //float fmin = 999999;
1274 //float fmax = -999999; 1362 //float fmax = -999999;
1275 //float s = 0; 1363 //float s = 0;
1276 1364
1277 //for (int i=0;i<6;i++) 1365 //for (int i=0;i<6;i++)
1278 //{ 1366 //{
1279 //s = iray.Direction.Dot(normals[i]); 1367 //s = iray.Direction.Dot(normals[i]);
1280 //d = normals[i].Dot(FaceB[i]); 1368 //d = normals[i].Dot(FaceB[i]);
1281 1369
1282 //if (s == 0) 1370 //if (s == 0)
1283 //{ 1371 //{
1284 //if (iray.Origin.Dot(normals[i]) > d) 1372 //if (iray.Origin.Dot(normals[i]) > d)
1285 //{ 1373 //{
1286 //return returnresult; 1374 //return returnresult;
1287 //} 1375 //}
1288 // else 1376 // else
1289 //{ 1377 //{
1290 //continue; 1378 //continue;
1291 //} 1379 //}
1292 //} 1380 //}
1293 //a = (d - iray.Origin.Dot(normals[i])) / s; 1381 //a = (d - iray.Origin.Dot(normals[i])) / s;
1294 //if ( iray.Direction.Dot(normals[i]) < 0) 1382 //if ( iray.Direction.Dot(normals[i]) < 0)
1295 //{ 1383 //{
1296 //if (a > fmax) 1384 //if (a > fmax)
1297 //{ 1385 //{
1298 //if (a > fmin) 1386 //if (a > fmin)
1299 //{ 1387 //{
1300 //return returnresult; 1388 //return returnresult;
1301 //} 1389 //}
1302 //fmax = a; 1390 //fmax = a;
1303 //} 1391 //}
1304 1392
1305 //} 1393 //}
1306 //else 1394 //else
1307 //{ 1395 //{
1308 //if (a < fmin) 1396 //if (a < fmin)
1309 //{ 1397 //{
1310 //if (a < 0 || a < fmax) 1398 //if (a < 0 || a < fmax)
1311 //{ 1399 //{
1312 //return returnresult; 1400 //return returnresult;
1313 //} 1401 //}
1314 //fmin = a; 1402 //fmin = a;
1315 //} 1403 //}
1316 //} 1404 //}
1317 //} 1405 //}
1318 //if (fmax > 0) 1406 //if (fmax > 0)
1319 // a= fmax; 1407 // a= fmax;
1320 //else 1408 //else
1321 // a=fmin; 1409 // a=fmin;
1322 1410
1323 //q = iray.Origin + a * iray.Direction; 1411 //q = iray.Origin + a * iray.Direction;
1412
1324 #endregion 1413 #endregion
1325 1414
1326 // Loop over faces (6 of them) 1415 // Loop over faces (6 of them)
@@ -1341,7 +1430,6 @@ namespace OpenSim.Region.Environment.Scenes
1341 // If the normal is pointing outside the object 1430 // If the normal is pointing outside the object
1342 if (iray.Direction.Dot(normals[i]) < 0 || !frontFacesOnly) 1431 if (iray.Direction.Dot(normals[i]) < 0 || !frontFacesOnly)
1343 { 1432 {
1344
1345 if (faceCenters) 1433 if (faceCenters)
1346 { 1434 {
1347 q = AXpos + a * AAfacenormals[i]; //(FaceA[i] + FaceB[i] + FaceC[1] + FaceD[i]) / 4f; 1435 q = AXpos + a * AAfacenormals[i]; //(FaceA[i] + FaceB[i] + FaceC[1] + FaceD[i]) / 4f;
@@ -1351,13 +1439,13 @@ namespace OpenSim.Region.Environment.Scenes
1351 q = iray.Origin + a * iray.Direction; 1439 q = iray.Origin + a * iray.Direction;
1352 } 1440 }
1353 1441
1354 float distance2 = (float)GetDistanceTo(q, AXpos); 1442 float distance2 = (float) GetDistanceTo(q, AXpos);
1355 // Is this the closest hit to the object's origin? 1443 // Is this the closest hit to the object's origin?
1356 if (faceCenters) 1444 if (faceCenters)
1357 { 1445 {
1358 distance2 = (float)GetDistanceTo(q, iray.Origin); 1446 distance2 = (float) GetDistanceTo(q, iray.Origin);
1359 } 1447 }
1360 1448
1361 1449
1362 if (distance2 < returnresult.distance) 1450 if (distance2 < returnresult.distance)
1363 { 1451 {
@@ -1368,14 +1456,12 @@ namespace OpenSim.Region.Environment.Scenes
1368 //m_log.Info("[POINT]: " + q.ToString()); 1456 //m_log.Info("[POINT]: " + q.ToString());
1369 returnresult.normal = normals[i]; 1457 returnresult.normal = normals[i];
1370 returnresult.AAfaceNormal = AAfacenormals[i]; 1458 returnresult.AAfaceNormal = AAfacenormals[i];
1371
1372 } 1459 }
1373 } 1460 }
1374
1375 } 1461 }
1376 return returnresult; 1462 return returnresult;
1377 } 1463 }
1378 1464
1379 // Use this for attachments! LocalID should be avatar's localid 1465 // Use this for attachments! LocalID should be avatar's localid
1380 public void SetParentLocalId(uint localID) 1466 public void SetParentLocalId(uint localID)
1381 { 1467 {
@@ -1385,14 +1471,14 @@ namespace OpenSim.Region.Environment.Scenes
1385 public void SetAttachmentPoint(uint AttachmentPoint) 1471 public void SetAttachmentPoint(uint AttachmentPoint)
1386 { 1472 {
1387 m_attachmentPoint = AttachmentPoint; 1473 m_attachmentPoint = AttachmentPoint;
1388 1474
1389 // save the attachment point. 1475 // save the attachment point.
1390 //if (AttachmentPoint != 0) 1476 //if (AttachmentPoint != 0)
1391 //{ 1477 //{
1392 m_shape.State = (byte)AttachmentPoint; 1478 m_shape.State = (byte) AttachmentPoint;
1393 //} 1479 //}
1394
1395 } 1480 }
1481
1396 /// <summary> 1482 /// <summary>
1397 /// 1483 ///
1398 /// </summary> 1484 /// </summary>
@@ -1414,13 +1500,12 @@ namespace OpenSim.Region.Environment.Scenes
1414 PhysActor.Buoyancy = fvalue; 1500 PhysActor.Buoyancy = fvalue;
1415 } 1501 }
1416 } 1502 }
1417 1503
1418 public void SetAxisRotation(int axis, int rotate) 1504 public void SetAxisRotation(int axis, int rotate)
1419 { 1505 {
1420 if (m_parentGroup != null) 1506 if (m_parentGroup != null)
1421 { 1507 {
1422 m_parentGroup.SetAxisRotation(axis, rotate); 1508 m_parentGroup.SetAxisRotation(axis, rotate);
1423
1424 } 1509 }
1425 } 1510 }
1426 1511
@@ -1442,10 +1527,9 @@ namespace OpenSim.Region.Environment.Scenes
1442 { 1527 {
1443 PhysActor.FloatOnWater = false; 1528 PhysActor.FloatOnWater = false;
1444 } 1529 }
1445
1446 } 1530 }
1447 } 1531 }
1448 1532
1449 1533
1450 public LLVector3 GetSitTargetPositionLL() 1534 public LLVector3 GetSitTargetPositionLL()
1451 { 1535 {
@@ -1516,66 +1600,403 @@ namespace OpenSim.Region.Environment.Scenes
1516 return part; 1600 return part;
1517 } 1601 }
1518 1602
1519 #region Copying
1520
1521 /// <summary> 1603 /// <summary>
1522 /// Duplicates this part. 1604 /// Reset LLUUIDs for this part. This involves generate this part's own LLUUID and
1605 /// generating new LLUUIDs for all the items in the inventory.
1523 /// </summary> 1606 /// </summary>
1524 /// <returns></returns> 1607 /// <param name="linkNum">Link number for the part</param>
1525 public SceneObjectPart Copy(uint localID, LLUUID AgentID, LLUUID GroupID, int linkNum) 1608 public void ResetIDs(int linkNum)
1526 { 1609 {
1527 SceneObjectPart dupe = (SceneObjectPart) MemberwiseClone(); 1610 UUID = LLUUID.Random();
1528 dupe.m_shape = m_shape.Copy(); 1611 LinkNum = linkNum;
1529 dupe.m_regionHandle = m_regionHandle;
1530 dupe.UUID = LLUUID.Random();
1531 dupe.LocalId = localID;
1532 dupe.OwnerID = AgentID;
1533 dupe.GroupID = GroupID;
1534 dupe.GroupPosition = new LLVector3(GroupPosition.X, GroupPosition.Y, GroupPosition.Z);
1535 dupe.OffsetPosition = new LLVector3(OffsetPosition.X, OffsetPosition.Y, OffsetPosition.Z);
1536 dupe.RotationOffset =
1537 new LLQuaternion(RotationOffset.X, RotationOffset.Y, RotationOffset.Z, RotationOffset.W);
1538 dupe.Velocity = new LLVector3(0, 0, 0);
1539 dupe.Acceleration = new LLVector3(0, 0, 0);
1540 dupe.AngularVelocity = new LLVector3(0, 0, 0);
1541 dupe.ObjectFlags = ObjectFlags;
1542 1612
1543 dupe.OwnershipCost = OwnershipCost; 1613 ResetInventoryIDs();
1544 dupe.ObjectSaleType = ObjectSaleType; 1614 }
1545 dupe.SalePrice = SalePrice;
1546 dupe.Category = Category;
1547
1548 dupe.TaskInventory = (TaskInventoryDictionary)dupe.TaskInventory.Clone();
1549
1550 dupe.ResetIDs(linkNum);
1551 1615
1552 // This may be wrong... it might have to be applied in SceneObjectGroup to the object that's being duplicated. 1616 public void UpdatePermissions(LLUUID AgentID, byte field, uint localID, uint mask, byte addRemTF)
1553 dupe.LastOwnerID = ObjectOwner; 1617 {
1618 bool set = addRemTF == 1;
1554 1619
1555 byte[] extraP = new byte[Shape.ExtraParams.Length]; 1620 // Are we the owner?
1556 Array.Copy(Shape.ExtraParams, extraP, extraP.Length); 1621 if (AgentID == OwnerID)
1557 dupe.Shape.ExtraParams = extraP; 1622 {
1558 bool UsePhysics = ((dupe.ObjectFlags & (uint) LLObject.ObjectFlags.Physics) != 0); 1623 switch (field)
1559 dupe.DoPhysicsPropertyUpdate(UsePhysics, true); 1624 {
1625 case 2:
1626 OwnerMask = ApplyMask(OwnerMask, set, mask);
1627 break;
1628 case 4:
1629 GroupMask = ApplyMask(GroupMask, set, mask);
1630 break;
1631 case 8:
1632 EveryoneMask = ApplyMask(EveryoneMask, set, mask);
1633 break;
1634 case 16:
1635 NextOwnerMask = ApplyMask(NextOwnerMask, set, mask);
1636 break;
1637 }
1638 SendFullUpdateToAllClients();
1560 1639
1561 return dupe; 1640 SendObjectPropertiesToClient(AgentID);
1641 }
1642 }
1643
1644 private void SendObjectPropertiesToClient(LLUUID AgentID)
1645 {
1646 List<ScenePresence> avatars = m_parentGroup.GetScenePresences();
1647 for (int i = 0; i < avatars.Count; i++)
1648 {
1649 // Ugly reference :(
1650 if (avatars[i].UUID == AgentID)
1651 {
1652 m_parentGroup.GetProperties(avatars[i].ControllingClient);
1653 }
1654 }
1655 }
1656
1657 private uint ApplyMask(uint val, bool set, uint mask)
1658 {
1659 if (set)
1660 {
1661 return val |= mask;
1662 }
1663 else
1664 {
1665 return val &= ~mask;
1666 }
1667 }
1668
1669 public virtual void UpdateMovement()
1670 {
1671 }
1672
1673 public void PhysicsOutOfBounds(PhysicsVector pos)
1674 {
1675 m_log.Info("[PHYSICS]: Physical Object went out of bounds.");
1676 RemFlag(LLObject.ObjectFlags.Physics);
1677 DoPhysicsPropertyUpdate(false, true);
1678 //m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor);
1679 }
1680
1681 public virtual void OnGrab(LLVector3 offsetPos, IClientAPI remoteClient)
1682 {
1683 }
1684
1685
1686 public void SetText(string text)
1687 {
1688 Text = text;
1689 ScheduleFullUpdate();
1690 }
1691
1692 public int registerTargetWaypoint(LLVector3 target, float tolerance)
1693 {
1694 if (m_parentGroup != null)
1695 {
1696 return m_parentGroup.registerTargetWaypoint(target, tolerance);
1697 }
1698 return 0;
1699 }
1700
1701 public void unregisterTargetWaypoint(int handle)
1702 {
1703 if (m_parentGroup != null)
1704 {
1705 m_parentGroup.unregisterTargetWaypoint(handle);
1706 }
1707 }
1708
1709
1710 public void Undo()
1711 {
1712 if (m_undo.Count > 0)
1713 {
1714 UndoState goback = m_undo.Pop();
1715 if (goback != null)
1716 goback.PlaybackState(this);
1717 }
1718 }
1719
1720 public void SetScriptEvents(LLUUID scriptid, int events)
1721 {
1722 scriptEvents oldparts;
1723 lock (m_scriptEvents)
1724 {
1725 if (m_scriptEvents.ContainsKey(scriptid))
1726 {
1727 oldparts = m_scriptEvents[scriptid];
1728
1729 // remove values from aggregated script events
1730 m_scriptEvents[scriptid] = (scriptEvents) events;
1731 }
1732 else
1733 {
1734 m_scriptEvents.Add(scriptid, (scriptEvents) events);
1735 }
1736 }
1737 aggregateScriptEvents();
1738 }
1739
1740 public void RemoveScriptEvents(LLUUID scriptid)
1741 {
1742 lock (m_scriptEvents)
1743 {
1744 if (m_scriptEvents.ContainsKey(scriptid))
1745 {
1746 scriptEvents oldparts = scriptEvents.None;
1747 oldparts = m_scriptEvents[scriptid];
1748
1749 // remove values from aggregated script events
1750 m_aggregateScriptEvents &= ~oldparts;
1751 m_scriptEvents.Remove(scriptid);
1752 }
1753 }
1754 aggregateScriptEvents();
1755 }
1756
1757 public void aggregateScriptEvents()
1758 {
1759 // Aggregate script events
1760 lock (m_scriptEvents)
1761 {
1762 foreach (scriptEvents s in m_scriptEvents.Values)
1763 {
1764 m_aggregateScriptEvents |= s;
1765 }
1766 }
1767
1768 uint objectflagupdate = 0;
1769
1770 if (
1771 ((m_aggregateScriptEvents & scriptEvents.touch) != 0) ||
1772 ((m_aggregateScriptEvents & scriptEvents.touch_end) != 0) ||
1773 ((m_aggregateScriptEvents & scriptEvents.touch_start) != 0)
1774 )
1775 {
1776 objectflagupdate |= (uint) LLObject.ObjectFlags.Touch;
1777 }
1778
1779 if ((m_aggregateScriptEvents & scriptEvents.money) != 0)
1780 {
1781 objectflagupdate |= (uint) LLObject.ObjectFlags.Money;
1782 }
1783
1784 if (
1785 ((m_aggregateScriptEvents & scriptEvents.collision) != 0) ||
1786 ((m_aggregateScriptEvents & scriptEvents.collision_end) != 0) ||
1787 ((m_aggregateScriptEvents & scriptEvents.collision_start) != 0)
1788 )
1789 {
1790 // subscribe to physics updates.
1791 }
1792
1793 LocalFlags = (LLObject.ObjectFlags) objectflagupdate;
1794
1795 if (m_parentGroup != null && m_parentGroup.RootPart == this)
1796 m_parentGroup.aggregateScriptEvents();
1797 else
1798 ScheduleFullUpdate();
1799 }
1800
1801 #region Events
1802
1803 public void PhysicsRequestingTerseUpdate()
1804 {
1805 if (PhysActor != null)
1806 {
1807 LLVector3 newpos = new LLVector3(PhysActor.Position.GetBytes(), 0);
1808 if (newpos.X > 257f || newpos.X < -1f || newpos.Y > 257f || newpos.Y < -1f)
1809 {
1810 m_parentGroup.AbsolutePosition = newpos;
1811 return;
1812 }
1813 }
1814 ScheduleTerseUpdate();
1815
1816 //SendTerseUpdateToAllClients();
1562 } 1817 }
1563 1818
1564 #endregion 1819 #endregion
1565 1820
1821 #region Client Update Methods
1822
1566 /// <summary> 1823 /// <summary>
1567 /// Reset LLUUIDs for this part. This involves generate this part's own LLUUID and 1824 /// Tell all scene presences that they should send updates for this part to their clients
1568 /// generating new LLUUIDs for all the items in the inventory.
1569 /// </summary> 1825 /// </summary>
1570 /// <param name="linkNum">Link number for the part</param> 1826 public void AddFullUpdateToAllAvatars()
1571 public void ResetIDs(int linkNum)
1572 { 1827 {
1573 UUID = LLUUID.Random(); 1828 List<ScenePresence> avatars = m_parentGroup.GetScenePresences();
1574 LinkNum = linkNum; 1829 for (int i = 0; i < avatars.Count; i++)
1575 1830 {
1576 ResetInventoryIDs(); 1831 avatars[i].QueuePartForUpdate(this);
1832 }
1833 }
1834
1835 public void SendFullUpdateToAllClientsExcept(LLUUID agentID)
1836 {
1837 List<ScenePresence> avatars = m_parentGroup.GetScenePresences();
1838 for (int i = 0; i < avatars.Count; i++)
1839 {
1840 // Ugly reference :(
1841 if (avatars[i].UUID != agentID)
1842 {
1843 m_parentGroup.SendPartFullUpdate(avatars[i].ControllingClient, this,
1844 avatars[i].GenerateClientFlags(UUID));
1845 }
1846 }
1847 }
1848
1849
1850 public void AddFullUpdateToAvatar(ScenePresence presence)
1851 {
1852 presence.QueuePartForUpdate(this);
1853 }
1854
1855 /// <summary>
1856 ///
1857 /// </summary>
1858 public void SendFullUpdateToAllClients()
1859 {
1860 List<ScenePresence> avatars = m_parentGroup.GetScenePresences();
1861 for (int i = 0; i < avatars.Count; i++)
1862 {
1863 // Ugly reference :(
1864 m_parentGroup.SendPartFullUpdate(avatars[i].ControllingClient, this,
1865 avatars[i].GenerateClientFlags(UUID));
1866 }
1867 }
1868
1869 /// <summary>
1870 ///
1871 /// </summary>
1872 /// <param name="remoteClient"></param>
1873 public void SendFullUpdate(IClientAPI remoteClient, uint clientFlags)
1874 {
1875 m_parentGroup.SendPartFullUpdate(remoteClient, this, clientFlags);
1876 }
1877
1878 /// <summary>
1879 /// Sends a full update to the client
1880 /// </summary>
1881 /// <param name="remoteClient"></param>
1882 /// <param name="clientFlags"></param>
1883 public void SendFullUpdateToClient(IClientAPI remoteClient, uint clientflags)
1884 {
1885 LLVector3 lPos;
1886 lPos = OffsetPosition;
1887 SendFullUpdateToClient(remoteClient, lPos, clientflags);
1888 }
1889
1890 /// <summary>
1891 /// Sends a full update to the client
1892 /// </summary>
1893 /// <param name="remoteClient"></param>
1894 /// <param name="lPos"></param>
1895 /// <param name="clientFlags"></param>
1896 public void SendFullUpdateToClient(IClientAPI remoteClient, LLVector3 lPos, uint clientFlags)
1897 {
1898 LLQuaternion lRot;
1899 lRot = RotationOffset;
1900 clientFlags &= ~(uint) LLObject.ObjectFlags.CreateSelected;
1901
1902 if (remoteClient.AgentId == OwnerID)
1903 {
1904 if ((uint) (Flags & LLObject.ObjectFlags.CreateSelected) != 0)
1905 {
1906 clientFlags |= (uint) LLObject.ObjectFlags.CreateSelected;
1907 Flags &= ~LLObject.ObjectFlags.CreateSelected;
1908 }
1909 }
1910
1911
1912 byte[] color = new[] {m_color.R, m_color.G, m_color.B, m_color.A};
1913 remoteClient.SendPrimitiveToClient(m_regionHandle, (ushort) (m_parentGroup.GetTimeDilation() * ushort.MaxValue), LocalId, m_shape, lPos, clientFlags,
1914 m_uuid,
1915 OwnerID,
1916 m_text, color, ParentID, m_particleSystem, lRot, m_clickAction, m_TextureAnimation, m_IsAttachment,
1917 m_attachmentPoint, fromAssetID);
1918 }
1919
1920 /// Terse updates
1921 public void AddTerseUpdateToAllAvatars()
1922 {
1923 List<ScenePresence> avatars = m_parentGroup.GetScenePresences();
1924 for (int i = 0; i < avatars.Count; i++)
1925 {
1926 avatars[i].QueuePartForUpdate(this);
1927 }
1928 }
1929
1930 public void AddTerseUpdateToAvatar(ScenePresence presence)
1931 {
1932 presence.QueuePartForUpdate(this);
1933 }
1934
1935 /// <summary>
1936 ///
1937 /// </summary>
1938 public void SendTerseUpdateToAllClients()
1939 {
1940 List<ScenePresence> avatars = m_parentGroup.GetScenePresences();
1941 for (int i = 0; i < avatars.Count; i++)
1942 {
1943 m_parentGroup.SendPartTerseUpdate(avatars[i].ControllingClient, this);
1944 }
1945 }
1946
1947 /// <summary>
1948 /// Send a terse update to the client.
1949 /// </summary>
1950 /// <param name="remoteClient"></param>
1951 public void SendTerseUpdate(IClientAPI remoteClient)
1952 {
1953 m_parentGroup.SendPartTerseUpdate(remoteClient, this);
1954 }
1955
1956 public void SendTerseUpdateToClient(IClientAPI remoteClient)
1957 {
1958 LLVector3 lPos;
1959 lPos = OffsetPosition;
1960 LLQuaternion mRot = RotationOffset;
1961 if ((ObjectFlags & (uint) LLObject.ObjectFlags.Physics) == 0)
1962 {
1963 remoteClient.SendPrimTerseUpdate(m_regionHandle, (ushort) (m_parentGroup.GetTimeDilation() * ushort.MaxValue), LocalId, lPos, mRot, Shape.State,
1964 fromAssetID);
1965 }
1966 else
1967 {
1968 remoteClient.SendPrimTerseUpdate(m_regionHandle, (ushort) (m_parentGroup.GetTimeDilation() * ushort.MaxValue), LocalId, lPos, mRot, Velocity,
1969 RotationalVelocity);
1970 //System.Console.WriteLine("LID: " + LocalID + " RVel:" + RotationalVelocity.ToString() + " TD: " + ((ushort)(m_parentGroup.Scene.TimeDilation * 500000f)).ToString() + ":" + m_parentGroup.Scene.TimeDilation.ToString());
1971 }
1972 }
1973
1974 public void SendTerseUpdateToClient(IClientAPI remoteClient, LLVector3 lPos)
1975 {
1976 LLQuaternion mRot = RotationOffset;
1977 if (m_IsAttachment)
1978 {
1979 remoteClient.SendPrimTerseUpdate(m_regionHandle, (ushort) (m_parentGroup.GetTimeDilation() * ushort.MaxValue), LocalId, lPos, mRot,
1980 (byte) ((m_attachmentPoint % 16) * 16 + (m_attachmentPoint / 16)), fromAssetID);
1981 }
1982 else
1983 {
1984 if ((ObjectFlags & (uint) LLObject.ObjectFlags.Physics) == 0)
1985 {
1986 remoteClient.SendPrimTerseUpdate(m_regionHandle, (ushort) (m_parentGroup.GetTimeDilation() * ushort.MaxValue), LocalId, lPos, mRot,
1987 Shape.State, fromAssetID);
1988 }
1989 else
1990 {
1991 remoteClient.SendPrimTerseUpdate(m_regionHandle, (ushort) (m_parentGroup.GetTimeDilation() * ushort.MaxValue), LocalId, lPos, mRot, Velocity,
1992 RotationalVelocity);
1993 //System.Console.WriteLine("LID: " + LocalID + "RVel:" + RotationalVelocity.ToString() + " TD: " + ((ushort)(m_parentGroup.Scene.TimeDilation * 500000f)).ToString() + ":" + m_parentGroup.Scene.TimeDilation.ToString());
1994 }
1995 }
1577 } 1996 }
1578 1997
1998 #endregion
1999
1579 #region Update Scheduling 2000 #region Update Scheduling
1580 2001
1581 /// <summary> 2002 /// <summary>
@@ -1596,9 +2017,9 @@ namespace OpenSim.Region.Environment.Scenes
1596 m_parentGroup.HasGroupChanged = true; 2017 m_parentGroup.HasGroupChanged = true;
1597 m_parentGroup.QueueForUpdateCheck(); 2018 m_parentGroup.QueueForUpdateCheck();
1598 } 2019 }
1599 2020
1600 int timeNow = Util.UnixTimeSinceEpoch(); 2021 int timeNow = Util.UnixTimeSinceEpoch();
1601 2022
1602 // If multiple updates are scheduled on the same second, we still need to perform all of them 2023 // If multiple updates are scheduled on the same second, we still need to perform all of them
1603 // So we'll force the issue by bumping up the timestamp so that later processing sees these need 2024 // So we'll force the issue by bumping up the timestamp so that later processing sees these need
1604 // to be performed. 2025 // to be performed.
@@ -1608,11 +2029,11 @@ namespace OpenSim.Region.Environment.Scenes
1608 } 2029 }
1609 else 2030 else
1610 { 2031 {
1611 TimeStampFull = (uint)timeNow; 2032 TimeStampFull = (uint) timeNow;
1612 } 2033 }
1613 2034
1614 m_updateFlag = 2; 2035 m_updateFlag = 2;
1615 2036
1616// m_log.DebugFormat( 2037// m_log.DebugFormat(
1617// "[SCENE OBJECT PART]: Scheduling full update for {0}, {1} at {2}", 2038// "[SCENE OBJECT PART]: Scheduling full update for {0}, {1} at {2}",
1618// UUID, Name, TimeStampFull); 2039// UUID, Name, TimeStampFull);
@@ -1735,15 +2156,13 @@ namespace OpenSim.Region.Environment.Scenes
1735 2156
1736 public void UpdatePrimFlags(ushort type, bool inUse, byte[] data) 2157 public void UpdatePrimFlags(ushort type, bool inUse, byte[] data)
1737 { 2158 {
1738
1739
1740 //m_log.Info("TSomething1:" + ((type & (ushort)ExtraParamType.Something1) == (ushort)ExtraParamType.Something1)); 2159 //m_log.Info("TSomething1:" + ((type & (ushort)ExtraParamType.Something1) == (ushort)ExtraParamType.Something1));
1741 //m_log.Info("TSomething2:" + ((type & (ushort)ExtraParamType.Something2) == (ushort)ExtraParamType.Something2)); 2160 //m_log.Info("TSomething2:" + ((type & (ushort)ExtraParamType.Something2) == (ushort)ExtraParamType.Something2));
1742 //m_log.Info("TSomething3:" + ((type & (ushort)ExtraParamType.Something3) == (ushort)ExtraParamType.Something3)); 2161 //m_log.Info("TSomething3:" + ((type & (ushort)ExtraParamType.Something3) == (ushort)ExtraParamType.Something3));
1743 //m_log.Info("TSomething4:" + ((type & (ushort)ExtraParamType.Something4) == (ushort)ExtraParamType.Something4)); 2162 //m_log.Info("TSomething4:" + ((type & (ushort)ExtraParamType.Something4) == (ushort)ExtraParamType.Something4));
1744 //m_log.Info("TSomething5:" + ((type & (ushort)ExtraParamType.Something5) == (ushort)ExtraParamType.Something5)); 2163 //m_log.Info("TSomething5:" + ((type & (ushort)ExtraParamType.Something5) == (ushort)ExtraParamType.Something5));
1745 //m_log.Info("TSomething6:" + ((type & (ushort)ExtraParamType.Something6) == (ushort)ExtraParamType.Something6)); 2164 //m_log.Info("TSomething6:" + ((type & (ushort)ExtraParamType.Something6) == (ushort)ExtraParamType.Something6));
1746 2165
1747 bool usePhysics = false; 2166 bool usePhysics = false;
1748 bool IsTemporary = false; 2167 bool IsTemporary = false;
1749 bool IsPhantom = false; 2168 bool IsPhantom = false;
@@ -1751,7 +2170,7 @@ namespace OpenSim.Region.Environment.Scenes
1751 bool wasUsingPhysics = ((ObjectFlags & (uint) LLObject.ObjectFlags.Physics) != 0); 2170 bool wasUsingPhysics = ((ObjectFlags & (uint) LLObject.ObjectFlags.Physics) != 0);
1752 //bool IsLocked = false; 2171 //bool IsLocked = false;
1753 int i = 0; 2172 int i = 0;
1754 2173
1755 2174
1756 try 2175 try
1757 { 2176 {
@@ -1835,6 +2254,7 @@ namespace OpenSim.Region.Environment.Scenes
1835 // System.Console.WriteLine("Update: PHY:" + UsePhysics.ToString() + ", T:" + IsTemporary.ToString() + ", PHA:" + IsPhantom.ToString() + " S:" + CastsShadows.ToString()); 2254 // System.Console.WriteLine("Update: PHY:" + UsePhysics.ToString() + ", T:" + IsTemporary.ToString() + ", PHA:" + IsPhantom.ToString() + " S:" + CastsShadows.ToString());
1836 ScheduleFullUpdate(); 2255 ScheduleFullUpdate();
1837 } 2256 }
2257
1838 public void ScriptSetPhysicsStatus(bool UsePhysics) 2258 public void ScriptSetPhysicsStatus(bool UsePhysics)
1839 { 2259 {
1840 if (m_parentGroup != null) 2260 if (m_parentGroup != null)
@@ -1842,6 +2262,7 @@ namespace OpenSim.Region.Environment.Scenes
1842 m_parentGroup.ScriptSetPhysicsStatus(UsePhysics); 2262 m_parentGroup.ScriptSetPhysicsStatus(UsePhysics);
1843 } 2263 }
1844 } 2264 }
2265
1845 public void ScriptSetPhantomStatus(bool Phantom) 2266 public void ScriptSetPhantomStatus(bool Phantom)
1846 { 2267 {
1847 if (m_parentGroup != null) 2268 if (m_parentGroup != null)
@@ -1849,6 +2270,7 @@ namespace OpenSim.Region.Environment.Scenes
1849 m_parentGroup.ScriptSetPhantomStatus(Phantom); 2270 m_parentGroup.ScriptSetPhantomStatus(Phantom);
1850 } 2271 }
1851 } 2272 }
2273
1852 public void DoPhysicsPropertyUpdate(bool UsePhysics, bool isNew) 2274 public void DoPhysicsPropertyUpdate(bool UsePhysics, bool isNew)
1853 { 2275 {
1854 if (PhysActor != null) 2276 if (PhysActor != null)
@@ -1897,7 +2319,6 @@ namespace OpenSim.Region.Environment.Scenes
1897 PhysActor.link(ParentGroup.RootPart.PhysActor); 2319 PhysActor.link(ParentGroup.RootPart.PhysActor);
1898 } 2320 }
1899 } 2321 }
1900
1901 } 2322 }
1902 } 2323 }
1903 } 2324 }
@@ -1911,13 +2332,13 @@ namespace OpenSim.Region.Environment.Scenes
1911 int i = 0; 2332 int i = 0;
1912 uint length = (uint) data.Length; 2333 uint length = (uint) data.Length;
1913 m_shape.ExtraParams[i++] = 1; 2334 m_shape.ExtraParams[i++] = 1;
1914 m_shape.ExtraParams[i++] = (byte) (type%256); 2335 m_shape.ExtraParams[i++] = (byte) (type % 256);
1915 m_shape.ExtraParams[i++] = (byte) ((type >> 8)%256); 2336 m_shape.ExtraParams[i++] = (byte) ((type >> 8) % 256);
1916 2337
1917 m_shape.ExtraParams[i++] = (byte) (length%256); 2338 m_shape.ExtraParams[i++] = (byte) (length % 256);
1918 m_shape.ExtraParams[i++] = (byte) ((length >> 8)%256); 2339 m_shape.ExtraParams[i++] = (byte) ((length >> 8) % 256);
1919 m_shape.ExtraParams[i++] = (byte) ((length >> 16)%256); 2340 m_shape.ExtraParams[i++] = (byte) ((length >> 16) % 256);
1920 m_shape.ExtraParams[i++] = (byte) ((length >> 24)%256); 2341 m_shape.ExtraParams[i++] = (byte) ((length >> 24) % 256);
1921 Array.Copy(data, 0, m_shape.ExtraParams, i, data.Length); 2342 Array.Copy(data, 0, m_shape.ExtraParams, i, data.Length);
1922 2343
1923 ScheduleFullUpdate(); 2344 ScheduleFullUpdate();
@@ -1995,14 +2416,14 @@ namespace OpenSim.Region.Environment.Scenes
1995 2416
1996 public byte ConvertScriptUintToByte(uint indata) 2417 public byte ConvertScriptUintToByte(uint indata)
1997 { 2418 {
1998 byte outdata = (byte)TextureAnimFlags.NONE; 2419 byte outdata = (byte) TextureAnimFlags.NONE;
1999 if ((indata & 1) != 0) outdata |= (byte)TextureAnimFlags.ANIM_ON; 2420 if ((indata & 1) != 0) outdata |= (byte) TextureAnimFlags.ANIM_ON;
2000 if ((indata & 2) != 0) outdata |= (byte)TextureAnimFlags.LOOP; 2421 if ((indata & 2) != 0) outdata |= (byte) TextureAnimFlags.LOOP;
2001 if ((indata & 4) != 0) outdata |= (byte)TextureAnimFlags.REVERSE; 2422 if ((indata & 4) != 0) outdata |= (byte) TextureAnimFlags.REVERSE;
2002 if ((indata & 8) != 0) outdata |= (byte)TextureAnimFlags.PING_PONG; 2423 if ((indata & 8) != 0) outdata |= (byte) TextureAnimFlags.PING_PONG;
2003 if ((indata & 16) != 0) outdata |= (byte)TextureAnimFlags.SMOOTH; 2424 if ((indata & 16) != 0) outdata |= (byte) TextureAnimFlags.SMOOTH;
2004 if ((indata & 32) != 0) outdata |= (byte)TextureAnimFlags.ROTATE; 2425 if ((indata & 32) != 0) outdata |= (byte) TextureAnimFlags.ROTATE;
2005 if ((indata & 64) != 0) outdata |= (byte)TextureAnimFlags.SCALE; 2426 if ((indata & 64) != 0) outdata |= (byte) TextureAnimFlags.SCALE;
2006 return outdata; 2427 return outdata;
2007 } 2428 }
2008 2429
@@ -2014,13 +2435,17 @@ namespace OpenSim.Region.Environment.Scenes
2014 // The flags don't like conversion from uint to byte, so we have to do 2435 // The flags don't like conversion from uint to byte, so we have to do
2015 // it the crappy way. See the above function :( 2436 // it the crappy way. See the above function :(
2016 2437
2017 data[pos] = ConvertScriptUintToByte(pTexAnim.Flags); pos++; 2438 data[pos] = ConvertScriptUintToByte(pTexAnim.Flags);
2018 data[pos] = (byte)pTexAnim.Face; pos++; 2439 pos++;
2019 data[pos] = (byte)pTexAnim.SizeX; pos++; 2440 data[pos] = (byte) pTexAnim.Face;
2020 data[pos] = (byte)pTexAnim.SizeY; pos++; 2441 pos++;
2442 data[pos] = (byte) pTexAnim.SizeX;
2443 pos++;
2444 data[pos] = (byte) pTexAnim.SizeY;
2445 pos++;
2021 2446
2022 Helpers.FloatToBytes(pTexAnim.Start).CopyTo(data, pos); 2447 Helpers.FloatToBytes(pTexAnim.Start).CopyTo(data, pos);
2023 Helpers.FloatToBytes(pTexAnim.Length ).CopyTo(data, pos + 4); 2448 Helpers.FloatToBytes(pTexAnim.Length).CopyTo(data, pos + 4);
2024 Helpers.FloatToBytes(pTexAnim.Rate).CopyTo(data, pos + 8); 2449 Helpers.FloatToBytes(pTexAnim.Rate).CopyTo(data, pos + 8);
2025 2450
2026 m_TextureAnimation = data; 2451 m_TextureAnimation = data;
@@ -2071,6 +2496,7 @@ namespace OpenSim.Region.Environment.Scenes
2071 #endregion 2496 #endregion
2072 2497
2073 #region Sound 2498 #region Sound
2499
2074 public void PreloadSound(string sound) 2500 public void PreloadSound(string sound)
2075 { 2501 {
2076 LLUUID ownerID = OwnerID; 2502 LLUUID ownerID = OwnerID;
@@ -2096,7 +2522,7 @@ namespace OpenSim.Region.Environment.Scenes
2096 foreach (ScenePresence p in avatarts) 2522 foreach (ScenePresence p in avatarts)
2097 { 2523 {
2098 // TODO: some filtering by distance of avatar 2524 // TODO: some filtering by distance of avatar
2099 2525
2100 p.ControllingClient.SendPreLoadSound(objectID, objectID, soundID); 2526 p.ControllingClient.SendPreLoadSound(objectID, objectID, soundID);
2101 } 2527 }
2102 } 2528 }
@@ -2111,7 +2537,7 @@ namespace OpenSim.Region.Environment.Scenes
2111 List<ScenePresence> avatarts = m_parentGroup.Scene.GetAvatars(); 2537 List<ScenePresence> avatarts = m_parentGroup.Scene.GetAvatars();
2112 foreach (ScenePresence p in avatarts) 2538 foreach (ScenePresence p in avatarts)
2113 { 2539 {
2114 p.ControllingClient.SendAttachedSoundGainChange(UUID, (float)volume); 2540 p.ControllingClient.SendAttachedSoundGainChange(UUID, (float) volume);
2115 } 2541 }
2116 } 2542 }
2117 2543
@@ -2137,7 +2563,7 @@ namespace OpenSim.Region.Environment.Scenes
2137 SceneObjectPart op = this; 2563 SceneObjectPart op = this;
2138 foreach (KeyValuePair<LLUUID, TaskInventoryItem> item in op.TaskInventory) 2564 foreach (KeyValuePair<LLUUID, TaskInventoryItem> item in op.TaskInventory)
2139 { 2565 {
2140 if (item.Value.Name == sound && item.Value.Type == (int)AssetType.Sound) 2566 if (item.Value.Name == sound && item.Value.Type == (int) AssetType.Sound)
2141 { 2567 {
2142 soundID = item.Value.ItemID; 2568 soundID = item.Value.ItemID;
2143 break; 2569 break;
@@ -2145,26 +2571,26 @@ namespace OpenSim.Region.Environment.Scenes
2145 } 2571 }
2146 } 2572 }
2147 2573
2148 if(soundID == LLUUID.Zero) 2574 if (soundID == LLUUID.Zero)
2149 return; 2575 return;
2150 2576
2151 List<ScenePresence> avatarts = m_parentGroup.Scene.GetAvatars(); 2577 List<ScenePresence> avatarts = m_parentGroup.Scene.GetAvatars();
2152 foreach (ScenePresence p in avatarts) 2578 foreach (ScenePresence p in avatarts)
2153 { 2579 {
2154 double dis=Util.GetDistanceTo(p.AbsolutePosition, position); 2580 double dis = Util.GetDistanceTo(p.AbsolutePosition, position);
2155 if(dis > 100.0) // Max audio distance 2581 if (dis > 100.0) // Max audio distance
2156 continue; 2582 continue;
2157 2583
2158 // Scale by distance 2584 // Scale by distance
2159 volume*=((100.0-dis)/100.0); 2585 volume *= ((100.0 - dis) / 100.0);
2160 2586
2161 if (triggered) 2587 if (triggered)
2162 { 2588 {
2163 p.ControllingClient.SendTriggeredSound(soundID, ownerID, objectID, parentID, regionHandle, position, (float)volume); 2589 p.ControllingClient.SendTriggeredSound(soundID, ownerID, objectID, parentID, regionHandle, position, (float) volume);
2164 } 2590 }
2165 else 2591 else
2166 { 2592 {
2167 p.ControllingClient.SendPlayAttachedSound(soundID, objectID, ownerID, (float)volume, flags); 2593 p.ControllingClient.SendPlayAttachedSound(soundID, objectID, ownerID, (float) volume, flags);
2168 } 2594 }
2169 } 2595 }
2170 } 2596 }
@@ -2181,513 +2607,57 @@ namespace OpenSim.Region.Environment.Scenes
2181 { 2607 {
2182 StoreUndoState(); 2608 StoreUndoState();
2183 m_shape.Scale = scale; 2609 m_shape.Scale = scale;
2184 2610
2185 ScheduleFullUpdate(); 2611 ScheduleFullUpdate();
2186 } 2612 }
2187 2613
2188 #endregion 2614 #endregion
2189 2615
2190 public void UpdatePermissions(LLUUID AgentID, byte field, uint localID, uint mask, byte addRemTF) 2616 #region Copying
2191 {
2192 bool set = addRemTF == 1;
2193
2194 // Are we the owner?
2195 if (AgentID == OwnerID)
2196 {
2197 switch (field)
2198 {
2199 case 2:
2200 OwnerMask = ApplyMask(OwnerMask, set, mask);
2201 break;
2202 case 4:
2203 GroupMask = ApplyMask(GroupMask, set, mask);
2204 break;
2205 case 8:
2206 EveryoneMask = ApplyMask(EveryoneMask, set, mask);
2207 break;
2208 case 16:
2209 NextOwnerMask = ApplyMask(NextOwnerMask, set, mask);
2210 break;
2211 }
2212 SendFullUpdateToAllClients();
2213
2214 SendObjectPropertiesToClient(AgentID);
2215
2216 }
2217 }
2218
2219 private void SendObjectPropertiesToClient(LLUUID AgentID)
2220 {
2221 List<ScenePresence> avatars = m_parentGroup.GetScenePresences();
2222 for (int i = 0; i < avatars.Count; i++)
2223 {
2224 // Ugly reference :(
2225 if (avatars[i].UUID == AgentID)
2226 {
2227 m_parentGroup.GetProperties(avatars[i].ControllingClient);
2228 }
2229 }
2230 }
2231
2232 private uint ApplyMask(uint val, bool set, uint mask)
2233 {
2234 if (set)
2235 {
2236 return val |= mask;
2237 }
2238 else
2239 {
2240 return val &= ~mask;
2241 }
2242 }
2243
2244 #region Client Update Methods
2245
2246 /// <summary>
2247 /// Tell all scene presences that they should send updates for this part to their clients
2248 /// </summary>
2249 public void AddFullUpdateToAllAvatars()
2250 {
2251 List<ScenePresence> avatars = m_parentGroup.GetScenePresences();
2252 for (int i = 0; i < avatars.Count; i++)
2253 {
2254 avatars[i].QueuePartForUpdate(this);
2255 }
2256 }
2257
2258 public void SendFullUpdateToAllClientsExcept(LLUUID agentID)
2259 {
2260 List<ScenePresence> avatars = m_parentGroup.GetScenePresences();
2261 for (int i = 0; i < avatars.Count; i++)
2262 {
2263 // Ugly reference :(
2264 if (avatars[i].UUID != agentID)
2265 {
2266 m_parentGroup.SendPartFullUpdate(avatars[i].ControllingClient, this,
2267 avatars[i].GenerateClientFlags(UUID));
2268 }
2269 }
2270 }
2271
2272
2273 public void AddFullUpdateToAvatar(ScenePresence presence)
2274 {
2275 presence.QueuePartForUpdate(this);
2276 }
2277
2278 /// <summary>
2279 ///
2280 /// </summary>
2281 public void SendFullUpdateToAllClients()
2282 {
2283 List<ScenePresence> avatars = m_parentGroup.GetScenePresences();
2284 for (int i = 0; i < avatars.Count; i++)
2285 {
2286 // Ugly reference :(
2287 m_parentGroup.SendPartFullUpdate(avatars[i].ControllingClient, this,
2288 avatars[i].GenerateClientFlags(UUID));
2289 }
2290 }
2291
2292 /// <summary>
2293 ///
2294 /// </summary>
2295 /// <param name="remoteClient"></param>
2296 public void SendFullUpdate(IClientAPI remoteClient, uint clientFlags)
2297 {
2298 m_parentGroup.SendPartFullUpdate(remoteClient, this, clientFlags);
2299 }
2300
2301 /// <summary>
2302 /// Sends a full update to the client
2303 /// </summary>
2304 /// <param name="remoteClient"></param>
2305 /// <param name="clientFlags"></param>
2306 public void SendFullUpdateToClient(IClientAPI remoteClient, uint clientflags)
2307 {
2308 LLVector3 lPos;
2309 lPos = OffsetPosition;
2310 SendFullUpdateToClient(remoteClient, lPos, clientflags);
2311 }
2312
2313 /// <summary>
2314 /// Sends a full update to the client
2315 /// </summary>
2316 /// <param name="remoteClient"></param>
2317 /// <param name="lPos"></param>
2318 /// <param name="clientFlags"></param>
2319 public void SendFullUpdateToClient(IClientAPI remoteClient, LLVector3 lPos, uint clientFlags)
2320 {
2321 LLQuaternion lRot;
2322 lRot = RotationOffset;
2323 clientFlags &= ~(uint) LLObject.ObjectFlags.CreateSelected;
2324
2325 if (remoteClient.AgentId == OwnerID)
2326 {
2327 if ((uint) (Flags & LLObject.ObjectFlags.CreateSelected) != 0)
2328 {
2329 clientFlags |= (uint) LLObject.ObjectFlags.CreateSelected;
2330 Flags &= ~LLObject.ObjectFlags.CreateSelected;
2331 }
2332 }
2333
2334
2335 byte[] color = new byte[] {m_color.R, m_color.G, m_color.B, m_color.A};
2336 remoteClient.SendPrimitiveToClient(m_regionHandle, (ushort)(m_parentGroup.GetTimeDilation() * (float)ushort.MaxValue), LocalId, m_shape, lPos, clientFlags, m_uuid,
2337 OwnerID,
2338 m_text, color, ParentID, m_particleSystem, lRot, m_clickAction, m_TextureAnimation, m_IsAttachment, m_attachmentPoint,fromAssetID);
2339 }
2340
2341 /// Terse updates
2342 public void AddTerseUpdateToAllAvatars()
2343 {
2344 List<ScenePresence> avatars = m_parentGroup.GetScenePresences();
2345 for (int i = 0; i < avatars.Count; i++)
2346 {
2347 avatars[i].QueuePartForUpdate(this);
2348 }
2349 }
2350
2351 public void AddTerseUpdateToAvatar(ScenePresence presence)
2352 {
2353 presence.QueuePartForUpdate(this);
2354 }
2355
2356 /// <summary>
2357 ///
2358 /// </summary>
2359 public void SendTerseUpdateToAllClients()
2360 {
2361 List<ScenePresence> avatars = m_parentGroup.GetScenePresences();
2362 for (int i = 0; i < avatars.Count; i++)
2363 {
2364 m_parentGroup.SendPartTerseUpdate(avatars[i].ControllingClient, this);
2365 }
2366 }
2367 2617
2368 /// <summary> 2618 /// <summary>
2369 /// Send a terse update to the client. 2619 /// Duplicates this part.
2370 /// </summary> 2620 /// </summary>
2371 /// <param name="remoteClient"></param> 2621 /// <returns></returns>
2372 public void SendTerseUpdate(IClientAPI remoteClient) 2622 public SceneObjectPart Copy(uint localID, LLUUID AgentID, LLUUID GroupID, int linkNum)
2373 {
2374 m_parentGroup.SendPartTerseUpdate(remoteClient, this);
2375 }
2376
2377 public void SendTerseUpdateToClient(IClientAPI remoteClient)
2378 { 2623 {
2379 LLVector3 lPos; 2624 SceneObjectPart dupe = (SceneObjectPart) MemberwiseClone();
2380 lPos = OffsetPosition; 2625 dupe.m_shape = m_shape.Copy();
2381 LLQuaternion mRot = RotationOffset; 2626 dupe.m_regionHandle = m_regionHandle;
2382 if ((ObjectFlags & (uint) LLObject.ObjectFlags.Physics) == 0) 2627 dupe.UUID = LLUUID.Random();
2383 { 2628 dupe.LocalId = localID;
2384 remoteClient.SendPrimTerseUpdate(m_regionHandle, (ushort)(m_parentGroup.GetTimeDilation() * (float)ushort.MaxValue), LocalId, lPos, mRot, Shape.State, fromAssetID); 2629 dupe.OwnerID = AgentID;
2385 } 2630 dupe.GroupID = GroupID;
2386 else 2631 dupe.GroupPosition = new LLVector3(GroupPosition.X, GroupPosition.Y, GroupPosition.Z);
2387 { 2632 dupe.OffsetPosition = new LLVector3(OffsetPosition.X, OffsetPosition.Y, OffsetPosition.Z);
2388 remoteClient.SendPrimTerseUpdate(m_regionHandle, (ushort)(m_parentGroup.GetTimeDilation() * (float)ushort.MaxValue), LocalId, lPos, mRot, Velocity, 2633 dupe.RotationOffset =
2389 RotationalVelocity); 2634 new LLQuaternion(RotationOffset.X, RotationOffset.Y, RotationOffset.Z, RotationOffset.W);
2390 //System.Console.WriteLine("LID: " + LocalID + " RVel:" + RotationalVelocity.ToString() + " TD: " + ((ushort)(m_parentGroup.Scene.TimeDilation * 500000f)).ToString() + ":" + m_parentGroup.Scene.TimeDilation.ToString()); 2635 dupe.Velocity = new LLVector3(0, 0, 0);
2391 } 2636 dupe.Acceleration = new LLVector3(0, 0, 0);
2392 } 2637 dupe.AngularVelocity = new LLVector3(0, 0, 0);
2638 dupe.ObjectFlags = ObjectFlags;
2393 2639
2394 public void SendTerseUpdateToClient(IClientAPI remoteClient, LLVector3 lPos) 2640 dupe.OwnershipCost = OwnershipCost;
2395 { 2641 dupe.ObjectSaleType = ObjectSaleType;
2396 LLQuaternion mRot = RotationOffset; 2642 dupe.SalePrice = SalePrice;
2397 if (m_IsAttachment) 2643 dupe.Category = Category;
2398 {
2399 remoteClient.SendPrimTerseUpdate(m_regionHandle, (ushort)(m_parentGroup.GetTimeDilation() * (float)ushort.MaxValue), LocalId, lPos, mRot, (byte)((m_attachmentPoint % 16) * 16 + (m_attachmentPoint / 16)),fromAssetID);
2400 }
2401 else
2402 {
2403 if ((ObjectFlags & (uint)LLObject.ObjectFlags.Physics) == 0)
2404 {
2405 remoteClient.SendPrimTerseUpdate(m_regionHandle, (ushort)(m_parentGroup.GetTimeDilation() * (float)ushort.MaxValue), LocalId, lPos, mRot, Shape.State, fromAssetID);
2406 }
2407 else
2408 {
2409 remoteClient.SendPrimTerseUpdate(m_regionHandle, (ushort)(m_parentGroup.GetTimeDilation() * (float)ushort.MaxValue), LocalId, lPos, mRot, Velocity,
2410 RotationalVelocity);
2411 //System.Console.WriteLine("LID: " + LocalID + "RVel:" + RotationalVelocity.ToString() + " TD: " + ((ushort)(m_parentGroup.Scene.TimeDilation * 500000f)).ToString() + ":" + m_parentGroup.Scene.TimeDilation.ToString());
2412 }
2413 }
2414 }
2415 2644
2416 #endregion 2645 dupe.TaskInventory = (TaskInventoryDictionary) dupe.TaskInventory.Clone();
2417 2646
2418 public virtual void UpdateMovement() 2647 dupe.ResetIDs(linkNum);
2419 {
2420 }
2421 2648
2422 #region Events 2649 // This may be wrong... it might have to be applied in SceneObjectGroup to the object that's being duplicated.
2650 dupe.LastOwnerID = ObjectOwner;
2423 2651
2424 public void PhysicsRequestingTerseUpdate() 2652 byte[] extraP = new byte[Shape.ExtraParams.Length];
2425 { 2653 Array.Copy(Shape.ExtraParams, extraP, extraP.Length);
2426 if (PhysActor != null) 2654 dupe.Shape.ExtraParams = extraP;
2427 { 2655 bool UsePhysics = ((dupe.ObjectFlags & (uint) LLObject.ObjectFlags.Physics) != 0);
2428 LLVector3 newpos = new LLVector3(PhysActor.Position.GetBytes(), 0); 2656 dupe.DoPhysicsPropertyUpdate(UsePhysics, true);
2429 if (newpos.X > 257f || newpos.X < -1f || newpos.Y > 257f || newpos.Y < -1f)
2430 {
2431 m_parentGroup.AbsolutePosition = newpos;
2432 return;
2433 }
2434
2435 }
2436 ScheduleTerseUpdate();
2437 2657
2438 //SendTerseUpdateToAllClients(); 2658 return dupe;
2439 } 2659 }
2440 2660
2441 #endregion 2661 #endregion
2442
2443 public void PhysicsOutOfBounds(PhysicsVector pos)
2444 {
2445 m_log.Info("[PHYSICS]: Physical Object went out of bounds.");
2446 RemFlag(LLObject.ObjectFlags.Physics);
2447 DoPhysicsPropertyUpdate(false, true);
2448 //m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor);
2449 }
2450
2451 public virtual void OnGrab(LLVector3 offsetPos, IClientAPI remoteClient)
2452 {
2453 }
2454
2455
2456 public void SetText(string text)
2457 {
2458 Text = text;
2459 ScheduleFullUpdate();
2460 }
2461
2462 public void SetText(string text, Vector3 color, double alpha)
2463 {
2464 Color = Color.FromArgb(0xff - (int) (alpha*0xff),
2465 (int) (color.x*0xff),
2466 (int) (color.y*0xff),
2467 (int) (color.z*0xff));
2468 SetText( text );
2469 }
2470
2471 public int registerTargetWaypoint(LLVector3 target, float tolerance)
2472 {
2473 if (m_parentGroup != null)
2474 {
2475 return m_parentGroup.registerTargetWaypoint(target, tolerance);
2476 }
2477 return 0;
2478 }
2479 public void unregisterTargetWaypoint(int handle)
2480 {
2481 if (m_parentGroup != null)
2482 {
2483 m_parentGroup.unregisterTargetWaypoint(handle);
2484 }
2485 }
2486 protected SceneObjectPart(SerializationInfo info, StreamingContext context)
2487 {
2488 //System.Console.WriteLine("SceneObjectPart Deserialize BGN");
2489
2490 if (info == null)
2491 {
2492 throw new ArgumentNullException("info");
2493 }
2494
2495 /*
2496 m_queue = (Queue<SceneObjectPart>)info.GetValue("m_queue", typeof(Queue<SceneObjectPart>));
2497 m_ids = (List<LLUUID>)info.GetValue("m_ids", typeof(List<LLUUID>));
2498 */
2499
2500 //System.Console.WriteLine("SceneObjectPart Deserialize END");
2501 }
2502
2503 [SecurityPermission(SecurityAction.LinkDemand,
2504 Flags = SecurityPermissionFlag.SerializationFormatter)]
2505 public virtual void GetObjectData(
2506 SerializationInfo info, StreamingContext context)
2507 {
2508 if (info == null)
2509 {
2510 throw new ArgumentNullException("info");
2511 }
2512
2513 info.AddValue("m_inventoryFileName", m_inventoryFileName);
2514 info.AddValue("m_folderID", m_folderID.UUID);
2515 info.AddValue("PhysActor", PhysActor);
2516
2517 Dictionary<Guid, TaskInventoryItem> TaskInventory_work = new Dictionary<Guid, TaskInventoryItem>();
2518
2519 foreach (LLUUID id in TaskInventory.Keys)
2520 {
2521 TaskInventory_work.Add(id.UUID, TaskInventory[id]);
2522 }
2523
2524 info.AddValue("TaskInventory", TaskInventory_work);
2525
2526 info.AddValue("LastOwnerID", LastOwnerID.UUID);
2527 info.AddValue("OwnerID", OwnerID.UUID);
2528 info.AddValue("GroupID", GroupID.UUID);
2529
2530 info.AddValue("OwnershipCost", OwnershipCost);
2531 info.AddValue("ObjectSaleType", ObjectSaleType);
2532 info.AddValue("SalePrice", SalePrice);
2533 info.AddValue("Category", Category);
2534
2535 info.AddValue("CreationDate", CreationDate);
2536 info.AddValue("ParentID", ParentID);
2537
2538 info.AddValue("OwnerMask", OwnerMask);
2539 info.AddValue("NextOwnerMask", NextOwnerMask);
2540 info.AddValue("GroupMask", GroupMask);
2541 info.AddValue("EveryoneMask", EveryoneMask);
2542 info.AddValue("BaseMask", BaseMask);
2543
2544 info.AddValue("m_particleSystem", m_particleSystem);
2545
2546 info.AddValue("TimeStampFull", TimeStampFull);
2547 info.AddValue("TimeStampTerse", TimeStampTerse);
2548 info.AddValue("TimeStampLastActivity", TimeStampLastActivity);
2549
2550 info.AddValue("m_updateFlag", m_updateFlag);
2551 info.AddValue("CreatorID", CreatorID.UUID);
2552
2553 info.AddValue("m_inventorySerial", m_inventorySerial);
2554 info.AddValue("m_uuid", m_uuid.UUID);
2555 info.AddValue("m_localID", m_localId);
2556 info.AddValue("m_name", m_name);
2557 info.AddValue("m_flags", Flags);
2558 info.AddValue("m_material", m_material);
2559 info.AddValue("m_regionHandle", m_regionHandle);
2560
2561 info.AddValue("m_groupPosition.X", m_groupPosition.X);
2562 info.AddValue("m_groupPosition.Y", m_groupPosition.Y);
2563 info.AddValue("m_groupPosition.Z", m_groupPosition.Z);
2564
2565 info.AddValue("m_offsetPosition.X", m_offsetPosition.X);
2566 info.AddValue("m_offsetPosition.Y", m_offsetPosition.Y);
2567 info.AddValue("m_offsetPosition.Z", m_offsetPosition.Z);
2568
2569 info.AddValue("m_rotationOffset.W", m_rotationOffset.W);
2570 info.AddValue("m_rotationOffset.X", m_rotationOffset.X);
2571 info.AddValue("m_rotationOffset.Y", m_rotationOffset.Y);
2572 info.AddValue("m_rotationOffset.Z", m_rotationOffset.Z);
2573
2574 info.AddValue("m_velocity.X", m_velocity.X);
2575 info.AddValue("m_velocity.Y", m_velocity.Y);
2576 info.AddValue("m_velocity.Z", m_velocity.Z);
2577
2578 info.AddValue("m_rotationalvelocity.X", m_rotationalvelocity.X);
2579 info.AddValue("m_rotationalvelocity.Y", m_rotationalvelocity.Y);
2580 info.AddValue("m_rotationalvelocity.Z", m_rotationalvelocity.Z);
2581
2582 info.AddValue("m_angularVelocity.X", m_angularVelocity.X);
2583 info.AddValue("m_angularVelocity.Y", m_angularVelocity.Y);
2584 info.AddValue("m_angularVelocity.Z", m_angularVelocity.Z);
2585
2586 info.AddValue("m_acceleration.X", m_acceleration.X);
2587 info.AddValue("m_acceleration.Y", m_acceleration.Y);
2588 info.AddValue("m_acceleration.Z", m_acceleration.Z);
2589
2590 info.AddValue("m_description", m_description);
2591 info.AddValue("m_color", m_color);
2592 info.AddValue("m_text", m_text);
2593 info.AddValue("m_sitName", m_sitName);
2594 info.AddValue("m_touchName", m_touchName);
2595 info.AddValue("m_clickAction", m_clickAction);
2596 info.AddValue("m_shape", m_shape);
2597 info.AddValue("m_parentGroup", m_parentGroup);
2598 info.AddValue("PayPrice", PayPrice);
2599 }
2600
2601
2602 public void Undo()
2603 {
2604 if (m_undo.Count > 0)
2605 {
2606 UndoState goback = m_undo.Pop();
2607 if (goback != null)
2608 goback.PlaybackState(this);
2609 }
2610 }
2611
2612 public void SetScriptEvents(LLUUID scriptid, int events)
2613 {
2614 scriptEvents oldparts;
2615 lock (m_scriptEvents)
2616 {
2617 if (m_scriptEvents.ContainsKey(scriptid))
2618 {
2619 oldparts = m_scriptEvents[scriptid];
2620
2621 // remove values from aggregated script events
2622 m_scriptEvents[scriptid] = (scriptEvents) events;
2623 }
2624 else
2625 {
2626 m_scriptEvents.Add(scriptid, (scriptEvents) events);
2627 }
2628 }
2629 aggregateScriptEvents();
2630 }
2631
2632 public void RemoveScriptEvents(LLUUID scriptid)
2633 {
2634 lock (m_scriptEvents)
2635 {
2636 if (m_scriptEvents.ContainsKey(scriptid))
2637 {
2638 scriptEvents oldparts = scriptEvents.None;
2639 oldparts = (scriptEvents) m_scriptEvents[scriptid];
2640
2641 // remove values from aggregated script events
2642 m_aggregateScriptEvents &= ~oldparts;
2643 m_scriptEvents.Remove(scriptid);
2644 }
2645 }
2646 aggregateScriptEvents();
2647 }
2648
2649 public void aggregateScriptEvents()
2650 {
2651 // Aggregate script events
2652 lock (m_scriptEvents)
2653 {
2654 foreach (scriptEvents s in m_scriptEvents.Values)
2655 {
2656 m_aggregateScriptEvents |= s;
2657 }
2658 }
2659
2660 uint objectflagupdate = 0;
2661
2662 if (
2663 ((m_aggregateScriptEvents & scriptEvents.touch) != 0) ||
2664 ((m_aggregateScriptEvents & scriptEvents.touch_end) != 0) ||
2665 ((m_aggregateScriptEvents & scriptEvents.touch_start) != 0)
2666 )
2667 {
2668 objectflagupdate |= (uint) LLObject.ObjectFlags.Touch;
2669 }
2670
2671 if ((m_aggregateScriptEvents & scriptEvents.money) != 0)
2672 {
2673 objectflagupdate |= (uint) LLObject.ObjectFlags.Money;
2674 }
2675
2676 if (
2677 ((m_aggregateScriptEvents & scriptEvents.collision) != 0) ||
2678 ((m_aggregateScriptEvents & scriptEvents.collision_end) != 0) ||
2679 ((m_aggregateScriptEvents & scriptEvents.collision_start) != 0)
2680 )
2681 {
2682 // subscribe to physics updates.
2683 }
2684
2685 LocalFlags=(LLObject.ObjectFlags)objectflagupdate;
2686
2687 if(m_parentGroup != null && m_parentGroup.RootPart == this)
2688 m_parentGroup.aggregateScriptEvents();
2689 else
2690 ScheduleFullUpdate();
2691 }
2692 } 2662 }
2693} 2663} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs
index 74e9cdc..4cdf7f1 100644
--- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs
@@ -40,117 +40,111 @@ using OpenSim.Region.Physics.Manager;
40 40
41namespace OpenSim.Region.Environment.Scenes 41namespace OpenSim.Region.Environment.Scenes
42{ 42{
43 [Serializable] 43 [Serializable]
44 public class ScenePresence : EntityBase, ISerializable 44 public class ScenePresence : EntityBase, ISerializable
45 { 45 {
46// ~ScenePresence() 46// ~ScenePresence()
47// { 47// {
48// System.Console.WriteLine("[ScenePresence] Destructor called"); 48// System.Console.WriteLine("[ScenePresence] Destructor called");
49// } 49// }
50
51 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
52 50
53 public static AvatarAnimations Animations = new AvatarAnimations(); 51 #region Delegates
54 public static byte[] DefaultTexture;
55 52
56 public LLUUID currentParcelUUID = LLUUID.Zero; 53 public delegate void SignificantClientMovement(IClientAPI remote_client);
57 private List<LLUUID> m_animations = new List<LLUUID>();
58 private List<int> m_animationSeqs = new List<int>();
59 public Vector3 lastKnownAllowedPosition = new Vector3();
60 public bool sentMessageAboutRestrictedParcelFlyingDown = false;
61 54
62 private bool m_updateflag = false; 55 #endregion
63 private byte m_movementflag = 0;
64 private readonly List<NewForce> m_forcesList = new List<NewForce>();
65 private short m_updateCount = 0;
66 private uint m_requestedSitTargetID = 0;
67 private LLVector3 m_requestedSitOffset = new LLVector3();
68 private float m_sitAvatarHeight = 2.0f;
69 private float m_godlevel = 0;
70 private LLVector3 m_LastChildAgentUpdatePosition = new LLVector3();
71 56
72 private int m_perfMonMS = 0; 57 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
73 58
74 private bool m_setAlwaysRun = false; 59 public static AvatarAnimations Animations = new AvatarAnimations();
60 public static byte[] DefaultTexture;
61 private readonly Vector3[] Dir_Vectors = new Vector3[6];
62 private readonly uint m_AgentControlFlags = 0;
75 63
76 private Quaternion m_bodyRot; 64 private readonly List<LLUUID> m_animations = new List<LLUUID>();
65 private readonly List<int> m_animationSeqs = new List<int>();
66 private readonly List<NewForce> m_forcesList = new List<NewForce>();
67 private readonly List<ulong> m_knownChildRegions = new List<ulong>();
68 private readonly List<LLUUID> m_knownPrimUUID = new List<LLUUID>();
69 private readonly UpdateQueue m_partsUpdateQueue = new UpdateQueue();
70 private readonly byte m_state = 0;
71 private readonly Dictionary<LLUUID, ScenePartUpdate> m_updateTimes = new Dictionary<LLUUID, ScenePartUpdate>();
72 protected ulong crossingFromRegion;
73 public LLUUID currentParcelUUID = LLUUID.Zero;
74 private SignificantClientMovement handlerSignificantClientMovement; //OnSignificantClientMovement;
77 75
78 public bool IsRestrictedToRegion = false; 76 public bool IsRestrictedToRegion;
79 77
80 public string JID = string.Empty; 78 public string JID = string.Empty;
79 public Vector3 lastKnownAllowedPosition;
81 80
82 // Agent moves with a PID controller causing a force to be exerted. 81 // Agent moves with a PID controller causing a force to be exerted.
83 private bool m_newForce = false; 82 private LLVector3 lastPhysPos;
84 private bool m_newCoarseLocations = true; 83 protected AvatarAppearance m_appearance;
85 private bool m_gotAllObjectsInScene = false;
86 84
87 private LLVector3 m_lastVelocity = LLVector3.Zero; 85 protected List<SceneObjectGroup> m_attachments = new List<SceneObjectGroup>();
88
89 // Default AV Height
90 private float m_avHeight = 127.0f; 86 private float m_avHeight = 127.0f;
91 87 private Quaternion m_bodyRot;
92 protected RegionInfo m_regionInfo;
93 protected ulong crossingFromRegion = 0;
94
95 private readonly Vector3[] Dir_Vectors = new Vector3[6];
96 private LLVector3 lastPhysPos = new LLVector3();
97 88
98 // Position of agent's camera in world (region cordinates) 89 // Position of agent's camera in world (region cordinates)
99 protected Vector3 m_CameraCenter = new Vector3(0, 0, 0);
100 90
101 // Use these three vectors to figure out what the agent is looking at 91 // Use these three vectors to figure out what the agent is looking at
102 // Convert it to a Matrix and/or Quaternion 92 // Convert it to a Matrix and/or Quaternion
103 protected Vector3 m_CameraAtAxis = new Vector3(0, 0, 0); 93 protected Vector3 m_CameraAtAxis = new Vector3(0, 0, 0);
94 protected Vector3 m_CameraCenter = new Vector3(0, 0, 0);
104 protected Vector3 m_CameraLeftAxis = new Vector3(0, 0, 0); 95 protected Vector3 m_CameraLeftAxis = new Vector3(0, 0, 0);
105 protected Vector3 m_CameraUpAxis = new Vector3(0, 0, 0); 96 protected Vector3 m_CameraUpAxis = new Vector3(0, 0, 0);
106 private uint m_AgentControlFlags = (uint) 0; 97 protected float m_DrawDistance;
107 private LLQuaternion m_headrotation = new LLQuaternion(); 98 private float m_godlevel;
108 private byte m_state = (byte) 0; 99 private bool m_gotAllObjectsInScene;
100 private LLQuaternion m_headrotation;
101 private LLVector3 m_LastChildAgentUpdatePosition;
102 private LLVector3 m_lastVelocity = LLVector3.Zero;
103 private byte m_movementflag;
104 private bool m_newCoarseLocations = true;
105 private bool m_newForce;
106 private int m_perfMonMS;
107 protected RegionInfo m_regionInfo;
108 private LLVector3 m_requestedSitOffset;
109 private uint m_requestedSitTargetID;
110 private bool m_setAlwaysRun;
111 private float m_sitAvatarHeight = 2.0f;
112 private short m_updateCount;
113 private bool m_updateflag;
109 114
110 //Reuse the LLVector3 instead of creating a new one on the UpdateMovement method 115 //Reuse the LLVector3 instead of creating a new one on the UpdateMovement method
111 private LLVector3 movementvector = new LLVector3(); 116 private LLVector3 movementvector;
112
113 private List<LLUUID> m_knownPrimUUID = new List<LLUUID>();
114 117
115 // Agent's Draw distance. 118 /// <summary>
116 protected float m_DrawDistance = 0f; 119 /// Position at which a significant movement was made
117 120 /// </summary>
118 protected AvatarAppearance m_appearance; 121 private LLVector3 posLastSignificantMove;
119 122
120 protected List<SceneObjectGroup> m_attachments = new List<SceneObjectGroup>(); 123 public bool sentMessageAboutRestrictedParcelFlyingDown;
121 124
122 //neighbouring regions we have enabled a child agent in 125 #region Properties
123 private readonly List<ulong> m_knownChildRegions = new List<ulong>();
124 126
125 private SignificantClientMovement handlerSignificantClientMovement = null; //OnSignificantClientMovement; 127 private readonly string m_firstname;
128 private readonly string m_lastname;
129 private readonly ulong m_regionHandle;
130 protected bool m_allowMovement = true;
126 131
127 /// <summary> 132 /// <summary>
128 /// Implemented Control Flags 133 /// This works out to be the ClientView object associated with this avatar, or it's UDP connection manager
129 /// </summary> 134 /// </summary>
130 private enum Dir_ControlFlags 135 private IClientAPI m_controllingClient;
131 {
132 DIR_CONTROL_FLAG_FORWARD = AgentManager.ControlFlags.AGENT_CONTROL_AT_POS,
133 DIR_CONTROL_FLAG_BACK = AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG,
134 DIR_CONTROL_FLAG_LEFT = AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS,
135 DIR_CONTROL_FLAG_RIGHT = AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG,
136 DIR_CONTROL_FLAG_UP = AgentManager.ControlFlags.AGENT_CONTROL_UP_POS,
137 DIR_CONTROL_FLAG_DOWN = AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG,
138 DIR_CONTROL_FLAG_DOWN_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG
139 }
140 136
141 /// <summary> 137 /// <summary>
142 /// Position at which a significant movement was made 138 /// If this is true, agent doesn't have a representation in this scene.
139 /// this is an agent 'looking into' this scene from a nearby scene(region)
140 ///
141 /// if False, this agent has a representation in this scene
143 /// </summary> 142 /// </summary>
144 private LLVector3 posLastSignificantMove = new LLVector3(); 143 private bool m_isChildAgent = true;
145
146 public delegate void SignificantClientMovement(IClientAPI remote_client);
147
148 public event SignificantClientMovement OnSignificantClientMovement;
149
150 private UpdateQueue m_partsUpdateQueue = new UpdateQueue();
151 private Dictionary<LLUUID, ScenePartUpdate> m_updateTimes = new Dictionary<LLUUID, ScenePartUpdate>();
152 144
153 #region Properties 145 private uint m_parentID;
146 protected LLVector3 m_parentPosition;
147 protected PhysicsActor m_physicsActor;
154 148
155 /// <summary> 149 /// <summary>
156 /// Physical scene representation of this Avatar. 150 /// Physical scene representation of this Avatar.
@@ -167,16 +161,6 @@ namespace OpenSim.Region.Environment.Scenes
167 get { return m_movementflag; } 161 get { return m_movementflag; }
168 } 162 }
169 163
170 public bool KnownPrim(LLUUID primID)
171 {
172 if (m_knownPrimUUID.Contains(primID))
173 {
174 return true;
175 }
176 m_knownPrimUUID.Add(primID);
177 return false;
178 }
179
180 164
181 public bool Updated 165 public bool Updated
182 { 166 {
@@ -184,8 +168,6 @@ namespace OpenSim.Region.Environment.Scenes
184 get { return m_updateflag; } 168 get { return m_updateflag; }
185 } 169 }
186 170
187 private readonly ulong m_regionHandle;
188
189 public ulong RegionHandle 171 public ulong RegionHandle
190 { 172 {
191 get { return m_regionHandle; } 173 get { return m_regionHandle; }
@@ -196,15 +178,11 @@ namespace OpenSim.Region.Environment.Scenes
196 get { return m_CameraCenter; } 178 get { return m_CameraCenter; }
197 } 179 }
198 180
199 private readonly string m_firstname;
200
201 public string Firstname 181 public string Firstname
202 { 182 {
203 get { return m_firstname; } 183 get { return m_firstname; }
204 } 184 }
205 185
206 private readonly string m_lastname;
207
208 public string Lastname 186 public string Lastname
209 { 187 {
210 get { return m_lastname; } 188 get { return m_lastname; }
@@ -215,29 +193,18 @@ namespace OpenSim.Region.Environment.Scenes
215 get { return m_DrawDistance; } 193 get { return m_DrawDistance; }
216 } 194 }
217 195
218 protected bool m_allowMovement = true;
219
220 public bool AllowMovement 196 public bool AllowMovement
221 { 197 {
222 get { return m_allowMovement; } 198 get { return m_allowMovement; }
223 set { m_allowMovement = value; } 199 set { m_allowMovement = value; }
224 } 200 }
225 201
226 /// <summary>
227 /// This works out to be the ClientView object associated with this avatar, or it's UDP connection manager
228 /// </summary>
229 private IClientAPI m_controllingClient;
230
231 protected PhysicsActor m_physicsActor;
232
233 public IClientAPI ControllingClient 202 public IClientAPI ControllingClient
234 { 203 {
235 get { return m_controllingClient; } 204 get { return m_controllingClient; }
236 set { m_controllingClient = value; } 205 set { m_controllingClient = value; }
237 } 206 }
238 207
239 protected LLVector3 m_parentPosition = new LLVector3();
240
241 /// <summary> 208 /// <summary>
242 /// Absolute position of this avatar in 'region cordinates' 209 /// Absolute position of this avatar in 'region cordinates'
243 /// </summary> 210 /// </summary>
@@ -272,7 +239,7 @@ namespace OpenSim.Region.Environment.Scenes
272 } 239 }
273 240
274 m_pos = value; 241 m_pos = value;
275 m_parentPosition=new LLVector3(0, 0, 0); 242 m_parentPosition = new LLVector3(0, 0, 0);
276 } 243 }
277 } 244 }
278 245
@@ -313,22 +280,12 @@ namespace OpenSim.Region.Environment.Scenes
313 } 280 }
314 } 281 }
315 282
316 /// <summary>
317 /// If this is true, agent doesn't have a representation in this scene.
318 /// this is an agent 'looking into' this scene from a nearby scene(region)
319 ///
320 /// if False, this agent has a representation in this scene
321 /// </summary>
322 private bool m_isChildAgent = true;
323
324 public bool IsChildAgent 283 public bool IsChildAgent
325 { 284 {
326 get { return m_isChildAgent; } 285 get { return m_isChildAgent; }
327 set { m_isChildAgent = value; } 286 set { m_isChildAgent = value; }
328 } 287 }
329 288
330 private uint m_parentID = 0;
331
332 public uint ParentID 289 public uint ParentID
333 { 290 {
334 get { return m_parentID; } 291 get { return m_parentID; }
@@ -343,6 +300,16 @@ namespace OpenSim.Region.Environment.Scenes
343 get { return m_knownChildRegions; } 300 get { return m_knownChildRegions; }
344 } 301 }
345 302
303 public bool KnownPrim(LLUUID primID)
304 {
305 if (m_knownPrimUUID.Contains(primID))
306 {
307 return true;
308 }
309 m_knownPrimUUID.Add(primID);
310 return false;
311 }
312
346 #endregion 313 #endregion
347 314
348 #region Constructor(s) 315 #region Constructor(s)
@@ -420,6 +387,360 @@ namespace OpenSim.Region.Environment.Scenes
420 387
421 #endregion 388 #endregion
422 389
390 static ScenePresence()
391 {
392 LLObject.TextureEntry textu = AvatarAppearance.GetDefaultTextureEntry();
393 DefaultTexture = textu.ToBytes();
394 }
395
396 public ScenePresence()
397 {
398/* JB
399 if (Animations == null)
400 {
401 Animations = new AvatarAnimations();
402 Animations.LoadAnims();
403 }
404*/
405 if (DefaultTexture == null)
406 {
407 LLObject.TextureEntry textu = AvatarAppearance.GetDefaultTextureEntry();
408 DefaultTexture = textu.ToBytes();
409 }
410 }
411
412 protected ScenePresence(SerializationInfo info, StreamingContext context)
413 : base(info, context)
414 {
415 //System.Console.WriteLine("ScenePresence Deserialize BGN");
416
417 if (info == null)
418 {
419 throw new ArgumentNullException("info");
420 }
421/* JB
422 if (Animations == null)
423 {
424 Animations = new AvatarAnimations();
425 Animations.LoadAnims();
426 }
427*/
428 if (DefaultTexture == null)
429 {
430 LLObject.TextureEntry textu = AvatarAppearance.GetDefaultTextureEntry();
431 DefaultTexture = textu.ToBytes();
432 }
433
434 List<Guid> animations_work = (List<Guid>) info.GetValue("m_animations", typeof (List<Guid>));
435
436 foreach (Guid guid in animations_work)
437 {
438 m_animations.Add(new LLUUID(guid));
439 }
440
441 m_animationSeqs = (List<int>) info.GetValue("m_animationSeqs", typeof (List<int>));
442 m_updateflag = (bool) info.GetValue("m_updateflag", typeof (bool));
443 m_movementflag = (byte) info.GetValue("m_movementflag", typeof (byte));
444 m_forcesList = (List<NewForce>) info.GetValue("m_forcesList", typeof (List<NewForce>));
445 m_updateCount = (short) info.GetValue("m_updateCount", typeof (short));
446 m_requestedSitTargetID = (uint) info.GetValue("m_requestedSitTargetID", typeof (uint));
447
448 m_requestedSitOffset
449 = new LLVector3(
450 (float) info.GetValue("m_requestedSitOffset.X", typeof (float)),
451 (float) info.GetValue("m_requestedSitOffset.Y", typeof (float)),
452 (float) info.GetValue("m_requestedSitOffset.Z", typeof (float)));
453
454 m_sitAvatarHeight = (float) info.GetValue("m_sitAvatarHeight", typeof (float));
455 m_godlevel = (float) info.GetValue("m_godlevel", typeof (float));
456 m_setAlwaysRun = (bool) info.GetValue("m_setAlwaysRun", typeof (bool));
457
458 m_bodyRot
459 = new Quaternion(
460 (float) info.GetValue("m_bodyRot.w", typeof (float)),
461 (float) info.GetValue("m_bodyRot.x", typeof (float)),
462 (float) info.GetValue("m_bodyRot.y", typeof (float)),
463 (float) info.GetValue("m_bodyRot.z", typeof (float)));
464
465 IsRestrictedToRegion = (bool) info.GetValue("IsRestrictedToRegion", typeof (bool));
466 m_newForce = (bool) info.GetValue("m_newForce", typeof (bool));
467 //m_newAvatar = (bool)info.GetValue("m_newAvatar", typeof(bool));
468 m_newCoarseLocations = (bool) info.GetValue("m_newCoarseLocations", typeof (bool));
469 m_gotAllObjectsInScene = (bool) info.GetValue("m_gotAllObjectsInScene", typeof (bool));
470 m_avHeight = (float) info.GetValue("m_avHeight", typeof (float));
471 crossingFromRegion = (ulong) info.GetValue("crossingFromRegion", typeof (ulong));
472
473 List<float[]> Dir_Vectors_work = (List<float[]>) info.GetValue("Dir_Vectors", typeof (List<float[]>));
474 List<Vector3> Dir_Vectors_work2 = new List<Vector3>();
475
476 foreach (float[] f3 in Dir_Vectors_work)
477 {
478 Dir_Vectors_work2.Add(new Vector3(f3[0], f3[1], f3[2]));
479 }
480
481 Dir_Vectors = Dir_Vectors_work2.ToArray();
482
483 lastPhysPos
484 = new LLVector3(
485 (float) info.GetValue("lastPhysPos.X", typeof (float)),
486 (float) info.GetValue("lastPhysPos.Y", typeof (float)),
487 (float) info.GetValue("lastPhysPos.Z", typeof (float)));
488
489 m_CameraCenter
490 = new Vector3(
491 (float) info.GetValue("m_CameraCenter.X", typeof (float)),
492 (float) info.GetValue("m_CameraCenter.Y", typeof (float)),
493 (float) info.GetValue("m_CameraCenter.Z", typeof (float)));
494
495 m_CameraAtAxis
496 = new Vector3(
497 (float) info.GetValue("m_CameraAtAxis.X", typeof (float)),
498 (float) info.GetValue("m_CameraAtAxis.Y", typeof (float)),
499 (float) info.GetValue("m_CameraAtAxis.Z", typeof (float)));
500
501 m_CameraLeftAxis
502 = new Vector3(
503 (float) info.GetValue("m_CameraLeftAxis.X", typeof (float)),
504 (float) info.GetValue("m_CameraLeftAxis.Y", typeof (float)),
505 (float) info.GetValue("m_CameraLeftAxis.Z", typeof (float)));
506
507 m_CameraUpAxis
508 = new Vector3(
509 (float) info.GetValue("m_CameraUpAxis.X", typeof (float)),
510 (float) info.GetValue("m_CameraUpAxis.Y", typeof (float)),
511 (float) info.GetValue("m_CameraUpAxis.Z", typeof (float)));
512
513 m_DrawDistance = (float) info.GetValue("m_DrawDistance", typeof (float));
514 m_appearance = (AvatarAppearance) info.GetValue("m_appearance", typeof (AvatarAppearance));
515 m_knownChildRegions = (List<ulong>) info.GetValue("m_knownChildRegions", typeof (List<ulong>));
516
517 posLastSignificantMove
518 = new LLVector3(
519 (float) info.GetValue("posLastSignificantMove.X", typeof (float)),
520 (float) info.GetValue("posLastSignificantMove.Y", typeof (float)),
521 (float) info.GetValue("posLastSignificantMove.Z", typeof (float)));
522
523 // m_partsUpdateQueue = (UpdateQueue)info.GetValue("m_partsUpdateQueue", typeof(UpdateQueue));
524
525 /*
526 Dictionary<Guid, ScenePartUpdate> updateTimes_work
527 = (Dictionary<Guid, ScenePartUpdate>)info.GetValue("m_updateTimes", typeof(Dictionary<Guid, ScenePartUpdate>));
528
529 foreach (Guid id in updateTimes_work.Keys)
530 {
531 m_updateTimes.Add(new LLUUID(id), updateTimes_work[id]);
532 }
533 */
534 m_regionHandle = (ulong) info.GetValue("m_regionHandle", typeof (ulong));
535 m_firstname = (string) info.GetValue("m_firstname", typeof (string));
536 m_lastname = (string) info.GetValue("m_lastname", typeof (string));
537 m_allowMovement = (bool) info.GetValue("m_allowMovement", typeof (bool));
538 m_parentPosition = new LLVector3((float) info.GetValue("m_parentPosition.X", typeof (float)),
539 (float) info.GetValue("m_parentPosition.Y", typeof (float)),
540 (float) info.GetValue("m_parentPosition.Z", typeof (float)));
541
542 m_isChildAgent = (bool) info.GetValue("m_isChildAgent", typeof (bool));
543 m_parentID = (uint) info.GetValue("m_parentID", typeof (uint));
544
545// for OpenSim_v0.5
546 currentParcelUUID = new LLUUID((Guid) info.GetValue("currentParcelUUID", typeof (Guid)));
547
548 lastKnownAllowedPosition
549 = new Vector3(
550 (float) info.GetValue("lastKnownAllowedPosition.X", typeof (float)),
551 (float) info.GetValue("lastKnownAllowedPosition.Y", typeof (float)),
552 (float) info.GetValue("lastKnownAllowedPosition.Z", typeof (float)));
553
554 sentMessageAboutRestrictedParcelFlyingDown = (bool) info.GetValue("sentMessageAboutRestrictedParcelFlyingDown", typeof (bool));
555
556 m_LastChildAgentUpdatePosition
557 = new LLVector3(
558 (float) info.GetValue("m_LastChildAgentUpdatePosition.X", typeof (float)),
559 (float) info.GetValue("m_LastChildAgentUpdatePosition.Y", typeof (float)),
560 (float) info.GetValue("m_LastChildAgentUpdatePosition.Z", typeof (float)));
561
562 m_perfMonMS = (int) info.GetValue("m_perfMonMS", typeof (int));
563 m_AgentControlFlags = (uint) info.GetValue("m_AgentControlFlags", typeof (uint));
564
565 m_headrotation
566 = new LLQuaternion(
567 (float) info.GetValue("m_headrotation.W", typeof (float)),
568 (float) info.GetValue("m_headrotation.X", typeof (float)),
569 (float) info.GetValue("m_headrotation.Y", typeof (float)),
570 (float) info.GetValue("m_headrotation.Z", typeof (float)));
571
572 m_state = (byte) info.GetValue("m_state", typeof (byte));
573
574 List<Guid> knownPrimUUID_work = (List<Guid>) info.GetValue("m_knownPrimUUID", typeof (List<Guid>));
575
576 foreach (Guid id in knownPrimUUID_work)
577 {
578 m_knownPrimUUID.Add(new LLUUID(id));
579 }
580
581 //System.Console.WriteLine("ScenePresence Deserialize END");
582 }
583
584 #region ISerializable Members
585
586 [SecurityPermission(SecurityAction.LinkDemand,
587 Flags = SecurityPermissionFlag.SerializationFormatter)]
588 public override void GetObjectData(
589 SerializationInfo info, StreamingContext context)
590 {
591 if (info == null)
592 {
593 throw new ArgumentNullException("info");
594 }
595
596 base.GetObjectData(info, context);
597
598 List<Guid> animations_work = new List<Guid>();
599
600 foreach (LLUUID uuid in m_animations)
601 {
602 animations_work.Add(uuid.UUID);
603 }
604
605 info.AddValue("m_animations", animations_work);
606
607 info.AddValue("m_animationSeqs", m_animationSeqs);
608 info.AddValue("m_updateflag", m_updateflag);
609 info.AddValue("m_movementflag", m_movementflag);
610 info.AddValue("m_forcesList", m_forcesList);
611 info.AddValue("m_updateCount", m_updateCount);
612 info.AddValue("m_requestedSitTargetID", m_requestedSitTargetID);
613
614 // LLVector3
615 info.AddValue("m_requestedSitOffset.X", m_requestedSitOffset.X);
616 info.AddValue("m_requestedSitOffset.Y", m_requestedSitOffset.Y);
617 info.AddValue("m_requestedSitOffset.Z", m_requestedSitOffset.Z);
618
619 info.AddValue("m_sitAvatarHeight", m_sitAvatarHeight);
620 info.AddValue("m_godlevel", m_godlevel);
621 info.AddValue("m_setAlwaysRun", m_setAlwaysRun);
622
623 // Quaternion
624 info.AddValue("m_bodyRot.w", m_bodyRot.w);
625 info.AddValue("m_bodyRot.x", m_bodyRot.x);
626 info.AddValue("m_bodyRot.y", m_bodyRot.y);
627 info.AddValue("m_bodyRot.z", m_bodyRot.z);
628
629 info.AddValue("IsRestrictedToRegion", IsRestrictedToRegion);
630 info.AddValue("m_newForce", m_newForce);
631 //info.AddValue("m_newAvatar", m_newAvatar);
632 info.AddValue("m_newCoarseLocations", m_newCoarseLocations);
633 info.AddValue("m_gotAllObjectsInScene", m_gotAllObjectsInScene);
634 info.AddValue("m_avHeight", m_avHeight);
635
636 // info.AddValue("m_regionInfo", m_regionInfo);
637
638 info.AddValue("crossingFromRegion", crossingFromRegion);
639
640 List<float[]> Dir_Vectors_work = new List<float[]>();
641
642 foreach (Vector3 v3 in Dir_Vectors)
643 {
644 Dir_Vectors_work.Add(new[] {v3.x, v3.y, v3.z});
645 }
646
647 info.AddValue("Dir_Vectors", Dir_Vectors_work);
648
649 // LLVector3
650 info.AddValue("lastPhysPos.X", lastPhysPos.X);
651 info.AddValue("lastPhysPos.Y", lastPhysPos.Y);
652 info.AddValue("lastPhysPos.Z", lastPhysPos.Z);
653
654 // Vector3
655 info.AddValue("m_CameraCenter.X", m_CameraCenter.x);
656 info.AddValue("m_CameraCenter.Y", m_CameraCenter.y);
657 info.AddValue("m_CameraCenter.Z", m_CameraCenter.z);
658
659 // Vector3
660 info.AddValue("m_CameraAtAxis.X", m_CameraAtAxis.x);
661 info.AddValue("m_CameraAtAxis.Y", m_CameraAtAxis.y);
662 info.AddValue("m_CameraAtAxis.Z", m_CameraAtAxis.z);
663
664 // Vector3
665 info.AddValue("m_CameraLeftAxis.X", m_CameraLeftAxis.x);
666 info.AddValue("m_CameraLeftAxis.Y", m_CameraLeftAxis.y);
667 info.AddValue("m_CameraLeftAxis.Z", m_CameraLeftAxis.z);
668
669 // Vector3
670 info.AddValue("m_CameraUpAxis.X", m_CameraUpAxis.x);
671 info.AddValue("m_CameraUpAxis.Y", m_CameraUpAxis.y);
672 info.AddValue("m_CameraUpAxis.Z", m_CameraUpAxis.z);
673
674 info.AddValue("m_DrawDistance", m_DrawDistance);
675 info.AddValue("m_appearance", m_appearance);
676 info.AddValue("m_knownChildRegions", m_knownChildRegions);
677
678 // LLVector3
679 info.AddValue("posLastSignificantMove.X", posLastSignificantMove.X);
680 info.AddValue("posLastSignificantMove.Y", posLastSignificantMove.Y);
681 info.AddValue("posLastSignificantMove.Z", posLastSignificantMove.Z);
682
683 //info.AddValue("m_partsUpdateQueue", m_partsUpdateQueue);
684
685 /*
686 Dictionary<Guid, ScenePartUpdate> updateTimes_work = new Dictionary<Guid, ScenePartUpdate>();
687
688 foreach ( LLUUID id in m_updateTimes.Keys)
689 {
690 updateTimes_work.Add(id.UUID, m_updateTimes[id]);
691 }
692
693 info.AddValue("m_updateTimes", updateTimes_work);
694 */
695
696 info.AddValue("m_regionHandle", m_regionHandle);
697 info.AddValue("m_firstname", m_firstname);
698 info.AddValue("m_lastname", m_lastname);
699 info.AddValue("m_allowMovement", m_allowMovement);
700 //info.AddValue("m_physicsActor", m_physicsActor);
701 info.AddValue("m_parentPosition.X", m_parentPosition.X);
702 info.AddValue("m_parentPosition.Y", m_parentPosition.Y);
703 info.AddValue("m_parentPosition.Z", m_parentPosition.Z);
704 info.AddValue("m_isChildAgent", m_isChildAgent);
705 info.AddValue("m_parentID", m_parentID);
706
707// for OpenSim_v0.5
708 info.AddValue("currentParcelUUID", currentParcelUUID.UUID);
709
710 info.AddValue("lastKnownAllowedPosition.X", lastKnownAllowedPosition.x);
711 info.AddValue("lastKnownAllowedPosition.Y", lastKnownAllowedPosition.y);
712 info.AddValue("lastKnownAllowedPosition.Z", lastKnownAllowedPosition.z);
713
714 info.AddValue("sentMessageAboutRestrictedParcelFlyingDown", sentMessageAboutRestrictedParcelFlyingDown);
715
716 info.AddValue("m_LastChildAgentUpdatePosition.X", m_LastChildAgentUpdatePosition.X);
717 info.AddValue("m_LastChildAgentUpdatePosition.Y", m_LastChildAgentUpdatePosition.Y);
718 info.AddValue("m_LastChildAgentUpdatePosition.Z", m_LastChildAgentUpdatePosition.Z);
719
720 info.AddValue("m_perfMonMS", m_perfMonMS);
721 info.AddValue("m_AgentControlFlags", m_AgentControlFlags);
722
723 info.AddValue("m_headrotation.W", m_headrotation.W);
724 info.AddValue("m_headrotation.X", m_headrotation.X);
725 info.AddValue("m_headrotation.Y", m_headrotation.Y);
726 info.AddValue("m_headrotation.Z", m_headrotation.Z);
727
728 info.AddValue("m_state", m_state);
729
730 List<Guid> knownPrimUUID_work = new List<Guid>();
731
732 foreach (LLUUID id in m_knownPrimUUID)
733 {
734 knownPrimUUID_work.Add(id.UUID);
735 }
736
737 info.AddValue("m_knownPrimUUID", knownPrimUUID_work);
738 }
739
740 #endregion
741
742 public event SignificantClientMovement OnSignificantClientMovement;
743
423 /// <summary> 744 /// <summary>
424 /// Add the part to the queue of parts for which we need to send an update to the client 745 /// Add the part to the queue of parts for which we need to send an update to the client
425 /// </summary> 746 /// </summary>
@@ -457,12 +778,12 @@ namespace OpenSim.Region.Environment.Scenes
457 if (!m_gotAllObjectsInScene) 778 if (!m_gotAllObjectsInScene)
458 { 779 {
459 if (!m_isChildAgent || m_scene.m_seeIntoRegionFromNeighbor) 780 if (!m_isChildAgent || m_scene.m_seeIntoRegionFromNeighbor)
460 { 781 {
461 m_scene.SendAllSceneObjectsToClient(this); 782 m_scene.SendAllSceneObjectsToClient(this);
462 m_gotAllObjectsInScene = true; 783 m_gotAllObjectsInScene = true;
463 } 784 }
464 } 785 }
465 786
466 if (m_partsUpdateQueue.Count > 0) 787 if (m_partsUpdateQueue.Count > 0)
467 { 788 {
468 bool runUpdate = true; 789 bool runUpdate = true;
@@ -481,7 +802,7 @@ namespace OpenSim.Region.Environment.Scenes
481// m_log.DebugFormat( 802// m_log.DebugFormat(
482// "[SCENE PRESENCE]: Fully updating prim {0}, {1} - part timestamp {2}", 803// "[SCENE PRESENCE]: Fully updating prim {0}, {1} - part timestamp {2}",
483// part.Name, part.UUID, part.TimeStampFull); 804// part.Name, part.UUID, part.TimeStampFull);
484 805
485 part.SendFullUpdate(ControllingClient, GenerateClientFlags(part.UUID)); 806 part.SendFullUpdate(ControllingClient, GenerateClientFlags(part.UUID));
486 807
487 // We'll update to the part's timestamp rather than the current time to 808 // We'll update to the part's timestamp rather than the current time to
@@ -497,7 +818,7 @@ namespace OpenSim.Region.Environment.Scenes
497// m_log.DebugFormat( 818// m_log.DebugFormat(
498// "[SCENE PRESENCE]: Tersely updating prim {0}, {1} - part timestamp {2}", 819// "[SCENE PRESENCE]: Tersely updating prim {0}, {1} - part timestamp {2}",
499// part.Name, part.UUID, part.TimeStampTerse); 820// part.Name, part.UUID, part.TimeStampTerse);
500 821
501 part.SendTerseUpdate(ControllingClient); 822 part.SendTerseUpdate(ControllingClient);
502 823
503 update.LastTerseUpdateTime = part.TimeStampTerse; 824 update.LastTerseUpdateTime = part.TimeStampTerse;
@@ -530,6 +851,235 @@ namespace OpenSim.Region.Environment.Scenes
530 AddNewMovement(position, rotation); 851 AddNewMovement(position, rotation);
531 } 852 }
532 853
854 /// <summary>
855 /// This allows the Sim owner the abiility to kick users from their sim currently.
856 /// It tells the client that the agent has permission to do so.
857 /// </summary>
858 public void GrantGodlikePowers(LLUUID agentID, LLUUID sessionID, LLUUID token, bool godStatus)
859 {
860 GrantGodlikePowersPacket respondPacket = new GrantGodlikePowersPacket();
861 GrantGodlikePowersPacket.GrantDataBlock gdb = new GrantGodlikePowersPacket.GrantDataBlock();
862 GrantGodlikePowersPacket.AgentDataBlock adb = new GrantGodlikePowersPacket.AgentDataBlock();
863
864 adb.AgentID = agentID;
865 adb.SessionID = sessionID; // More security
866
867 if (godStatus)
868 {
869 gdb.GodLevel = 250;
870 m_godlevel = 250;
871 }
872 else
873 {
874 gdb.GodLevel = 0;
875 m_godlevel = 0;
876 }
877
878 gdb.Token = token;
879 //respondPacket.AgentData = (GrantGodlikePowersPacket.AgentDataBlock)ablock;
880 respondPacket.GrantData = gdb;
881 respondPacket.AgentData = adb;
882 ControllingClient.OutPacket(respondPacket, ThrottleOutPacketType.Task);
883 }
884
885 /// <summary>
886 /// This updates important decision making data about a child agent
887 /// The main purpose is to figure out what objects to send to a child agent that's in a neighboring region
888 /// </summary>
889 public void ChildAgentDataUpdate(ChildAgentDataUpdate cAgentData, uint tRegionX, uint tRegionY, uint rRegionX, uint rRegionY)
890 {
891 //
892 int shiftx = ((int) rRegionX - (int) tRegionX) * (int) Constants.RegionSize;
893 int shifty = ((int) rRegionY - (int) tRegionY) * (int) Constants.RegionSize;
894
895 m_DrawDistance = cAgentData.drawdistance;
896 m_pos = new LLVector3(cAgentData.Position.x + shiftx, cAgentData.Position.y + shifty, cAgentData.Position.z);
897
898 // It's hard to say here.. We can't really tell where the camera position is unless it's in world cordinates from the sending region
899 m_CameraCenter =
900 new Vector3(cAgentData.cameraPosition.x, cAgentData.cameraPosition.y, cAgentData.cameraPosition.z);
901
902
903 m_godlevel = cAgentData.godlevel;
904 SetHeight(cAgentData.AVHeight);
905
906 ControllingClient.SetChildAgentThrottle(cAgentData.throttles);
907
908
909 // Sends out the objects in the user's draw distance if m_sendTasksToChild is true.
910 if (m_scene.m_seeIntoRegionFromNeighbor)
911 m_scene.SendAllSceneObjectsToClient(this);
912 //cAgentData.AVHeight;
913 //cAgentData.regionHandle;
914 //m_velocity = cAgentData.Velocity;
915 }
916
917 /// <summary>
918 /// Handles part of the PID controller function for moving an avatar.
919 /// </summary>
920 public override void UpdateMovement()
921 {
922 m_newForce = false;
923 lock (m_forcesList)
924 {
925 if (m_forcesList.Count > 0)
926 {
927 for (int i = 0; i < m_forcesList.Count; i++)
928 {
929 NewForce force = m_forcesList[i];
930
931 m_updateflag = true;
932 try
933 {
934 movementvector.X = force.X;
935 movementvector.Y = force.Y;
936 movementvector.Z = force.Z;
937 Velocity = movementvector;
938 }
939 catch (NullReferenceException)
940 {
941 // Under extreme load, this returns a NullReference Exception that we can ignore.
942 // Ignoring this causes no movement to be sent to the physics engine...
943 // which when the scene is moving at 1 frame every 10 seconds, it doesn't really matter!
944 }
945 m_newForce = true;
946 }
947 for (int i = 0; i < m_forcesList.Count; i++)
948 {
949 m_forcesList.RemoveAt(0);
950 }
951 }
952 }
953 }
954
955 public override void SetText(string text, Vector3 color, double alpha)
956 {
957 throw new Exception("Can't set Text on avatar.");
958 }
959
960 /// <summary>
961 /// Adds a physical representation of the avatar to the Physics plugin
962 /// </summary>
963 public void AddToPhysicalScene()
964 {
965 PhysicsScene scene = m_scene.PhysicsScene;
966
967 PhysicsVector pVec =
968 new PhysicsVector(AbsolutePosition.X, AbsolutePosition.Y,
969 AbsolutePosition.Z);
970 if (m_avHeight == 127.0f)
971 {
972 m_physicsActor = scene.AddAvatar(Firstname + "." + Lastname, pVec, new PhysicsVector(0, 0, 1.56f));
973 }
974 else
975 {
976 m_physicsActor = scene.AddAvatar(Firstname + "." + Lastname, pVec, new PhysicsVector(0, 0, m_avHeight));
977 }
978 //m_physicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients;
979 m_physicsActor.OnCollisionUpdate += PhysicsCollisionUpdate;
980 m_physicsActor.LocalID = LocalId;
981 }
982
983 // Event called by the physics plugin to tell the avatar about a collision.
984 private void PhysicsCollisionUpdate(EventArgs e)
985 {
986 bool isUserMoving = Velocity.X > 0 || Velocity.Y > 0;
987 UpdateMovementAnimations(isUserMoving);
988 }
989
990 internal void Close()
991 {
992 lock (m_attachments)
993 {
994 foreach (SceneObjectGroup grp in m_attachments)
995 {
996 // ControllingClient may be null at this point!
997 m_scene.m_innerScene.DetachSingleAttachmentToInv(grp.GetFromAssetID(), ControllingClient);
998 }
999 m_attachments.Clear();
1000 }
1001 lock (m_knownPrimUUID)
1002 {
1003 m_knownPrimUUID.Clear();
1004 }
1005 lock (m_knownChildRegions)
1006 {
1007 m_knownChildRegions.Clear();
1008 }
1009 lock (m_updateTimes)
1010 {
1011 m_updateTimes.Clear();
1012 }
1013 lock (m_partsUpdateQueue)
1014 {
1015 m_partsUpdateQueue.Clear();
1016 }
1017
1018 RemoveFromPhysicalScene();
1019 GC.Collect();
1020 }
1021
1022 public void AddAttachment(SceneObjectGroup gobj)
1023 {
1024 lock (m_attachments)
1025 {
1026 m_attachments.Add(gobj);
1027 }
1028 }
1029
1030 public void RemoveAttachment(SceneObjectGroup gobj)
1031 {
1032 lock (m_attachments)
1033 {
1034 if (m_attachments.Contains(gobj))
1035 {
1036 m_attachments.Remove(gobj);
1037 }
1038 }
1039 }
1040
1041 public void CrossAttachmentsIntoNewRegion(ulong regionHandle)
1042 {
1043 lock (m_attachments)
1044 {
1045 foreach (SceneObjectGroup gobj in m_attachments)
1046 {
1047 // If the prim group is null then something must have happened to it!
1048 if (gobj != null)
1049 {
1050 // Set the parent localID to 0 so it transfers over properly.
1051 gobj.RootPart.SetParentLocalId(0);
1052 gobj.RootPart.m_IsAttachment = false;
1053 gobj.AbsolutePosition = gobj.RootPart.m_attachedPos;
1054 gobj.RootPart.LastOwnerID = gobj.GetFromAssetID();
1055 m_scene.CrossPrimGroupIntoNewRegion(regionHandle, gobj);
1056 }
1057 }
1058 m_attachments.Clear();
1059 }
1060 }
1061
1062 public void initializeScenePresence(IClientAPI client, RegionInfo region, Scene scene)
1063 {
1064 m_controllingClient = client;
1065 m_regionInfo = region;
1066 m_scene = scene;
1067 RegisterToEvents();
1068
1069 /*
1070 AbsolutePosition = client.StartPos;
1071
1072 Animations = new AvatarAnimations();
1073 Animations.LoadAnims();
1074
1075 m_animations = new List<LLUUID>();
1076 m_animations.Add(Animations.AnimsLLUUID["STAND"]);
1077 m_animationSeqs.Add(m_controllingClient.NextAnimationSequenceNumber);
1078
1079 SetDirectionVectors();
1080 */
1081 }
1082
533 #region Status Methods 1083 #region Status Methods
534 1084
535 /// <summary> 1085 /// <summary>
@@ -542,7 +1092,7 @@ namespace OpenSim.Region.Environment.Scenes
542// m_log.DebugFormat( 1092// m_log.DebugFormat(
543// "[SCENEPRESENCE]: Upgrading child agent {0}, {1} to a root agent in {2}", 1093// "[SCENEPRESENCE]: Upgrading child agent {0}, {1} to a root agent in {2}",
544// Name, UUID, m_scene.RegionInfo.RegionName); 1094// Name, UUID, m_scene.RegionInfo.RegionName);
545 1095
546 m_isChildAgent = false; 1096 m_isChildAgent = false;
547 1097
548 AbsolutePosition = pos; 1098 AbsolutePosition = pos;
@@ -558,7 +1108,7 @@ namespace OpenSim.Region.Environment.Scenes
558 //{ 1108 //{
559 m_scene.SendAllSceneObjectsToClient(this); 1109 m_scene.SendAllSceneObjectsToClient(this);
560 m_scene.LandChannel.sendLandUpdate(this, true); 1110 m_scene.LandChannel.sendLandUpdate(this, true);
561 1111
562 //m_gotAllObjectsInScene = true; 1112 //m_gotAllObjectsInScene = true;
563 //} 1113 //}
564 } 1114 }
@@ -572,9 +1122,9 @@ namespace OpenSim.Region.Environment.Scenes
572 /// </summary> 1122 /// </summary>
573 public void MakeChildAgent() 1123 public void MakeChildAgent()
574 { 1124 {
575 if(m_animations.Count > 0) 1125 if (m_animations.Count > 0)
576 { 1126 {
577 LLUUID movement=m_animations[0]; 1127 LLUUID movement = m_animations[0];
578 1128
579 m_animations.Clear(); 1129 m_animations.Clear();
580 m_animationSeqs.Clear(); 1130 m_animationSeqs.Clear();
@@ -584,7 +1134,7 @@ namespace OpenSim.Region.Environment.Scenes
584// m_log.DebugFormat( 1134// m_log.DebugFormat(
585// "[SCENEPRESENCE]: Downgrading child agent {0}, {1} to a root agent in {2}", 1135// "[SCENEPRESENCE]: Downgrading child agent {0}, {1} to a root agent in {2}",
586// Name, UUID, m_scene.RegionInfo.RegionName); 1136// Name, UUID, m_scene.RegionInfo.RegionName);
587 1137
588 Velocity = new LLVector3(0, 0, 0); 1138 Velocity = new LLVector3(0, 0, 0);
589 m_isChildAgent = true; 1139 m_isChildAgent = true;
590 m_scene.SwapRootAgentCount(true); 1140 m_scene.SwapRootAgentCount(true);
@@ -841,9 +1391,8 @@ namespace OpenSim.Region.Environment.Scenes
841 ((flags & (uint) AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)); 1391 ((flags & (uint) AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0));
842 1392
843 // Are the collision requirements fulfilled? 1393 // Are the collision requirements fulfilled?
844 bool colliding = (m_physicsActor.IsColliding == true); 1394 bool colliding = m_physicsActor.IsColliding;
845 1395
846
847 1396
848 if (m_physicsActor.Flying && colliding && controlland) 1397 if (m_physicsActor.Flying && colliding && controlland)
849 { 1398 {
@@ -857,9 +1406,9 @@ namespace OpenSim.Region.Environment.Scenes
857 UpdateMovementAnimations(update_movementflag); 1406 UpdateMovementAnimations(update_movementflag);
858 } 1407 }
859 } 1408 }
860 1409
861 m_scene.EventManager.TriggerOnClientMovement(this); 1410 m_scene.EventManager.TriggerOnClientMovement(this);
862 1411
863 m_scene.AddAgentTime(System.Environment.TickCount - m_perfMonMS); 1412 m_scene.AddAgentTime(System.Environment.TickCount - m_perfMonMS);
864 } 1413 }
865 1414
@@ -886,9 +1435,9 @@ namespace OpenSim.Region.Environment.Scenes
886 AddToPhysicalScene(); 1435 AddToPhysicalScene();
887 } 1436 }
888 1437
889 m_pos += m_parentPosition + new LLVector3(0.0f, 0.0f, 2.0f*m_sitAvatarHeight); 1438 m_pos += m_parentPosition + new LLVector3(0.0f, 0.0f, 2.0f * m_sitAvatarHeight);
890 m_parentPosition = new LLVector3(); 1439 m_parentPosition = new LLVector3();
891 1440
892 m_parentID = 0; 1441 m_parentID = 0;
893 SendFullUpdateToAllClients(); 1442 SendFullUpdateToAllClients();
894 1443
@@ -991,7 +1540,7 @@ namespace OpenSim.Region.Environment.Scenes
991 } 1540 }
992 else 1541 else
993 { 1542 {
994 m_log.Warn("Sit requested on unknown object: " + targetID.ToString()); 1543 m_log.Warn("Sit requested on unknown object: " + targetID);
995 } 1544 }
996 SendSitResponse(remoteClient, targetID, offset); 1545 SendSitResponse(remoteClient, targetID, offset);
997 } 1546 }
@@ -1053,11 +1602,11 @@ namespace OpenSim.Region.Environment.Scenes
1053 1602
1054 public void AddAnimation(LLUUID animID) 1603 public void AddAnimation(LLUUID animID)
1055 { 1604 {
1056 if(m_isChildAgent) 1605 if (m_isChildAgent)
1057 return; 1606 return;
1058 1607
1059 // Don't let this animation become the movement animation 1608 // Don't let this animation become the movement animation
1060 if(m_animations.Count < 1) 1609 if (m_animations.Count < 1)
1061 SetMovementAnimation(Animations.AnimsLLUUID["STAND"]); 1610 SetMovementAnimation(Animations.AnimsLLUUID["STAND"]);
1062 1611
1063 if (!m_animations.Contains(animID)) 1612 if (!m_animations.Contains(animID))
@@ -1070,7 +1619,7 @@ namespace OpenSim.Region.Environment.Scenes
1070 1619
1071 public void RemoveAnimation(LLUUID animID) 1620 public void RemoveAnimation(LLUUID animID)
1072 { 1621 {
1073 if(m_isChildAgent) 1622 if (m_isChildAgent)
1074 return; 1623 return;
1075 1624
1076 if (m_animations.Contains(animID)) 1625 if (m_animations.Contains(animID))
@@ -1084,11 +1633,11 @@ namespace OpenSim.Region.Environment.Scenes
1084 // What a HACK!! Anim list really needs to be an object! 1633 // What a HACK!! Anim list really needs to be an object!
1085 int idx; 1634 int idx;
1086 1635
1087 for(idx=0;idx < m_animations.Count;idx++) 1636 for (idx = 0; idx < m_animations.Count; idx++)
1088 { 1637 {
1089 if(m_animations[idx] == animID) 1638 if (m_animations[idx] == animID)
1090 { 1639 {
1091 int seq=m_animationSeqs[idx]; 1640 int seq = m_animationSeqs[idx];
1092 1641
1093 m_animations.Remove(animID); 1642 m_animations.Remove(animID);
1094 m_animationSeqs.Remove(seq); 1643 m_animationSeqs.Remove(seq);
@@ -1117,7 +1666,7 @@ namespace OpenSim.Region.Environment.Scenes
1117 /// </summary> 1666 /// </summary>
1118 protected void SetMovementAnimation(LLUUID anim) 1667 protected void SetMovementAnimation(LLUUID anim)
1119 { 1668 {
1120 if(m_animations.Count < 1) 1669 if (m_animations.Count < 1)
1121 { 1670 {
1122 m_animations.Add(Animations.AnimsLLUUID["STAND"]); 1671 m_animations.Add(Animations.AnimsLLUUID["STAND"]);
1123 m_animationSeqs.Add(1); 1672 m_animationSeqs.Add(1);
@@ -1150,8 +1699,6 @@ namespace OpenSim.Region.Environment.Scenes
1150 /// </summary> 1699 /// </summary>
1151 protected void UpdateMovementAnimations(bool update_movementflag) 1700 protected void UpdateMovementAnimations(bool update_movementflag)
1152 { 1701 {
1153
1154
1155 if (update_movementflag) 1702 if (update_movementflag)
1156 { 1703 {
1157 // Are we moving? 1704 // Are we moving?
@@ -1184,7 +1731,8 @@ namespace OpenSim.Region.Environment.Scenes
1184 SetMovementAnimation(Animations.AnimsLLUUID["JUMP"]); 1731 SetMovementAnimation(Animations.AnimsLLUUID["JUMP"]);
1185 } 1732 }
1186 catch (KeyNotFoundException) 1733 catch (KeyNotFoundException)
1187 { } 1734 {
1735 }
1188 } 1736 }
1189 else if (m_setAlwaysRun) 1737 else if (m_setAlwaysRun)
1190 { 1738 {
@@ -1194,7 +1742,8 @@ namespace OpenSim.Region.Environment.Scenes
1194 SetMovementAnimation(Animations.AnimsLLUUID["RUN"]); 1742 SetMovementAnimation(Animations.AnimsLLUUID["RUN"]);
1195 } 1743 }
1196 catch (KeyNotFoundException) 1744 catch (KeyNotFoundException)
1197 { } 1745 {
1746 }
1198 } 1747 }
1199 else 1748 else
1200 { 1749 {
@@ -1204,8 +1753,8 @@ namespace OpenSim.Region.Environment.Scenes
1204 SetMovementAnimation(Animations.AnimsLLUUID["WALK"]); 1753 SetMovementAnimation(Animations.AnimsLLUUID["WALK"]);
1205 } 1754 }
1206 catch (KeyNotFoundException) 1755 catch (KeyNotFoundException)
1207 { } 1756 {
1208 1757 }
1209 } 1758 }
1210 } 1759 }
1211 else 1760 else
@@ -1239,15 +1788,14 @@ namespace OpenSim.Region.Environment.Scenes
1239 // We're not moving.. and we're not doing anything.. so play the stand animation 1788 // We're not moving.. and we're not doing anything.. so play the stand animation
1240 try 1789 try
1241 { 1790 {
1242
1243 SetMovementAnimation(Animations.AnimsLLUUID["STAND"]); 1791 SetMovementAnimation(Animations.AnimsLLUUID["STAND"]);
1244 } 1792 }
1245 catch (KeyNotFoundException) 1793 catch (KeyNotFoundException)
1246 { } 1794 {
1795 }
1247 } 1796 }
1248 } 1797 }
1249 } 1798 }
1250
1251 } 1799 }
1252 1800
1253 /// <summary> 1801 /// <summary>
@@ -1262,13 +1810,13 @@ namespace OpenSim.Region.Environment.Scenes
1262 } 1810 }
1263 1811
1264 m_perfMonMS = System.Environment.TickCount; 1812 m_perfMonMS = System.Environment.TickCount;
1265 1813
1266 m_rotation = rotation; 1814 m_rotation = rotation;
1267 NewForce newVelocity = new NewForce(); 1815 NewForce newVelocity = new NewForce();
1268 Vector3 direc = rotation*vec; 1816 Vector3 direc = rotation * vec;
1269 direc.Normalize(); 1817 direc.Normalize();
1270 1818
1271 direc *= 0.03f*128f; 1819 direc *= 0.03f * 128f;
1272 if (m_physicsActor.Flying) 1820 if (m_physicsActor.Flying)
1273 { 1821 {
1274 direc *= 4; 1822 direc *= 4;
@@ -1300,7 +1848,8 @@ namespace OpenSim.Region.Environment.Scenes
1300 SetMovementAnimation(Animations.AnimsLLUUID["JUMP"]); 1848 SetMovementAnimation(Animations.AnimsLLUUID["JUMP"]);
1301 } 1849 }
1302 catch (KeyNotFoundException) 1850 catch (KeyNotFoundException)
1303 { } 1851 {
1852 }
1304 } 1853 }
1305 } 1854 }
1306 } 1855 }
@@ -1346,23 +1895,18 @@ namespace OpenSim.Region.Environment.Scenes
1346 m_updateCount = 0; 1895 m_updateCount = 0;
1347 } 1896 }
1348 } 1897 }
1349 else if ((Util.GetDistanceTo(lastPhysPos, AbsolutePosition) > 0.02) || (Util.GetDistanceTo(m_lastVelocity, m_velocity) > 0.02)) // physics-related movement 1898 else if ((Util.GetDistanceTo(lastPhysPos, AbsolutePosition) > 0.02) || (Util.GetDistanceTo(m_lastVelocity, m_velocity) > 0.02))
1899 // physics-related movement
1350 { 1900 {
1351
1352
1353 // Send Terse Update to all clients updates lastPhysPos and m_lastVelocity 1901 // Send Terse Update to all clients updates lastPhysPos and m_lastVelocity
1354 // doing the above assures us that we know what we sent the clients last 1902 // doing the above assures us that we know what we sent the clients last
1355 SendTerseUpdateToAllClients(); 1903 SendTerseUpdateToAllClients();
1356 m_updateCount = 0; 1904 m_updateCount = 0;
1357
1358
1359
1360 } 1905 }
1361 1906
1362 // followed suggestion from mic bowman. reversed the two lines below. 1907 // followed suggestion from mic bowman. reversed the two lines below.
1363 CheckForBorderCrossing(); 1908 CheckForBorderCrossing();
1364 CheckForSignificantMovement(); // sends update to the modules. 1909 CheckForSignificantMovement(); // sends update to the modules.
1365
1366 } 1910 }
1367 } 1911 }
1368 1912
@@ -1381,7 +1925,7 @@ namespace OpenSim.Region.Environment.Scenes
1381 LLVector3 pos = m_pos; 1925 LLVector3 pos = m_pos;
1382 LLVector3 vel = Velocity; 1926 LLVector3 vel = Velocity;
1383 LLQuaternion rot = new LLQuaternion(m_bodyRot.x, m_bodyRot.y, m_bodyRot.z, m_bodyRot.w); 1927 LLQuaternion rot = new LLQuaternion(m_bodyRot.x, m_bodyRot.y, m_bodyRot.z, m_bodyRot.w);
1384 remoteClient.SendAvatarTerseUpdate(m_regionHandle, (ushort)(m_scene.TimeDilation * (float)ushort.MaxValue), LocalId, new LLVector3(pos.X, pos.Y, pos.Z), 1928 remoteClient.SendAvatarTerseUpdate(m_regionHandle, (ushort) (m_scene.TimeDilation * ushort.MaxValue), LocalId, new LLVector3(pos.X, pos.Y, pos.Z),
1385 new LLVector3(vel.X, vel.Y, vel.Z), rot); 1929 new LLVector3(vel.X, vel.Y, vel.Z), rot);
1386 1930
1387 m_scene.AddAgentTime(System.Environment.TickCount - m_perfMonMS); 1931 m_scene.AddAgentTime(System.Environment.TickCount - m_perfMonMS);
@@ -1401,7 +1945,6 @@ namespace OpenSim.Region.Environment.Scenes
1401 lastPhysPos = AbsolutePosition; 1945 lastPhysPos = AbsolutePosition;
1402 1946
1403 m_scene.AddAgentTime(System.Environment.TickCount - m_perfMonMS); 1947 m_scene.AddAgentTime(System.Environment.TickCount - m_perfMonMS);
1404
1405 } 1948 }
1406 1949
1407 public void SendCoarseLocations() 1950 public void SendCoarseLocations()
@@ -1497,15 +2040,15 @@ namespace OpenSim.Region.Environment.Scenes
1497 /// </summary> 2040 /// </summary>
1498 public void SendAppearanceToAllOtherAgents() 2041 public void SendAppearanceToAllOtherAgents()
1499 { 2042 {
1500 m_perfMonMS=System.Environment.TickCount; 2043 m_perfMonMS = System.Environment.TickCount;
1501 2044
1502 m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence) 2045 m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence)
1503 {
1504 if (scenePresence.UUID != UUID)
1505 { 2046 {
1506 m_appearance.SendAppearanceToOtherAgent(scenePresence); 2047 if (scenePresence.UUID != UUID)
1507 } 2048 {
1508 }); 2049 m_appearance.SendAppearanceToOtherAgent(scenePresence);
2050 }
2051 });
1509 m_scene.AddAgentTime(System.Environment.TickCount - m_perfMonMS); 2052 m_scene.AddAgentTime(System.Environment.TickCount - m_perfMonMS);
1510 } 2053 }
1511 2054
@@ -1534,7 +2077,7 @@ namespace OpenSim.Region.Environment.Scenes
1534 /// <param name="seqs"></param> 2077 /// <param name="seqs"></param>
1535 public void SendAnimPack(LLUUID[] animations, int[] seqs) 2078 public void SendAnimPack(LLUUID[] animations, int[] seqs)
1536 { 2079 {
1537 if(m_isChildAgent) 2080 if (m_isChildAgent)
1538 return; 2081 return;
1539 2082
1540 m_scene.Broadcast( 2083 m_scene.Broadcast(
@@ -1570,10 +2113,10 @@ namespace OpenSim.Region.Environment.Scenes
1570 } 2113 }
1571 2114
1572 // Minimum Draw distance is 64 meters, the Radius of the draw distance sphere is 32m 2115 // Minimum Draw distance is 64 meters, the Radius of the draw distance sphere is 32m
1573 if (Util.GetDistanceTo(AbsolutePosition,m_LastChildAgentUpdatePosition) > 32) 2116 if (Util.GetDistanceTo(AbsolutePosition, m_LastChildAgentUpdatePosition) > 32)
1574 { 2117 {
1575 ChildAgentDataUpdate cadu = new ChildAgentDataUpdate(); 2118 ChildAgentDataUpdate cadu = new ChildAgentDataUpdate();
1576 cadu.ActiveGroupID=LLUUID.Zero.UUID; 2119 cadu.ActiveGroupID = LLUUID.Zero.UUID;
1577 cadu.AgentID = UUID.UUID; 2120 cadu.AgentID = UUID.UUID;
1578 cadu.alwaysrun = m_setAlwaysRun; 2121 cadu.alwaysrun = m_setAlwaysRun;
1579 cadu.AVHeight = m_avHeight; 2122 cadu.AVHeight = m_avHeight;
@@ -1585,8 +2128,8 @@ namespace OpenSim.Region.Environment.Scenes
1585 cadu.Position = new sLLVector3(AbsolutePosition); 2128 cadu.Position = new sLLVector3(AbsolutePosition);
1586 cadu.regionHandle = m_scene.RegionInfo.RegionHandle; 2129 cadu.regionHandle = m_scene.RegionInfo.RegionHandle;
1587 cadu.throttles = ControllingClient.GetThrottlesPacked(1f); 2130 cadu.throttles = ControllingClient.GetThrottlesPacked(1f);
1588 cadu.Velocity = new sLLVector3(Velocity); 2131 cadu.Velocity = new sLLVector3(Velocity);
1589 m_scene.SendOutChildAgentUpdates(cadu,this); 2132 m_scene.SendOutChildAgentUpdates(cadu, this);
1590 m_LastChildAgentUpdatePosition.X = AbsolutePosition.X; 2133 m_LastChildAgentUpdatePosition.X = AbsolutePosition.X;
1591 m_LastChildAgentUpdatePosition.Y = AbsolutePosition.Y; 2134 m_LastChildAgentUpdatePosition.Y = AbsolutePosition.Y;
1592 m_LastChildAgentUpdatePosition.Z = AbsolutePosition.Z; 2135 m_LastChildAgentUpdatePosition.Z = AbsolutePosition.Z;
@@ -1606,9 +2149,9 @@ namespace OpenSim.Region.Environment.Scenes
1606 LLVector3 vel = Velocity; 2149 LLVector3 vel = Velocity;
1607 2150
1608 float timeStep = 0.1f; 2151 float timeStep = 0.1f;
1609 pos2.X = pos2.X + (vel.X*timeStep); 2152 pos2.X = pos2.X + (vel.X * timeStep);
1610 pos2.Y = pos2.Y + (vel.Y*timeStep); 2153 pos2.Y = pos2.Y + (vel.Y * timeStep);
1611 pos2.Z = pos2.Z + (vel.Z*timeStep); 2154 pos2.Z = pos2.Z + (vel.Z * timeStep);
1612 2155
1613 if ((pos2.X < 0) || (pos2.X > Constants.RegionSize)) 2156 if ((pos2.X < 0) || (pos2.X > Constants.RegionSize))
1614 { 2157 {
@@ -1663,10 +2206,10 @@ namespace OpenSim.Region.Environment.Scenes
1663 } 2206 }
1664 2207
1665 LLVector3 vel = m_velocity; 2208 LLVector3 vel = m_velocity;
1666 ulong neighbourHandle = Helpers.UIntsToLong((uint)(neighbourx * Constants.RegionSize), (uint)(neighboury * Constants.RegionSize)); 2209 ulong neighbourHandle = Helpers.UIntsToLong((neighbourx * Constants.RegionSize), (neighboury * Constants.RegionSize));
1667 SimpleRegionInfo neighbourRegion = m_scene.RequestNeighbouringRegionInfo(neighbourHandle); 2210 SimpleRegionInfo neighbourRegion = m_scene.RequestNeighbouringRegionInfo(neighbourHandle);
1668 if (neighbourRegion != null) 2211 if (neighbourRegion != null)
1669 { 2212 {
1670 // When the neighbour is informed of the border crossing, it will set up CAPS handlers for the avatar 2213 // When the neighbour is informed of the border crossing, it will set up CAPS handlers for the avatar
1671 // This means we need to remove the current caps handler here and possibly compensate later, 2214 // This means we need to remove the current caps handler here and possibly compensate later,
1672 // in case both scenes are being hosted on the same region server. Messy 2215 // in case both scenes are being hosted on the same region server. Messy
@@ -1676,17 +2219,17 @@ namespace OpenSim.Region.Environment.Scenes
1676 m_scene.InformNeighbourOfCrossing(neighbourHandle, m_controllingClient.AgentId, newpos, 2219 m_scene.InformNeighbourOfCrossing(neighbourHandle, m_controllingClient.AgentId, newpos,
1677 m_physicsActor.Flying); 2220 m_physicsActor.Flying);
1678 if (res) 2221 if (res)
1679 { 2222 {
1680 AgentCircuitData circuitdata = m_controllingClient.RequestClientInfo(); 2223 AgentCircuitData circuitdata = m_controllingClient.RequestClientInfo();
1681 2224
1682 // TODO Should construct this behind a method 2225 // TODO Should construct this behind a method
1683 string capsPath = 2226 string capsPath =
1684 "http://" + neighbourRegion.ExternalHostName + ":" + neighbourRegion.HttpPort 2227 "http://" + neighbourRegion.ExternalHostName + ":" + neighbourRegion.HttpPort
1685 + "/CAPS/" + circuitdata.CapsPath + "0000/"; 2228 + "/CAPS/" + circuitdata.CapsPath + "0000/";
1686 2229
1687 m_log.DebugFormat( 2230 m_log.DebugFormat(
1688 "[CAPS]: Sending new CAPS seed url {0} to client {1}", capsPath, m_uuid); 2231 "[CAPS]: Sending new CAPS seed url {0} to client {1}", capsPath, m_uuid);
1689 2232
1690 m_controllingClient.CrossRegion(neighbourHandle, newpos, vel, neighbourRegion.ExternalEndPoint, 2233 m_controllingClient.CrossRegion(neighbourHandle, newpos, vel, neighbourRegion.ExternalEndPoint,
1691 capsPath); 2234 capsPath);
1692 MakeChildAgent(); 2235 MakeChildAgent();
@@ -1703,128 +2246,40 @@ namespace OpenSim.Region.Environment.Scenes
1703 2246
1704 #endregion 2247 #endregion
1705 2248
1706 /// <summary> 2249 #region Nested type: Dir_ControlFlags
1707 /// This allows the Sim owner the abiility to kick users from their sim currently.
1708 /// It tells the client that the agent has permission to do so.
1709 /// </summary>
1710 public void GrantGodlikePowers(LLUUID agentID, LLUUID sessionID, LLUUID token, bool godStatus)
1711 {
1712 GrantGodlikePowersPacket respondPacket = new GrantGodlikePowersPacket();
1713 GrantGodlikePowersPacket.GrantDataBlock gdb = new GrantGodlikePowersPacket.GrantDataBlock();
1714 GrantGodlikePowersPacket.AgentDataBlock adb = new GrantGodlikePowersPacket.AgentDataBlock();
1715
1716 adb.AgentID = agentID;
1717 adb.SessionID = sessionID; // More security
1718
1719 if (godStatus)
1720 {
1721 gdb.GodLevel = (byte)250;
1722 m_godlevel = 250;
1723 }
1724 else
1725 {
1726 gdb.GodLevel = (byte)0;
1727 m_godlevel = 0;
1728 }
1729
1730 gdb.Token = token;
1731 //respondPacket.AgentData = (GrantGodlikePowersPacket.AgentDataBlock)ablock;
1732 respondPacket.GrantData = gdb;
1733 respondPacket.AgentData = adb;
1734 ControllingClient.OutPacket(respondPacket, ThrottleOutPacketType.Task);
1735 }
1736 2250
1737 /// <summary> 2251 /// <summary>
1738 /// This updates important decision making data about a child agent 2252 /// Implemented Control Flags
1739 /// The main purpose is to figure out what objects to send to a child agent that's in a neighboring region
1740 /// </summary> 2253 /// </summary>
1741 public void ChildAgentDataUpdate(ChildAgentDataUpdate cAgentData, uint tRegionX, uint tRegionY, uint rRegionX, uint rRegionY) 2254 private enum Dir_ControlFlags
1742 { 2255 {
1743 // 2256 DIR_CONTROL_FLAG_FORWARD = AgentManager.ControlFlags.AGENT_CONTROL_AT_POS,
1744 int shiftx = ((int)rRegionX - (int)tRegionX) * (int)Constants.RegionSize; 2257 DIR_CONTROL_FLAG_BACK = AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG,
1745 int shifty = ((int)rRegionY - (int)tRegionY) * (int)Constants.RegionSize; 2258 DIR_CONTROL_FLAG_LEFT = AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS,
1746 2259 DIR_CONTROL_FLAG_RIGHT = AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG,
1747 m_DrawDistance = cAgentData.drawdistance; 2260 DIR_CONTROL_FLAG_UP = AgentManager.ControlFlags.AGENT_CONTROL_UP_POS,
1748 m_pos = new LLVector3(cAgentData.Position.x + shiftx, cAgentData.Position.y + shifty, cAgentData.Position.z); 2261 DIR_CONTROL_FLAG_DOWN = AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG,
1749 2262 DIR_CONTROL_FLAG_DOWN_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG
1750 // It's hard to say here.. We can't really tell where the camera position is unless it's in world cordinates from the sending region
1751 m_CameraCenter =
1752 new Vector3(cAgentData.cameraPosition.x, cAgentData.cameraPosition.y, cAgentData.cameraPosition.z);
1753
1754
1755 m_godlevel = cAgentData.godlevel;
1756 SetHeight(cAgentData.AVHeight);
1757
1758 ControllingClient.SetChildAgentThrottle(cAgentData.throttles);
1759
1760
1761
1762 // Sends out the objects in the user's draw distance if m_sendTasksToChild is true.
1763 if (m_scene.m_seeIntoRegionFromNeighbor)
1764 m_scene.SendAllSceneObjectsToClient(this);
1765 //cAgentData.AVHeight;
1766 //cAgentData.regionHandle;
1767 //m_velocity = cAgentData.Velocity;
1768 } 2263 }
1769 2264
1770 /// <summary> 2265 #endregion
1771 /// Handles part of the PID controller function for moving an avatar.
1772 /// </summary>
1773 public override void UpdateMovement()
1774 {
1775 m_newForce = false;
1776 lock (m_forcesList)
1777 {
1778 if (m_forcesList.Count > 0)
1779 {
1780 for (int i = 0; i < m_forcesList.Count; i++)
1781 {
1782 NewForce force = m_forcesList[i];
1783
1784 m_updateflag = true;
1785 try
1786 {
1787 movementvector.X = force.X;
1788 movementvector.Y = force.Y;
1789 movementvector.Z = force.Z;
1790 Velocity = movementvector;
1791 }
1792 catch (NullReferenceException)
1793 {
1794 // Under extreme load, this returns a NullReference Exception that we can ignore.
1795 // Ignoring this causes no movement to be sent to the physics engine...
1796 // which when the scene is moving at 1 frame every 10 seconds, it doesn't really matter!
1797 }
1798 m_newForce = true;
1799 }
1800 for (int i = 0; i < m_forcesList.Count; i++)
1801 {
1802 m_forcesList.RemoveAt(0);
1803 }
1804 }
1805 }
1806 }
1807 2266
1808 static ScenePresence() 2267 #region Nested type: NewForce
1809 {
1810 LLObject.TextureEntry textu = AvatarAppearance.GetDefaultTextureEntry();
1811 DefaultTexture = textu.ToBytes();
1812 }
1813 2268
1814 [Serializable] 2269 [Serializable]
1815 public class NewForce 2270 public class NewForce
1816 { 2271 {
1817 public float X; 2272 public float X;
1818 public float Y; 2273 public float Y;
1819 public float Z; 2274 public float Z;
1820
1821 public NewForce()
1822 {
1823 }
1824 } 2275 }
1825 2276
1826 [Serializable] 2277 #endregion
1827 public class ScenePartUpdate : ISerializable 2278
2279 #region Nested type: ScenePartUpdate
2280
2281 [Serializable]
2282 public class ScenePartUpdate : ISerializable
1828 { 2283 {
1829 public LLUUID FullID; 2284 public LLUUID FullID;
1830 public uint LastFullUpdateTime; 2285 public uint LastFullUpdateTime;
@@ -1846,15 +2301,17 @@ namespace OpenSim.Region.Environment.Scenes
1846 throw new ArgumentNullException("info"); 2301 throw new ArgumentNullException("info");
1847 } 2302 }
1848 2303
1849 FullID = new LLUUID((Guid)info.GetValue("FullID", typeof(Guid))); 2304 FullID = new LLUUID((Guid) info.GetValue("FullID", typeof (Guid)));
1850 LastFullUpdateTime = (uint)info.GetValue("LastFullUpdateTime", typeof(uint)); 2305 LastFullUpdateTime = (uint) info.GetValue("LastFullUpdateTime", typeof (uint));
1851 LastTerseUpdateTime = (uint)info.GetValue("LastTerseUpdateTime", typeof(uint)); 2306 LastTerseUpdateTime = (uint) info.GetValue("LastTerseUpdateTime", typeof (uint));
1852 2307
1853 //System.Console.WriteLine("ScenePartUpdate Deserialize END"); 2308 //System.Console.WriteLine("ScenePartUpdate Deserialize END");
1854 } 2309 }
1855 2310
2311 #region ISerializable Members
2312
1856 [SecurityPermission(SecurityAction.LinkDemand, 2313 [SecurityPermission(SecurityAction.LinkDemand,
1857 Flags = SecurityPermissionFlag.SerializationFormatter)] 2314 Flags = SecurityPermissionFlag.SerializationFormatter)]
1858 public virtual void GetObjectData( 2315 public virtual void GetObjectData(
1859 SerializationInfo info, StreamingContext context) 2316 SerializationInfo info, StreamingContext context)
1860 { 2317 {
@@ -1867,473 +2324,10 @@ namespace OpenSim.Region.Environment.Scenes
1867 info.AddValue("LastFullUpdateTime", LastFullUpdateTime); 2324 info.AddValue("LastFullUpdateTime", LastFullUpdateTime);
1868 info.AddValue("LastTerseUpdateTime", LastTerseUpdateTime); 2325 info.AddValue("LastTerseUpdateTime", LastTerseUpdateTime);
1869 } 2326 }
1870 }
1871
1872 public override void SetText(string text, Vector3 color, double alpha)
1873 {
1874 throw new Exception("Can't set Text on avatar.");
1875 }
1876
1877 /// <summary>
1878 /// Adds a physical representation of the avatar to the Physics plugin
1879 /// </summary>
1880 public void AddToPhysicalScene()
1881 {
1882 PhysicsScene scene = m_scene.PhysicsScene;
1883
1884 PhysicsVector pVec =
1885 new PhysicsVector(AbsolutePosition.X, AbsolutePosition.Y,
1886 AbsolutePosition.Z);
1887 if (m_avHeight == 127.0f)
1888 {
1889 m_physicsActor = scene.AddAvatar(Firstname + "." + Lastname, pVec, new PhysicsVector(0, 0, 1.56f));
1890 }
1891 else
1892 {
1893 m_physicsActor = scene.AddAvatar(Firstname + "." + Lastname, pVec, new PhysicsVector(0, 0, m_avHeight));
1894 }
1895 //m_physicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients;
1896 m_physicsActor.OnCollisionUpdate += PhysicsCollisionUpdate;
1897 m_physicsActor.LocalID = LocalId;
1898 }
1899
1900 // Event called by the physics plugin to tell the avatar about a collision.
1901 private void PhysicsCollisionUpdate(EventArgs e)
1902 {
1903 bool isUserMoving = Velocity.X > 0 || Velocity.Y > 0;
1904 UpdateMovementAnimations(isUserMoving);
1905 }
1906
1907 internal void Close()
1908 {
1909 lock (m_attachments)
1910 {
1911 foreach (SceneObjectGroup grp in m_attachments)
1912 {
1913 // ControllingClient may be null at this point!
1914 m_scene.m_innerScene.DetachSingleAttachmentToInv(grp.GetFromAssetID(), ControllingClient);
1915 }
1916 m_attachments.Clear();
1917 }
1918 lock (m_knownPrimUUID)
1919 {
1920 m_knownPrimUUID.Clear();
1921 }
1922 lock (m_knownChildRegions)
1923 {
1924 m_knownChildRegions.Clear();
1925 }
1926 lock (m_updateTimes)
1927 {
1928 m_updateTimes.Clear();
1929 }
1930 lock (m_partsUpdateQueue)
1931 {
1932 m_partsUpdateQueue.Clear();
1933 }
1934 2327
1935 RemoveFromPhysicalScene(); 2328 #endregion
1936 GC.Collect();
1937 } 2329 }
1938 2330
1939 public ScenePresence() 2331 #endregion
1940 {
1941/* JB
1942 if (Animations == null)
1943 {
1944 Animations = new AvatarAnimations();
1945 Animations.LoadAnims();
1946 }
1947*/
1948 if (DefaultTexture == null)
1949 {
1950 LLObject.TextureEntry textu = AvatarAppearance.GetDefaultTextureEntry();
1951 DefaultTexture = textu.ToBytes();
1952 }
1953 }
1954 public void AddAttachment(SceneObjectGroup gobj)
1955 {
1956 lock (m_attachments)
1957 {
1958 m_attachments.Add(gobj);
1959 }
1960 }
1961 public void RemoveAttachment(SceneObjectGroup gobj)
1962 {
1963 lock (m_attachments)
1964 {
1965 if (m_attachments.Contains(gobj))
1966 {
1967 m_attachments.Remove(gobj);
1968 }
1969 }
1970 }
1971 public void CrossAttachmentsIntoNewRegion(ulong regionHandle)
1972 {
1973 lock (m_attachments)
1974 {
1975 foreach (SceneObjectGroup gobj in m_attachments)
1976 {
1977 // If the prim group is null then something must have happened to it!
1978 if (gobj != null)
1979 {
1980 // Set the parent localID to 0 so it transfers over properly.
1981 gobj.RootPart.SetParentLocalId(0);
1982 gobj.RootPart.m_IsAttachment = false;
1983 gobj.AbsolutePosition = gobj.RootPart.m_attachedPos;
1984 gobj.RootPart.LastOwnerID = gobj.GetFromAssetID();
1985 m_scene.CrossPrimGroupIntoNewRegion(regionHandle, gobj);
1986 }
1987 }
1988 m_attachments.Clear();
1989 }
1990
1991 }
1992 public void initializeScenePresence(IClientAPI client, RegionInfo region, Scene scene)
1993 {
1994 m_controllingClient = client;
1995 m_regionInfo = region;
1996 m_scene = scene;
1997 RegisterToEvents();
1998
1999 /*
2000 AbsolutePosition = client.StartPos;
2001
2002 Animations = new AvatarAnimations();
2003 Animations.LoadAnims();
2004
2005 m_animations = new List<LLUUID>();
2006 m_animations.Add(Animations.AnimsLLUUID["STAND"]);
2007 m_animationSeqs.Add(m_controllingClient.NextAnimationSequenceNumber);
2008
2009 SetDirectionVectors();
2010 */
2011 }
2012
2013 protected ScenePresence(SerializationInfo info, StreamingContext context)
2014 : base (info, context)
2015 {
2016 //System.Console.WriteLine("ScenePresence Deserialize BGN");
2017
2018 if (info == null)
2019 {
2020 throw new ArgumentNullException("info");
2021 }
2022/* JB
2023 if (Animations == null)
2024 {
2025 Animations = new AvatarAnimations();
2026 Animations.LoadAnims();
2027 }
2028*/
2029 if (DefaultTexture == null)
2030 {
2031 LLObject.TextureEntry textu = AvatarAppearance.GetDefaultTextureEntry();
2032 DefaultTexture = textu.ToBytes();
2033 }
2034
2035 List<Guid> animations_work = (List<Guid>)info.GetValue("m_animations", typeof(List<Guid>));
2036
2037 foreach (Guid guid in animations_work)
2038 {
2039 m_animations.Add(new LLUUID(guid));
2040 }
2041
2042 m_animationSeqs = (List<int>)info.GetValue("m_animationSeqs", typeof(List<int>));
2043 m_updateflag = (bool)info.GetValue("m_updateflag", typeof(bool));
2044 m_movementflag = (byte)info.GetValue("m_movementflag", typeof(byte));
2045 m_forcesList = (List<NewForce>)info.GetValue("m_forcesList", typeof(List<NewForce>));
2046 m_updateCount = (short)info.GetValue("m_updateCount", typeof(short));
2047 m_requestedSitTargetID = (uint)info.GetValue("m_requestedSitTargetID", typeof(uint));
2048
2049 m_requestedSitOffset
2050 = new LLVector3(
2051 (float)info.GetValue("m_requestedSitOffset.X", typeof(float)),
2052 (float)info.GetValue("m_requestedSitOffset.Y", typeof(float)),
2053 (float)info.GetValue("m_requestedSitOffset.Z", typeof(float)));
2054
2055 m_sitAvatarHeight = (float)info.GetValue("m_sitAvatarHeight", typeof(float));
2056 m_godlevel = (float)info.GetValue("m_godlevel", typeof(float));
2057 m_setAlwaysRun = (bool)info.GetValue("m_setAlwaysRun", typeof(bool));
2058
2059 m_bodyRot
2060 = new Quaternion(
2061 (float)info.GetValue("m_bodyRot.w", typeof(float)),
2062 (float)info.GetValue("m_bodyRot.x", typeof(float)),
2063 (float)info.GetValue("m_bodyRot.y", typeof(float)),
2064 (float)info.GetValue("m_bodyRot.z", typeof(float)));
2065
2066 IsRestrictedToRegion = (bool)info.GetValue("IsRestrictedToRegion", typeof(bool));
2067 m_newForce = (bool)info.GetValue("m_newForce", typeof(bool));
2068 //m_newAvatar = (bool)info.GetValue("m_newAvatar", typeof(bool));
2069 m_newCoarseLocations = (bool)info.GetValue("m_newCoarseLocations", typeof(bool));
2070 m_gotAllObjectsInScene = (bool)info.GetValue("m_gotAllObjectsInScene", typeof(bool));
2071 m_avHeight = (float)info.GetValue("m_avHeight", typeof(float));
2072 crossingFromRegion = (ulong)info.GetValue("crossingFromRegion", typeof(ulong));
2073
2074 List<float[]> Dir_Vectors_work = (List<float[]>)info.GetValue("Dir_Vectors", typeof(List<float[]>));
2075 List<Vector3> Dir_Vectors_work2 = new List<Vector3>();
2076
2077 foreach (float[] f3 in Dir_Vectors_work)
2078 {
2079 Dir_Vectors_work2.Add(new Vector3(f3[0], f3[1], f3[2]));
2080 }
2081
2082 Dir_Vectors = Dir_Vectors_work2.ToArray();
2083
2084 lastPhysPos
2085 = new LLVector3(
2086 (float)info.GetValue("lastPhysPos.X", typeof(float)),
2087 (float)info.GetValue("lastPhysPos.Y", typeof(float)),
2088 (float)info.GetValue("lastPhysPos.Z", typeof(float)));
2089
2090 m_CameraCenter
2091 = new Vector3(
2092 (float)info.GetValue("m_CameraCenter.X", typeof(float)),
2093 (float)info.GetValue("m_CameraCenter.Y", typeof(float)),
2094 (float)info.GetValue("m_CameraCenter.Z", typeof(float)));
2095
2096 m_CameraAtAxis
2097 = new Vector3(
2098 (float)info.GetValue("m_CameraAtAxis.X", typeof(float)),
2099 (float)info.GetValue("m_CameraAtAxis.Y", typeof(float)),
2100 (float)info.GetValue("m_CameraAtAxis.Z", typeof(float)));
2101
2102 m_CameraLeftAxis
2103 = new Vector3(
2104 (float)info.GetValue("m_CameraLeftAxis.X", typeof(float)),
2105 (float)info.GetValue("m_CameraLeftAxis.Y", typeof(float)),
2106 (float)info.GetValue("m_CameraLeftAxis.Z", typeof(float)));
2107
2108 m_CameraUpAxis
2109 = new Vector3(
2110 (float)info.GetValue("m_CameraUpAxis.X", typeof(float)),
2111 (float)info.GetValue("m_CameraUpAxis.Y", typeof(float)),
2112 (float)info.GetValue("m_CameraUpAxis.Z", typeof(float)));
2113
2114 m_DrawDistance = (float)info.GetValue("m_DrawDistance", typeof(float));
2115 m_appearance = (AvatarAppearance)info.GetValue("m_appearance", typeof(AvatarAppearance));
2116 m_knownChildRegions = (List<ulong>)info.GetValue("m_knownChildRegions", typeof(List<ulong>));
2117
2118 posLastSignificantMove
2119 = new LLVector3(
2120 (float)info.GetValue("posLastSignificantMove.X", typeof(float)),
2121 (float)info.GetValue("posLastSignificantMove.Y", typeof(float)),
2122 (float)info.GetValue("posLastSignificantMove.Z", typeof(float)));
2123
2124 // m_partsUpdateQueue = (UpdateQueue)info.GetValue("m_partsUpdateQueue", typeof(UpdateQueue));
2125
2126 /*
2127 Dictionary<Guid, ScenePartUpdate> updateTimes_work
2128 = (Dictionary<Guid, ScenePartUpdate>)info.GetValue("m_updateTimes", typeof(Dictionary<Guid, ScenePartUpdate>));
2129
2130 foreach (Guid id in updateTimes_work.Keys)
2131 {
2132 m_updateTimes.Add(new LLUUID(id), updateTimes_work[id]);
2133 }
2134 */
2135 m_regionHandle = (ulong)info.GetValue("m_regionHandle", typeof(ulong));
2136 m_firstname = (string)info.GetValue("m_firstname", typeof(string));
2137 m_lastname = (string)info.GetValue("m_lastname", typeof(string));
2138 m_allowMovement = (bool)info.GetValue("m_allowMovement", typeof(bool));
2139 m_parentPosition = new LLVector3((float)info.GetValue("m_parentPosition.X", typeof(float)),
2140 (float)info.GetValue("m_parentPosition.Y", typeof(float)),
2141 (float)info.GetValue("m_parentPosition.Z", typeof(float)));
2142
2143 m_isChildAgent = (bool)info.GetValue("m_isChildAgent", typeof(bool));
2144 m_parentID = (uint)info.GetValue("m_parentID", typeof(uint));
2145
2146// for OpenSim_v0.5
2147 currentParcelUUID = new LLUUID((Guid)info.GetValue("currentParcelUUID", typeof(Guid)));
2148
2149 lastKnownAllowedPosition
2150 = new Vector3(
2151 (float)info.GetValue("lastKnownAllowedPosition.X", typeof(float)),
2152 (float)info.GetValue("lastKnownAllowedPosition.Y", typeof(float)),
2153 (float)info.GetValue("lastKnownAllowedPosition.Z", typeof(float)));
2154
2155 sentMessageAboutRestrictedParcelFlyingDown = (bool)info.GetValue("sentMessageAboutRestrictedParcelFlyingDown", typeof(bool));
2156
2157 m_LastChildAgentUpdatePosition
2158 = new LLVector3(
2159 (float)info.GetValue("m_LastChildAgentUpdatePosition.X", typeof(float)),
2160 (float)info.GetValue("m_LastChildAgentUpdatePosition.Y", typeof(float)),
2161 (float)info.GetValue("m_LastChildAgentUpdatePosition.Z", typeof(float)));
2162
2163 m_perfMonMS = (int)info.GetValue("m_perfMonMS", typeof(int));
2164 m_AgentControlFlags = (uint)info.GetValue("m_AgentControlFlags", typeof(uint));
2165
2166 m_headrotation
2167 = new LLQuaternion(
2168 (float)info.GetValue("m_headrotation.W", typeof(float)),
2169 (float)info.GetValue("m_headrotation.X", typeof(float)),
2170 (float)info.GetValue("m_headrotation.Y", typeof(float)),
2171 (float)info.GetValue("m_headrotation.Z", typeof(float)));
2172
2173 m_state = (byte)info.GetValue("m_state", typeof(byte));
2174
2175 List<Guid> knownPrimUUID_work = (List<Guid>)info.GetValue("m_knownPrimUUID", typeof(List<Guid>));
2176
2177 foreach (Guid id in knownPrimUUID_work)
2178 {
2179 m_knownPrimUUID.Add(new LLUUID(id));
2180 }
2181
2182 //System.Console.WriteLine("ScenePresence Deserialize END");
2183 }
2184
2185 [SecurityPermission(SecurityAction.LinkDemand,
2186 Flags = SecurityPermissionFlag.SerializationFormatter)]
2187 public override void GetObjectData(
2188 SerializationInfo info, StreamingContext context)
2189 {
2190 if (info == null)
2191 {
2192 throw new ArgumentNullException("info");
2193 }
2194
2195 base.GetObjectData(info, context);
2196
2197 List<Guid> animations_work = new List<Guid>();
2198
2199 foreach (LLUUID uuid in m_animations)
2200 {
2201 animations_work.Add(uuid.UUID);
2202 }
2203
2204 info.AddValue("m_animations", animations_work);
2205
2206 info.AddValue("m_animationSeqs", m_animationSeqs);
2207 info.AddValue("m_updateflag", m_updateflag);
2208 info.AddValue("m_movementflag", m_movementflag);
2209 info.AddValue("m_forcesList", m_forcesList);
2210 info.AddValue("m_updateCount", m_updateCount);
2211 info.AddValue("m_requestedSitTargetID", m_requestedSitTargetID);
2212
2213 // LLVector3
2214 info.AddValue("m_requestedSitOffset.X", m_requestedSitOffset.X);
2215 info.AddValue("m_requestedSitOffset.Y", m_requestedSitOffset.Y);
2216 info.AddValue("m_requestedSitOffset.Z", m_requestedSitOffset.Z);
2217
2218 info.AddValue("m_sitAvatarHeight", m_sitAvatarHeight);
2219 info.AddValue("m_godlevel", m_godlevel);
2220 info.AddValue("m_setAlwaysRun", m_setAlwaysRun);
2221
2222 // Quaternion
2223 info.AddValue("m_bodyRot.w", m_bodyRot.w);
2224 info.AddValue("m_bodyRot.x", m_bodyRot.x);
2225 info.AddValue("m_bodyRot.y", m_bodyRot.y);
2226 info.AddValue("m_bodyRot.z", m_bodyRot.z);
2227
2228 info.AddValue("IsRestrictedToRegion", IsRestrictedToRegion);
2229 info.AddValue("m_newForce", m_newForce);
2230 //info.AddValue("m_newAvatar", m_newAvatar);
2231 info.AddValue("m_newCoarseLocations", m_newCoarseLocations);
2232 info.AddValue("m_gotAllObjectsInScene", m_gotAllObjectsInScene);
2233 info.AddValue("m_avHeight", m_avHeight);
2234
2235 // info.AddValue("m_regionInfo", m_regionInfo);
2236
2237 info.AddValue("crossingFromRegion", crossingFromRegion);
2238
2239 List<float[]> Dir_Vectors_work = new List<float[]>();
2240
2241 foreach (Vector3 v3 in Dir_Vectors)
2242 {
2243 Dir_Vectors_work.Add(new float[] { v3.x, v3.y, v3.z });
2244 }
2245
2246 info.AddValue("Dir_Vectors", Dir_Vectors_work);
2247
2248 // LLVector3
2249 info.AddValue("lastPhysPos.X", lastPhysPos.X);
2250 info.AddValue("lastPhysPos.Y", lastPhysPos.Y);
2251 info.AddValue("lastPhysPos.Z", lastPhysPos.Z);
2252
2253 // Vector3
2254 info.AddValue("m_CameraCenter.X", m_CameraCenter.x);
2255 info.AddValue("m_CameraCenter.Y", m_CameraCenter.y);
2256 info.AddValue("m_CameraCenter.Z", m_CameraCenter.z);
2257
2258 // Vector3
2259 info.AddValue("m_CameraAtAxis.X", m_CameraAtAxis.x);
2260 info.AddValue("m_CameraAtAxis.Y", m_CameraAtAxis.y);
2261 info.AddValue("m_CameraAtAxis.Z", m_CameraAtAxis.z);
2262
2263 // Vector3
2264 info.AddValue("m_CameraLeftAxis.X", m_CameraLeftAxis.x);
2265 info.AddValue("m_CameraLeftAxis.Y", m_CameraLeftAxis.y);
2266 info.AddValue("m_CameraLeftAxis.Z", m_CameraLeftAxis.z);
2267
2268 // Vector3
2269 info.AddValue("m_CameraUpAxis.X", m_CameraUpAxis.x);
2270 info.AddValue("m_CameraUpAxis.Y", m_CameraUpAxis.y);
2271 info.AddValue("m_CameraUpAxis.Z", m_CameraUpAxis.z);
2272
2273 info.AddValue("m_DrawDistance", m_DrawDistance);
2274 info.AddValue("m_appearance", m_appearance);
2275 info.AddValue("m_knownChildRegions", m_knownChildRegions);
2276
2277 // LLVector3
2278 info.AddValue("posLastSignificantMove.X", posLastSignificantMove.X);
2279 info.AddValue("posLastSignificantMove.Y", posLastSignificantMove.Y);
2280 info.AddValue("posLastSignificantMove.Z", posLastSignificantMove.Z);
2281
2282 //info.AddValue("m_partsUpdateQueue", m_partsUpdateQueue);
2283
2284 /*
2285 Dictionary<Guid, ScenePartUpdate> updateTimes_work = new Dictionary<Guid, ScenePartUpdate>();
2286
2287 foreach ( LLUUID id in m_updateTimes.Keys)
2288 {
2289 updateTimes_work.Add(id.UUID, m_updateTimes[id]);
2290 }
2291
2292 info.AddValue("m_updateTimes", updateTimes_work);
2293 */
2294
2295 info.AddValue("m_regionHandle", m_regionHandle);
2296 info.AddValue("m_firstname", m_firstname);
2297 info.AddValue("m_lastname", m_lastname);
2298 info.AddValue("m_allowMovement", m_allowMovement);
2299 //info.AddValue("m_physicsActor", m_physicsActor);
2300 info.AddValue("m_parentPosition.X", m_parentPosition.X);
2301 info.AddValue("m_parentPosition.Y", m_parentPosition.Y);
2302 info.AddValue("m_parentPosition.Z", m_parentPosition.Z);
2303 info.AddValue("m_isChildAgent", m_isChildAgent);
2304 info.AddValue("m_parentID", m_parentID);
2305
2306// for OpenSim_v0.5
2307 info.AddValue("currentParcelUUID", currentParcelUUID.UUID);
2308
2309 info.AddValue("lastKnownAllowedPosition.X", lastKnownAllowedPosition.x);
2310 info.AddValue("lastKnownAllowedPosition.Y", lastKnownAllowedPosition.y);
2311 info.AddValue("lastKnownAllowedPosition.Z", lastKnownAllowedPosition.z);
2312
2313 info.AddValue("sentMessageAboutRestrictedParcelFlyingDown", sentMessageAboutRestrictedParcelFlyingDown);
2314
2315 info.AddValue("m_LastChildAgentUpdatePosition.X", m_LastChildAgentUpdatePosition.X);
2316 info.AddValue("m_LastChildAgentUpdatePosition.Y", m_LastChildAgentUpdatePosition.Y);
2317 info.AddValue("m_LastChildAgentUpdatePosition.Z", m_LastChildAgentUpdatePosition.Z);
2318
2319 info.AddValue("m_perfMonMS", m_perfMonMS);
2320 info.AddValue("m_AgentControlFlags", m_AgentControlFlags);
2321
2322 info.AddValue("m_headrotation.W", m_headrotation.W);
2323 info.AddValue("m_headrotation.X", m_headrotation.X);
2324 info.AddValue("m_headrotation.Y", m_headrotation.Y);
2325 info.AddValue("m_headrotation.Z", m_headrotation.Z);
2326
2327 info.AddValue("m_state", m_state);
2328
2329 List<Guid> knownPrimUUID_work = new List<Guid>();
2330
2331 foreach (LLUUID id in m_knownPrimUUID)
2332 {
2333 knownPrimUUID_work.Add(id.UUID);
2334 }
2335
2336 info.AddValue("m_knownPrimUUID", knownPrimUUID_work);
2337 }
2338 } 2332 }
2339} 2333} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Scenes/SceneXmlLoader.cs b/OpenSim/Region/Environment/Scenes/SceneXmlLoader.cs
index 8390f64..386d87b 100644
--- a/OpenSim/Region/Environment/Scenes/SceneXmlLoader.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneXmlLoader.cs
@@ -39,8 +39,8 @@ namespace OpenSim.Region.Environment.Scenes
39 public class SceneXmlLoader // can move to a module? 39 public class SceneXmlLoader // can move to a module?
40 { 40 {
41 protected InnerScene m_innerScene; 41 protected InnerScene m_innerScene;
42 protected RegionInfo m_regInfo;
43 protected Scene m_parentScene; 42 protected Scene m_parentScene;
43 protected RegionInfo m_regInfo;
44 44
45 public SceneXmlLoader(Scene parentScene, InnerScene innerScene, RegionInfo regionInfo) 45 public SceneXmlLoader(Scene parentScene, InnerScene innerScene, RegionInfo regionInfo)
46 { 46 {
@@ -136,14 +136,13 @@ namespace OpenSim.Region.Environment.Scenes
136 returnstring += grp.ToXmlString2(); 136 returnstring += grp.ToXmlString2();
137 returnstring += "</scene>\n"; 137 returnstring += "</scene>\n";
138 return returnstring; 138 return returnstring;
139
140 } 139 }
141 140
142 public void LoadGroupFromXml2String(string xmlString) 141 public void LoadGroupFromXml2String(string xmlString)
143 { 142 {
144 XmlDocument doc = new XmlDocument(); 143 XmlDocument doc = new XmlDocument();
145 XmlNode rootNode; 144 XmlNode rootNode;
146 145
147 XmlTextReader reader = new XmlTextReader(new StringReader(xmlString)); 146 XmlTextReader reader = new XmlTextReader(new StringReader(xmlString));
148 reader.WhitespaceHandling = WhitespaceHandling.None; 147 reader.WhitespaceHandling = WhitespaceHandling.None;
149 doc.Load(reader); 148 doc.Load(reader);
@@ -153,7 +152,6 @@ namespace OpenSim.Region.Environment.Scenes
153 { 152 {
154 CreatePrimFromXml(aPrimNode.OuterXml); 153 CreatePrimFromXml(aPrimNode.OuterXml);
155 } 154 }
156
157 } 155 }
158 156
159 public void LoadPrimsFromXml2(string fileName) 157 public void LoadPrimsFromXml2(string fileName)
@@ -206,7 +204,7 @@ namespace OpenSim.Region.Environment.Scenes
206 rootPart.PhysActor.LocalID = rootPart.LocalId; 204 rootPart.PhysActor.LocalID = rootPart.LocalId;
207 rootPart.DoPhysicsPropertyUpdate(UsePhysics, true); 205 rootPart.DoPhysicsPropertyUpdate(UsePhysics, true);
208 } 206 }
209 rootPart.Velocity = receivedVelocity; 207 rootPart.Velocity = receivedVelocity;
210 } 208 }
211 209
212 obj.ScheduleGroupForFullUpdate(); 210 obj.ScheduleGroupForFullUpdate();
@@ -234,4 +232,4 @@ namespace OpenSim.Region.Environment.Scenes
234 file.Close(); 232 file.Close();
235 } 233 }
236 } 234 }
237} 235} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Scenes/Scripting/IScriptHost.cs b/OpenSim/Region/Environment/Scenes/Scripting/IScriptHost.cs
index dbe2516..ccb2aa7 100644
--- a/OpenSim/Region/Environment/Scenes/Scripting/IScriptHost.cs
+++ b/OpenSim/Region/Environment/Scenes/Scripting/IScriptHost.cs
@@ -44,4 +44,4 @@ namespace OpenSim.Region.Environment.Scenes.Scripting
44 string TouchName { get; set; } 44 string TouchName { get; set; }
45 void SetText(string text, Vector3 color, double alpha); 45 void SetText(string text, Vector3 color, double alpha);
46 } 46 }
47} 47} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Scenes/Scripting/NullScriptHost.cs b/OpenSim/Region/Environment/Scenes/Scripting/NullScriptHost.cs
index 4b1b56a..a37ce53 100644
--- a/OpenSim/Region/Environment/Scenes/Scripting/NullScriptHost.cs
+++ b/OpenSim/Region/Environment/Scenes/Scripting/NullScriptHost.cs
@@ -33,7 +33,9 @@ namespace OpenSim.Region.Environment.Scenes.Scripting
33{ 33{
34 public class NullScriptHost : IScriptHost 34 public class NullScriptHost : IScriptHost
35 { 35 {
36 private LLVector3 m_pos = new LLVector3(128, 128, 30); 36 private readonly LLVector3 m_pos = new LLVector3(128, 128, 30);
37
38 #region IScriptHost Members
37 39
38 public string Name 40 public string Name
39 { 41 {
@@ -83,5 +85,7 @@ namespace OpenSim.Region.Environment.Scenes.Scripting
83 { 85 {
84 Console.WriteLine("Tried to SetText [{0}] on NullScriptHost", text); 86 Console.WriteLine("Tried to SetText [{0}] on NullScriptHost", text);
85 } 87 }
88
89 #endregion
86 } 90 }
87} 91} \ 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 b1ee519..cb0e1e8 100644
--- a/OpenSim/Region/Environment/Scenes/Scripting/ScriptEngineInterface.cs
+++ b/OpenSim/Region/Environment/Scenes/Scripting/ScriptEngineInterface.cs
@@ -35,4 +35,4 @@ namespace OpenSim.Region.Environment.Scenes.Scripting
35 void Shutdown(); 35 void Shutdown();
36// void StartScript(string ScriptID, IScriptHost ObjectID); 36// void StartScript(string ScriptID, IScriptHost ObjectID);
37 } 37 }
38} 38} \ 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 6216e2c..0048e6b 100644
--- a/OpenSim/Region/Environment/Scenes/Scripting/ScriptEngineLoader.cs
+++ b/OpenSim/Region/Environment/Scenes/Scripting/ScriptEngineLoader.cs
@@ -51,7 +51,7 @@ namespace OpenSim.Region.Environment.Scenes.Scripting
51 { 51 {
52 m_log.Error("[ScriptEngine]: " + 52 m_log.Error("[ScriptEngine]: " +
53 "Error loading assembly \"" + EngineName + "\": " + e.Message + ", " + 53 "Error loading assembly \"" + EngineName + "\": " + e.Message + ", " +
54 e.StackTrace.ToString()); 54 e.StackTrace);
55 } 55 }
56 return ret; 56 return ret;
57 } 57 }
@@ -116,4 +116,4 @@ namespace OpenSim.Region.Environment.Scenes.Scripting
116 return ret; 116 return ret;
117 } 117 }
118 } 118 }
119} 119} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Scenes/SimStatsReporter.cs b/OpenSim/Region/Environment/Scenes/SimStatsReporter.cs
index a53bfcd..1f02f23 100644
--- a/OpenSim/Region/Environment/Scenes/SimStatsReporter.cs
+++ b/OpenSim/Region/Environment/Scenes/SimStatsReporter.cs
@@ -34,105 +34,68 @@ namespace OpenSim.Region.Environment.Scenes
34{ 34{
35 public class SimStatsReporter 35 public class SimStatsReporter
36 { 36 {
37 public delegate void SendStatResult(SimStatsPacket pack); 37 #region Delegates
38
39 public event SendStatResult OnSendStatsResult;
40
41 private SendStatResult handlerSendStatResult = null;
42 38
43 private enum Stats : uint 39 public delegate void SendStatResult(SimStatsPacket pack);
44 {
45 TimeDilation = 0,
46 SimFPS = 1,
47 PhysicsFPS = 2,
48 AgentUpdates = 3,
49 FrameMS = 4,
50 NetMS = 5,
51 OtherMS = 6,
52 PhysicsMS = 7,
53 AgentMS = 8,
54 ImageMS = 9,
55 ScriptMS = 10,
56 TotalPrim = 11,
57 ActivePrim = 12,
58 Agents = 13,
59 ChildAgents = 14,
60 ActiveScripts = 15,
61 ScriptLinesPerSecond = 16,
62 InPacketsPerSecond = 17,
63 OutPacketsPerSecond = 18,
64 PendingDownloads = 19,
65 PendingUploads = 20,
66 UnAckedBytes = 24,
67 40
68 // Havok4 related... May or may not be in upcoming LLclients 41 #endregion
69 // (kelly added them sometime late in January 2008)
70 NumRCCSLODReduced = 25,
71 NumRCCSFixed = 26
72 }
73 42
74 // Sending a stats update every 3 seconds 43 private readonly Timer m_report = new Timer();
75 private int statsUpdatesEveryMS = 3000; 44 private readonly SimStatsPacket.RegionBlock rb = new SimStatsPacket.RegionBlock();
76 private float statsUpdateFactor = 0; 45 private readonly RegionInfo ReportingRegion;
77 private float m_timeDilation = 0; 46 private readonly SimStatsPacket.StatBlock[] sb = new SimStatsPacket.StatBlock[21];
78 private int m_fps = 0; 47 private readonly SimStatsPacket statpack = (SimStatsPacket) PacketPool.Instance.GetPacket(PacketType.SimStats);
79 private float m_pfps = 0; 48
80 private int m_agentUpdates = 0; 49 private SendStatResult handlerSendStatResult;
81 50 private int m_activePrim;
82 private int m_frameMS = 0; 51 private int m_activeScripts;
83 private int m_netMS = 0; 52 private int m_agentMS;
84 private int m_agentMS = 0; 53
85 private int m_physicsMS = 0; 54 private int m_agentUpdates;
86 private int m_imageMS = 0; 55 private int m_childAgents;
87 private int m_otherMS = 0; 56 private int m_fps;
88 57
89//Ckrinke: (3-21-08) Comment out to remove a compiler warning. Bring back into play when needed. 58 private int m_frameMS;
90//Ckrinke private int m_scriptMS = 0; 59 private int m_imageMS;
91 60 private int m_inPacketsPerSecond;
92 private int m_rootAgents = 0; 61 private int m_netMS;
93 private int m_childAgents = 0; 62 private int m_numPrim;
94 private int m_numPrim = 0; 63 private int m_otherMS;
95 private int m_inPacketsPerSecond = 0; 64 private int m_outPacketsPerSecond;
96 private int m_outPacketsPerSecond = 0; 65 private int m_pendingDownloads;
97 private int m_activePrim = 0; 66 private int m_pendingUploads;
98 private int m_unAckedBytes = 0; 67 private float m_pfps;
99 private int m_pendingDownloads = 0; 68 private int m_physicsMS;
100 private int m_pendingUploads = 0; 69 private int m_rootAgents;
101 private int m_activeScripts = 0; 70 private int m_scriptLinesPerSecond;
102 private int m_scriptLinesPerSecond = 0; 71 private float m_timeDilation;
72 private int m_unAckedBytes;
103 73
104 private int objectCapacity = 45000; 74 private int objectCapacity = 45000;
105 75 private float statsUpdateFactor;
106 76 private int statsUpdatesEveryMS = 3000;
107 SimStatsPacket.StatBlock[] sb = new SimStatsPacket.StatBlock[21];
108 SimStatsPacket.RegionBlock rb = new SimStatsPacket.RegionBlock();
109 SimStatsPacket statpack = (SimStatsPacket)PacketPool.Instance.GetPacket(PacketType.SimStats);
110
111
112 private RegionInfo ReportingRegion;
113
114 private Timer m_report = new Timer();
115 77
116 78
117 public SimStatsReporter(RegionInfo regionData) 79 public SimStatsReporter(RegionInfo regionData)
118 { 80 {
119 81 statsUpdateFactor = (statsUpdatesEveryMS / 1000);
120 statsUpdateFactor = (float)(statsUpdatesEveryMS / 1000);
121 ReportingRegion = regionData; 82 ReportingRegion = regionData;
122 for (int i = 0; i<21;i++) 83 for (int i = 0; i < 21; i++)
123 { 84 {
124 sb[i] = new SimStatsPacket.StatBlock(); 85 sb[i] = new SimStatsPacket.StatBlock();
125 } 86 }
126 m_report.AutoReset = true; 87 m_report.AutoReset = true;
127 m_report.Interval = statsUpdatesEveryMS; 88 m_report.Interval = statsUpdatesEveryMS;
128 m_report.Elapsed += new ElapsedEventHandler(statsHeartBeat); 89 m_report.Elapsed += statsHeartBeat;
129 m_report.Enabled = true; 90 m_report.Enabled = true;
130 } 91 }
131 92
93 public event SendStatResult OnSendStatsResult;
94
132 public void SetUpdateMS(int ms) 95 public void SetUpdateMS(int ms)
133 { 96 {
134 statsUpdatesEveryMS = ms; 97 statsUpdatesEveryMS = ms;
135 statsUpdateFactor = (float)(statsUpdatesEveryMS / 1000); 98 statsUpdateFactor = (statsUpdatesEveryMS / 1000);
136 m_report.Interval = statsUpdatesEveryMS; 99 m_report.Interval = statsUpdatesEveryMS;
137 } 100 }
138 101
@@ -143,8 +106,8 @@ namespace OpenSim.Region.Environment.Scenes
143 lock (m_report) 106 lock (m_report)
144 { 107 {
145 // Packet is already initialized and ready for data insert 108 // Packet is already initialized and ready for data insert
146 109
147 110
148 statpack.Region = rb; 111 statpack.Region = rb;
149 statpack.Region.RegionX = ReportingRegion.RegionLocX; 112 statpack.Region.RegionX = ReportingRegion.RegionLocX;
150 statpack.Region.RegionY = ReportingRegion.RegionLocY; 113 statpack.Region.RegionY = ReportingRegion.RegionLocY;
@@ -154,102 +117,102 @@ namespace OpenSim.Region.Environment.Scenes
154 } 117 }
155 catch (Exception) 118 catch (Exception)
156 { 119 {
157 statpack.Region.RegionFlags = (uint) 0; 120 statpack.Region.RegionFlags = 0;
158 } 121 }
159 statpack.Region.ObjectCapacity = (uint) objectCapacity; 122 statpack.Region.ObjectCapacity = (uint) objectCapacity;
160 123
161#region various statistic googly moogly 124 #region various statistic googly moogly
162 125
163 // Our FPS is actually 10fps, so multiplying by 5 to get the amount that people expect there 126 // Our FPS is actually 10fps, so multiplying by 5 to get the amount that people expect there
164 // 0-50 is pretty close to 0-45 127 // 0-50 is pretty close to 0-45
165 float simfps = (int) ((m_fps * 5)); 128 float simfps = ((m_fps * 5));
166 129
167 //if (simfps > 45) 130 //if (simfps > 45)
168 //simfps = simfps - (simfps - 45); 131 //simfps = simfps - (simfps - 45);
169 //if (simfps < 0) 132 //if (simfps < 0)
170 //simfps = 0; 133 //simfps = 0;
171 134
172 // 135 //
173 float physfps = ((m_pfps / 1000)); 136 float physfps = ((m_pfps / 1000));
174 137
175 //if (physfps > 600) 138 //if (physfps > 600)
176 //physfps = physfps - (physfps - 600); 139 //physfps = physfps - (physfps - 600);
177 140
178 if (physfps < 0) 141 if (physfps < 0)
179 physfps = 0; 142 physfps = 0;
180 143
181#endregion 144 #endregion
182 145
183 //Our time dilation is 0.91 when we're running a full speed, 146 //Our time dilation is 0.91 when we're running a full speed,
184 // therefore to make sure we get an appropriate range, 147 // therefore to make sure we get an appropriate range,
185 // we have to factor in our error. (0.10f * statsUpdateFactor) 148 // we have to factor in our error. (0.10f * statsUpdateFactor)
186 // multiplies the fix for the error times the amount of times it'll occur a second 149 // multiplies the fix for the error times the amount of times it'll occur a second
187 // / 10 divides the value by the number of times the sim heartbeat runs (10fps) 150 // / 10 divides the value by the number of times the sim heartbeat runs (10fps)
188 // Then we divide the whole amount by the amount of seconds pass in between stats updates. 151 // Then we divide the whole amount by the amount of seconds pass in between stats updates.
189 152
190 sb[0].StatID = (uint) Stats.TimeDilation; 153 sb[0].StatID = (uint) Stats.TimeDilation;
191 sb[0].StatValue = m_timeDilation ; //((((m_timeDilation + (0.10f * statsUpdateFactor)) /10) / statsUpdateFactor)); 154 sb[0].StatValue = m_timeDilation; //((((m_timeDilation + (0.10f * statsUpdateFactor)) /10) / statsUpdateFactor));
192 155
193 sb[1].StatID = (uint) Stats.SimFPS; 156 sb[1].StatID = (uint) Stats.SimFPS;
194 sb[1].StatValue = simfps/statsUpdateFactor; 157 sb[1].StatValue = simfps / statsUpdateFactor;
195 158
196 sb[2].StatID = (uint) Stats.PhysicsFPS; 159 sb[2].StatID = (uint) Stats.PhysicsFPS;
197 sb[2].StatValue = physfps / statsUpdateFactor; 160 sb[2].StatValue = physfps / statsUpdateFactor;
198 161
199 sb[3].StatID = (uint) Stats.AgentUpdates; 162 sb[3].StatID = (uint) Stats.AgentUpdates;
200 sb[3].StatValue = (m_agentUpdates / statsUpdateFactor); 163 sb[3].StatValue = (m_agentUpdates / statsUpdateFactor);
201 164
202 sb[4].StatID = (uint) Stats.Agents; 165 sb[4].StatID = (uint) Stats.Agents;
203 sb[4].StatValue = m_rootAgents; 166 sb[4].StatValue = m_rootAgents;
204 167
205 sb[5].StatID = (uint) Stats.ChildAgents; 168 sb[5].StatID = (uint) Stats.ChildAgents;
206 sb[5].StatValue = m_childAgents; 169 sb[5].StatValue = m_childAgents;
207 170
208 sb[6].StatID = (uint) Stats.TotalPrim; 171 sb[6].StatID = (uint) Stats.TotalPrim;
209 sb[6].StatValue = m_numPrim; 172 sb[6].StatValue = m_numPrim;
210 173
211 sb[7].StatID = (uint) Stats.ActivePrim; 174 sb[7].StatID = (uint) Stats.ActivePrim;
212 sb[7].StatValue = m_activePrim; 175 sb[7].StatValue = m_activePrim;
213 176
214 sb[8].StatID = (uint)Stats.FrameMS; 177 sb[8].StatID = (uint) Stats.FrameMS;
215 sb[8].StatValue = m_frameMS / statsUpdateFactor; 178 sb[8].StatValue = m_frameMS / statsUpdateFactor;
216 179
217 sb[9].StatID = (uint)Stats.NetMS; 180 sb[9].StatID = (uint) Stats.NetMS;
218 sb[9].StatValue = m_netMS / statsUpdateFactor; 181 sb[9].StatValue = m_netMS / statsUpdateFactor;
219 182
220 sb[10].StatID = (uint)Stats.PhysicsMS; 183 sb[10].StatID = (uint) Stats.PhysicsMS;
221 sb[10].StatValue = m_physicsMS / statsUpdateFactor; 184 sb[10].StatValue = m_physicsMS / statsUpdateFactor;
222 185
223 sb[11].StatID = (uint)Stats.ImageMS ; 186 sb[11].StatID = (uint) Stats.ImageMS;
224 sb[11].StatValue = m_imageMS / statsUpdateFactor; 187 sb[11].StatValue = m_imageMS / statsUpdateFactor;
225 188
226 sb[12].StatID = (uint)Stats.OtherMS; 189 sb[12].StatID = (uint) Stats.OtherMS;
227 sb[12].StatValue = m_otherMS / statsUpdateFactor; 190 sb[12].StatValue = m_otherMS / statsUpdateFactor;
228 191
229 sb[13].StatID = (uint)Stats.InPacketsPerSecond; 192 sb[13].StatID = (uint) Stats.InPacketsPerSecond;
230 sb[13].StatValue = (m_inPacketsPerSecond); 193 sb[13].StatValue = (m_inPacketsPerSecond);
231 194
232 sb[14].StatID = (uint)Stats.OutPacketsPerSecond; 195 sb[14].StatID = (uint) Stats.OutPacketsPerSecond;
233 sb[14].StatValue = (m_outPacketsPerSecond / statsUpdateFactor); 196 sb[14].StatValue = (m_outPacketsPerSecond / statsUpdateFactor);
234 197
235 sb[15].StatID = (uint)Stats.UnAckedBytes; 198 sb[15].StatID = (uint) Stats.UnAckedBytes;
236 sb[15].StatValue = m_unAckedBytes; 199 sb[15].StatValue = m_unAckedBytes;
237 200
238 sb[16].StatID = (uint)Stats.AgentMS; 201 sb[16].StatID = (uint) Stats.AgentMS;
239 sb[16].StatValue = m_agentMS / statsUpdateFactor; 202 sb[16].StatValue = m_agentMS / statsUpdateFactor;
240 203
241 sb[17].StatID = (uint)Stats.PendingDownloads; 204 sb[17].StatID = (uint) Stats.PendingDownloads;
242 sb[17].StatValue = m_pendingDownloads; 205 sb[17].StatValue = m_pendingDownloads;
243 206
244 sb[18].StatID = (uint)Stats.PendingUploads; 207 sb[18].StatID = (uint) Stats.PendingUploads;
245 sb[18].StatValue = m_pendingUploads; 208 sb[18].StatValue = m_pendingUploads;
246 209
247 sb[19].StatID = (uint)Stats.ActiveScripts; 210 sb[19].StatID = (uint) Stats.ActiveScripts;
248 sb[19].StatValue = m_activeScripts; 211 sb[19].StatValue = m_activeScripts;
249 212
250 sb[20].StatID = (uint)Stats.ScriptLinesPerSecond; 213 sb[20].StatID = (uint) Stats.ScriptLinesPerSecond;
251 sb[20].StatValue = m_scriptLinesPerSecond / statsUpdateFactor; 214 sb[20].StatValue = m_scriptLinesPerSecond / statsUpdateFactor;
252 215
253 statpack.Stat = sb; 216 statpack.Stat = sb;
254 217
255 handlerSendStatResult = OnSendStatsResult; 218 handlerSendStatResult = OnSendStatsResult;
@@ -260,7 +223,7 @@ namespace OpenSim.Region.Environment.Scenes
260 resetvalues(); 223 resetvalues();
261 } 224 }
262 } 225 }
263 226
264 private void resetvalues() 227 private void resetvalues()
265 { 228 {
266 m_timeDilation = 0; 229 m_timeDilation = 0;
@@ -284,6 +247,7 @@ namespace OpenSim.Region.Environment.Scenes
284 } 247 }
285 248
286 # region methods called from Scene 249 # region methods called from Scene
250
287 // The majority of these functions are additive 251 // The majority of these functions are additive
288 // so that you can easily change the amount of 252 // so that you can easily change the amount of
289 // seconds in between sim stats updates 253 // seconds in between sim stats updates
@@ -292,10 +256,10 @@ namespace OpenSim.Region.Environment.Scenes
292 { 256 {
293 //float tdsetting = td; 257 //float tdsetting = td;
294 //if (tdsetting > 1.0f) 258 //if (tdsetting > 1.0f)
295 //tdsetting = (tdsetting - (tdsetting - 0.91f)); 259 //tdsetting = (tdsetting - (tdsetting - 0.91f));
296 260
297 //if (tdsetting < 0) 261 //if (tdsetting < 0)
298 //tdsetting = 0.0f; 262 //tdsetting = 0.0f;
299 m_timeDilation = td; 263 m_timeDilation = td;
300 } 264 }
301 265
@@ -353,30 +317,35 @@ namespace OpenSim.Region.Environment.Scenes
353 { 317 {
354 m_frameMS += ms; 318 m_frameMS += ms;
355 } 319 }
320
356 public void addNetMS(int ms) 321 public void addNetMS(int ms)
357 { 322 {
358 m_netMS += ms; 323 m_netMS += ms;
359 } 324 }
325
360 public void addAgentMS(int ms) 326 public void addAgentMS(int ms)
361 { 327 {
362 m_agentMS += ms; 328 m_agentMS += ms;
363 } 329 }
330
364 public void addPhysicsMS(int ms) 331 public void addPhysicsMS(int ms)
365 { 332 {
366 m_physicsMS += ms; 333 m_physicsMS += ms;
367 } 334 }
335
368 public void addImageMS(int ms) 336 public void addImageMS(int ms)
369 { 337 {
370 m_imageMS += ms; 338 m_imageMS += ms;
371 } 339 }
340
372 public void addOtherMS(int ms) 341 public void addOtherMS(int ms)
373 { 342 {
374 m_otherMS += ms; 343 m_otherMS += ms;
375 } 344 }
376 345
377// private static readonly log4net.ILog m_log 346// private static readonly log4net.ILog m_log
378// = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); 347// = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
379 348
380 public void addPendingDownload(int count) 349 public void addPendingDownload(int count)
381 { 350 {
382 m_pendingDownloads += count; 351 m_pendingDownloads += count;
@@ -399,5 +368,40 @@ namespace OpenSim.Region.Environment.Scenes
399 } 368 }
400 369
401 #endregion 370 #endregion
371
372 #region Nested type: Stats
373
374 private enum Stats : uint
375 {
376 TimeDilation = 0,
377 SimFPS = 1,
378 PhysicsFPS = 2,
379 AgentUpdates = 3,
380 FrameMS = 4,
381 NetMS = 5,
382 OtherMS = 6,
383 PhysicsMS = 7,
384 AgentMS = 8,
385 ImageMS = 9,
386 ScriptMS = 10,
387 TotalPrim = 11,
388 ActivePrim = 12,
389 Agents = 13,
390 ChildAgents = 14,
391 ActiveScripts = 15,
392 ScriptLinesPerSecond = 16,
393 InPacketsPerSecond = 17,
394 OutPacketsPerSecond = 18,
395 PendingDownloads = 19,
396 PendingUploads = 20,
397 UnAckedBytes = 24,
398
399 // Havok4 related... May or may not be in upcoming LLclients
400 // (kelly added them sometime late in January 2008)
401 NumRCCSLODReduced = 25,
402 NumRCCSFixed = 26
403 }
404
405 #endregion
402 } 406 }
403} 407} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Scenes/UndoState.cs b/OpenSim/Region/Environment/Scenes/UndoState.cs
index daabd8d..f16bb34 100644
--- a/OpenSim/Region/Environment/Scenes/UndoState.cs
+++ b/OpenSim/Region/Environment/Scenes/UndoState.cs
@@ -32,8 +32,8 @@ namespace OpenSim.Region.Environment.Scenes
32 public class UndoState 32 public class UndoState
33 { 33 {
34 public LLVector3 Position = LLVector3.Zero; 34 public LLVector3 Position = LLVector3.Zero;
35 public LLVector3 Scale = LLVector3.Zero;
36 public LLQuaternion Rotation = LLQuaternion.Identity; 35 public LLQuaternion Rotation = LLQuaternion.Identity;
36 public LLVector3 Scale = LLVector3.Zero;
37 37
38 public UndoState(LLVector3 pos, LLQuaternion rot, LLVector3 scale) 38 public UndoState(LLVector3 pos, LLQuaternion rot, LLVector3 scale)
39 { 39 {
@@ -41,7 +41,7 @@ namespace OpenSim.Region.Environment.Scenes
41 Rotation = rot; 41 Rotation = rot;
42 Scale = scale; 42 Scale = scale;
43 } 43 }
44 44
45 public UndoState(SceneObjectPart part) 45 public UndoState(SceneObjectPart part)
46 { 46 {
47 if (part != null) 47 if (part != null)
@@ -50,18 +50,20 @@ namespace OpenSim.Region.Environment.Scenes
50 { 50 {
51 Position = part.AbsolutePosition; 51 Position = part.AbsolutePosition;
52 Rotation = part.RotationOffset; 52 Rotation = part.RotationOffset;
53
54 } 53 }
55 else 54 else
56 { 55 {
57 Position = part.GroupPosition; 56 Position = part.GroupPosition;
58 Rotation = part.RotationOffset; 57 Rotation = part.RotationOffset;
59 Scale = part.Shape.Scale; 58 Scale = part.Shape.Scale;
60
61 } 59 }
62 } 60 }
63 } 61 }
64 62
63 public UndoState()
64 {
65 }
66
65 public bool Compare(SceneObjectPart part) 67 public bool Compare(SceneObjectPart part)
66 { 68 {
67 if (part != null) 69 if (part != null)
@@ -79,7 +81,6 @@ namespace OpenSim.Region.Environment.Scenes
79 return true; 81 return true;
80 else 82 else
81 return false; 83 return false;
82
83 } 84 }
84 } 85 }
85 return false; 86 return false;
@@ -90,7 +91,7 @@ namespace OpenSim.Region.Environment.Scenes
90 if (part != null) 91 if (part != null)
91 { 92 {
92 part.m_undoing = true; 93 part.m_undoing = true;
93 94
94 if (part.ParentID == 0) 95 if (part.ParentID == 0)
95 { 96 {
96 part.ParentGroup.AbsolutePosition = Position; 97 part.ParentGroup.AbsolutePosition = Position;
@@ -105,12 +106,7 @@ namespace OpenSim.Region.Environment.Scenes
105 part.ScheduleTerseUpdate(); 106 part.ScheduleTerseUpdate();
106 } 107 }
107 part.m_undoing = false; 108 part.m_undoing = false;
108
109 } 109 }
110 } 110 }
111
112 public UndoState()
113 {
114 }
115 } 111 }
116} 112} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/StorageManager.cs b/OpenSim/Region/Environment/StorageManager.cs
index b9a42a2..2178b5e 100644
--- a/OpenSim/Region/Environment/StorageManager.cs
+++ b/OpenSim/Region/Environment/StorageManager.cs
@@ -36,12 +36,7 @@ namespace OpenSim.Region.Environment
36 { 36 {
37 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 37 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
38 38
39 private IRegionDataStore m_dataStore; 39 private readonly IRegionDataStore m_dataStore;
40
41 public IRegionDataStore DataStore
42 {
43 get { return m_dataStore; }
44 }
45 40
46 public StorageManager(IRegionDataStore storage) 41 public StorageManager(IRegionDataStore storage)
47 { 42 {
@@ -74,5 +69,10 @@ namespace OpenSim.Region.Environment
74 69
75 //TODO: Add checking and warning to make sure it initialised. 70 //TODO: Add checking and warning to make sure it initialised.
76 } 71 }
72
73 public IRegionDataStore DataStore
74 {
75 get { return m_dataStore; }
76 }
77 } 77 }
78} 78} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Types/BasicQuadTreeNode.cs b/OpenSim/Region/Environment/Types/BasicQuadTreeNode.cs
index 24ce94b..41f17e5 100644
--- a/OpenSim/Region/Environment/Types/BasicQuadTreeNode.cs
+++ b/OpenSim/Region/Environment/Types/BasicQuadTreeNode.cs
@@ -33,16 +33,15 @@ namespace OpenSim.Region.Environment.Types
33{ 33{
34 public class BasicQuadTreeNode 34 public class BasicQuadTreeNode
35 { 35 {
36 private List<SceneObjectGroup> m_objects = new List<SceneObjectGroup>(); 36 private readonly short m_height;
37 private BasicQuadTreeNode[] m_childNodes = null; 37 private readonly short m_leftX;
38 private BasicQuadTreeNode m_parent = null; 38 private readonly short m_leftY;
39 39 private readonly List<SceneObjectGroup> m_objects = new List<SceneObjectGroup>();
40 private short m_leftX; 40 private readonly BasicQuadTreeNode m_parent;
41 private short m_leftY;
42 private short m_width;
43 private short m_height;
44 //private int m_quadNumber; 41 //private int m_quadNumber;
45 private string m_quadID; 42 private readonly string m_quadID;
43 private readonly short m_width;
44 private BasicQuadTreeNode[] m_childNodes;
46 45
47 public BasicQuadTreeNode(BasicQuadTreeNode parent, string quadID, short leftX, short leftY, short width, 46 public BasicQuadTreeNode(BasicQuadTreeNode parent, string quadID, short leftX, short leftY, short width,
48 short height) 47 short height)
@@ -67,9 +66,9 @@ namespace OpenSim.Region.Environment.Types
67 } 66 }
68 else 67 else
69 { 68 {
70 if (obj.AbsolutePosition.X < (m_leftX + (m_width/2))) 69 if (obj.AbsolutePosition.X < (m_leftX + (m_width / 2)))
71 { 70 {
72 if (obj.AbsolutePosition.Y < (m_leftY + (m_height/2))) 71 if (obj.AbsolutePosition.Y < (m_leftY + (m_height / 2)))
73 { 72 {
74 m_childNodes[0].AddObject(obj); 73 m_childNodes[0].AddObject(obj);
75 } 74 }
@@ -80,7 +79,7 @@ namespace OpenSim.Region.Environment.Types
80 } 79 }
81 else 80 else
82 { 81 {
83 if (obj.AbsolutePosition.Y < (m_leftY + (m_height/2))) 82 if (obj.AbsolutePosition.Y < (m_leftY + (m_height / 2)))
84 { 83 {
85 m_childNodes[1].AddObject(obj); 84 m_childNodes[1].AddObject(obj);
86 } 85 }
@@ -98,17 +97,17 @@ namespace OpenSim.Region.Environment.Types
98 { 97 {
99 m_childNodes = new BasicQuadTreeNode[4]; 98 m_childNodes = new BasicQuadTreeNode[4];
100 m_childNodes[0] = 99 m_childNodes[0] =
101 new BasicQuadTreeNode(this, m_quadID + "1/", m_leftX, m_leftY, (short) (m_width/2), 100 new BasicQuadTreeNode(this, m_quadID + "1/", m_leftX, m_leftY, (short) (m_width / 2),
102 (short) (m_height/2)); 101 (short) (m_height / 2));
103 m_childNodes[1] = 102 m_childNodes[1] =
104 new BasicQuadTreeNode(this, m_quadID + "2/", (short) (m_leftX + (m_width/2)), m_leftY, 103 new BasicQuadTreeNode(this, m_quadID + "2/", (short) (m_leftX + (m_width / 2)), m_leftY,
105 (short) (m_width/2), (short) (m_height/2)); 104 (short) (m_width / 2), (short) (m_height / 2));
106 m_childNodes[2] = 105 m_childNodes[2] =
107 new BasicQuadTreeNode(this, m_quadID + "3/", m_leftX, (short) (m_leftY + (m_height/2)), 106 new BasicQuadTreeNode(this, m_quadID + "3/", m_leftX, (short) (m_leftY + (m_height / 2)),
108 (short) (m_width/2), (short) (m_height/2)); 107 (short) (m_width / 2), (short) (m_height / 2));
109 m_childNodes[3] = 108 m_childNodes[3] =
110 new BasicQuadTreeNode(this, m_quadID + "4/", (short) (m_leftX + (m_width/2)), 109 new BasicQuadTreeNode(this, m_quadID + "4/", (short) (m_leftX + (m_width / 2)),
111 (short) (m_height + (m_height/2)), (short) (m_width/2), (short) (m_height/2)); 110 (short) (m_height + (m_height / 2)), (short) (m_width / 2), (short) (m_height / 2));
112 } 111 }
113 else 112 else
114 { 113 {
@@ -127,9 +126,9 @@ namespace OpenSim.Region.Environment.Types
127 } 126 }
128 else 127 else
129 { 128 {
130 if (x < m_leftX + (m_width/2)) 129 if (x < m_leftX + (m_width / 2))
131 { 130 {
132 if (y < m_leftY + (m_height/2)) 131 if (y < m_leftY + (m_height / 2))
133 { 132 {
134 return m_childNodes[0].GetObjectsFrom(x, y); 133 return m_childNodes[0].GetObjectsFrom(x, y);
135 } 134 }
@@ -140,7 +139,7 @@ namespace OpenSim.Region.Environment.Types
140 } 139 }
141 else 140 else
142 { 141 {
143 if (y < m_leftY + (m_height/2)) 142 if (y < m_leftY + (m_height / 2))
144 { 143 {
145 return m_childNodes[1].GetObjectsFrom(x, y); 144 return m_childNodes[1].GetObjectsFrom(x, y);
146 } 145 }
@@ -181,9 +180,9 @@ namespace OpenSim.Region.Environment.Types
181 } 180 }
182 else 181 else
183 { 182 {
184 if (x < m_leftX + (m_width/2)) 183 if (x < m_leftX + (m_width / 2))
185 { 184 {
186 if (y < m_leftY + (m_height/2)) 185 if (y < m_leftY + (m_height / 2))
187 { 186 {
188 return m_childNodes[0].GetNodeID(x, y); 187 return m_childNodes[0].GetNodeID(x, y);
189 } 188 }
@@ -194,7 +193,7 @@ namespace OpenSim.Region.Environment.Types
194 } 193 }
195 else 194 else
196 { 195 {
197 if (y < m_leftY + (m_height/2)) 196 if (y < m_leftY + (m_height / 2))
198 { 197 {
199 return m_childNodes[1].GetNodeID(x, y); 198 return m_childNodes[1].GetNodeID(x, y);
200 } 199 }
@@ -266,4 +265,4 @@ namespace OpenSim.Region.Environment.Types
266 return retVal; 265 return retVal;
267 } 266 }
268 } 267 }
269} 268} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Types/UpdateQueue.cs b/OpenSim/Region/Environment/Types/UpdateQueue.cs
index ec1ffd2..24fe116 100644
--- a/OpenSim/Region/Environment/Types/UpdateQueue.cs
+++ b/OpenSim/Region/Environment/Types/UpdateQueue.cs
@@ -34,26 +34,70 @@ using OpenSim.Region.Environment.Scenes;
34 34
35namespace OpenSim.Region.Environment.Types 35namespace OpenSim.Region.Environment.Types
36{ 36{
37 [Serializable] 37 [Serializable]
38 public class UpdateQueue : ISerializable 38 public class UpdateQueue : ISerializable
39 { 39 {
40 private Queue<SceneObjectPart> m_queue; 40 private readonly List<LLUUID> m_ids;
41 private readonly Queue<SceneObjectPart> m_queue;
41 42
42 private List<LLUUID> m_ids; 43 private readonly object m_syncObject = new object();
43 44
44 private object m_syncObject = new object(); 45 public UpdateQueue()
46 {
47 m_queue = new Queue<SceneObjectPart>();
48 m_ids = new List<LLUUID>();
49 }
50
51 protected UpdateQueue(SerializationInfo info, StreamingContext context)
52 {
53 //System.Console.WriteLine("UpdateQueue Deserialize BGN");
54
55 if (info == null)
56 {
57 throw new ArgumentNullException("info");
58 }
59
60 m_queue = (Queue<SceneObjectPart>) info.GetValue("m_queue", typeof (Queue<SceneObjectPart>));
61 List<Guid> ids_work = (List<Guid>) info.GetValue("m_ids", typeof (List<Guid>));
62
63 foreach (Guid guid in ids_work)
64 {
65 m_ids.Add(new LLUUID(guid));
66 }
67
68 //System.Console.WriteLine("UpdateQueue Deserialize END");
69 }
45 70
46 public int Count 71 public int Count
47 { 72 {
48 get { return m_queue.Count; } 73 get { return m_queue.Count; }
49 } 74 }
50 75
51 public UpdateQueue() 76 #region ISerializable Members
77
78 [SecurityPermission(SecurityAction.LinkDemand,
79 Flags = SecurityPermissionFlag.SerializationFormatter)]
80 public virtual void GetObjectData(
81 SerializationInfo info, StreamingContext context)
52 { 82 {
53 m_queue = new Queue<SceneObjectPart>(); 83 if (info == null)
54 m_ids = new List<LLUUID>(); 84 {
85 throw new ArgumentNullException("info");
86 }
87
88 List<Guid> ids_work = new List<Guid>();
89
90 foreach (LLUUID uuid in m_ids)
91 {
92 ids_work.Add(uuid.UUID);
93 }
94
95 info.AddValue("m_queue", m_queue);
96 info.AddValue("m_ids", ids_work);
55 } 97 }
56 98
99 #endregion
100
57 public void Clear() 101 public void Clear()
58 { 102 {
59 lock (m_syncObject) 103 lock (m_syncObject)
@@ -89,46 +133,5 @@ namespace OpenSim.Region.Environment.Types
89 133
90 return part; 134 return part;
91 } 135 }
92
93 protected UpdateQueue(SerializationInfo info, StreamingContext context)
94 {
95 //System.Console.WriteLine("UpdateQueue Deserialize BGN");
96
97 if (info == null)
98 {
99 throw new ArgumentNullException("info");
100 }
101
102 m_queue = (Queue<SceneObjectPart>)info.GetValue("m_queue", typeof(Queue<SceneObjectPart>));
103 List<Guid> ids_work = (List<Guid>)info.GetValue("m_ids", typeof(List<Guid>));
104
105 foreach (Guid guid in ids_work)
106 {
107 m_ids.Add(new LLUUID(guid));
108 }
109
110 //System.Console.WriteLine("UpdateQueue Deserialize END");
111 }
112
113 [SecurityPermission(SecurityAction.LinkDemand,
114 Flags = SecurityPermissionFlag.SerializationFormatter)]
115 public virtual void GetObjectData(
116 SerializationInfo info, StreamingContext context)
117 {
118 if (info == null)
119 {
120 throw new ArgumentNullException("info");
121 }
122
123 List<Guid> ids_work = new List<Guid>();
124
125 foreach (LLUUID uuid in m_ids)
126 {
127 ids_work.Add(uuid.UUID);
128 }
129
130 info.AddValue("m_queue", m_queue);
131 info.AddValue("m_ids", ids_work);
132 }
133 } 136 }
134} 137} \ No newline at end of file