aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment
diff options
context:
space:
mode:
authorAdam Frisby2008-05-01 18:04:42 +0000
committerAdam Frisby2008-05-01 18:04:42 +0000
commit20a9bf08f51351e1e0a9de94f184ff56cd572665 (patch)
tree52da64dab26353b903c8e4befed0178fa72a188b /OpenSim/Region/Environment
parentMore config cleanup in LaunchSLClient. (diff)
downloadopensim-SC_OLD-20a9bf08f51351e1e0a9de94f184ff56cd572665.zip
opensim-SC_OLD-20a9bf08f51351e1e0a9de94f184ff56cd572665.tar.gz
opensim-SC_OLD-20a9bf08f51351e1e0a9de94f184ff56cd572665.tar.bz2
opensim-SC_OLD-20a9bf08f51351e1e0a9de94f184ff56cd572665.tar.xz
* Rolled back a few changes.
Diffstat (limited to 'OpenSim/Region/Environment')
-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, 4029 insertions, 3896 deletions
diff --git a/OpenSim/Region/Environment/InstantMessageReceiver.cs b/OpenSim/Region/Environment/InstantMessageReceiver.cs
index cc7880d..b82b4aa 100644
--- a/OpenSim/Region/Environment/InstantMessageReceiver.cs
+++ b/OpenSim/Region/Environment/InstantMessageReceiver.cs
@@ -32,10 +32,13 @@ 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
35 // This prevents the Modules from sending Instant messages to other modules through the scene 36 // This prevents the Modules from sending Instant messages to other modules through the scene
36 // and then receiving the same messages 37 // and then receiving the same messages
38
37 // This is mostly here because on LLSL and the SecondLife Client, IMs,Groups and friends are linked 39 // This is mostly here because on LLSL and the SecondLife Client, IMs,Groups and friends are linked
38 // inseparably 40 // inseparably
41
39 [Flags] 42 [Flags]
40 public enum InstantMessageReceiver : uint 43 public enum InstantMessageReceiver : uint
41 { 44 {
@@ -48,4 +51,4 @@ namespace OpenSim.Region.Environment
48 /// <summary>The Groups Module</summary> 51 /// <summary>The Groups Module</summary>
49 GroupsModule = 0x00000004 52 GroupsModule = 0x00000004
50 } 53 }
51} \ No newline at end of file 54}
diff --git a/OpenSim/Region/Environment/Interfaces/IAgentAssetTransactions.cs b/OpenSim/Region/Environment/Interfaces/IAgentAssetTransactions.cs
index 5d2ec89..c099fa1 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} \ No newline at end of file 44}
diff --git a/OpenSim/Region/Environment/Interfaces/IAvatarFactory.cs b/OpenSim/Region/Environment/Interfaces/IAvatarFactory.cs
index d5473fb..3ebbaab 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} \ No newline at end of file 38}
diff --git a/OpenSim/Region/Environment/Interfaces/IHttpRequests.cs b/OpenSim/Region/Environment/Interfaces/IHttpRequests.cs
index 8e2c978..46ba9b2 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} \ No newline at end of file 42}
diff --git a/OpenSim/Region/Environment/Interfaces/ILandChannel.cs b/OpenSim/Region/Environment/Interfaces/ILandChannel.cs
index 8486f70..464a213 100644
--- a/OpenSim/Region/Environment/Interfaces/ILandChannel.cs
+++ b/OpenSim/Region/Environment/Interfaces/ILandChannel.cs
@@ -70,8 +70,7 @@ 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);
73 74
74 void handleParcelAccessUpdateRequest(LLUUID agentID, LLUUID sessionID, uint flags, int landLocalID, List<ParcelManager.ParcelAccessEntry> entries,
75 IClientAPI remote_client);
76 } 75 }
77} \ No newline at end of file 76}
diff --git a/OpenSim/Region/Environment/Interfaces/IRegionDataStore.cs b/OpenSim/Region/Environment/Interfaces/IRegionDataStore.cs
index e7af0a9..c757461 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} \ No newline at end of file 77}
diff --git a/OpenSim/Region/Environment/Interfaces/IRegionModule.cs b/OpenSim/Region/Environment/Interfaces/IRegionModule.cs
index 80698d5..ffa4f32 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; }
37 void Initialise(Scene scene, IConfigSource source); 35 void Initialise(Scene scene, IConfigSource source);
38 void PostInitialise(); 36 void PostInitialise();
39 void Close(); 37 void Close();
38 string Name { get; }
39 bool IsSharedModule { get; }
40 } 40 }
41} \ No newline at end of file 41}
diff --git a/OpenSim/Region/Environment/Interfaces/ISimChat.cs b/OpenSim/Region/Environment/Interfaces/ISimChat.cs
index 9335b00..d52e58b 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} \ No newline at end of file 37}
diff --git a/OpenSim/Region/Environment/Interfaces/IWorldComm.cs b/OpenSim/Region/Environment/Interfaces/IWorldComm.cs
index 992db19..8a63c54 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} \ No newline at end of file 46}
diff --git a/OpenSim/Region/Environment/Interfaces/IXMLRPC.cs b/OpenSim/Region/Environment/Interfaces/IXMLRPC.cs
index 959b0b7..6c1d025 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} \ No newline at end of file 48}
diff --git a/OpenSim/Region/Environment/Interfaces/IXfer.cs b/OpenSim/Region/Environment/Interfaces/IXfer.cs
index bb2caca..bad1833 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} \ No newline at end of file 34}
diff --git a/OpenSim/Region/Environment/ModuleLoader.cs b/OpenSim/Region/Environment/ModuleLoader.cs
index caaa28f..3f8b9ff 100644
--- a/OpenSim/Region/Environment/ModuleLoader.cs
+++ b/OpenSim/Region/Environment/ModuleLoader.cs
@@ -47,11 +47,12 @@ 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 private readonly IConfigSource m_config; 50
51 public Dictionary<string, Assembly> LoadedAssemblys = new Dictionary<string, Assembly>();
51 52
52 private readonly List<IRegionModule> m_loadedModules = new List<IRegionModule>(); 53 private readonly List<IRegionModule> m_loadedModules = new List<IRegionModule>();
53 private readonly Dictionary<string, IRegionModule> m_loadedSharedModules = new Dictionary<string, IRegionModule>(); 54 private readonly Dictionary<string, IRegionModule> m_loadedSharedModules = new Dictionary<string, IRegionModule>();
54 public Dictionary<string, Assembly> LoadedAssemblys = new Dictionary<string, Assembly>(); 55 private readonly IConfigSource m_config;
55 56
56 public ModuleLoader(IConfigSource config) 57 public ModuleLoader(IConfigSource config)
57 { 58 {
@@ -85,8 +86,7 @@ namespace OpenSim.Region.Environment
85 DynamicTextureModule dynamicModule = new DynamicTextureModule(); 86 DynamicTextureModule dynamicModule = new DynamicTextureModule();
86 if (m_loadedSharedModules.ContainsKey(dynamicModule.Name)) 87 if (m_loadedSharedModules.ContainsKey(dynamicModule.Name))
87 { 88 {
88 m_log.ErrorFormat("[MODULES]: Module name \"{0}\" already exists in module list. Module type {1} not added!", dynamicModule.Name, 89 m_log.ErrorFormat("[MODULES]: Module name \"{0}\" already exists in module list. Module type {1} not added!", dynamicModule.Name, "DynamicTextureModule");
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, 152 m_log.ErrorFormat("[MODULES]: Module name \"{0}\" already exists in module list. Module type {1} not added!", transactionsModule.Name, "TransactionModule");
153 "TransactionModule");
154 } 153 }
155 else 154 else
156 { 155 {
157 m_loadedSharedModules.Add(transactionsModule.Name, transactionsModule); 156 m_loadedSharedModules.Add(transactionsModule.Name, transactionsModule);
158 } 157 }
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} \ No newline at end of file 327}
diff --git a/OpenSim/Region/Environment/Modules/Agent/AssetDownload/AssetDownloadModule.cs b/OpenSim/Region/Environment/Modules/Agent/AssetDownload/AssetDownloadModule.cs
index 550b673..48db51b 100644
--- a/OpenSim/Region/Environment/Modules/Agent/AssetDownload/AssetDownloadModule.cs
+++ b/OpenSim/Region/Environment/Modules/Agent/AssetDownload/AssetDownloadModule.cs
@@ -40,16 +40,15 @@ 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 readonly List<AssetRequest> AssetRequests; 43 private List<AssetRequest> AssetRequests;
44 44
45 private readonly Dictionary<LLUUID, Scene> RegisteredScenes = new Dictionary<LLUUID, Scene>(); 45 private Scene m_scene;
46 private Dictionary<LLUUID, Scene> RegisteredScenes = new Dictionary<LLUUID, Scene>();
46 47
47 /// 48 ///
48 /// Assets requests (for each user) which are waiting for asset server data. This includes texture requests 49 /// Assets requests (for each user) which are waiting for asset server data. This includes texture requests
49 /// </summary> 50 /// </summary>
50 private readonly Dictionary<LLUUID, Dictionary<LLUUID, AssetRequest>> RequestedAssets; 51 private Dictionary<LLUUID, Dictionary<LLUUID, AssetRequest>> RequestedAssets;
51
52 private Scene m_scene;
53 52
54 public AssetDownloadModule() 53 public AssetDownloadModule()
55 { 54 {
@@ -206,18 +205,22 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetDownload
206 { 205 {
207 public AssetBase AssetInf; 206 public AssetBase AssetInf;
208 public byte AssetRequestSource = 2; 207 public byte AssetRequestSource = 2;
209 public long DataPointer; 208 public long DataPointer = 0;
210 public int DiscardLevel = -1; 209 public int DiscardLevel = -1;
211 public AssetBase ImageInfo; 210 public AssetBase ImageInfo;
212 public bool IsTextureRequest; 211 public bool IsTextureRequest;
213 public int NumPackets; 212 public int NumPackets = 0;
214 public int PacketCounter; 213 public int PacketCounter = 0;
215 public byte[] Params; 214 public byte[] Params = null;
216 public LLUUID RequestAssetID; 215 public LLUUID RequestAssetID;
217 public IClientAPI RequestUser; 216 public IClientAPI RequestUser;
218 public LLUUID TransferRequestID; 217 public LLUUID TransferRequestID;
219 //public bool AssetInCache; 218 //public bool AssetInCache;
220 //public int TimeRequested; 219 //public int TimeRequested;
220
221 public AssetRequest()
222 {
223 }
221 } 224 }
222 225
223 #endregion 226 #endregion
diff --git a/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AgentAssetsTransactions.cs b/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AgentAssetsTransactions.cs
index 008daa2..555d5f4 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 readonly bool m_dumpAssetsToFile; 47 private 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;
146 public bool AddToInventory; 144 public bool AddToInventory;
147 public AssetBase Asset; 145 public AssetBase Asset;
148 public LLUUID InventFolder = LLUUID.Zero; 146 public LLUUID InventFolder = LLUUID.Zero;
149 private sbyte invType; 147 private sbyte invType = 0;
150 private bool m_createItem; 148 private bool m_createItem = false;
151 private string m_description = String.Empty; 149 private string m_description = String.Empty;
152 private bool m_finished; 150 private bool m_dumpAssetToFile;
151 private bool m_finished = false;
153 private string m_name = String.Empty; 152 private string m_name = String.Empty;
154 private bool m_storeLocal; 153 private bool m_storeLocal;
155 private uint nextPerm; 154 private AgentAssetTransactions m_userTransactions;
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; 158 private sbyte type = 0;
159 public bool UploadComplete; 159 public bool UploadComplete;
160 private byte wearableType; 160 private byte wearableType = 0;
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 = wearableType; 393 item.Flags = (uint) 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 d7f5804..fcd0e0c 100644
--- a/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AssetTransactionModule.cs
+++ b/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AssetTransactionModule.cs
@@ -40,11 +40,16 @@ 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; 43 private bool m_dumpAssetsToFile = false;
44 private Scene m_scene; 44 private Scene m_scene = null;
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
48 #region IAgentAssetTransactions Members 53 #region IAgentAssetTransactions Members
49 54
50 public void HandleItemCreationFromTransaction(IClientAPI remoteClient, LLUUID transactionID, LLUUID folderID, 55 public void HandleItemCreationFromTransaction(IClientAPI remoteClient, LLUUID transactionID, LLUUID folderID,
@@ -140,13 +145,13 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction
140 /// <summary> 145 /// <summary>
141 /// Each agent has its own singleton collection of transactions 146 /// Each agent has its own singleton collection of transactions
142 /// </summary> 147 /// </summary>
143 private readonly Dictionary<LLUUID, AgentAssetTransactions> AgentTransactions = 148 private Dictionary<LLUUID, AgentAssetTransactions> AgentTransactions =
144 new Dictionary<LLUUID, AgentAssetTransactions>(); 149 new Dictionary<LLUUID, AgentAssetTransactions>();
145 150
146 /// <summary> 151 /// <summary>
147 /// Should we dump uploaded assets to the filesystem? 152 /// Should we dump uploaded assets to the filesystem?
148 /// </summary> 153 /// </summary>
149 private readonly bool m_dumpAssetsToFile; 154 private bool m_dumpAssetsToFile;
150 155
151 public Scene MyScene; 156 public Scene MyScene;
152 157
diff --git a/OpenSim/Region/Environment/Modules/Agent/TextureDownload/TextureDownloadModule.cs b/OpenSim/Region/Environment/Modules/Agent/TextureDownload/TextureDownloadModule.cs
index 96ef61f..474ac75 100644
--- a/OpenSim/Region/Environment/Modules/Agent/TextureDownload/TextureDownloadModule.cs
+++ b/OpenSim/Region/Environment/Modules/Agent/TextureDownload/TextureDownloadModule.cs
@@ -47,8 +47,6 @@ 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
52 /// <summary> 50 /// <summary>
53 /// Each user has their own texture download service. 51 /// Each user has their own texture download service.
54 /// </summary> 52 /// </summary>
@@ -56,9 +54,14 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload
56 new Dictionary<LLUUID, UserTextureDownloadService>(); 54 new Dictionary<LLUUID, UserTextureDownloadService>();
57 55
58 private Scene m_scene; 56 private Scene m_scene;
57 private List<Scene> m_scenes = new List<Scene>();
59 58
60 private Thread m_thread; 59 private Thread m_thread;
61 60
61 public TextureDownloadModule()
62 {
63 }
64
62 #region IRegionModule Members 65 #region IRegionModule Members
63 66
64 public void Initialise(Scene scene, IConfigSource config) 67 public void Initialise(Scene scene, IConfigSource config)
@@ -66,7 +69,7 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload
66 if (m_scene == null) 69 if (m_scene == null)
67 { 70 {
68 //Console.WriteLine("Creating Texture download module"); 71 //Console.WriteLine("Creating Texture download module");
69 m_thread = new Thread(ProcessTextureSenders); 72 m_thread = new Thread(new ThreadStart(ProcessTextureSenders));
70 m_thread.Name = "ProcessTextureSenderThread"; 73 m_thread.Name = "ProcessTextureSenderThread";
71 m_thread.IsBackground = true; 74 m_thread.IsBackground = true;
72 m_thread.Start(); 75 m_thread.Start();
diff --git a/OpenSim/Region/Environment/Modules/Agent/TextureDownload/TextureNotFoundSender.cs b/OpenSim/Region/Environment/Modules/Agent/TextureDownload/TextureNotFoundSender.cs
index 7d4c919..70e44d4 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 readonly LLUUID m_textureId; 43 private bool m_cancel = false;
44 private bool m_cancel;
45 private IClientAPI m_client; 44 private IClientAPI m_client;
46 45
47 // See ITextureSender 46 // See ITextureSender
48 47
49 private bool m_sending; 48 private bool m_sending = false;
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 44b9a23..02c541b 100644
--- a/OpenSim/Region/Environment/Modules/Agent/TextureSender/TextureSender.cs
+++ b/OpenSim/Region/Environment/Modules/Agent/TextureSender/TextureSender.cs
@@ -43,14 +43,12 @@ 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
48 /// <summary> 46 /// <summary>
49 /// Records the number of times texture send has been called. 47 /// Records the number of times texture send has been called.
50 /// </summary> 48 /// </summary>
51 public int counter; 49 public int counter = 0;
52 50
53 public bool ImageLoaded; 51 public bool ImageLoaded = false;
54 52
55 /// <summary> 53 /// <summary>
56 /// Holds the texture asset to send. 54 /// Holds the texture asset to send.
@@ -59,26 +57,27 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureSender
59 57
60 //public LLUUID assetID { get { return m_asset.FullID; } } 58 //public LLUUID assetID { get { return m_asset.FullID; } }
61 59
62 private bool m_cancel; 60 private bool m_cancel = false;
63 61
64 // See ITextureSender 62 // See ITextureSender
65 63
66 private bool m_sending; 64 private bool m_sending = false;
67 65
68 /// <summary> 66 /// <summary>
69 /// This is actually the number of extra packets required to send the texture data! We always assume 67 /// This is actually the number of extra packets required to send the texture data! We always assume
70 /// at least one is required. 68 /// at least one is required.
71 /// </summary> 69 /// </summary>
72 private int NumPackets; 70 private int NumPackets = 0;
73 71
74 /// <summary> 72 /// <summary>
75 /// Holds the packet number to send next. In this case, each packet is 1000 bytes long and starts 73 /// Holds the packet number to send next. In this case, each packet is 1000 bytes long and starts
76 /// at the 600th byte (0th indexed). 74 /// at the 600th byte (0th indexed).
77 /// </summary> 75 /// </summary>
78 private int PacketCounter; 76 private int PacketCounter = 0;
79 77
80 private int RequestedDiscardLevel = -1; 78 private int RequestedDiscardLevel = -1;
81 private uint StartPacketNumber; 79 private IClientAPI RequestUser;
80 private uint StartPacketNumber = 0;
82 81
83 public TextureSender(IClientAPI client, int discardLevel, uint packetNumber) 82 public TextureSender(IClientAPI client, int discardLevel, uint packetNumber)
84 { 83 {
@@ -191,7 +190,7 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureSender
191 catch (ArgumentOutOfRangeException) 190 catch (ArgumentOutOfRangeException)
192 { 191 {
193 m_log.Error("[TEXTURE SENDER]: Unable to separate texture into multiple packets: Array bounds failure on asset:" + 192 m_log.Error("[TEXTURE SENDER]: Unable to separate texture into multiple packets: Array bounds failure on asset:" +
194 m_asset.FullID); 193 m_asset.FullID.ToString());
195 return; 194 return;
196 } 195 }
197 RequestUser.OutPacket(im, ThrottleOutPacketType.Texture); 196 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 eaf2198..8e90d17 100644
--- a/OpenSim/Region/Environment/Modules/Agent/Xfer/XferModule.cs
+++ b/OpenSim/Region/Environment/Modules/Agent/Xfer/XferModule.cs
@@ -41,6 +41,10 @@ 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
44 #region IRegionModule Members 48 #region IRegionModule Members
45 49
46 public void Initialise(Scene scene, IConfigSource config) 50 public void Initialise(Scene scene, IConfigSource config)
@@ -145,11 +149,11 @@ namespace OpenSim.Region.Environment.Modules.Agent.Xfer
145 public IClientAPI Client; 149 public IClientAPI Client;
146 private bool complete; 150 private bool complete;
147 public byte[] Data = new byte[0]; 151 public byte[] Data = new byte[0];
148 public int DataPointer; 152 public int DataPointer = 0;
149 public string FileName = String.Empty; 153 public string FileName = String.Empty;
150 public uint Packet; 154 public uint Packet = 0;
151 public uint Serial = 1; 155 public uint Serial = 1;
152 public ulong XferID; 156 public ulong XferID = 0;
153 157
154 public XferDownLoad(string fileName, byte[] data, ulong xferID, IClientAPI client) 158 public XferDownLoad(string fileName, byte[] data, ulong xferID, IClientAPI client)
155 { 159 {
@@ -213,7 +217,7 @@ namespace OpenSim.Region.Environment.Modules.Agent.Xfer
213 { 217 {
214 byte[] transferData = new byte[Data.Length - DataPointer]; 218 byte[] transferData = new byte[Data.Length - DataPointer];
215 Array.Copy(Data, DataPointer, transferData, 0, Data.Length - DataPointer); 219 Array.Copy(Data, DataPointer, transferData, 0, Data.Length - DataPointer);
216 uint endPacket = Packet |= 0x80000000; 220 uint endPacket = Packet |= (uint) 0x80000000;
217 Client.SendXferPacket(XferID, endPacket, transferData); 221 Client.SendXferPacket(XferID, endPacket, transferData);
218 Packet++; 222 Packet++;
219 DataPointer += (Data.Length - DataPointer); 223 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 8d42681..15720fc 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 readonly List<Scene> m_scenes = new List<Scene>(); 47 private string m_defaultzone = null;
48 private string m_defaultzone;
49 48
50 private IRCChatModule m_irc; 49 private IRCChatModule m_irc = null;
51 private Thread m_irc_connector; 50 private Thread m_irc_connector = null;
52 51
53 private string m_last_leaving_user; 52 private string m_last_leaving_user = null;
54 private string m_last_new_user; 53 private string m_last_new_user = null;
55 private int m_saydistance = 30; 54 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); 260 m_log.Error("[IRC]: NewClient exception trap:" + ex.ToString());
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); 287 m_log.Error("[IRC]: ClientLoggedOut exception trap:" + ex.ToString());
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
376 private readonly string m_basenick;
377 private readonly string m_channel;
378 private readonly bool m_enabled;
379 private readonly uint m_port = 6668;
380 private readonly string m_privmsgformat = "PRIVMSG {0} :<{1} in {2}>: {3}";
381 private readonly string m_user = "USER OpenSimBot 8 * :I'm a OpenSim to irc bot";
382 private Thread listener; 375 private Thread listener;
383 private bool m_connected; 376
384 private List<Scene> m_last_scenes; 377 private string m_basenick = null;
385 private string m_nick; 378 private string m_channel = null;
379 private bool m_connected = false;
380 private bool m_enabled = false;
381 private List<Scene> m_last_scenes = null;
382 private string m_nick = null;
383 private uint m_port = 6668;
384 private string m_privmsgformat = "PRIVMSG {0} :<{1} in {2}>: {3}";
386 private StreamReader m_reader; 385 private StreamReader m_reader;
387 private List<Scene> m_scenes; 386 private List<Scene> m_scenes = null;
388 private string m_server; 387 private string m_server = null;
389 388
390 private NetworkStream m_stream; 389 private NetworkStream m_stream;
391 internal object m_syncConnect = new object(); 390 internal object m_syncConnect = new object();
392 private TcpClient m_tcp; 391 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(PingRun); 481 pingSender = new Thread(new ThreadStart(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(ListenerRun); 487 listener = new Thread(new ThreadStart(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); 548 m_log.Error("[IRC]: PrivMsg exception trap:" + ex.ToString());
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) 591 if (m_connected == true)
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 + "\n" + ex.StackTrace); 605 m_log.Error("[IRC]: PingRun exception trap:" + ex.ToString() + "\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 && ((inputLine = m_reader.ReadLine()) != null)) 618 while ((m_connected == true) && ((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 + "\n" + ex.StackTrace); 662 m_log.Error("[IRC]: ListenerRun exception trap:" + ex.ToString() + "\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 + "\n" + ex.StackTrace); 688 m_log.Error("[IRC]: BroadcastSim Exception Trap:" + ex.ToString() + "\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 cc6fd77..966c5e2 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>();
79 68
80 /// <summary> 69 /// <summary>
81 /// Where Stipends come from and Fees go to. 70 /// Where Stipends come from and Fees go to.
82 /// </summary> 71 /// </summary>
83 private LLUUID EconomyBaseAccount = LLUUID.Zero; 72 private LLUUID EconomyBaseAccount = LLUUID.Zero;
84 73
85 private float EnergyEfficiency; 74 private float EnergyEfficiency = 0f;
86 private bool gridmode; 75 private bool gridmode = false;
87 private ObjectPaid handerOnObjectPaid; 76 private ObjectPaid handerOnObjectPaid;
88 private bool m_enabled = true; 77 private bool m_enabled = true;
89 78
90 private IConfigSource m_gConfig; 79 private IConfigSource m_gConfig;
91 80
92 private bool m_keepMoneyAcrossLogins = true; 81 private bool m_keepMoneyAcrossLogins = true;
82 private Dictionary<LLUUID, int> m_KnownClientFunds = new Dictionary<LLUUID, int>();
93 private string m_LandAddress = String.Empty; 83 private string m_LandAddress = String.Empty;
94 84
95 private int m_minFundsBeforeRefresh = 100; 85 private int m_minFundsBeforeRefresh = 100;
96 private string m_MoneyAddress = String.Empty; 86 private string m_MoneyAddress = String.Empty;
97 87
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; 101 private int ObjectCount = 0;
102 private int PriceEnergyUnit; 102 private int PriceEnergyUnit = 0;
103 private int PriceGroupCreate; 103 private int PriceGroupCreate = 0;
104 private int PriceObjectClaim; 104 private int PriceObjectClaim = 0;
105 private float PriceObjectRent; 105 private float PriceObjectRent = 0f;
106 private float PriceObjectScaleFactor; 106 private float PriceObjectScaleFactor = 0f;
107 private int PriceParcelClaim; 107 private int PriceParcelClaim = 0;
108 private float PriceParcelClaimFactor; 108 private float PriceParcelClaimFactor = 0f;
109 private int PriceParcelRent; 109 private int PriceParcelRent = 0;
110 private int PricePublicObjectDecay; 110 private int PricePublicObjectDecay = 0;
111 private int PricePublicObjectDelete; 111 private int PricePublicObjectDelete = 0;
112 private int PriceRentLight; 112 private int PriceRentLight = 0;
113 private int PriceUpload; 113 private int PriceUpload = 0;
114 private int TeleportMinPrice; 114 private int TeleportMinPrice = 0;
115 115
116 private float TeleportPriceExponent; 116 private float TeleportPriceExponent = 0f;
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"]) 308 if ((bool) hbinfo["success"] == true)
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 hbinfo["errorMessage"]); 336 (string) 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"]) 663 if ((bool) hresult["success"] == true)
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"]) 721 if ((bool) hbinfo["success"] == true)
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 hbinfo["errorMessage"]); 746 (string) 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 == secret) 815 if (userScene.RegionInfo.regionSecret.ToString() == 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 && e.transactionID == 0) 1241 if (e.economyValidated == true && 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 + " Receiver: " + e.receiver + " Amount: " + e.amount); 1331 e.sender.ToString() + " Receiver: " + e.receiver.ToString() + " Amount: " + e.amount.ToString());
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"]) 1403 if ((bool) hresult["success"] == true)
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"]) 1435 if ((bool) hresult["success"] == true)
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 1463 public enum TransactionType : int
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 1dffc62..dd6a92e 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 readonly Dictionary<LLUUID, List<FriendListItem>> FriendLists = new Dictionary<LLUUID, List<FriendListItem>>(); 45 private Dictionary<LLUUID, List<FriendListItem>> FriendLists = new Dictionary<LLUUID, List<FriendListItem>>();
46 private readonly Dictionary<LLUUID, LLUUID> m_pendingFriendRequests = new Dictionary<LLUUID, LLUUID>(); 46 private Dictionary<LLUUID, LLUUID> m_pendingFriendRequests = new Dictionary<LLUUID, LLUUID>();
47 private readonly Dictionary<LLUUID, ulong> m_rootAgents = new Dictionary<LLUUID, ulong>(); 47 private Dictionary<LLUUID, ulong> m_rootAgents = new Dictionary<LLUUID, ulong>();
48 private readonly List<Scene> m_scene = new List<Scene>(); 48 private 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) 216 if (fli.onlinestatus == true)
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 == 38) 360 if (dialog == (byte) 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 + " To: " + toAgentID + " Session:" + imSessionID + " Message:" + 366 m_log.Info("[FRIEND]: 38 - From:" + fromAgentID.ToString() + " To: " + toAgentID.ToString() + " Session:" + imSessionID.ToString() + " 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); 373 m_log.Info("[FRIEND]: Filling Session: " + msg.imSessionID.ToString());
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 == 39) 396 if (dialog == (byte) 39)
397 { 397 {
398 m_log.Info("[FRIEND]: 39 - From:" + fromAgentID + " To: " + toAgentID + " Session:" + imSessionID + " Message:" + 398 m_log.Info("[FRIEND]: 39 - From:" + fromAgentID.ToString() + " To: " + toAgentID.ToString() + " Session:" + imSessionID.ToString() + " Message:" +
399 message); 399 message);
400 } 400 }
401 401
402 // 40 == Decline Friendship 402 // 40 == Decline Friendship
403 if (dialog == 40) 403 if (dialog == (byte) 40)
404 { 404 {
405 m_log.Info("[FRIEND]: 40 - From:" + fromAgentID + " To: " + toAgentID + " Session:" + imSessionID + " Message:" + 405 m_log.Info("[FRIEND]: 40 - From:" + fromAgentID.ToString() + " To: " + toAgentID.ToString() + " Session:" + imSessionID.ToString() + " 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 = 39; // Approved friend request 436 msg.dialog = (byte) 39; // Approved friend request
437 msg.Position = new sLLVector3(); 437 msg.Position = new sLLVector3();
438 msg.offline = 0; 438 msg.offline = (byte) 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, 1); 443 SceneAgentIn.StoreAddFriendship(m_pendingFriendRequests[transactionID], agentID, (uint) 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 = 40; // Deny friend request 474 msg.dialog = (byte) 40; // Deny friend request
475 msg.Position = new sLLVector3(); 475 msg.Position = new sLLVector3();
476 msg.offline = 0; 476 msg.offline = (byte) 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 858cf21..6edc44d 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 readonly Dictionary<LLUUID, GroupList> m_grouplistmap = new Dictionary<LLUUID, GroupList>(); 44 private Dictionary<LLUUID, GroupList> m_grouplistmap = new Dictionary<LLUUID, GroupList>();
45 private readonly Dictionary<LLUUID, GroupData> m_groupmap = new Dictionary<LLUUID, GroupData>(); 45 private Dictionary<LLUUID, GroupData> m_groupmap = new Dictionary<LLUUID, GroupData>();
46 private readonly Dictionary<LLUUID, IClientAPI> m_iclientmap = new Dictionary<LLUUID, IClientAPI>(); 46 private Dictionary<LLUUID, IClientAPI> m_iclientmap = new Dictionary<LLUUID, IClientAPI>();
47 private readonly List<Scene> m_scene = new List<Scene>(); 47 private 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); 217 m_log.Info("[GROUP]: Removing all reference to groups for " + agentID.ToString());
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 9f2d461..624f307 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 readonly IDictionary<LLUUID, LLUUID> m_pendingOffers = new Dictionary<LLUUID, LLUUID>(); 49 private 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 87f0177..15825b6 100644
--- a/OpenSim/Region/Environment/Modules/Avatar/Profiles/AvatarProfilesModule.cs
+++ b/OpenSim/Region/Environment/Modules/Avatar/Profiles/AvatarProfilesModule.cs
@@ -41,6 +41,10 @@ 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
44 #region IRegionModule Members 48 #region IRegionModule Members
45 49
46 public void Initialise(Scene scene, IConfigSource config) 50 public void Initialise(Scene scene, IConfigSource config)
@@ -100,7 +104,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Profiles
100 } 104 }
101 else 105 else
102 { 106 {
103 m_log.Debug("[AvatarProfilesModule]: Got null for profile for " + avatarID); 107 m_log.Debug("[AvatarProfilesModule]: Got null for profile for " + avatarID.ToString());
104 } 108 }
105 } 109 }
106 110
diff --git a/OpenSim/Region/Environment/Modules/Framework/Commander.cs b/OpenSim/Region/Environment/Modules/Framework/Commander.cs
index d226c3d..4430c10 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 readonly List<CommandArgument> m_args = new List<CommandArgument>(); 45 private List<CommandArgument> m_args = new List<CommandArgument>();
46 46
47 private readonly Action<object[]> m_command; 47 private Action<object[]> m_command;
48 private readonly string m_help; 48 private string m_help;
49 private readonly string m_name; 49 private 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 readonly string m_help; 167 private string m_help;
168 private readonly string m_name; 168 private string m_name;
169 private readonly string m_type; 169 private 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 readonly Dictionary<string, ICommand> m_commands = new Dictionary<string, ICommand>(); 207 private Dictionary<string, ICommand> m_commands = new Dictionary<string, ICommand>();
208 private readonly string m_name; 208 private 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 + "];\n"; 238 classSrc += "\t\tObject[] args = new Object[" + com.Arguments.Count.ToString() + "];\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 + "] = " + Util.Md5Hash(arg.Key) + " " + ";\n"; 242 classSrc += "\t\targs[" + i.ToString() + "] = " + 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 3df9129..7b5c981 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 readonly Commander m_commander = new Commander("CommanderTest"); 37 private 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 ac2ac0b..2ca4df9 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();
33 private readonly List<Location> m_myLocations = new List<Location>(); 32 private readonly List<Location> m_myLocations = new List<Location>();
34 33
35 private readonly Dictionary<Location, string[]> m_neighbourInterfaces = new Dictionary<Location, string[]>(); 34 private readonly Dictionary<Location, string[]> m_neighbourInterfaces = new Dictionary<Location, string[]>();
36 private readonly Dictionary<Location, RemotingObject> m_neighbourRemote = new Dictionary<Location, RemotingObject>(); 35 private readonly Dictionary<Location, RemotingObject> m_neighbourRemote = new Dictionary<Location, RemotingObject>();
37 private IConfigSource m_config; 36 private IConfigSource m_config;
38 private bool m_enabled; 37 private bool m_enabled = false;
39 38
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 d926714..c0e3d3b 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 readonly Dictionary<LLUUID, Scene> RegisteredScenes = new Dictionary<LLUUID, Scene>(); 43 private Dictionary<LLUUID, Scene> RegisteredScenes = new Dictionary<LLUUID, Scene>();
44 44
45 private readonly Dictionary<string, IDynamicTextureRender> RenderPlugins = 45 private Dictionary<string, IDynamicTextureRender> RenderPlugins =
46 new Dictionary<string, IDynamicTextureRender>(); 46 new Dictionary<string, IDynamicTextureRender>();
47 47
48 private readonly Dictionary<LLUUID, DynamicTextureUpdater> Updaters = new Dictionary<LLUUID, DynamicTextureUpdater>(); 48 private 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; 179 public bool BlendWithOldTexture = false;
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; 186 public bool SetNewFrontAlpha = false;
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 4bde33b..e1339a3 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 readonly object HttpListLock = new object(); 87 private 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,6 +93,10 @@ 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
96 #region IHttpRequests Members 100 #region IHttpRequests Members
97 101
98 public LLUUID MakeHttpRequest(string url, string parameters, string body) 102 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 f39f16d..c828ef0 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 = WebRequest.Create(url); 123 WebRequest request = HttpWebRequest.Create(url);
124 RequestState state = new RequestState((HttpWebRequest) request, requestID); 124 RequestState state = new RequestState((HttpWebRequest) request, requestID);
125 IAsyncResult result = request.BeginGetResponse(HttpRequestReturn, state); 125 IAsyncResult result = request.BeginGetResponse(new AsyncCallback(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 = state.Request; 134 WebRequest request = (WebRequest) 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; 178 public HttpWebRequest Request = null;
179 public LLUUID RequestID = LLUUID.Zero; 179 public LLUUID RequestID = LLUUID.Zero;
180 public int TimeOfRequest; 180 public int TimeOfRequest = 0;
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 8e434c7..626c60f 100644
--- a/OpenSim/Region/Environment/Modules/Scripting/VectorRender/VectorRenderModule.cs
+++ b/OpenSim/Region/Environment/Modules/Scripting/VectorRender/VectorRenderModule.cs
@@ -48,6 +48,10 @@ 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
51 #region IDynamicTextureRender Members 55 #region IDynamicTextureRender Members
52 56
53 public string GetContentType() 57 public string GetContentType()
@@ -134,7 +138,7 @@ namespace OpenSim.Region.Environment.Modules.Scripting.VectorRender
134 catch (Exception e) 138 catch (Exception e)
135 { 139 {
136//Ckrinke: Add a WriteLine to remove the warning about 'e' defined but not used 140//Ckrinke: Add a WriteLine to remove the warning about 'e' defined but not used
137 Console.WriteLine("Problem with Draw. Please verify parameters." + e); 141 Console.WriteLine("Problem with Draw. Please verify parameters." + e.ToString());
138 } 142 }
139 143
140 if ((size < 128) || (size > 1024)) 144 if ((size < 128) || (size > 1024))
@@ -256,7 +260,7 @@ namespace OpenSim.Region.Environment.Modules.Scripting.VectorRender
256 endPoint.X = (int) x; 260 endPoint.X = (int) x;
257 endPoint.Y = (int) y; 261 endPoint.Y = (int) y;
258 Image image = ImageHttpRequest(nextLine); 262 Image image = ImageHttpRequest(nextLine);
259 graph.DrawImage(image, startPoint.X, startPoint.Y, x, y); 263 graph.DrawImage(image, (float) startPoint.X, (float) startPoint.Y, x, y);
260 startPoint.X += endPoint.X; 264 startPoint.X += endPoint.X;
261 startPoint.Y += endPoint.Y; 265 startPoint.Y += endPoint.Y;
262 } 266 }
@@ -349,7 +353,7 @@ namespace OpenSim.Region.Environment.Modules.Scripting.VectorRender
349 353
350 private Bitmap ImageHttpRequest(string url) 354 private Bitmap ImageHttpRequest(string url)
351 { 355 {
352 WebRequest request = WebRequest.Create(url); 356 WebRequest request = HttpWebRequest.Create(url);
353//Ckrinke: Comment out for now as 'str' is unused. Bring it back into play later when it is used. 357//Ckrinke: Comment out for now as 'str' is unused. Bring it back into play later when it is used.
354//Ckrinke Stream str = null; 358//Ckrinke Stream str = null;
355 HttpWebResponse response = (HttpWebResponse) (request).GetResponse(); 359 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 c4c1718..e79b2bd 100644
--- a/OpenSim/Region/Environment/Modules/Scripting/WorldComm/WorldCommModule.cs
+++ b/OpenSim/Region/Environment/Modules/Scripting/WorldComm/WorldCommModule.cs
@@ -75,6 +75,10 @@ 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
78 #region IRegionModule Members 82 #region IRegionModule Members
79 83
80 public void Initialise(Scene scene, IConfigSource config) 84 public void Initialise(Scene scene, IConfigSource config)
@@ -320,8 +324,8 @@ namespace OpenSim.Region.Environment.Modules.Scripting.WorldComm
320 public class ListenerManager 324 public class ListenerManager
321 { 325 {
322 //private Dictionary<int, ListenerInfo> m_listeners; 326 //private Dictionary<int, ListenerInfo> m_listeners;
323 private readonly Hashtable m_listeners = Hashtable.Synchronized(new Hashtable());
324 private object ListenersLock = new object(); 327 private object ListenersLock = new object();
328 private Hashtable m_listeners = Hashtable.Synchronized(new Hashtable());
325 private int m_MaxListeners = 100; 329 private int m_MaxListeners = 100;
326 330
327 public int AddListener(uint localID, LLUUID itemID, LLUUID hostID, int channel, string name, string id, string msg) 331 public int AddListener(uint localID, LLUUID itemID, LLUUID hostID, int channel, string name, string id, string msg)
@@ -481,7 +485,6 @@ namespace OpenSim.Region.Environment.Modules.Scripting.WorldComm
481 485
482 public class ListenerInfo 486 public class ListenerInfo
483 { 487 {
484 private readonly LLUUID m_sourceItemID; // ID of the scenePart or avatar source of the message
485 private bool m_active; // Listener is active or not 488 private bool m_active; // Listener is active or not
486 private int m_channel; // Channel 489 private int m_channel; // Channel
487 private int m_handle; // Assigned handle of this listener 490 private int m_handle; // Assigned handle of this listener
@@ -491,6 +494,7 @@ namespace OpenSim.Region.Environment.Modules.Scripting.WorldComm
491 private uint m_localID; // Local ID from script engine 494 private uint m_localID; // Local ID from script engine
492 private string m_message; // The message 495 private string m_message; // The message
493 private string m_name; // Object name to filter messages from 496 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
494 498
495 public ListenerInfo(uint localID, int handle, LLUUID ItemID, LLUUID hostID, int channel, string name, LLUUID id, string message) 499 public ListenerInfo(uint localID, int handle, LLUUID ItemID, LLUUID hostID, int channel, string name, LLUUID id, string message)
496 { 500 {
diff --git a/OpenSim/Region/Environment/Modules/Scripting/XMLRPC/XMLRPCModule.cs b/OpenSim/Region/Environment/Modules/Scripting/XMLRPC/XMLRPCModule.cs
index 4f6808e..a039d42 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();
83 81
84 private string m_name = "XMLRPCModule"; 82 private string m_name = "XMLRPCModule";
85 83
86 // <channel id, RPCChannelInfo> 84 // <channel id, RPCChannelInfo>
87 private Dictionary<LLUUID, RPCChannelInfo> m_openChannels; 85 private Dictionary<LLUUID, RPCChannelInfo> m_openChannels;
88 private Dictionary<LLUUID, SendRemoteDataRequest> m_pendingSRDResponses; 86 private Dictionary<LLUUID, SendRemoteDataRequest> m_pendingSRDResponses;
89 private int m_remoteDataPort; 87 private int m_remoteDataPort = 0;
90 88
91 private Dictionary<LLUUID, RPCRequestInfo> m_rpcPending; 89 private Dictionary<LLUUID, RPCRequestInfo> m_rpcPending;
92 private Dictionary<LLUUID, RPCRequestInfo> m_rpcPendingResponses; 90 private Dictionary<LLUUID, RPCRequestInfo> m_rpcPendingResponses;
91 private List<Scene> m_scenes = new List<Scene>();
93 private int RemoteReplyScriptTimeout = 9000; 92 private int RemoteReplyScriptTimeout = 9000;
94 private int RemoteReplyScriptWait = 300; 93 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 readonly LLUUID m_ChannelKey; 431 private LLUUID m_ChannelKey;
432 private readonly string m_IntVal; 432 private string m_IntVal;
433 private readonly LLUUID m_ItemID; 433 private LLUUID m_ItemID;
434 private readonly uint m_localID; 434 private uint m_localID;
435 private readonly LLUUID m_MessageID; 435 private LLUUID m_MessageID;
436 private readonly string m_StrVal;
437 private bool m_processed; 436 private bool m_processed;
438 private int m_respInt; 437 private int m_respInt;
439 private string m_respStr; 438 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 readonly LLUUID m_ChannelKey; 517 private LLUUID m_ChannelKey;
518 private readonly LLUUID m_itemID; 518 private LLUUID m_itemID;
519 private readonly uint m_localID; 519 private 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 20d02c4..9ac3cc3 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 = 128; //Equals 10000000 47 public const byte LAND_FLAG_PROPERTY_BORDER_SOUTH = (byte) 128; //Equals 10000000
48 public const byte LAND_FLAG_PROPERTY_BORDER_WEST = 64; //Equals 01000000 48 public const byte LAND_FLAG_PROPERTY_BORDER_WEST = (byte) 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 = 5; //Equals 00000101 58 public const byte LAND_TYPE_IS_BEING_AUCTIONED = (byte) 5; //Equals 00000101
59 public const byte LAND_TYPE_IS_FOR_SALE = 4; //Equals 00000100 59 public const byte LAND_TYPE_IS_FOR_SALE = (byte) 4; //Equals 00000100
60 public const byte LAND_TYPE_OWNED_BY_GROUP = 2; //Equals 00000010 60 public const byte LAND_TYPE_OWNED_BY_GROUP = (byte) 2; //Equals 00000010
61 public const byte LAND_TYPE_OWNED_BY_OTHER = 1; //Equals 00000001 61 public const byte LAND_TYPE_OWNED_BY_OTHER = (byte) 1; //Equals 00000001
62 public const byte LAND_TYPE_OWNED_BY_REQUESTER = 3; //Equals 00000011 62 public const byte LAND_TYPE_OWNED_BY_REQUESTER = (byte) 3; //Equals 00000011
63 public const byte LAND_TYPE_PUBLIC = 0; //Equals 00000000 63 public const byte LAND_TYPE_PUBLIC = (byte) 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 readonly int[,] landIDList = new int[64,64]; 70 private int[,] landIDList = new int[64,64];
71 private readonly Dictionary<int, ILandObject> landList = new Dictionary<int, ILandObject>(); 71 private Dictionary<int, ILandObject> landList = new Dictionary<int, ILandObject>();
72 private readonly Scene m_scene;
73 72
74 private bool landPrimCountTainted; 73 private bool landPrimCountTainted = false;
75 private int lastLandLocalID = START_LAND_LOCAL_ID - 1; 74 private int lastLandLocalID = START_LAND_LOCAL_ID - 1;
76 75
77 private bool m_allowedForcefulBans = true; 76 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, new_land.Copy()); 195 landList.Add(lastLandLocalID, (LandObject) 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 = 0; //This represents the byte for the current 4x4 535 byte tempByte = (byte) 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, ThrottleOutPacketType.Task); 614 remote_client.OutPacket((Packet) 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 e6e1ae4..877bed5 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 += landChannel.handleAvatarChangingParcel; 48 m_scene.EventManager.OnAvatarEnteringNewParcel += new EventManager.AvatarEnteringNewParcel(landChannel.handleAvatarChangingParcel);
49 m_scene.EventManager.OnClientMovement += landChannel.handleAnyClientMovement; 49 m_scene.EventManager.OnClientMovement += new EventManager.ClientMovement(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 = landChannel; 55 m_scene.LandChannel = (ILandChannel) 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 54fe9ae..e297b10 100644
--- a/OpenSim/Region/Environment/Modules/World/Land/LandObject.cs
+++ b/OpenSim/Region/Environment/Modules/World/Land/LandObject.cs
@@ -73,8 +73,6 @@ 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
78 #region Constructors 76 #region Constructors
79 77
80 public LandObject(LLUUID owner_id, bool is_group_owned, Scene scene) 78 public LandObject(LLUUID owner_id, bool is_group_owned, Scene scene)
@@ -100,7 +98,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
100 { 98 {
101 if (x >= 0 && y >= 0 && x <= Constants.RegionSize && x <= Constants.RegionSize) 99 if (x >= 0 && y >= 0 && x <= Constants.RegionSize && x <= Constants.RegionSize)
102 { 100 {
103 return landBitmap[x / 4, y / 4]; 101 return (landBitmap[x / 4, y / 4] == true);
104 } 102 }
105 else 103 else
106 { 104 {
@@ -150,7 +148,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
150 updatePacket.ParcelData.GroupID = landData.groupID; 148 updatePacket.ParcelData.GroupID = landData.groupID;
151 updatePacket.ParcelData.GroupPrims = landData.groupPrims; 149 updatePacket.ParcelData.GroupPrims = landData.groupPrims;
152 updatePacket.ParcelData.IsGroupOwned = landData.isGroupOwned; 150 updatePacket.ParcelData.IsGroupOwned = landData.isGroupOwned;
153 updatePacket.ParcelData.LandingType = landData.landingType; 151 updatePacket.ParcelData.LandingType = (byte) landData.landingType;
154 updatePacket.ParcelData.LocalID = landData.localID; 152 updatePacket.ParcelData.LocalID = landData.localID;
155 if (landData.area > 0) 153 if (landData.area > 0)
156 { 154 {
@@ -214,7 +212,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
214 landData.selectedPrims; 212 landData.selectedPrims;
215 updatePacket.ParcelData.UserLocation = landData.userLocation; 213 updatePacket.ParcelData.UserLocation = landData.userLocation;
216 updatePacket.ParcelData.UserLookAt = landData.userLookAt; 214 updatePacket.ParcelData.UserLookAt = landData.userLookAt;
217 remote_client.OutPacket(updatePacket, ThrottleOutPacketType.Task); 215 remote_client.OutPacket((Packet) updatePacket, ThrottleOutPacketType.Task);
218 } 216 }
219 217
220 public void updateLandProperties(ParcelPropertiesUpdatePacket packet, IClientAPI remote_client) 218 public void updateLandProperties(ParcelPropertiesUpdatePacket packet, IClientAPI remote_client)
@@ -357,7 +355,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
357 { 355 {
358 ParcelAccessListReplyPacket.ListBlock listBlock = new ParcelAccessListReplyPacket.ListBlock(); 356 ParcelAccessListReplyPacket.ListBlock listBlock = new ParcelAccessListReplyPacket.ListBlock();
359 357
360 listBlock.Flags = 0; 358 listBlock.Flags = (uint) 0;
361 listBlock.ID = entry.AgentID; 359 listBlock.ID = entry.AgentID;
362 listBlock.Time = 0; 360 listBlock.Time = 0;
363 361
@@ -369,7 +367,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
369 { 367 {
370 ParcelAccessListReplyPacket.ListBlock listBlock = new ParcelAccessListReplyPacket.ListBlock(); 368 ParcelAccessListReplyPacket.ListBlock listBlock = new ParcelAccessListReplyPacket.ListBlock();
371 369
372 listBlock.Flags = 0; 370 listBlock.Flags = (uint) 0;
373 listBlock.ID = LLUUID.Zero; 371 listBlock.ID = LLUUID.Zero;
374 listBlock.Time = 0; 372 listBlock.Time = 0;
375 373
@@ -392,7 +390,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
392 replyPacket.Data.SequenceID = 0; 390 replyPacket.Data.SequenceID = 0;
393 391
394 replyPacket.List = createAccessListArrayByFlag(ParcelManager.AccessList.Access); 392 replyPacket.List = createAccessListArrayByFlag(ParcelManager.AccessList.Access);
395 remote_client.OutPacket(replyPacket, ThrottleOutPacketType.Task); 393 remote_client.OutPacket((Packet) replyPacket, ThrottleOutPacketType.Task);
396 } 394 }
397 395
398 if (flags == (uint) ParcelManager.AccessList.Ban || flags == (uint) ParcelManager.AccessList.Both) 396 if (flags == (uint) ParcelManager.AccessList.Ban || flags == (uint) ParcelManager.AccessList.Both)
@@ -404,7 +402,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
404 replyPacket.Data.SequenceID = 0; 402 replyPacket.Data.SequenceID = 0;
405 403
406 replyPacket.List = createAccessListArrayByFlag(ParcelManager.AccessList.Ban); 404 replyPacket.List = createAccessListArrayByFlag(ParcelManager.AccessList.Ban);
407 remote_client.OutPacket(replyPacket, ThrottleOutPacketType.Task); 405 remote_client.OutPacket((Packet) replyPacket, ThrottleOutPacketType.Task);
408 } 406 }
409 } 407 }
410 408
@@ -484,7 +482,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
484 { 482 {
485 for (y = 0; y < 64; y++) 483 for (y = 0; y < 64; y++)
486 { 484 {
487 if (landBitmap[x, y]) 485 if (landBitmap[x, y] == true)
488 { 486 {
489 if (min_x > x) min_x = x; 487 if (min_x > x) min_x = x;
490 if (min_y > y) min_y = y; 488 if (min_y > y) min_y = y;
@@ -501,7 +499,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
501 if (ty > 255) 499 if (ty > 255)
502 ty = 255; 500 ty = 255;
503 landData.AABBMin = 501 landData.AABBMin =
504 new LLVector3((min_x * 4), (min_y * 4), 502 new LLVector3((float) (min_x * 4), (float) (min_y * 4),
505 (float) m_scene.Heightmap[tx, ty]); 503 (float) m_scene.Heightmap[tx, ty]);
506 504
507 tx = max_x * 4; 505 tx = max_x * 4;
@@ -511,7 +509,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
511 if (ty > 255) 509 if (ty > 255)
512 ty = 255; 510 ty = 255;
513 landData.AABBMax = 511 landData.AABBMax =
514 new LLVector3((max_x * 4), (max_y * 4), 512 new LLVector3((float) (max_x * 4), (float) (max_y * 4),
515 (float) m_scene.Heightmap[tx, ty]); 513 (float) m_scene.Heightmap[tx, ty]);
516 landData.area = tempArea; 514 landData.area = tempArea;
517 } 515 }
@@ -659,7 +657,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
659 if (i % 8 == 0) 657 if (i % 8 == 0)
660 { 658 {
661 tempConvertArr[byteNum] = tempByte; 659 tempConvertArr[byteNum] = tempByte;
662 tempByte = 0; 660 tempByte = (byte) 0;
663 i = 0; 661 i = 0;
664 byteNum++; 662 byteNum++;
665 } 663 }
@@ -679,7 +677,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
679 tempByte = landData.landBitmapByteArray[i]; 677 tempByte = landData.landBitmapByteArray[i];
680 for (bitNum = 0; bitNum < 8; bitNum++) 678 for (bitNum = 0; bitNum < 8; bitNum++)
681 { 679 {
682 bool bit = Convert.ToBoolean(Convert.ToByte(tempByte >> bitNum) & 1); 680 bool bit = Convert.ToBoolean(Convert.ToByte(tempByte >> bitNum) & (byte) 1);
683 tempConvertMap[x, y] = bit; 681 tempConvertMap[x, y] = bit;
684 x++; 682 x++;
685 if (x > 63) 683 if (x > 63)
@@ -753,7 +751,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
753 resultLocalIDs.RemoveAt(0); 751 resultLocalIDs.RemoveAt(0);
754 } 752 }
755 pack.Data = data; 753 pack.Data = data;
756 remote_client.OutPacket(pack, ThrottleOutPacketType.Task); 754 remote_client.OutPacket((Packet) pack, ThrottleOutPacketType.Task);
757 } 755 }
758 } 756 }
759 757
@@ -924,5 +922,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
924 #endregion 922 #endregion
925 923
926 #endregion 924 #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 854d2ee..4406e17 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 readonly Commander m_commander = new Commander("Export"); 40 private Commander m_commander = new Commander("Export");
41 private readonly List<Scene> m_regions = new List<Scene>(); 41 private List<Scene> m_regions = new List<Scene>();
42 private readonly List<IFileSerialiser> m_serialisers = new List<IFileSerialiser>();
43 private string m_savedir = "exports" + "/"; 42 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); 108 regionInfoWriter.WriteLine("Region ID: " + scene.RegionInfo.RegionID.ToString());
109 regionInfoWriter.WriteLine("Backup Time: UTC " + DateTime.UtcNow); 109 regionInfoWriter.WriteLine("Backup Time: UTC " + DateTime.UtcNow.ToString());
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 + "/"); 144 List<string> results = SerialiseRegion(region, m_savedir + region.RegionInfo.RegionID.ToString() + "/");
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 + "/"); 153 List<string> results = SerialiseRegion(region, m_savedir + region.RegionInfo.RegionID.ToString() + "/");
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 05fae22..47ce258 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 dt.Hour + (dt.Minute / 60.0); 130 return (double) dt.Hour + ((double) 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 331c49d..a2e0c40 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]) 81 if (cliffMask[x, y] == true)
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 90728da..5d6723f 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] = bs.ReadByte() * (bs.ReadByte() / 127.0); 50 retval[x, y] = (double) bs.ReadByte() * ((double) 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)] = (i * (j / 127.0)); 79 lookupHeightTable[i + (j * 256)] = ((double) i * ((double) 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 04c3f1a..7cb4b00 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 (Encoding.ASCII.GetString(bs.ReadBytes(16)) == "TERRAGENTERRAIN ") 53 if (ASCIIEncoding.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 = Encoding.ASCII.GetString(bs.ReadBytes(4)); 60 string tmp = ASCIIEncoding.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] = baseHeight + bs.ReadInt16() * (double) heightScale / 65536.0; 87 retval[x, y] = (double) baseHeight + (double) 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 fa52a00..dee455f 100644
--- a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/FlattenSphere.cs
+++ b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/FlattenSphere.cs
@@ -31,6 +31,7 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes
31{ 31{
32 public class FlattenSphere : ITerrainPaintableEffect 32 public class FlattenSphere : ITerrainPaintableEffect
33 { 33 {
34
34 #region ITerrainPaintableEffect Members 35 #region ITerrainPaintableEffect Members
35 36
36 public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength, double duration) 37 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 5037533..8ae583e 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(x / (double) Constants.RegionSize, y / (double) Constants.RegionSize, 8, 1.0); 60 double noise = TerrainUtil.PerlinNoise2D((double) x / (double) Constants.RegionSize, (double) 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 acce32e..b47e041 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 readonly ITerrainChannel m_revertmap; 35 private 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 2411de0..f5c0fe4 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() 34 public TerrainException() : base()
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 c105620..eff6159 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; 86 private bool m_tainted = false;
87 87
88 #region ICommandableModule Members 88 #region ICommandableModule Members
89 89
@@ -223,8 +223,6 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain
223 } 223 }
224 } 224 }
225 225
226 #endregion
227
228 #region Plugin Loading Methods 226 #region Plugin Loading Methods
229 227
230 private void LoadPlugins() 228 private void LoadPlugins()
@@ -278,6 +276,8 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain
278 276
279 #endregion 277 #endregion
280 278
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 d964fe4..4b22700 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 += EventManager_OnPluginConsole; 69 m_scene.EventManager.OnPluginConsole += new EventManager.OnPluginConsoleDelegate(EventManager_OnPluginConsole);
70 70
71 Timer CalculateTrees = new Timer(m_tree_updates); 71 Timer CalculateTrees = new Timer(m_tree_updates);
72 CalculateTrees.Elapsed += CalculateTrees_Elapsed; 72 CalculateTrees.Elapsed += new ElapsedEventHandler(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 b2829a1..fd8387b 100644
--- a/OpenSim/Region/Environment/PermissionManager.cs
+++ b/OpenSim/Region/Environment/PermissionManager.cs
@@ -33,21 +33,27 @@ 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;
41 protected Scene m_scene; 36 protected Scene m_scene;
42 37
43 // These are here for testing. They will be taken out 38 // These are here for testing. They will be taken out
39
44 //private uint PERM_ALL = (uint)2147483647; 40 //private uint PERM_ALL = (uint)2147483647;
45 private uint PERM_COPY = 32768; 41 private uint PERM_COPY = (uint)32768;
46 //private uint PERM_MODIFY = (uint)16384; 42 //private uint PERM_MODIFY = (uint)16384;
43 private uint PERM_MOVE = (uint)524288;
47 //private uint PERM_TRANS = (uint)8192; 44 //private uint PERM_TRANS = (uint)8192;
48 private uint PERM_LOCKED = 540672; 45 private uint PERM_LOCKED = (uint)540672;
49 private uint PERM_MOVE = 524288; 46 // Bypasses the permissions engine (always returns OK)
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;
50 51
52 public bool BypassPermissions
53 {
54 get { return m_bypassPermissions; }
55 set { m_bypassPermissions = value; }
56 }
51 57
52 public PermissionManager() 58 public PermissionManager()
53 { 59 {
@@ -58,12 +64,6 @@ namespace OpenSim.Region.Environment
58 m_scene = scene; 64 m_scene = scene;
59 } 65 }
60 66
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,6 +168,8 @@ 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
171 if ((newPos.X > 257f || newPos.X < -1f || newPos.Y > 257f || newPos.Y < -1f)) 173 if ((newPos.X > 257f || newPos.X < -1f || newPos.Y > 257f || newPos.Y < -1f))
172 { 174 {
173 return true; 175 return true;
@@ -191,7 +193,7 @@ namespace OpenSim.Region.Environment
191 return true; 193 return true;
192 } 194 }
193 195
194 if ((land2.landData.landFlags & ((int) Parcel.ParcelFlags.AllowAllObjectEntry)) != 0) 196 if ((land2.landData.landFlags & ((int)Parcel.ParcelFlags.AllowAllObjectEntry)) != 0)
195 { 197 {
196 return true; 198 return true;
197 } 199 }
@@ -208,142 +210,11 @@ namespace OpenSim.Region.Environment
208 return false; 210 return false;
209 } 211 }
210 212
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
343 #region Object Permissions 213 #region Object Permissions
344 214
345 public virtual uint GenerateClientFlags(LLUUID user, LLUUID objID) 215 public virtual uint GenerateClientFlags(LLUUID user, LLUUID objID)
346 { 216 {
217
347 // Here's the way this works, 218 // Here's the way this works,
348 // ObjectFlags and Permission flags are two different enumerations 219 // ObjectFlags and Permission flags are two different enumerations
349 // ObjectFlags, however, tells the client to change what it will allow the user to do. 220 // ObjectFlags, however, tells the client to change what it will allow the user to do.
@@ -355,33 +226,32 @@ namespace OpenSim.Region.Environment
355 // Outside of this method, they should never be added to objectflags! 226 // Outside of this method, they should never be added to objectflags!
356 // -teravus 227 // -teravus
357 228
358 SceneObjectPart task = m_scene.GetSceneObjectPart(objID); 229 SceneObjectPart task=m_scene.GetSceneObjectPart(objID);
359 230
360 // this shouldn't ever happen.. return no permissions/objectflags. 231 // this shouldn't ever happen.. return no permissions/objectflags.
361 if (task == null) 232 if (task == null)
362 return 0; 233 return (uint)0;
363 234
364 uint objflags = task.GetEffectiveObjectFlags(); 235 uint objflags = task.GetEffectiveObjectFlags();
365 LLUUID objectOwner = task.OwnerID; 236 LLUUID objectOwner = task.OwnerID;
366 237
367 238
368 // Remove any of the objectFlags that are temporary. These will get added back if appropriate 239 // Remove any of the objectFlags that are temporary. These will get added back if appropriate
369 // in the next bit of code 240 // in the next bit of code
370 241
371 objflags &= (uint) 242 objflags &= (uint)
372 ~(LLObject.ObjectFlags.ObjectCopy | // Tells client you can copy the object 243 ~(LLObject.ObjectFlags.ObjectCopy | // Tells client you can copy the object
373 LLObject.ObjectFlags.ObjectModify | // tells client you can modify the object 244 LLObject.ObjectFlags.ObjectModify | // tells client you can modify the object
374 LLObject.ObjectFlags.ObjectMove | // tells client that you can move the object (only, no mod) 245 LLObject.ObjectFlags.ObjectMove | // tells client that you can move the object (only, no mod)
375 LLObject.ObjectFlags.ObjectTransfer | // tells the client that you can /take/ the object if you don't own it 246 LLObject.ObjectFlags.ObjectTransfer | // tells the client that you can /take/ the object if you don't own it
376 LLObject.ObjectFlags.ObjectYouOwner | // Tells client that you're the owner of the object 247 LLObject.ObjectFlags.ObjectYouOwner | // Tells client that you're the owner of the object
377 LLObject.ObjectFlags.ObjectYouOfficer 248 LLObject.ObjectFlags.ObjectYouOfficer // Tells client that you've got group object editing permission. Used when ObjectGroupOwned is set
378 // Tells client that you've got group object editing permission. Used when ObjectGroupOwned is set 249 );
379 );
380 250
381 // Creating the three ObjectFlags options for this method to choose from. 251 // Creating the three ObjectFlags options for this method to choose from.
382 // Customize the OwnerMask 252 // Customize the OwnerMask
383 uint objectOwnerMask = ApplyObjectModifyMasks(task.OwnerMask, objflags); 253 uint objectOwnerMask = ApplyObjectModifyMasks(task.OwnerMask, objflags);
384 objectOwnerMask |= (uint) LLObject.ObjectFlags.ObjectYouOwner; 254 objectOwnerMask |= (uint)LLObject.ObjectFlags.ObjectYouOwner;
385 255
386 // Customize the GroupMask 256 // Customize the GroupMask
387 uint objectGroupMask = ApplyObjectModifyMasks(task.GroupMask, objflags); 257 uint objectGroupMask = ApplyObjectModifyMasks(task.GroupMask, objflags);
@@ -391,8 +261,8 @@ namespace OpenSim.Region.Environment
391 261
392 262
393 // Hack to allow collaboration until Groups and Group Permissions are implemented 263 // Hack to allow collaboration until Groups and Group Permissions are implemented
394 if ((objectEveryoneMask & (uint) LLObject.ObjectFlags.ObjectMove) != 0) 264 if ((objectEveryoneMask & (uint)LLObject.ObjectFlags.ObjectMove) != 0)
395 objectEveryoneMask |= (uint) LLObject.ObjectFlags.ObjectModify; 265 objectEveryoneMask |= (uint)LLObject.ObjectFlags.ObjectModify;
396 266
397 if (m_bypassPermissions) 267 if (m_bypassPermissions)
398 return objectOwnerMask; 268 return objectOwnerMask;
@@ -417,6 +287,7 @@ namespace OpenSim.Region.Environment
417 return objectOwnerMask; 287 return objectOwnerMask;
418 288
419 289
290
420 // Admin should be able to edit anything in the sim (including admin objects) 291 // Admin should be able to edit anything in the sim (including admin objects)
421 if (IsAdministrator(user)) 292 if (IsAdministrator(user))
422 return objectOwnerMask; 293 return objectOwnerMask;
@@ -426,29 +297,30 @@ namespace OpenSim.Region.Environment
426 } 297 }
427 298
428 299
300
429 private uint ApplyObjectModifyMasks(uint setPermissionMask, uint objectFlagsMask) 301 private uint ApplyObjectModifyMasks(uint setPermissionMask, uint objectFlagsMask)
430 { 302 {
431 // We are adding the temporary objectflags to the object's objectflags based on the 303 // We are adding the temporary objectflags to the object's objectflags based on the
432 // permission flag given. These change the F flags on the client. 304 // permission flag given. These change the F flags on the client.
433 305
434 if ((setPermissionMask & (uint) PermissionMask.Copy) != 0) 306 if ((setPermissionMask & (uint)PermissionMask.Copy) != 0)
435 { 307 {
436 objectFlagsMask |= (uint) LLObject.ObjectFlags.ObjectCopy; 308 objectFlagsMask |= (uint)LLObject.ObjectFlags.ObjectCopy;
437 } 309 }
438 310
439 if ((setPermissionMask & (uint) PermissionMask.Move) != 0) 311 if ((setPermissionMask & (uint)PermissionMask.Move) != 0)
440 { 312 {
441 objectFlagsMask |= (uint) LLObject.ObjectFlags.ObjectMove; 313 objectFlagsMask |= (uint)LLObject.ObjectFlags.ObjectMove;
442 } 314 }
443 315
444 if ((setPermissionMask & (uint) PermissionMask.Modify) != 0) 316 if ((setPermissionMask & (uint)PermissionMask.Modify) != 0)
445 { 317 {
446 objectFlagsMask |= (uint) LLObject.ObjectFlags.ObjectModify; 318 objectFlagsMask |= (uint)LLObject.ObjectFlags.ObjectModify;
447 } 319 }
448 320
449 if ((setPermissionMask & (uint) PermissionMask.Transfer) != 0) 321 if ((setPermissionMask & (uint)PermissionMask.Transfer) != 0)
450 { 322 {
451 objectFlagsMask |= (uint) LLObject.ObjectFlags.ObjectTransfer; 323 objectFlagsMask |= (uint)LLObject.ObjectFlags.ObjectTransfer;
452 } 324 }
453 325
454 return objectFlagsMask; 326 return objectFlagsMask;
@@ -472,7 +344,7 @@ namespace OpenSim.Region.Environment
472 } 344 }
473 345
474 346
475 SceneObjectGroup group = (SceneObjectGroup) m_scene.Entities[objId]; 347 SceneObjectGroup group = (SceneObjectGroup)m_scene.Entities[objId];
476 348
477 LLUUID objectOwner = group.OwnerID; 349 LLUUID objectOwner = group.OwnerID;
478 locked = ((group.RootPart.OwnerMask & PERM_LOCKED) == 0); 350 locked = ((group.RootPart.OwnerMask & PERM_LOCKED) == 0);
@@ -560,7 +432,7 @@ namespace OpenSim.Region.Environment
560 } 432 }
561 433
562 434
563 SceneObjectGroup task = (SceneObjectGroup) m_scene.Entities[obj]; 435 SceneObjectGroup task = (SceneObjectGroup)m_scene.Entities[obj];
564 436
565 437
566 LLUUID taskOwner = null; 438 LLUUID taskOwner = null;
@@ -575,6 +447,7 @@ namespace OpenSim.Region.Environment
575 // Locked 447 // Locked
576 if ((task.RootPart.OwnerMask & PERM_LOCKED) == 0) 448 if ((task.RootPart.OwnerMask & PERM_LOCKED) == 0)
577 permission = false; 449 permission = false;
450
578 } 451 }
579 else 452 else
580 { 453 {
@@ -591,7 +464,7 @@ namespace OpenSim.Region.Environment
591 } 464 }
592 465
593 466
594 SceneObjectGroup group = (SceneObjectGroup) m_scene.Entities[obj]; 467 SceneObjectGroup group = (SceneObjectGroup)m_scene.Entities[obj];
595 468
596 LLUUID objectOwner = group.OwnerID; 469 LLUUID objectOwner = group.OwnerID;
597 locked = ((group.RootPart.OwnerMask & PERM_LOCKED) == 0); 470 locked = ((group.RootPart.OwnerMask & PERM_LOCKED) == 0);
@@ -629,7 +502,7 @@ namespace OpenSim.Region.Environment
629 return false; 502 return false;
630 } 503 }
631 504
632 SceneObjectGroup task = (SceneObjectGroup) m_scene.Entities[obj]; 505 SceneObjectGroup task = (SceneObjectGroup)m_scene.Entities[obj];
633 LLUUID taskOwner = null; 506 LLUUID taskOwner = null;
634 // Added this because at this point in time it wouldn't be wise for 507 // Added this because at this point in time it wouldn't be wise for
635 // the administrator object permissions to take effect. 508 // the administrator object permissions to take effect.
@@ -685,5 +558,137 @@ namespace OpenSim.Region.Environment
685 } 558 }
686 559
687 #endregion 560 #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
688 } 693 }
689} \ No newline at end of file 694}
diff --git a/OpenSim/Region/Environment/Scenes/AvatarAnimations.cs b/OpenSim/Region/Environment/Scenes/AvatarAnimations.cs
index 2fc2a10..fe9c8e7 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 = nod.Attributes["name"].Value; 49 string name = (string)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} \ No newline at end of file 59}
diff --git a/OpenSim/Region/Environment/Scenes/AvatarAppearance.cs b/OpenSim/Region/Environment/Scenes/AvatarAppearance.cs
index 860399c..8f29507 100644
--- a/OpenSim/Region/Environment/Scenes/AvatarAppearance.cs
+++ b/OpenSim/Region/Environment/Scenes/AvatarAppearance.cs
@@ -37,54 +37,14 @@ 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;
41 protected LLUUID m_scenePresenceID; 40 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 }
82 41
83 public LLUUID ScenePresenceID 42 public LLUUID ScenePresenceID
84 { 43 {
85 get { return m_scenePresenceID; } 44 get { return m_scenePresenceID; }
86 set { m_scenePresenceID = value; } 45 set { m_scenePresenceID = value; }
87 } 46 }
47 protected int m_wearablesSerial = 1;
88 48
89 public int WearablesSerial 49 public int WearablesSerial
90 { 50 {
@@ -92,51 +52,50 @@ namespace OpenSim.Region.Environment.Scenes
92 set { m_wearablesSerial = value; } 52 set { m_wearablesSerial = value; }
93 } 53 }
94 54
55 protected byte[] m_visualParams;
56
95 public byte[] VisualParams 57 public byte[] VisualParams
96 { 58 {
97 get { return m_visualParams; } 59 get { return m_visualParams; }
98 set { m_visualParams = value; } 60 set { m_visualParams = value; }
99 } 61 }
100 62
63 protected AvatarWearable[] m_wearables;
64
101 public AvatarWearable[] Wearables 65 public AvatarWearable[] Wearables
102 { 66 {
103 get { return m_wearables; } 67 get { return m_wearables; }
104 set { m_wearables = value; } 68 set { m_wearables = value; }
105 } 69 }
106 70
71 protected LLObject.TextureEntry m_textureEntry;
72
107 public LLObject.TextureEntry TextureEntry 73 public LLObject.TextureEntry TextureEntry
108 { 74 {
109 get { return m_textureEntry; } 75 get { return m_textureEntry; }
110 set { m_textureEntry = value; } 76 set { m_textureEntry = value; }
111 } 77 }
112 78
79 protected float m_avatarHeight = 0;
80
113 public float AvatarHeight 81 public float AvatarHeight
114 { 82 {
115 get { return m_avatarHeight; } 83 get { return m_avatarHeight; }
116 set { m_avatarHeight = value; } 84 set { m_avatarHeight = value; }
117 } 85 }
118 86
119 #region ISerializable Members 87 public AvatarAppearance()
120
121 [SecurityPermission(SecurityAction.LinkDemand,
122 Flags = SecurityPermissionFlag.SerializationFormatter)]
123 public virtual void GetObjectData(
124 SerializationInfo info, StreamingContext context)
125 { 88 {
126 if (info == null)
127 {
128 throw new ArgumentNullException("info");
129 }
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);
137 } 89 }
138 90
139 #endregion 91 public AvatarAppearance(LLUUID avatarID, AvatarWearable[] wearables, byte[] visualParams)
92 {
93 m_scenePresenceID = avatarID;
94 m_wearablesSerial = 1;
95 m_wearables = wearables;
96 m_visualParams = visualParams;
97 m_textureEntry = GetDefaultTextureEntry();
98 }
140 99
141 /// <summary> 100 /// <summary>
142 /// 101 ///
@@ -156,8 +115,8 @@ namespace OpenSim.Region.Environment.Scenes
156 // Teravus : Nifty AV Height Getting Maaaaagical formula. Oh how we love turning 0-255 into meters. 115 // Teravus : Nifty AV Height Getting Maaaaagical formula. Oh how we love turning 0-255 into meters.
157 // (float)m_visualParams[25] = Height 116 // (float)m_visualParams[25] = Height
158 // (float)m_visualParams[125] = LegLength 117 // (float)m_visualParams[125] = LegLength
159 m_avatarHeight = (1.50856f + ((m_visualParams[25] / 255.0f) * (2.525506f - 1.50856f))) 118 m_avatarHeight = (1.50856f + (((float) m_visualParams[25]/255.0f)*(2.525506f - 1.50856f)))
160 + ((m_visualParams[125] / 255.0f) / 1.5f); 119 + (((float) m_visualParams[125]/255.0f)/1.5f);
161 } 120 }
162 121
163 /// <summary> 122 /// <summary>
@@ -193,5 +152,45 @@ namespace OpenSim.Region.Environment.Scenes
193 textu.CreateFace(6).TextureID = new LLUUID("00000000-0000-1111-9999-000000000011"); 152 textu.CreateFace(6).TextureID = new LLUUID("00000000-0000-1111-9999-000000000011");
194 return textu; 153 return textu;
195 } 154 }
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 }
196 } 195 }
197} \ No newline at end of file 196}
diff --git a/OpenSim/Region/Environment/Scenes/EntityBase.cs b/OpenSim/Region/Environment/Scenes/EntityBase.cs
index 7e43718..11bafb7 100644
--- a/OpenSim/Region/Environment/Scenes/EntityBase.cs
+++ b/OpenSim/Region/Environment/Scenes/EntityBase.cs
@@ -36,83 +36,23 @@ 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;
44 protected Scene m_scene; 39 protected Scene m_scene;
45 40
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
105 public Scene Scene 41 public Scene Scene
106 { 42 {
107 get { return m_scene; } 43 get { return m_scene; }
108 } 44 }
109 45
46 protected LLUUID m_uuid;
47
110 public virtual LLUUID UUID 48 public virtual LLUUID UUID
111 { 49 {
112 get { return m_uuid; } 50 get { return m_uuid; }
113 set { m_uuid = value; } 51 set { m_uuid = value; }
114 } 52 }
115 53
54 protected string m_name;
55
116 /// <summary> 56 /// <summary>
117 /// 57 ///
118 /// </summary> 58 /// </summary>
@@ -122,6 +62,8 @@ namespace OpenSim.Region.Environment.Scenes
122 set { m_name = value; } 62 set { m_name = value; }
123 } 63 }
124 64
65 protected LLVector3 m_pos;
66
125 /// <summary> 67 /// <summary>
126 /// 68 ///
127 /// </summary> 69 /// </summary>
@@ -131,6 +73,9 @@ namespace OpenSim.Region.Environment.Scenes
131 set { m_pos = value; } 73 set { m_pos = value; }
132 } 74 }
133 75
76 protected LLVector3 m_velocity;
77 protected LLVector3 m_rotationalvelocity;
78
134 /// <summary> 79 /// <summary>
135 /// 80 ///
136 /// </summary> 81 /// </summary>
@@ -140,24 +85,104 @@ namespace OpenSim.Region.Environment.Scenes
140 set { m_velocity = value; } 85 set { m_velocity = value; }
141 } 86 }
142 87
88 protected Quaternion m_rotation = new Quaternion(0, 0, 1, 0);
89
143 public virtual Quaternion Rotation 90 public virtual Quaternion Rotation
144 { 91 {
145 get { return m_rotation; } 92 get { return m_rotation; }
146 set { m_rotation = value; } 93 set { m_rotation = value; }
147 } 94 }
148 95
96 protected uint m_localId;
97
149 public virtual uint LocalId 98 public virtual uint LocalId
150 { 99 {
151 get { return m_localId; } 100 get { return m_localId; }
152 set { m_localId = value; } 101 set { m_localId = value; }
153 } 102 }
154 103
155 #region ISerializable Members 104 /// <summary>
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 }
156 181
157 [SecurityPermission(SecurityAction.LinkDemand, 182 [SecurityPermission(SecurityAction.LinkDemand,
158 Flags = SecurityPermissionFlag.SerializationFormatter)] 183 Flags = SecurityPermissionFlag.SerializationFormatter)]
159 public virtual void GetObjectData( 184 public virtual void GetObjectData(
160 SerializationInfo info, StreamingContext context) 185 SerializationInfo info, StreamingContext context)
161 { 186 {
162 if (info == null) 187 if (info == null)
163 { 188 {
@@ -190,42 +215,18 @@ namespace OpenSim.Region.Environment.Scenes
190 215
191 info.AddValue("m_localId", m_localId); 216 info.AddValue("m_localId", m_localId);
192 } 217 }
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);
217 } 218 }
218 219
219 //Nested Classes 220 //Nested Classes
220 public class EntityIntersection 221 public class EntityIntersection
221 { 222 {
222 public Vector3 AAfaceNormal = new Vector3(0, 0, 0);
223 public float distance;
224 public int face = -1;
225 public bool HitTF;
226 public Vector3 ipoint = new Vector3(0, 0, 0); 223 public Vector3 ipoint = new Vector3(0, 0, 0);
227 public Vector3 normal = new Vector3(0, 0, 0); 224 public Vector3 normal = new Vector3(0, 0, 0);
225 public Vector3 AAfaceNormal = new Vector3(0, 0, 0);
226 public int face = -1;
227 public bool HitTF = false;
228 public SceneObjectPart obj; 228 public SceneObjectPart obj;
229 public float distance = 0;
229 230
230 public EntityIntersection() 231 public EntityIntersection()
231 { 232 {
@@ -238,4 +239,4 @@ namespace OpenSim.Region.Environment.Scenes
238 HitTF = _HitTF; 239 HitTF = _HitTF;
239 } 240 }
240 } 241 }
241} \ No newline at end of file 242}
diff --git a/OpenSim/Region/Environment/Scenes/IScenePresenceBody.cs b/OpenSim/Region/Environment/Scenes/IScenePresenceBody.cs
index 508eb67..3a20190 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} \ No newline at end of file 37}
diff --git a/OpenSim/Region/Environment/Scenes/InnerScene.cs b/OpenSim/Region/Environment/Scenes/InnerScene.cs
index 3889741..da286ad 100644
--- a/OpenSim/Region/Environment/Scenes/InnerScene.cs
+++ b/OpenSim/Region/Environment/Scenes/InnerScene.cs
@@ -46,33 +46,36 @@ namespace OpenSim.Region.Environment.Scenes
46 46
47 #region Events 47 #region Events
48 48
49 private PhysicsCrash handlerPhysicsCrash;
50 public event PhysicsCrash UnRecoverableError; 49 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;
56 // SceneObjects is not currently populated or used. 57 // SceneObjects is not currently populated or used.
57 //public Dictionary<LLUUID, SceneObjectGroup> SceneObjects; 58 //public Dictionary<LLUUID, SceneObjectGroup> SceneObjects;
58 public PhysicsScene _PhyScene;
59 public Dictionary<LLUUID, EntityBase> Entities; 59 public Dictionary<LLUUID, EntityBase> Entities;
60 protected int m_activeScripts; 60 public Dictionary<LLUUID, ScenePresence> RestorePresences;
61 protected int m_numChildAgents; 61
62 protected int m_numPrim; 62 public BasicQuadTreeNode QuadTree;
63 protected int m_numRootAgents; 63
64 protected Scene m_parentScene;
65 protected int m_physicalPrim;
66 protected RegionInfo m_regInfo; 64 protected RegionInfo m_regInfo;
65 protected Scene m_parentScene;
66 protected PermissionManager PermissionsMngr;
67 protected List<EntityBase> m_updateList = new List<EntityBase>();
68 protected int m_numRootAgents = 0;
69 protected int m_numPrim = 0;
70 protected int m_numChildAgents = 0;
71 protected int m_physicalPrim = 0;
67 72
68 protected int m_scriptLPS; 73 protected int m_activeScripts = 0;
74 protected int m_scriptLPS = 0;
69 75
70 internal object m_syncRoot = new object(); 76 internal object m_syncRoot = new object();
71 protected List<EntityBase> m_updateList = new List<EntityBase>(); 77
72 protected PermissionManager PermissionsMngr; 78 public PhysicsScene _PhyScene;
73 public BasicQuadTreeNode QuadTree;
74 public Dictionary<LLUUID, ScenePresence> RestorePresences;
75 public Dictionary<LLUUID, ScenePresence> ScenePresences;
76 79
77 #endregion 80 #endregion
78 81
@@ -81,7 +84,7 @@ namespace OpenSim.Region.Environment.Scenes
81 m_parentScene = parent; 84 m_parentScene = parent;
82 m_regInfo = regInfo; 85 m_regInfo = regInfo;
83 PermissionsMngr = permissionsMngr; 86 PermissionsMngr = permissionsMngr;
84 QuadTree = new BasicQuadTreeNode(null, "/0/", 0, 0, (short) Constants.RegionSize, (short) Constants.RegionSize); 87 QuadTree = new BasicQuadTreeNode(null, "/0/", 0, 0, (short)Constants.RegionSize, (short)Constants.RegionSize);
85 QuadTree.Subdivide(); 88 QuadTree.Subdivide();
86 QuadTree.Subdivide(); 89 QuadTree.Subdivide();
87 } 90 }
@@ -159,7 +162,7 @@ namespace OpenSim.Region.Environment.Scenes
159 { 162 {
160 lock (m_syncRoot) 163 lock (m_syncRoot)
161 { 164 {
162 return _PhyScene.Simulate((float) elapsed); 165 return _PhyScene.Simulate((float)elapsed);
163 } 166 }
164 } 167 }
165 168
@@ -184,6 +187,7 @@ namespace OpenSim.Region.Environment.Scenes
184 foreach (SceneObjectPart part in sceneObject.Children.Values) 187 foreach (SceneObjectPart part in sceneObject.Children.Values)
185 { 188 {
186 part.LocalId = m_parentScene.PrimIDAllocate(); 189 part.LocalId = m_parentScene.PrimIDAllocate();
190
187 } 191 }
188 sceneObject.UpdateParentIDs(); 192 sceneObject.UpdateParentIDs();
189 AddEntity(sceneObject); 193 AddEntity(sceneObject);
@@ -229,7 +233,7 @@ namespace OpenSim.Region.Environment.Scenes
229 for (int i = 0; i < m_updateList.Count; i++) 233 for (int i = 0; i < m_updateList.Count; i++)
230 { 234 {
231 EntityBase entity = m_updateList[i]; 235 EntityBase entity = m_updateList[i];
232 236
233 // Don't abort the whole update if one entity happens to give us an exception. 237 // Don't abort the whole update if one entity happens to give us an exception.
234 try 238 try
235 { 239 {
@@ -245,7 +249,7 @@ namespace OpenSim.Region.Environment.Scenes
245 } 249 }
246 catch (Exception e) 250 catch (Exception e)
247 { 251 {
248 m_log.ErrorFormat("[INNER SCENE]: Failed to update {0}, - {1}", entity.Name, e); //entity.m_uuid 252 m_log.ErrorFormat("[INNER SCENE]: Failed to update {0}, - {1}", entity.Name, e);//entity.m_uuid
249 } 253 }
250 } 254 }
251 m_updateList.Clear(); 255 m_updateList.Clear();
@@ -280,16 +284,15 @@ namespace OpenSim.Region.Environment.Scenes
280 { 284 {
281 if (obj is SceneObjectGroup) 285 if (obj is SceneObjectGroup)
282 { 286 {
283 if ((obj).LocalId == localID) 287 if (((SceneObjectGroup)obj).LocalId == localID)
284 { 288 {
285 m_parentScene.RemoveEntity((SceneObjectGroup) obj); 289 m_parentScene.RemoveEntity((SceneObjectGroup)obj);
286 m_numPrim--; 290 m_numPrim--;
287 return; 291 return;
288 } 292 }
289 } 293 }
290 } 294 }
291 } 295 }
292
293 public void DetachObject(uint objectLocalID, IClientAPI remoteClient) 296 public void DetachObject(uint objectLocalID, IClientAPI remoteClient)
294 { 297 {
295 List<EntityBase> EntityList = GetEntities(); 298 List<EntityBase> EntityList = GetEntities();
@@ -298,25 +301,29 @@ namespace OpenSim.Region.Environment.Scenes
298 { 301 {
299 if (obj is SceneObjectGroup) 302 if (obj is SceneObjectGroup)
300 { 303 {
301 if ((obj).LocalId == objectLocalID) 304 if (((SceneObjectGroup)obj).LocalId == objectLocalID)
302 { 305 {
303 SceneObjectGroup group = (SceneObjectGroup) obj; 306 SceneObjectGroup group = (SceneObjectGroup)obj;
304 307
305 //group.DetachToGround(); 308 //group.DetachToGround();
306 DetachSingleAttachmentToInv(group.GetFromAssetID(), remoteClient); 309 DetachSingleAttachmentToInv(group.GetFromAssetID(),remoteClient);
307 } 310 }
308 } 311 }
309 } 312 }
313
310 } 314 }
311 315
312 public void HandleUndo(IClientAPI remoteClient, LLUUID primId) 316 public void HandleUndo(IClientAPI remoteClient, LLUUID primId)
313 { 317 {
314 if (primId != LLUUID.Zero) 318 if (primId != LLUUID.Zero)
315 { 319 {
316 SceneObjectPart part = m_parentScene.GetSceneObjectPart(primId); 320 SceneObjectPart part = m_parentScene.GetSceneObjectPart(primId);
317 if (part != null) 321 if (part != null)
318 part.Undo(); 322 part.Undo();
323
319 } 324 }
325
326
320 } 327 }
321 328
322 /// <summary> 329 /// <summary>
@@ -331,29 +338,27 @@ namespace OpenSim.Region.Environment.Scenes
331 // Calls attach with a Zero position 338 // Calls attach with a Zero position
332 AttachObject(remoteClient, objectLocalID, AttachmentPt, rot, LLVector3.Zero); 339 AttachObject(remoteClient, objectLocalID, AttachmentPt, rot, LLVector3.Zero);
333 } 340 }
334 341 public void RezSingleAttachment(IClientAPI remoteClient, LLUUID itemID, uint AttachmentPt,uint ItemFlags, uint NextOwnerMask)
335 public void RezSingleAttachment(IClientAPI remoteClient, LLUUID itemID, uint AttachmentPt, uint ItemFlags, uint NextOwnerMask)
336 { 342 {
337 SceneObjectGroup objatt = m_parentScene.RezObject(remoteClient, itemID, LLVector3.Zero, LLVector3.Zero, LLUUID.Zero, 1, true, 343 SceneObjectGroup objatt = m_parentScene.RezObject(remoteClient, itemID, LLVector3.Zero, LLVector3.Zero, LLUUID.Zero, (byte)1, true,
338 (uint) 344 (uint)(PermissionMask.Copy | PermissionMask.Move | PermissionMask.Modify | PermissionMask.Transfer),
339 (PermissionMask.Copy | PermissionMask.Move | PermissionMask.Modify | PermissionMask.Transfer), 345 (uint)(PermissionMask.Copy | PermissionMask.Move | PermissionMask.Modify | PermissionMask.Transfer),
340 (uint) 346 (uint)(PermissionMask.Copy | PermissionMask.Move | PermissionMask.Modify | PermissionMask.Transfer),
341 (PermissionMask.Copy | PermissionMask.Move | PermissionMask.Modify | PermissionMask.Transfer), 347 ItemFlags, false, false, remoteClient.AgentId, true);
342 (uint)
343 (PermissionMask.Copy | PermissionMask.Move | PermissionMask.Modify | PermissionMask.Transfer),
344 ItemFlags, false, false, remoteClient.AgentId, true);
345 348
346 if (objatt != null) 349 if (objatt != null)
347 { 350 {
348 AttachObject(remoteClient, objatt.LocalId, AttachmentPt, new LLQuaternion(0, 0, 0, 1), objatt.AbsolutePosition); 351 AttachObject(remoteClient,objatt.LocalId,AttachmentPt,new LLQuaternion(0,0,0,1),objatt.AbsolutePosition);
349 objatt.ScheduleGroupForFullUpdate(); 352 objatt.ScheduleGroupForFullUpdate();
350 } 353 }
354
351 } 355 }
352 356
353 // What makes this method odd and unique is it tries to detach using an LLUUID.... Yay for standards. 357 // What makes this method odd and unique is it tries to detach using an LLUUID.... Yay for standards.
354 // To LocalId or LLUUID, *THAT* is the question. How now Brown LLUUID?? 358 // To LocalId or LLUUID, *THAT* is the question. How now Brown LLUUID??
355 public void DetachSingleAttachmentToInv(LLUUID itemID, IClientAPI remoteClient) 359 public void DetachSingleAttachmentToInv(LLUUID itemID, IClientAPI remoteClient)
356 { 360 {
361
357 if (itemID == LLUUID.Zero) // If this happened, someone made a mistake.... 362 if (itemID == LLUUID.Zero) // If this happened, someone made a mistake....
358 return; 363 return;
359 364
@@ -363,16 +368,17 @@ namespace OpenSim.Region.Environment.Scenes
363 { 368 {
364 if (obj is SceneObjectGroup) 369 if (obj is SceneObjectGroup)
365 { 370 {
366 if (((SceneObjectGroup) obj).GetFromAssetID() == itemID) 371 if (((SceneObjectGroup)obj).GetFromAssetID() == itemID)
367 { 372 {
368 SceneObjectGroup group = (SceneObjectGroup) obj; 373 SceneObjectGroup group = (SceneObjectGroup)obj;
369 group.DetachToInventoryPrep(); 374 group.DetachToInventoryPrep();
370 m_log.Debug("[DETACH]: Saving attachpoint: " + ((uint) group.GetAttachmentPoint())); 375 m_log.Debug("[DETACH]: Saving attachpoint: " + ((uint)group.GetAttachmentPoint()).ToString());
371 m_parentScene.updateKnownAsset(remoteClient, group, group.GetFromAssetID(), group.OwnerID); 376 m_parentScene.updateKnownAsset(remoteClient, group, group.GetFromAssetID(),group.OwnerID);
372 m_parentScene.DeleteSceneObjectGroup(group); 377 m_parentScene.DeleteSceneObjectGroup(group);
373 } 378 }
374 } 379 }
375 } 380 }
381
376 } 382 }
377 383
378 public void AttachObject(IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, LLQuaternion rot, LLVector3 attachPos) 384 public void AttachObject(IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, LLQuaternion rot, LLVector3 attachPos)
@@ -382,34 +388,39 @@ namespace OpenSim.Region.Environment.Scenes
382 { 388 {
383 if (obj is SceneObjectGroup) 389 if (obj is SceneObjectGroup)
384 { 390 {
385 if ((obj).LocalId == objectLocalID) 391 if (((SceneObjectGroup)obj).LocalId == objectLocalID)
386 { 392 {
387 SceneObjectGroup group = (SceneObjectGroup) obj; 393 SceneObjectGroup group = (SceneObjectGroup)obj;
388 394
389 // If the attachment point isn't the same as the one previously used 395 // If the attachment point isn't the same as the one previously used
390 // set it's offset position = 0 so that it appears on the attachment point 396 // set it's offset position = 0 so that it appears on the attachment point
391 // and not in a weird location somewhere unknown. 397 // and not in a weird location somewhere unknown.
392 if (AttachmentPt != 0 && AttachmentPt != group.GetAttachmentPoint()) 398 if (AttachmentPt != 0 && AttachmentPt != (uint)group.GetAttachmentPoint())
393 { 399 {
400
394 attachPos = LLVector3.Zero; 401 attachPos = LLVector3.Zero;
395 } 402 }
396 403
397 // AttachmentPt 0 means the client chose to 'wear' the attachment. 404 // AttachmentPt 0 means the client chose to 'wear' the attachment.
398 if (AttachmentPt == 0) 405 if (AttachmentPt == 0)
399 { 406 {
407
400 // Check object for stored attachment point 408 // Check object for stored attachment point
401 AttachmentPt = group.GetAttachmentPoint(); 409 AttachmentPt = (uint)group.GetAttachmentPoint();
410
411
402 } 412 }
403 413
404 // if we still didn't find a suitable attachment point....... 414 // if we still didn't find a suitable attachment point.......
405 if (AttachmentPt == 0) 415 if (AttachmentPt == 0)
406 { 416 {
407 // Stick it on left hand with Zero Offset from the attachment point. 417 // Stick it on left hand with Zero Offset from the attachment point.
408 AttachmentPt = (uint) AttachmentPoint.LeftHand; 418 AttachmentPt = (uint)AttachmentPoint.LeftHand;
409 attachPos = LLVector3.Zero; 419 attachPos = LLVector3.Zero;
410 } 420 }
411 m_log.Debug("[ATTACH]: Using attachpoint: " + AttachmentPt); 421 m_log.Debug("[ATTACH]: Using attachpoint: " + AttachmentPt.ToString());
412 422
423
413 424
414 // Saves and gets assetID 425 // Saves and gets assetID
415 if (group.GetFromAssetID() == LLUUID.Zero) 426 if (group.GetFromAssetID() == LLUUID.Zero)
@@ -420,14 +431,16 @@ namespace OpenSim.Region.Environment.Scenes
420 group.SetFromAssetID(newAssetID); 431 group.SetFromAssetID(newAssetID);
421 } 432 }
422 group.AttachToAgent(remoteClient.AgentId, AttachmentPt, attachPos); 433 group.AttachToAgent(remoteClient.AgentId, AttachmentPt, attachPos);
434
423 } 435 }
436
424 } 437 }
425 } 438 }
426 }
427 439
440 }
428 // Use the above method. 441 // Use the above method.
429 public void AttachObject(IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, LLQuaternion rot, 442 public void AttachObject(IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, LLQuaternion rot,
430 bool deadMethod) 443 bool deadMethod)
431 { 444 {
432 Console.WriteLine("Attaching object " + objectLocalID + " to " + AttachmentPt); 445 Console.WriteLine("Attaching object " + objectLocalID + " to " + AttachmentPt);
433 SceneObjectPart p = GetSceneObjectPart(objectLocalID); 446 SceneObjectPart p = GetSceneObjectPart(objectLocalID);
@@ -476,14 +489,14 @@ namespace OpenSim.Region.Environment.Scenes
476 objupdate.ObjectData[0].ParentID = 0; 489 objupdate.ObjectData[0].ParentID = 0;
477 objupdate.ObjectData[0].OwnerID = LLUUID.Zero; 490 objupdate.ObjectData[0].OwnerID = LLUUID.Zero;
478 objupdate.ObjectData[0].Scale = new LLVector3(1, 1, 1); 491 objupdate.ObjectData[0].Scale = new LLVector3(1, 1, 1);
479 objupdate.ObjectData[0].PCode = (byte) PCode.Avatar; 492 objupdate.ObjectData[0].PCode = (byte)PCode.Avatar;
480 objupdate.ObjectData[0].TextureEntry = ScenePresence.DefaultTexture; 493 objupdate.ObjectData[0].TextureEntry = ScenePresence.DefaultTexture;
481 494
482 objupdate.ObjectData[0].ID = av.LocalId; 495 objupdate.ObjectData[0].ID = av.LocalId;
483 objupdate.ObjectData[0].FullID = remoteClient.AgentId; 496 objupdate.ObjectData[0].FullID = remoteClient.AgentId;
484 objupdate.ObjectData[0].ParentID = 0; 497 objupdate.ObjectData[0].ParentID = 0;
485 objupdate.ObjectData[0].NameValue = 498 objupdate.ObjectData[0].NameValue =
486 Helpers.StringToField("FirstName STRING RW SV " + av.Firstname + "\nLastName STRING RW SV " + av.Lastname); 499 Helpers.StringToField("FirstName STRING RW SV " + av.Firstname + "\nLastName STRING RW SV " + av.Lastname);
487 LLVector3 pos2 = av.AbsolutePosition; 500 LLVector3 pos2 = av.AbsolutePosition;
488 // new LLVector3((float) Pos.X, (float) Pos.Y, (float) Pos.Z); 501 // new LLVector3((float) Pos.X, (float) Pos.Y, (float) Pos.Z);
489 byte[] pb = pos2.GetBytes(); 502 byte[] pb = pos2.GetBytes();
@@ -516,7 +529,7 @@ namespace OpenSim.Region.Environment.Scenes
516 529
517 objupdate.ObjectData[1].TextureEntry = primData.TextureEntry; 530 objupdate.ObjectData[1].TextureEntry = primData.TextureEntry;
518 objupdate.ObjectData[1].PCode = primData.PCode; 531 objupdate.ObjectData[1].PCode = primData.PCode;
519 objupdate.ObjectData[1].State = (byte) (((byte) AttachmentPt) << 4); 532 objupdate.ObjectData[1].State = (byte)(((byte)AttachmentPt) << 4);
520 objupdate.ObjectData[1].PathBegin = primData.PathBegin; 533 objupdate.ObjectData[1].PathBegin = primData.PathBegin;
521 objupdate.ObjectData[1].PathEnd = primData.PathEnd; 534 objupdate.ObjectData[1].PathEnd = primData.PathEnd;
522 objupdate.ObjectData[1].PathScaleX = primData.PathScaleX; 535 objupdate.ObjectData[1].PathScaleX = primData.PathScaleX;
@@ -553,8 +566,8 @@ namespace OpenSim.Region.Environment.Scenes
553 //objupdate.ObjectData[1].ClickAction = clickAction; 566 //objupdate.ObjectData[1].ClickAction = clickAction;
554 objupdate.ObjectData[1].Radius = 20; 567 objupdate.ObjectData[1].Radius = 20;
555 objupdate.ObjectData[1].NameValue = 568 objupdate.ObjectData[1].NameValue =
556 Helpers.StringToField("AttachItemID STRING RW SV " + p.UUID); 569 Helpers.StringToField("AttachItemID STRING RW SV " + p.UUID);
557 LLVector3 pos = new LLVector3((float) 0.0, (float) 0.0, (float) 0.0); 570 LLVector3 pos = new LLVector3((float)0.0, (float)0.0, (float)0.0);
558 571
559 pb = pos.GetBytes(); 572 pb = pos.GetBytes();
560 Array.Copy(pb, 0, objupdate.ObjectData[1].ObjectData, 0, pb.Length); 573 Array.Copy(pb, 0, objupdate.ObjectData[1].ObjectData, 0, pb.Length);
@@ -725,7 +738,6 @@ namespace OpenSim.Region.Environment.Scenes
725 m_scriptLPS = 0; 738 m_scriptLPS = 0;
726 return returnval; 739 return returnval;
727 } 740 }
728
729 #endregion 741 #endregion
730 742
731 #region Get Methods 743 #region Get Methods
@@ -753,7 +765,7 @@ namespace OpenSim.Region.Environment.Scenes
753 765
754 return result; 766 return result;
755 } 767 }
756 768
757 /// <summary> 769 /// <summary>
758 /// Get the controlling client for the given avatar, if there is one. 770 /// Get the controlling client for the given avatar, if there is one.
759 /// 771 ///
@@ -767,12 +779,12 @@ namespace OpenSim.Region.Environment.Scenes
767 public IClientAPI GetControllingClient(LLUUID agentId) 779 public IClientAPI GetControllingClient(LLUUID agentId)
768 { 780 {
769 ScenePresence presence = GetScenePresence(agentId); 781 ScenePresence presence = GetScenePresence(agentId);
770 782
771 if (presence != null) 783 if (presence != null)
772 { 784 {
773 return presence.ControllingClient; 785 return presence.ControllingClient;
774 } 786 }
775 787
776 return null; 788 return null;
777 } 789 }
778 790
@@ -807,7 +819,7 @@ namespace OpenSim.Region.Environment.Scenes
807 { 819 {
808 return ScenePresences[agentID]; 820 return ScenePresences[agentID];
809 } 821 }
810 822
811 return null; 823 return null;
812 } 824 }
813 825
@@ -819,8 +831,8 @@ namespace OpenSim.Region.Environment.Scenes
819 { 831 {
820 if (ent is SceneObjectGroup) 832 if (ent is SceneObjectGroup)
821 { 833 {
822 if (((SceneObjectGroup) ent).HasChildPrim(localID)) 834 if (((SceneObjectGroup)ent).HasChildPrim(localID))
823 return (SceneObjectGroup) ent; 835 return (SceneObjectGroup)ent;
824 } 836 }
825 } 837 }
826 return null; 838 return null;
@@ -834,8 +846,8 @@ namespace OpenSim.Region.Environment.Scenes
834 { 846 {
835 if (ent is SceneObjectGroup) 847 if (ent is SceneObjectGroup)
836 { 848 {
837 if (((SceneObjectGroup) ent).HasChildPrim(fullID)) 849 if (((SceneObjectGroup)ent).HasChildPrim(fullID))
838 return (SceneObjectGroup) ent; 850 return (SceneObjectGroup)ent;
839 } 851 }
840 } 852 }
841 return null; 853 return null;
@@ -850,7 +862,7 @@ namespace OpenSim.Region.Environment.Scenes
850 { 862 {
851 if (ent is SceneObjectGroup) 863 if (ent is SceneObjectGroup)
852 { 864 {
853 SceneObjectGroup reportingG = (SceneObjectGroup) ent; 865 SceneObjectGroup reportingG = (SceneObjectGroup)ent;
854 EntityIntersection result = reportingG.TestIntersection(hray, frontFacesOnly, faceCenters); 866 EntityIntersection result = reportingG.TestIntersection(hray, frontFacesOnly, faceCenters);
855 if (result.HitTF) 867 if (result.HitTF)
856 { 868 {
@@ -890,13 +902,13 @@ namespace OpenSim.Region.Environment.Scenes
890 { 902 {
891 if (!presence.IsChildAgent) 903 if (!presence.IsChildAgent)
892 { 904 {
893 avatar = presence; 905 avatar = presence;
894 return true; 906 return true;
895 } 907 }
896 else 908 else
897 { 909 {
898 m_log.WarnFormat( 910 m_log.WarnFormat(
899 "[INNER SCENE]: Requested avatar {0} could not be found in scene {1} since it is only registered as a child agent!", 911 "[INNER SCENE]: Requested avatar {0} could not be found in scene {1} since it is only registered as a child agent!",
900 avatarId, m_parentScene.RegionInfo.RegionName); 912 avatarId, m_parentScene.RegionInfo.RegionName);
901 } 913 }
902 } 914 }
@@ -975,8 +987,8 @@ namespace OpenSim.Region.Environment.Scenes
975 987
976 if (presence.IsChildAgent && m_parentScene.m_seeIntoRegionFromNeighbor) 988 if (presence.IsChildAgent && m_parentScene.m_seeIntoRegionFromNeighbor)
977 { 989 {
978 LLVector3 oLoc = (ent).AbsolutePosition; 990 LLVector3 oLoc = ((SceneObjectGroup)ent).AbsolutePosition;
979 float distResult = (float) Util.GetDistanceTo(presence.AbsolutePosition, oLoc); 991 float distResult = (float)Util.GetDistanceTo(presence.AbsolutePosition, oLoc);
980 992
981 //m_log.Info("[DISTANCE]: " + distResult.ToString()); 993 //m_log.Info("[DISTANCE]: " + distResult.ToString());
982 994
@@ -984,13 +996,13 @@ namespace OpenSim.Region.Environment.Scenes
984 { 996 {
985 // Send Only if we don't already know about it. 997 // Send Only if we don't already know about it.
986 // KnownPrim also makes the prim known when called. 998 // KnownPrim also makes the prim known when called.
987 if (!presence.KnownPrim((ent).UUID)) 999 if (!presence.KnownPrim(((SceneObjectGroup)ent).UUID))
988 ((SceneObjectGroup) ent).ScheduleFullUpdateToAvatar(presence); 1000 ((SceneObjectGroup)ent).ScheduleFullUpdateToAvatar(presence);
989 } 1001 }
990 } 1002 }
991 else 1003 else
992 { 1004 {
993 ((SceneObjectGroup) ent).ScheduleFullUpdateToAvatar(presence); 1005 ((SceneObjectGroup)ent).ScheduleFullUpdateToAvatar(presence);
994 } 1006 }
995 } 1007 }
996 } 1008 }
@@ -1025,7 +1037,6 @@ namespace OpenSim.Region.Environment.Scenes
1025 } 1037 }
1026 } 1038 }
1027 } 1039 }
1028
1029 public void UpdatePrimGroupScale(uint localID, LLVector3 scale, IClientAPI remoteClient) 1040 public void UpdatePrimGroupScale(uint localID, LLVector3 scale, IClientAPI remoteClient)
1030 { 1041 {
1031 SceneObjectGroup group = GetGroupByPrim(localID); 1042 SceneObjectGroup group = GetGroupByPrim(localID);
@@ -1140,12 +1151,13 @@ namespace OpenSim.Region.Environment.Scenes
1140 SceneObjectGroup group = GetGroupByPrim(localID); 1151 SceneObjectGroup group = GetGroupByPrim(localID);
1141 if (group != null) 1152 if (group != null)
1142 { 1153 {
1154
1143 LLVector3 oldPos = group.AbsolutePosition; 1155 LLVector3 oldPos = group.AbsolutePosition;
1144 if (group.RootPart.m_IsAttachment) 1156 if (group.RootPart.m_IsAttachment)
1145 { 1157 {
1146 group.UpdateGroupPosition(pos); 1158 group.UpdateGroupPosition(pos);
1147 } 1159 }
1148 else 1160 else
1149 { 1161 {
1150 if (!PermissionsMngr.CanObjectEntry(remoteClient.AgentId, oldPos, pos) && !group.RootPart.m_IsAttachment) 1162 if (!PermissionsMngr.CanObjectEntry(remoteClient.AgentId, oldPos, pos) && !group.RootPart.m_IsAttachment)
1151 { 1163 {
@@ -1191,7 +1203,7 @@ namespace OpenSim.Region.Environment.Scenes
1191 { 1203 {
1192 if (PermissionsMngr.CanEditObject(remoteClient.AgentId, group.UUID)) 1204 if (PermissionsMngr.CanEditObject(remoteClient.AgentId, group.UUID))
1193 { 1205 {
1194 group.UpdatePrimFlags(localID, (ushort) packet.Type, true, packet.ToBytes()); 1206 group.UpdatePrimFlags(localID, (ushort)packet.Type, true, packet.ToBytes());
1195 } 1207 }
1196 } 1208 }
1197 } 1209 }
@@ -1201,7 +1213,7 @@ namespace OpenSim.Region.Environment.Scenes
1201 SceneObjectGroup group = GetGroupByPrim(objectID); 1213 SceneObjectGroup group = GetGroupByPrim(objectID);
1202 if (group != null) 1214 if (group != null)
1203 { 1215 {
1204 if (PermissionsMngr.CanEditObjectPosition(remoteClient.AgentId, group.UUID)) // && PermissionsMngr.) 1216 if (PermissionsMngr.CanEditObjectPosition(remoteClient.AgentId, group.UUID))// && PermissionsMngr.)
1205 { 1217 {
1206 group.GrabMovement(offset, pos, remoteClient); 1218 group.GrabMovement(offset, pos, remoteClient);
1207 } 1219 }
@@ -1292,9 +1304,9 @@ namespace OpenSim.Region.Environment.Scenes
1292 { 1304 {
1293 if (ent is SceneObjectGroup) 1305 if (ent is SceneObjectGroup)
1294 { 1306 {
1295 if ((ent).LocalId == parentPrim) 1307 if (((SceneObjectGroup)ent).LocalId == parentPrim)
1296 { 1308 {
1297 parenPrim = (SceneObjectGroup) ent; 1309 parenPrim = (SceneObjectGroup)ent;
1298 break; 1310 break;
1299 } 1311 }
1300 } 1312 }
@@ -1309,9 +1321,9 @@ namespace OpenSim.Region.Environment.Scenes
1309 { 1321 {
1310 if (ent is SceneObjectGroup) 1322 if (ent is SceneObjectGroup)
1311 { 1323 {
1312 if ((ent).LocalId == childPrims[i]) 1324 if (((SceneObjectGroup)ent).LocalId == childPrims[i])
1313 { 1325 {
1314 children.Add((SceneObjectGroup) ent); 1326 children.Add((SceneObjectGroup)ent);
1315 } 1327 }
1316 } 1328 }
1317 } 1329 }
@@ -1322,7 +1334,7 @@ namespace OpenSim.Region.Environment.Scenes
1322 { 1334 {
1323 parenPrim.LinkToGroup(sceneObj); 1335 parenPrim.LinkToGroup(sceneObj);
1324 } 1336 }
1325 1337
1326 // We need to explicitly resend the newly link prim's object properties since no other actions 1338 // We need to explicitly resend the newly link prim's object properties since no other actions
1327 // occur on link to invoke this elsewhere (such as object selection) 1339 // occur on link to invoke this elsewhere (such as object selection)
1328 parenPrim.GetProperties(client); 1340 parenPrim.GetProperties(client);
@@ -1348,16 +1360,19 @@ namespace OpenSim.Region.Environment.Scenes
1348 { 1360 {
1349 if (ent is SceneObjectGroup) 1361 if (ent is SceneObjectGroup)
1350 { 1362 {
1351 SceneObjectGroup obj = (SceneObjectGroup) ent; 1363 SceneObjectGroup obj = (SceneObjectGroup)ent;
1352 sceneObjects.Add(obj.LocalId, obj); 1364 sceneObjects.Add(obj.LocalId, obj);
1365
1353 } 1366 }
1354 } 1367 }
1355 1368
1356 // Find the root prim among the prim ids we've been given 1369 // Find the root prim among the prim ids we've been given
1357 for (int i = 0; i < primIds.Count; i++) 1370 for (int i = 0; i < primIds.Count; i++)
1358 { 1371 {
1372
1359 if (sceneObjects.ContainsKey(primIds[i])) 1373 if (sceneObjects.ContainsKey(primIds[i]))
1360 { 1374 {
1375
1361 parenPrim = sceneObjects[primIds[i]]; 1376 parenPrim = sceneObjects[primIds[i]];
1362 primIds.RemoveAt(i); 1377 primIds.RemoveAt(i);
1363 break; 1378 break;
@@ -1387,13 +1402,14 @@ namespace OpenSim.Region.Environment.Scenes
1387 grp.DelinkFromGroup(primIds[i]); 1402 grp.DelinkFromGroup(primIds[i]);
1388 delinkedSomething = true; 1403 delinkedSomething = true;
1389 } 1404 }
1405
1390 } 1406 }
1391 } 1407 }
1392 if (!delinkedSomething) 1408 if (!delinkedSomething)
1393 { 1409 {
1394 m_log.InfoFormat("[SCENE]: " + 1410 m_log.InfoFormat("[SCENE]: " +
1395 "DelinkObjects(): Could not find a root prim out of {0} as given to a delink request!", 1411 "DelinkObjects(): Could not find a root prim out of {0} as given to a delink request!",
1396 primIds); 1412 primIds);
1397 } 1413 }
1398 } 1414 }
1399 } 1415 }
@@ -1409,7 +1425,7 @@ namespace OpenSim.Region.Environment.Scenes
1409 { 1425 {
1410 if (ent is SceneObjectGroup) 1426 if (ent is SceneObjectGroup)
1411 { 1427 {
1412 foreach (KeyValuePair<LLUUID, SceneObjectPart> subent in ((SceneObjectGroup) ent).Children) 1428 foreach (KeyValuePair<LLUUID, SceneObjectPart> subent in ((SceneObjectGroup)ent).Children)
1413 { 1429 {
1414 if (subent.Value.LocalId == localID) 1430 if (subent.Value.LocalId == localID)
1415 { 1431 {
@@ -1419,7 +1435,7 @@ namespace OpenSim.Region.Environment.Scenes
1419 } 1435 }
1420 } 1436 }
1421 } 1437 }
1422 1438
1423 //Protip: In my day, we didn't call them searchable objects, we called them limited point-to-point joints 1439 //Protip: In my day, we didn't call them searchable objects, we called them limited point-to-point joints
1424 //aka ObjectFlags.JointWheel = IncludeInSearch 1440 //aka ObjectFlags.JointWheel = IncludeInSearch
1425 1441
@@ -1451,7 +1467,7 @@ namespace OpenSim.Region.Environment.Scenes
1451 public void DuplicateObject(uint originalPrim, LLVector3 offset, uint flags, LLUUID AgentID, LLUUID GroupID) 1467 public void DuplicateObject(uint originalPrim, LLVector3 offset, uint flags, LLUUID AgentID, LLUUID GroupID)
1452 { 1468 {
1453 m_log.DebugFormat("[SCENE]: Duplication of object {0} at offset {1} requested by agent {2}", originalPrim, offset, AgentID); 1469 m_log.DebugFormat("[SCENE]: Duplication of object {0} at offset {1} requested by agent {2}", originalPrim, offset, AgentID);
1454 1470
1455 List<EntityBase> EntityList = GetEntities(); 1471 List<EntityBase> EntityList = GetEntities();
1456 1472
1457 SceneObjectGroup originPrim = null; 1473 SceneObjectGroup originPrim = null;
@@ -1459,9 +1475,9 @@ namespace OpenSim.Region.Environment.Scenes
1459 { 1475 {
1460 if (ent is SceneObjectGroup) 1476 if (ent is SceneObjectGroup)
1461 { 1477 {
1462 if ((ent).LocalId == originalPrim) 1478 if (((SceneObjectGroup)ent).LocalId == originalPrim)
1463 { 1479 {
1464 originPrim = (SceneObjectGroup) ent; 1480 originPrim = (SceneObjectGroup)ent;
1465 break; 1481 break;
1466 } 1482 }
1467 } 1483 }
@@ -1510,4 +1526,4 @@ namespace OpenSim.Region.Environment.Scenes
1510 1526
1511 #endregion 1527 #endregion
1512 } 1528 }
1513} \ No newline at end of file 1529}
diff --git a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
index 1e6ebf9..6bd5d1a 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 = RequestModuleInterface<IAgentAssetTransactions>(); 301 IAgentAssetTransactions agentTransactions = this.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 + ", no root folder"); 398 m_log.Error("[AGENT INVENTORY]: Failed to find item " + itemId.ToString() + ", 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); 416 m_log.Error("[AGENT INVENTORY]: Failed to find user " + oldAgentID.ToString());
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); 425 m_log.Error("[AGENT INVENTORY]: Failed to find item " + oldItemID.ToString());
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); 431 m_log.Error("[AGENT INVENTORY]: Failed to find item " + oldItemID.ToString());
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); 475 m_log.Error("[AGENT INVENTORY]: Failed to find user " + remoteClient.AgentId.ToString());
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); 496 m_log.Error("[AGENT INVENTORY]: Failed to find item " + itemID.ToString());
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 + ", no root folder"); 502 m_log.Error("[AGENT INVENTORY]: Failed to find item " + itemID.ToString() + ", 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,19 +593,21 @@ 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 = RequestModuleInterface<IAgentAssetTransactions>(); 602 IAgentAssetTransactions agentTransactions = this.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
609 } 611 }
610 } 612 }
611 613
@@ -615,7 +617,7 @@ namespace OpenSim.Region.Environment.Scenes
615 = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId); 617 = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId);
616 if (userInfo == null) 618 if (userInfo == null)
617 { 619 {
618 m_log.Error("[AGENT INVENTORY]: Failed to find user " + remoteClient.AgentId); 620 m_log.Error("[AGENT INVENTORY]: Failed to find user " + remoteClient.AgentId.ToString());
619 return; 621 return;
620 } 622 }
621 623
@@ -639,7 +641,7 @@ namespace OpenSim.Region.Environment.Scenes
639 = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId); 641 = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId);
640 if (userInfo == null) 642 if (userInfo == null)
641 { 643 {
642 m_log.Error("[AGENT INVENTORY]: Failed to find user " + remoteClient.AgentId); 644 m_log.Error("[AGENT INVENTORY]: Failed to find user " + remoteClient.AgentId.ToString());
643 return; 645 return;
644 } 646 }
645 647
@@ -675,7 +677,7 @@ namespace OpenSim.Region.Environment.Scenes
675 /// <param name="remoteClient"></param> 677 /// <param name="remoteClient"></param>
676 /// <param name="primLocalID"></param> 678 /// <param name="primLocalID"></param>
677 public void RequestTaskInventory(IClientAPI remoteClient, uint primLocalID) 679 public void RequestTaskInventory(IClientAPI remoteClient, uint primLocalID)
678 { 680 {
679 SceneObjectGroup group = GetGroupByPrim(primLocalID); 681 SceneObjectGroup group = GetGroupByPrim(primLocalID);
680 if (group != null) 682 if (group != null)
681 { 683 {
@@ -723,7 +725,7 @@ namespace OpenSim.Region.Environment.Scenes
723 localID); 725 localID);
724 } 726 }
725 } 727 }
726 728
727 /// <summary> 729 /// <summary>
728 /// Move the given item in the given prim to a folder in the client's inventory 730 /// Move the given item in the given prim to a folder in the client's inventory
729 /// </summary> 731 /// </summary>
@@ -734,43 +736,43 @@ namespace OpenSim.Region.Environment.Scenes
734 public void MoveTaskInventoryItem(IClientAPI remoteClient, LLUUID folderId, uint primLocalId, LLUUID itemId) 736 public void MoveTaskInventoryItem(IClientAPI remoteClient, LLUUID folderId, uint primLocalId, LLUUID itemId)
735 { 737 {
736 SceneObjectGroup group = GetGroupByPrim(primLocalId); 738 SceneObjectGroup group = GetGroupByPrim(primLocalId);
737 739
738 if (null == group) 740 if (null == group)
739 { 741 {
740 m_log.WarnFormat( 742 m_log.WarnFormat(
741 "[PRIM INVENTORY]: " + 743 "[PRIM INVENTORY]: " +
742 "Move of inventory item {0} from prim with local id {1} failed because the prim could not be found", 744 "Move of inventory item {0} from prim with local id {1} failed because the prim could not be found",
743 itemId, primLocalId); 745 itemId, primLocalId);
744 746
745 return; 747 return;
746 } 748 }
747 749
748 TaskInventoryItem taskItem = group.GetInventoryItem(primLocalId, itemId); 750 TaskInventoryItem taskItem = group.GetInventoryItem(primLocalId, itemId);
749 751
750 if (null == taskItem) 752 if (null == taskItem)
751 { 753 {
752 // Console already notified of error in GetInventoryItem 754 // Console already notified of error in GetInventoryItem
753 return; 755 return;
754 } 756 }
755 757
756// bool permission; 758// bool permission;
757// permission = PermissionsMngr.CanCopyObject(remoteClient.AgentId, 759// permission = PermissionsMngr.CanCopyObject(remoteClient.AgentId,
758// ((SceneObjectGroup) selectedEnt).UUID); 760// ((SceneObjectGroup) selectedEnt).UUID);
759 761
760 // Pending resolving upstream problems with permissions, we just won't allow anybody who is not the owner 762 // Pending resolving upstream problems with permissions, we just won't allow anybody who is not the owner
761 // to copy 763 // to copy
762 if (remoteClient.AgentId != taskItem.OwnerID) 764 if (remoteClient.AgentId != taskItem.OwnerID)
763 { 765 {
764 m_log.InfoFormat( 766 m_log.InfoFormat(
765 "[PRIM INVENTORY]: Attempt made by {0} {1} to copy inventory item {2} {3} in prim {4} {5}," 767 "[PRIM INVENTORY]: Attempt made by {0} {1} to copy inventory item {2} {3} in prim {4} {5},"
766 + " but temporarily not allowed pending upstream bugfixes/feature implementation", 768 + " but temporarily not allowed pending upstream bugfixes/feature implementation",
767 remoteClient.Name, remoteClient.AgentId, taskItem.Name, taskItem.ItemID, group.Name, group.UUID); 769 remoteClient.Name, remoteClient.AgentId, taskItem.Name, taskItem.ItemID, group.Name, group.UUID);
768 770
769 return; 771 return;
770 } 772 }
771 773
772 InventoryItemBase agentItem = new InventoryItemBase(); 774 InventoryItemBase agentItem = new InventoryItemBase();
773 775
774 agentItem.ID = LLUUID.Random(); 776 agentItem.ID = LLUUID.Random();
775 agentItem.Creator = taskItem.CreatorID; 777 agentItem.Creator = taskItem.CreatorID;
776 agentItem.Owner = remoteClient.AgentId; 778 agentItem.Owner = remoteClient.AgentId;
@@ -781,9 +783,8 @@ namespace OpenSim.Region.Environment.Scenes
781 agentItem.InvType = taskItem.InvType; 783 agentItem.InvType = taskItem.InvType;
782 agentItem.Folder = folderId; 784 agentItem.Folder = folderId;
783 agentItem.EveryOnePermissions = taskItem.EveryoneMask; 785 agentItem.EveryOnePermissions = taskItem.EveryoneMask;
784 786
785 if (remoteClient.AgentId != taskItem.OwnerID) 787 if (remoteClient.AgentId != taskItem.OwnerID) {
786 {
787 agentItem.BasePermissions = taskItem.NextOwnerMask; 788 agentItem.BasePermissions = taskItem.NextOwnerMask;
788 agentItem.CurrentPermissions = taskItem.NextOwnerMask; 789 agentItem.CurrentPermissions = taskItem.NextOwnerMask;
789 agentItem.NextPermissions = taskItem.NextOwnerMask; 790 agentItem.NextPermissions = taskItem.NextOwnerMask;
@@ -792,9 +793,9 @@ namespace OpenSim.Region.Environment.Scenes
792 { 793 {
793 agentItem.BasePermissions = taskItem.BaseMask; 794 agentItem.BasePermissions = taskItem.BaseMask;
794 agentItem.CurrentPermissions = taskItem.OwnerMask; 795 agentItem.CurrentPermissions = taskItem.OwnerMask;
795 agentItem.NextPermissions = taskItem.NextOwnerMask; 796 agentItem.NextPermissions = taskItem.NextOwnerMask;
796 } 797 }
797 798
798 AddInventoryItem(remoteClient, agentItem); 799 AddInventoryItem(remoteClient, agentItem);
799 } 800 }
800 801
@@ -833,7 +834,7 @@ namespace OpenSim.Region.Environment.Scenes
833 { 834 {
834 group.AddInventoryItem(remoteClient, primLocalID, item, copyID); 835 group.AddInventoryItem(remoteClient, primLocalID, item, copyID);
835 m_log.InfoFormat( 836 m_log.InfoFormat(
836 "[PRIM INVENTORY]: Update with item {0} requested of prim {1} for {2}", 837 "[PRIM INVENTORY]: Update with item {0} requested of prim {1} for {2}",
837 item.Name, primLocalID, remoteClient.Name); 838 item.Name, primLocalID, remoteClient.Name);
838 group.GetProperties(remoteClient); 839 group.GetProperties(remoteClient);
839 } 840 }
@@ -864,22 +865,22 @@ namespace OpenSim.Region.Environment.Scenes
864 public void RezScript(IClientAPI remoteClient, LLUUID itemID, uint localID) 865 public void RezScript(IClientAPI remoteClient, LLUUID itemID, uint localID)
865 { 866 {
866 LLUUID copyID = LLUUID.Random(); 867 LLUUID copyID = LLUUID.Random();
867 868
868 if (itemID != LLUUID.Zero) 869 if (itemID != LLUUID.Zero)
869 { 870 {
870 CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId); 871 CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId);
871 872
872 if (userInfo != null && userInfo.RootFolder != null) 873 if (userInfo != null && userInfo.RootFolder != null)
873 { 874 {
874 InventoryItemBase item = userInfo.RootFolder.HasItem(itemID); 875 InventoryItemBase item = userInfo.RootFolder.HasItem(itemID);
875 876
876 // Try library 877 // Try library
877 // XXX clumsy, possibly should be one call 878 // XXX clumsy, possibly should be one call
878 if (null == item) 879 if (null == item)
879 { 880 {
880 item = CommsManager.UserProfileCacheService.libraryRoot.HasItem(itemID); 881 item = CommsManager.UserProfileCacheService.libraryRoot.HasItem(itemID);
881 } 882 }
882 883
883 if (item != null) 884 if (item != null)
884 { 885 {
885 SceneObjectGroup group = GetGroupByPrim(localID); 886 SceneObjectGroup group = GetGroupByPrim(localID);
@@ -888,10 +889,10 @@ namespace OpenSim.Region.Environment.Scenes
888 group.AddInventoryItem(remoteClient, localID, item, copyID); 889 group.AddInventoryItem(remoteClient, localID, item, copyID);
889 group.StartScript(localID, copyID); 890 group.StartScript(localID, copyID);
890 group.GetProperties(remoteClient); 891 group.GetProperties(remoteClient);
891 892
892 // m_log.InfoFormat("[PRIMINVENTORY]: " + 893 // m_log.InfoFormat("[PRIMINVENTORY]: " +
893 // "Rezzed script {0} into prim local ID {1} for user {2}", 894 // "Rezzed script {0} into prim local ID {1} for user {2}",
894 // item.inventoryName, localID, remoteClient.Name); 895 // item.inventoryName, localID, remoteClient.Name);
895 } 896 }
896 else 897 else
897 { 898 {
@@ -910,7 +911,7 @@ namespace OpenSim.Region.Environment.Scenes
910 } 911 }
911 } 912 }
912 } 913 }
913 else // If the itemID is zero then the script has been rezzed directly in an object's inventory 914 else // If the itemID is zero then the script has been rezzed directly in an object's inventory
914 { 915 {
915 // not yet implemented 916 // not yet implemented
916 // TODO Need to get more details from original RezScript packet 917 // TODO Need to get more details from original RezScript packet
@@ -926,7 +927,7 @@ namespace OpenSim.Region.Environment.Scenes
926 /// <param name="packet"></param> 927 /// <param name="packet"></param>
927 /// <param name="simClient"></param> 928 /// <param name="simClient"></param>
928 public virtual void DeRezObject(Packet packet, IClientAPI remoteClient) 929 public virtual void DeRezObject(Packet packet, IClientAPI remoteClient)
929 { 930 {
930 DeRezObjectPacket DeRezPacket = (DeRezObjectPacket) packet; 931 DeRezObjectPacket DeRezPacket = (DeRezObjectPacket) packet;
931 932
932 if (DeRezPacket.AgentBlock.DestinationID == LLUUID.Zero) 933 if (DeRezPacket.AgentBlock.DestinationID == LLUUID.Zero)
@@ -936,11 +937,11 @@ namespace OpenSim.Region.Environment.Scenes
936 else 937 else
937 { 938 {
938 foreach (DeRezObjectPacket.ObjectDataBlock Data in DeRezPacket.ObjectData) 939 foreach (DeRezObjectPacket.ObjectDataBlock Data in DeRezPacket.ObjectData)
939 { 940 {
940// m_log.DebugFormat( 941// m_log.DebugFormat(
941// "[AGENT INVENTORY]: Received request to derez {0} into folder {1}", 942// "[AGENT INVENTORY]: Received request to derez {0} into folder {1}",
942// Data.ObjectLocalID, DeRezPacket.AgentBlock.DestinationID); 943// Data.ObjectLocalID, DeRezPacket.AgentBlock.DestinationID);
943 944
944 EntityBase selectedEnt = null; 945 EntityBase selectedEnt = null;
945 //m_log.Info("[CLIENT]: LocalID:" + Data.ObjectLocalID.ToString()); 946 //m_log.Info("[CLIENT]: LocalID:" + Data.ObjectLocalID.ToString());
946 947
@@ -958,16 +959,14 @@ namespace OpenSim.Region.Environment.Scenes
958 { 959 {
959 bool permission; 960 bool permission;
960 if (DeRezPacket.AgentBlock.Destination == 1) 961 if (DeRezPacket.AgentBlock.Destination == 1)
961 { 962 { // Take Copy
962 // Take Copy 963 permission = PermissionsMngr.CanCopyObject(remoteClient.AgentId,
963 permission = PermissionsMngr.CanCopyObject(remoteClient.AgentId, 964 ((SceneObjectGroup) selectedEnt).UUID);
964 (selectedEnt).UUID);
965 } 965 }
966 else 966 else
967 { 967 { // Take
968 // Take 968 permission = PermissionsMngr.CanDeRezObject(remoteClient.AgentId,
969 permission = PermissionsMngr.CanDeRezObject(remoteClient.AgentId, 969 ((SceneObjectGroup) selectedEnt).UUID);
970 (selectedEnt).UUID);
971 } 970 }
972 971
973 if (permission) 972 if (permission)
@@ -998,8 +997,7 @@ namespace OpenSim.Region.Environment.Scenes
998 item.InvType = asset.InvType; 997 item.InvType = asset.InvType;
999 item.Folder = DeRezPacket.AgentBlock.DestinationID; 998 item.Folder = DeRezPacket.AgentBlock.DestinationID;
1000 item.EveryOnePermissions = objectGroup.RootPart.EveryoneMask; 999 item.EveryOnePermissions = objectGroup.RootPart.EveryoneMask;
1001 if (remoteClient.AgentId != objectGroup.RootPart.OwnerID) 1000 if (remoteClient.AgentId != objectGroup.RootPart.OwnerID) {
1002 {
1003 item.BasePermissions = objectGroup.RootPart.NextOwnerMask; 1001 item.BasePermissions = objectGroup.RootPart.NextOwnerMask;
1004 item.CurrentPermissions = objectGroup.RootPart.NextOwnerMask; 1002 item.CurrentPermissions = objectGroup.RootPart.NextOwnerMask;
1005 item.NextPermissions = objectGroup.RootPart.NextOwnerMask; 1003 item.NextPermissions = objectGroup.RootPart.NextOwnerMask;
@@ -1027,7 +1025,6 @@ namespace OpenSim.Region.Environment.Scenes
1027 } 1025 }
1028 } 1026 }
1029 } 1027 }
1030
1031 public void updateKnownAsset(IClientAPI remoteClient, SceneObjectGroup grp, LLUUID assetID, LLUUID agentID) 1028 public void updateKnownAsset(IClientAPI remoteClient, SceneObjectGroup grp, LLUUID assetID, LLUUID agentID)
1032 { 1029 {
1033 SceneObjectGroup objectGroup = grp; 1030 SceneObjectGroup objectGroup = grp;
@@ -1047,6 +1044,7 @@ namespace OpenSim.Region.Environment.Scenes
1047 // search through folders to find the asset. 1044 // search through folders to find the asset.
1048 while (searchfolders.Count > 0) 1045 while (searchfolders.Count > 0)
1049 { 1046 {
1047
1050 InventoryFolderImpl fld = searchfolders.Dequeue(); 1048 InventoryFolderImpl fld = searchfolders.Dequeue();
1051 lock (fld) 1049 lock (fld)
1052 { 1050 {
@@ -1071,8 +1069,8 @@ namespace OpenSim.Region.Environment.Scenes
1071 AssetBase asset = CreateAsset( 1069 AssetBase asset = CreateAsset(
1072 objectGroup.GetPartName(objectGroup.LocalId), 1070 objectGroup.GetPartName(objectGroup.LocalId),
1073 objectGroup.GetPartDescription(objectGroup.LocalId), 1071 objectGroup.GetPartDescription(objectGroup.LocalId),
1074 (sbyte) InventoryType.Object, 1072 (sbyte)InventoryType.Object,
1075 (sbyte) AssetType.Object, 1073 (sbyte)AssetType.Object,
1076 Helpers.StringToField(sceneObjectXml)); 1074 Helpers.StringToField(sceneObjectXml));
1077 AssetCache.AddAsset(asset); 1075 AssetCache.AddAsset(asset);
1078 1076
@@ -1088,7 +1086,7 @@ namespace OpenSim.Region.Environment.Scenes
1088 1086
1089 // Sticking it in root folder for now.. objects folder later? 1087 // Sticking it in root folder for now.. objects folder later?
1090 1088
1091 item.Folder = foundFolder; // DeRezPacket.AgentBlock.DestinationID; 1089 item.Folder = foundFolder;// DeRezPacket.AgentBlock.DestinationID;
1092 item.EveryOnePermissions = objectGroup.RootPart.EveryoneMask; 1090 item.EveryOnePermissions = objectGroup.RootPart.EveryoneMask;
1093 if (agentID != objectGroup.RootPart.OwnerID) 1091 if (agentID != objectGroup.RootPart.OwnerID)
1094 { 1092 {
@@ -1110,10 +1108,10 @@ namespace OpenSim.Region.Environment.Scenes
1110 { 1108 {
1111 remoteClient.SendInventoryItemCreateUpdate(item); 1109 remoteClient.SendInventoryItemCreateUpdate(item);
1112 } 1110 }
1111
1113 } 1112 }
1114 } 1113 }
1115 } 1114 }
1116
1117 public LLUUID attachObjectAssetStore(IClientAPI remoteClient, SceneObjectGroup grp, LLUUID AgentId) 1115 public LLUUID attachObjectAssetStore(IClientAPI remoteClient, SceneObjectGroup grp, LLUUID AgentId)
1118 { 1116 {
1119 SceneObjectGroup objectGroup = grp; 1117 SceneObjectGroup objectGroup = grp;
@@ -1128,8 +1126,8 @@ namespace OpenSim.Region.Environment.Scenes
1128 AssetBase asset = CreateAsset( 1126 AssetBase asset = CreateAsset(
1129 objectGroup.GetPartName(objectGroup.LocalId), 1127 objectGroup.GetPartName(objectGroup.LocalId),
1130 objectGroup.GetPartDescription(objectGroup.LocalId), 1128 objectGroup.GetPartDescription(objectGroup.LocalId),
1131 (sbyte) InventoryType.Object, 1129 (sbyte)InventoryType.Object,
1132 (sbyte) AssetType.Object, 1130 (sbyte)AssetType.Object,
1133 Helpers.StringToField(sceneObjectXml)); 1131 Helpers.StringToField(sceneObjectXml));
1134 AssetCache.AddAsset(asset); 1132 AssetCache.AddAsset(asset);
1135 1133
@@ -1142,10 +1140,10 @@ namespace OpenSim.Region.Environment.Scenes
1142 item.Name = asset.Name; 1140 item.Name = asset.Name;
1143 item.AssetType = asset.Type; 1141 item.AssetType = asset.Type;
1144 item.InvType = asset.InvType; 1142 item.InvType = asset.InvType;
1145 1143
1146 // Sticking it in root folder for now.. objects folder later? 1144 // Sticking it in root folder for now.. objects folder later?
1147 1145
1148 item.Folder = userInfo.RootFolder.ID; // DeRezPacket.AgentBlock.DestinationID; 1146 item.Folder = userInfo.RootFolder.ID;// DeRezPacket.AgentBlock.DestinationID;
1149 item.EveryOnePermissions = objectGroup.RootPart.EveryoneMask; 1147 item.EveryOnePermissions = objectGroup.RootPart.EveryoneMask;
1150 if (remoteClient.AgentId != objectGroup.RootPart.OwnerID) 1148 if (remoteClient.AgentId != objectGroup.RootPart.OwnerID)
1151 { 1149 {
@@ -1167,6 +1165,7 @@ namespace OpenSim.Region.Environment.Scenes
1167 return LLUUID.Zero; 1165 return LLUUID.Zero;
1168 } 1166 }
1169 return LLUUID.Zero; 1167 return LLUUID.Zero;
1168
1170 } 1169 }
1171 1170
1172 /// <summary> 1171 /// <summary>
@@ -1188,63 +1187,64 @@ namespace OpenSim.Region.Environment.Scenes
1188 /// <param name="RemoveItem"></param> 1187 /// <param name="RemoveItem"></param>
1189 /// <param name="fromTaskID"></param> 1188 /// <param name="fromTaskID"></param>
1190 public virtual void RezObject(IClientAPI remoteClient, LLUUID itemID, LLVector3 RayEnd, LLVector3 RayStart, 1189 public virtual void RezObject(IClientAPI remoteClient, LLUUID itemID, LLVector3 RayEnd, LLVector3 RayStart,
1191 LLUUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection, 1190 LLUUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection,
1192 uint EveryoneMask, uint GroupMask, uint NextOwnerMask, uint ItemFlags, 1191 uint EveryoneMask, uint GroupMask, uint NextOwnerMask, uint ItemFlags,
1193 bool RezSelected, bool RemoveItem, LLUUID fromTaskID) 1192 bool RezSelected, bool RemoveItem, LLUUID fromTaskID)
1194 { 1193 {
1195 SceneObjectGroup sog = RezObject(remoteClient, itemID, RayEnd, RayStart, 1194 SceneObjectGroup sog = RezObject(remoteClient, itemID, RayEnd, RayStart,
1196 RayTargetID, BypassRayCast, RayEndIsIntersection, 1195 RayTargetID, BypassRayCast, RayEndIsIntersection,
1197 EveryoneMask, GroupMask, NextOwnerMask, ItemFlags, 1196 EveryoneMask, GroupMask, NextOwnerMask, ItemFlags,
1198 RezSelected, RemoveItem, fromTaskID, false); 1197 RezSelected, RemoveItem, fromTaskID, false);
1199 } 1198 }
1200 1199
1201 1200
1202 /// <summary> 1201
1203 /// Returns SceneObjectGroup or null from asset request. 1202 /// <summary>
1204 /// </summary> 1203 /// Returns SceneObjectGroup or null from asset request.
1205 /// <param name="remoteClient"></param> 1204 /// </summary>
1206 /// <param name="itemID"></param> 1205 /// <param name="remoteClient"></param>
1207 /// <param name="RayEnd"></param> 1206 /// <param name="itemID"></param>
1208 /// <param name="RayStart"></param> 1207 /// <param name="RayEnd"></param>
1209 /// <param name="RayTargetID"></param> 1208 /// <param name="RayStart"></param>
1210 /// <param name="BypassRayCast"></param> 1209 /// <param name="RayTargetID"></param>
1211 /// <param name="RayEndIsIntersection"></param> 1210 /// <param name="BypassRayCast"></param>
1212 /// <param name="EveryoneMask"></param> 1211 /// <param name="RayEndIsIntersection"></param>
1213 /// <param name="GroupMask"></param> 1212 /// <param name="EveryoneMask"></param>
1214 /// <param name="NextOwnerMask"></param> 1213 /// <param name="GroupMask"></param>
1215 /// <param name="ItemFlags"></param> 1214 /// <param name="NextOwnerMask"></param>
1216 /// <param name="RezSelected"></param> 1215 /// <param name="ItemFlags"></param>
1217 /// <param name="RemoveItem"></param> 1216 /// <param name="RezSelected"></param>
1218 /// <param name="fromTaskID"></param> 1217 /// <param name="RemoveItem"></param>
1219 /// <param name="difference"></param> 1218 /// <param name="fromTaskID"></param>
1220 /// <returns></returns> 1219 /// <param name="difference"></param>
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 = 0; 1227 byte bRayEndIsIntersection = (byte)0;
1228 1228
1229 if (RayEndIsIntersection) 1229 if (RayEndIsIntersection)
1230 { 1230 {
1231 bRayEndIsIntersection = 1; 1231 bRayEndIsIntersection = (byte)1;
1232 } 1232 }
1233 else 1233 else
1234 { 1234 {
1235 bRayEndIsIntersection = 0; 1235 bRayEndIsIntersection = (byte)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,5 +1327,7 @@ namespace OpenSim.Region.Environment.Scenes
1327 } 1327 }
1328 return null; 1328 return null;
1329 } 1329 }
1330
1331
1330 } 1332 }
1331} \ No newline at end of file 1333}
diff --git a/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs
index b052096..dccc09a 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs
@@ -78,12 +78,11 @@ 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 ((ent).LocalId == primLocalID) 82 if (((SceneObjectGroup) 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, (ent).UUID) || 85 if (m_permissionManager.CanEditObjectPosition(remoteClient.AgentId, ((SceneObjectGroup)ent).UUID) || m_permissionManager.CanEditObject(remoteClient.AgentId, ((SceneObjectGroup)ent).UUID))
86 m_permissionManager.CanEditObject(remoteClient.AgentId, (ent).UUID))
87 { 86 {
88 ((SceneObjectGroup) ent).GetProperties(remoteClient); 87 ((SceneObjectGroup) ent).GetProperties(remoteClient);
89 ((SceneObjectGroup) ent).IsSelected = true; 88 ((SceneObjectGroup) ent).IsSelected = true;
@@ -108,10 +107,9 @@ namespace OpenSim.Region.Environment.Scenes
108 { 107 {
109 if (ent is SceneObjectGroup) 108 if (ent is SceneObjectGroup)
110 { 109 {
111 if ((ent).LocalId == primLocalID) 110 if (((SceneObjectGroup) ent).LocalId == primLocalID)
112 { 111 {
113 if (m_permissionManager.CanEditObjectPosition(remoteClient.AgentId, (ent).UUID) || 112 if (m_permissionManager.CanEditObjectPosition(remoteClient.AgentId, ((SceneObjectGroup)ent).UUID) || m_permissionManager.CanEditObject(remoteClient.AgentId, ((SceneObjectGroup)ent).UUID))
114 m_permissionManager.CanEditObject(remoteClient.AgentId, (ent).UUID))
115 { 113 {
116 ((SceneObjectGroup) ent).IsSelected = false; 114 ((SceneObjectGroup) ent).IsSelected = false;
117 LandChannel.setPrimsTainted(); 115 LandChannel.setPrimsTainted();
@@ -131,20 +129,21 @@ namespace OpenSim.Region.Environment.Scenes
131 } 129 }
132 130
133 public virtual void ProcessParcelBuy(LLUUID agentId, LLUUID groupId, bool final, bool groupOwned, 131 public virtual void ProcessParcelBuy(LLUUID agentId, LLUUID groupId, bool final, bool groupOwned,
134 bool removeContribution, int parcelLocalID, int parcelArea, int parcelPrice, bool authenticated) 132 bool removeContribution, int parcelLocalID, int parcelArea, int parcelPrice, bool authenticated)
135 { 133 {
136 EventManager.LandBuyArgs args = new EventManager.LandBuyArgs( 134 EventManager.LandBuyArgs args = new EventManager.LandBuyArgs(
137 agentId, groupId, final, groupOwned, removeContribution, parcelLocalID, parcelArea, parcelPrice, authenticated); 135 agentId, groupId, final, groupOwned, removeContribution, parcelLocalID, parcelArea, parcelPrice, authenticated);
138 136
139 // First, allow all validators a stab at it 137 // First, allow all validators a stab at it
140 m_eventManager.TriggerValidateLandBuy(this, args); 138 m_eventManager.TriggerValidateLandBuy(this, args);
141 139
142 // Then, check validation and transfer 140 // Then, check validation and transfer
143 m_eventManager.TriggerLandBuy(this, args); 141 m_eventManager.TriggerLandBuy(this, args);
144 } 142 }
145 143
146 public virtual void ProcessObjectGrab(uint localID, LLVector3 offsetPos, IClientAPI remoteClient) 144 public virtual void ProcessObjectGrab(uint localID, LLVector3 offsetPos, IClientAPI remoteClient)
147 { 145 {
146
148 List<EntityBase> EntitieList = GetEntities(); 147 List<EntityBase> EntitieList = GetEntities();
149 148
150 foreach (EntityBase ent in EntitieList) 149 foreach (EntityBase ent in EntitieList)
@@ -179,6 +178,7 @@ namespace OpenSim.Region.Environment.Scenes
179 178
180 public virtual void ProcessObjectDeGrab(uint localID, IClientAPI remoteClient) 179 public virtual void ProcessObjectDeGrab(uint localID, IClientAPI remoteClient)
181 { 180 {
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(item.firstName); 236 searchData[i].FirstName = Helpers.StringToField((string) item.firstName);
237 searchData[i].LastName = Helpers.StringToField(item.lastName); 237 searchData[i].LastName = Helpers.StringToField((string) 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} \ No newline at end of file 248}
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs
index 6617995..3113831 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.cs
@@ -53,99 +53,107 @@ namespace OpenSim.Region.Environment.Scenes
53 53
54 public partial class Scene : SceneBase 54 public partial class Scene : SceneBase
55 { 55 {
56 #region Delegates
57
58 public delegate void SynchronizeSceneHandler(Scene scene); 56 public delegate void SynchronizeSceneHandler(Scene scene);
57 public SynchronizeSceneHandler SynchronizeScene = null;
58 public int splitID = 0;
59 59
60 #endregion 60 #region Fields
61 61
62 public int splitID; 62 protected Timer m_heartbeatTimer = new Timer();
63 public SynchronizeSceneHandler SynchronizeScene; 63 protected Timer m_restartWaitTimer = new Timer();
64 64
65 #region Fields 65 protected SimStatsReporter m_statsReporter;
66
67 protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>();
68 protected List<RegionInfo> m_neighbours = new List<RegionInfo>();
69
70 public InnerScene m_innerScene;
66 71
72 private Random Rand = new Random();
73 private uint _primCount = 720000;
67 private readonly Mutex _primAllocateMutex = new Mutex(false); 74 private readonly Mutex _primAllocateMutex = new Mutex(false);
68 75
69 private readonly Timer m_restartTimer = new Timer(15000); // Wait before firing 76 private int m_timePhase = 24;
77
70 private readonly Mutex updateLock; 78 private readonly Mutex updateLock;
71 private uint _primCount = 720000; 79 public bool m_physicalPrim;
72 public CommunicationsManager CommsManager; 80 public bool m_seeIntoRegionFromNeighbor;
73 private int frameMS; 81 public int MaxUndoCount = 5;
82 private int m_RestartTimerCounter;
83 private readonly Timer m_restartTimer = new Timer(15000); // Wait before firing
84 private int m_incrementsof15seconds = 0;
85
86 public string m_simulatorVersion = "OpenSimulator 0.5";
87
88 protected ModuleLoader m_moduleLoader;
89 protected StorageManager m_storageManager;
74 protected AgentCircuitManager m_authenticateHandler; 90 protected AgentCircuitManager m_authenticateHandler;
91 public CommunicationsManager CommsManager;
75 // protected XferManager xferManager; 92 // protected XferManager xferManager;
76 protected IAvatarFactory m_AvatarFactory; 93 protected SceneCommunicationService m_sceneGridService;
94 protected SceneXmlLoader m_sceneXmlLoader;
77 95
78 /// <summary> 96 /// <summary>
79 /// Each agent has its own capabilities handler. 97 /// Each agent has its own capabilities handler.
80 /// </summary> 98 /// </summary>
81 protected Dictionary<LLUUID, Caps> m_capsHandlers = new Dictionary<LLUUID, Caps>(); 99 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;
82 117
83 // Central Update Loop 118 // Central Update Loop
84 119
85 protected int m_fps = 10; 120 protected int m_fps = 10;
86 protected int m_frame; 121 protected int m_frame = 0;
87 protected Timer m_heartbeatTimer = new Timer(); 122 protected float m_timespan = 0.089f;
88 protected BaseHttpServer m_httpListener;
89 protected IHttpRequests m_httpRequestModule;
90 private int m_incrementsof15seconds;
91 public InnerScene m_innerScene;
92 protected DateTime m_lastupdate = DateTime.Now; 123 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;
109 124
110 protected float m_timedilation = 1.0f; 125 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;
114 126
127 private int m_update_physics = 1;
128 private int m_update_entitymovement = 1;
115 private int m_update_entities = 1; // Run through all objects checking for updates 129 private int m_update_entities = 1; // Run through all objects checking for updates
116 private int m_update_entitiesquick = 200; // Run through objects that have scheduled updates checking for updates 130 private int m_update_entitiesquick = 200; // Run through objects that have scheduled updates checking for updates
117 private int m_update_entitymovement = 1;
118 private int m_update_events = 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 131 private int m_update_presences = 1; // Update scene presence movements
132 private int m_update_events = 1;
133 private int m_update_backup = 200;
122 private int m_update_terrain = 50; 134 private int m_update_terrain = 50;
123 protected IWorldComm m_worldCommModule; 135 private int m_update_land = 1;
124 protected IXMLRPC m_xmlrpcModule; 136
125 public int MaxUndoCount = 5; 137 private int frameMS = 0;
126 protected Dictionary<string, object> ModuleAPIMethods = new Dictionary<string, object>(); 138 private int physicsMS2 = 0;
127 public Dictionary<Type, object> ModuleInterfaces = new Dictionary<Type, object>(); 139 private int physicsMS = 0;
128 protected Dictionary<string, IRegionModule> Modules = new Dictionary<string, IRegionModule>(); 140 private int otherMS = 0;
141
142 private bool m_physics_enabled = true;
143 private bool m_scripts_enabled = true;
144
129 145
130 private int otherMS;
131 private int physicsMS;
132 private int physicsMS2;
133 private Random Rand = new Random();
134 public IXfer XferManager;
135 146
136 #endregion 147 #endregion
137 148
138 #region Properties 149 #region Properties
139 150
140 protected readonly EstateManager m_estateManager;
141 protected readonly PermissionManager m_permissionManager;
142 public int objectCapacity = 45000;
143
144 public AgentCircuitManager AuthenticateHandler 151 public AgentCircuitManager AuthenticateHandler
145 { 152 {
146 get { return m_authenticateHandler; } 153 get { return m_authenticateHandler; }
147 } 154 }
148 155
156 protected readonly EstateManager m_estateManager;
149 // an instance to the physics plugin's Scene object. 157 // an instance to the physics plugin's Scene object.
150 public PhysicsScene PhysicsScene 158 public PhysicsScene PhysicsScene
151 { 159 {
@@ -169,6 +177,7 @@ namespace OpenSim.Region.Environment.Scenes
169 get { return m_timedilation; } 177 get { return m_timedilation; }
170 } 178 }
171 179
180 protected readonly PermissionManager m_permissionManager;
172 // This is the instance to the permissions manager. 181 // This is the instance to the permissions manager.
173 // This manages permissions to clients on in world objects 182 // This manages permissions to clients on in world objects
174 183
@@ -206,13 +215,14 @@ namespace OpenSim.Region.Environment.Scenes
206 get { return m_innerScene.Entities; } 215 get { return m_innerScene.Entities; }
207 set { m_innerScene.Entities = value; } 216 set { m_innerScene.Entities = value; }
208 } 217 }
209
210 public Dictionary<LLUUID, ScenePresence> m_restorePresences 218 public Dictionary<LLUUID, ScenePresence> m_restorePresences
211 { 219 {
212 get { return m_innerScene.RestorePresences; } 220 get { return m_innerScene.RestorePresences; }
213 set { m_innerScene.RestorePresences = value; } 221 set { m_innerScene.RestorePresences = value; }
214 } 222 }
215 223
224 public int objectCapacity = 45000;
225
216 #endregion 226 #endregion
217 227
218 #region Constructors 228 #region Constructors
@@ -242,9 +252,9 @@ namespace OpenSim.Region.Environment.Scenes
242 252
243 //Bind Storage Manager functions to some land manager functions for this scene 253 //Bind Storage Manager functions to some land manager functions for this scene
244 EventManager.OnLandObjectAdded += 254 EventManager.OnLandObjectAdded +=
245 m_storageManager.DataStore.StoreLandObject; 255 new EventManager.LandObjectAdded(m_storageManager.DataStore.StoreLandObject);
246 EventManager.OnLandObjectRemoved += 256 EventManager.OnLandObjectRemoved +=
247 m_storageManager.DataStore.RemoveLandObject; 257 new EventManager.LandObjectRemoved(m_storageManager.DataStore.RemoveLandObject);
248 258
249 m_estateManager = new EstateManager(this, m_regInfo); 259 m_estateManager = new EstateManager(this, m_regInfo);
250 260
@@ -311,7 +321,7 @@ namespace OpenSim.Region.Environment.Scenes
311 OSString = OSString.Substring(0, 45); 321 OSString = OSString.Substring(0, 45);
312 } 322 }
313 323
314 m_simulatorVersion = "OpenSimulator v0.5-SVN on " + OSString + " ChilTasks:" + m_seeIntoRegionFromNeighbor + " PhysPrim:" + m_physicalPrim; 324 m_simulatorVersion = "OpenSimulator v0.5-SVN on " + OSString + " ChilTasks:" + m_seeIntoRegionFromNeighbor.ToString() + " PhysPrim:" + m_physicalPrim.ToString();
315 } 325 }
316 326
317 #endregion 327 #endregion
@@ -372,23 +382,23 @@ namespace OpenSim.Region.Environment.Scenes
372 } 382 }
373 // If these are cast to INT because long + negative values + abs returns invalid data 383 // If these are cast to INT because long + negative values + abs returns invalid data
374 384
375 int resultX = Math.Abs((int) otherRegion.RegionLocX - (int) RegionInfo.RegionLocX); 385 int resultX = Math.Abs((int)otherRegion.RegionLocX - (int)RegionInfo.RegionLocX);
376 int resultY = Math.Abs((int) otherRegion.RegionLocY - (int) RegionInfo.RegionLocY); 386 int resultY = Math.Abs((int)otherRegion.RegionLocY - (int)RegionInfo.RegionLocY);
377 if ((resultX <= 1) && 387 if ((resultX <= 1) &&
378 (resultY <= 1)) 388 (resultY <= 1))
379 { 389 {
380 try 390 try
381 { 391 {
382 ForEachScenePresence(delegate(ScenePresence agent) 392 ForEachScenePresence(delegate(ScenePresence agent)
393 {
394 // If agent is a root agent.
395 if (!agent.IsChildAgent)
383 { 396 {
384 // If agent is a root agent. 397 //agent.ControllingClient.new
385 if (!agent.IsChildAgent) 398 //this.CommsManager.InterRegion.InformRegionOfChildAgent(otherRegion.RegionHandle, agent.ControllingClient.RequestClientInfo());
386 { 399 InformClientOfNeighbor(agent, otherRegion);
387 //agent.ControllingClient.new
388 //this.CommsManager.InterRegion.InformRegionOfChildAgent(otherRegion.RegionHandle, agent.ControllingClient.RequestClientInfo());
389 InformClientOfNeighbor(agent, otherRegion);
390 }
391 } 400 }
401 }
392 ); 402 );
393 } 403 }
394 catch (NullReferenceException) 404 catch (NullReferenceException)
@@ -400,9 +410,9 @@ namespace OpenSim.Region.Environment.Scenes
400 } 410 }
401 else 411 else
402 { 412 {
403 m_log.Info("[INTERGRID]: Got notice about far away Region: " + otherRegion.RegionName + 413 m_log.Info("[INTERGRID]: Got notice about far away Region: " + otherRegion.RegionName.ToString() +
404 " at (" + otherRegion.RegionLocX + ", " + 414 " at (" + otherRegion.RegionLocX.ToString() + ", " +
405 otherRegion.RegionLocY + ")"); 415 otherRegion.RegionLocY.ToString() + ")");
406 } 416 }
407 } 417 }
408 return true; 418 return true;
@@ -426,10 +436,10 @@ namespace OpenSim.Region.Environment.Scenes
426 { 436 {
427 // Now we figure out what to set the timer to that does the notifications and calls, RestartNow() 437 // Now we figure out what to set the timer to that does the notifications and calls, RestartNow()
428 m_restartTimer.Interval = 15000; 438 m_restartTimer.Interval = 15000;
429 m_incrementsof15seconds = (int) seconds / 15; 439 m_incrementsof15seconds = (int)seconds / 15;
430 m_RestartTimerCounter = 0; 440 m_RestartTimerCounter = 0;
431 m_restartTimer.AutoReset = true; 441 m_restartTimer.AutoReset = true;
432 m_restartTimer.Elapsed += RestartTimer_Elapsed; 442 m_restartTimer.Elapsed += new ElapsedEventHandler(RestartTimer_Elapsed);
433 m_log.Error("[REGION]: Restarting Region in " + (seconds / 60) + " minutes"); 443 m_log.Error("[REGION]: Restarting Region in " + (seconds / 60) + " minutes");
434 m_restartTimer.Start(); 444 m_restartTimer.Start();
435 SendRegionMessageFromEstateTools(LLUUID.Random(), LLUUID.Random(), String.Empty, RegionInfo.RegionName + ": Restarting in 2 Minutes"); 445 SendRegionMessageFromEstateTools(LLUUID.Random(), LLUUID.Random(), String.Empty, RegionInfo.RegionName + ": Restarting in 2 Minutes");
@@ -448,7 +458,7 @@ namespace OpenSim.Region.Environment.Scenes
448 { 458 {
449 if (m_RestartTimerCounter == 4 || m_RestartTimerCounter == 6 || m_RestartTimerCounter == 7) 459 if (m_RestartTimerCounter == 4 || m_RestartTimerCounter == 6 || m_RestartTimerCounter == 7)
450 SendRegionMessageFromEstateTools(LLUUID.Random(), LLUUID.Random(), String.Empty, RegionInfo.RegionName + ": Restarting in " + 460 SendRegionMessageFromEstateTools(LLUUID.Random(), LLUUID.Random(), String.Empty, RegionInfo.RegionName + ": Restarting in " +
451 ((8 - m_RestartTimerCounter) * 15) + " seconds"); 461 ((8 - m_RestartTimerCounter) * 15) + " seconds");
452 462
453 // SendGeneralAlert(RegionInfo.RegionName + ": Restarting in " + ((8 - m_RestartTimerCounter)*15) + 463 // SendGeneralAlert(RegionInfo.RegionName + ": Restarting in " + ((8 - m_RestartTimerCounter)*15) +
454 //" seconds"); 464 //" seconds");
@@ -490,15 +500,15 @@ namespace OpenSim.Region.Environment.Scenes
490 try 500 try
491 { 501 {
492 ForEachScenePresence(delegate(ScenePresence agent) 502 ForEachScenePresence(delegate(ScenePresence agent)
503 {
504 // If agent is a root agent.
505 if (!agent.IsChildAgent)
493 { 506 {
494 // If agent is a root agent. 507 //agent.ControllingClient.new
495 if (!agent.IsChildAgent) 508 //this.CommsManager.InterRegion.InformRegionOfChildAgent(otherRegion.RegionHandle, agent.ControllingClient.RequestClientInfo());
496 { 509 InformClientOfNeighbor(agent, region);
497 //agent.ControllingClient.new
498 //this.CommsManager.InterRegion.InformRegionOfChildAgent(otherRegion.RegionHandle, agent.ControllingClient.RequestClientInfo());
499 InformClientOfNeighbor(agent, region);
500 }
501 } 510 }
511 }
502 ); 512 );
503 } 513 }
504 catch (NullReferenceException) 514 catch (NullReferenceException)
@@ -527,7 +537,7 @@ namespace OpenSim.Region.Environment.Scenes
527 { 537 {
528 if (ent is SceneObjectGroup) 538 if (ent is SceneObjectGroup)
529 { 539 {
530 ((SceneObjectGroup) ent).StopScripts(); 540 ((SceneObjectGroup)ent).StopScripts();
531 } 541 }
532 } 542 }
533 } 543 }
@@ -541,10 +551,12 @@ namespace OpenSim.Region.Environment.Scenes
541 { 551 {
542 if (ent is SceneObjectGroup) 552 if (ent is SceneObjectGroup)
543 { 553 {
544 ((SceneObjectGroup) ent).StartScripts(); 554 ((SceneObjectGroup)ent).StartScripts();
545 } 555 }
546 } 556 }
547 } 557 }
558
559
548 } 560 }
549 m_scripts_enabled = !ScriptEngine; 561 m_scripts_enabled = !ScriptEngine;
550 m_log.Info("[TOTEDD]: Here is the method to trigger disabling of the scripting engine"); 562 m_log.Info("[TOTEDD]: Here is the method to trigger disabling of the scripting engine");
@@ -552,7 +564,9 @@ namespace OpenSim.Region.Environment.Scenes
552 if (m_physics_enabled != !PhysicsEngine) 564 if (m_physics_enabled != !PhysicsEngine)
553 { 565 {
554 m_physics_enabled = !PhysicsEngine; 566 m_physics_enabled = !PhysicsEngine;
567
555 } 568 }
569
556 } 570 }
557 571
558 // This is the method that shuts down the scene. 572 // This is the method that shuts down the scene.
@@ -561,16 +575,16 @@ namespace OpenSim.Region.Environment.Scenes
561 m_log.Warn("[SCENE]: Closing down the single simulator: " + RegionInfo.RegionName); 575 m_log.Warn("[SCENE]: Closing down the single simulator: " + RegionInfo.RegionName);
562 // Kick all ROOT agents with the message, 'The simulator is going down' 576 // Kick all ROOT agents with the message, 'The simulator is going down'
563 ForEachScenePresence(delegate(ScenePresence avatar) 577 ForEachScenePresence(delegate(ScenePresence avatar)
564 { 578 {
565 if (avatar.KnownChildRegions.Contains(RegionInfo.RegionHandle)) 579 if (avatar.KnownChildRegions.Contains(RegionInfo.RegionHandle))
566 avatar.KnownChildRegions.Remove(RegionInfo.RegionHandle); 580 avatar.KnownChildRegions.Remove(RegionInfo.RegionHandle);
567 581
568 if (!avatar.IsChildAgent) 582 if (!avatar.IsChildAgent)
569 avatar.ControllingClient.Kick("The simulator is going down."); 583 avatar.ControllingClient.Kick("The simulator is going down.");
570 584
571 avatar.ControllingClient.OutPacket(PacketPool.Instance.GetPacket(PacketType.DisableSimulator), 585 avatar.ControllingClient.OutPacket(PacketPool.Instance.GetPacket(PacketType.DisableSimulator),
572 ThrottleOutPacketType.Task); 586 ThrottleOutPacketType.Task);
573 }); 587 });
574 588
575 // Wait here, or the kick messages won't actually get to the agents before the scene terminates. 589 // Wait here, or the kick messages won't actually get to the agents before the scene terminates.
576 Thread.Sleep(500); 590 Thread.Sleep(500);
@@ -605,8 +619,8 @@ namespace OpenSim.Region.Environment.Scenes
605 { 619 {
606 m_log.Debug("[SCENE]: Starting timer"); 620 m_log.Debug("[SCENE]: Starting timer");
607 m_heartbeatTimer.Enabled = true; 621 m_heartbeatTimer.Enabled = true;
608 m_heartbeatTimer.Interval = (int) (m_timespan * 1000); 622 m_heartbeatTimer.Interval = (int)(m_timespan * 1000);
609 m_heartbeatTimer.Elapsed += Heartbeat; 623 m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat);
610 } 624 }
611 625
612 public void SetModuleInterfaces() 626 public void SetModuleInterfaces()
@@ -708,13 +722,13 @@ namespace OpenSim.Region.Environment.Scenes
708 { 722 {
709 if (m_frame % m_update_events == 0) 723 if (m_frame % m_update_events == 0)
710 UpdateEvents(); 724 UpdateEvents();
711 725
712 if (m_frame % m_update_backup == 0) 726 if (m_frame % m_update_backup == 0)
713 UpdateStorageBackup(); 727 UpdateStorageBackup();
714 728
715 if (m_frame % m_update_terrain == 0) 729 if (m_frame % m_update_terrain == 0)
716 UpdateTerrain(); 730 UpdateTerrain();
717 731
718 if (m_frame % m_update_land == 0) 732 if (m_frame % m_update_land == 0)
719 UpdateLand(); 733 UpdateLand();
720 otherMS = System.Environment.TickCount - otherMS; 734 otherMS = System.Environment.TickCount - otherMS;
@@ -742,25 +756,28 @@ namespace OpenSim.Region.Environment.Scenes
742 } 756 }
743 catch (AccessViolationException e) 757 catch (AccessViolationException e)
744 { 758 {
745 m_log.Error("[Scene]: Failed with exception " + e + " On Region: " + RegionInfo.RegionName); 759 m_log.Error("[Scene]: Failed with exception " + e.ToString() + " On Region: " + RegionInfo.RegionName);
760
746 } 761 }
747 catch (NullReferenceException e) 762 catch (NullReferenceException e)
748 { 763 {
749 m_log.Error("[Scene]: Failed with exception " + e + " On Region: " + RegionInfo.RegionName); 764 m_log.Error("[Scene]: Failed with exception " + e.ToString() + " On Region: " + RegionInfo.RegionName);
765
750 } 766 }
751 catch (InvalidOperationException e) 767 catch (InvalidOperationException e)
752 { 768 {
753 m_log.Error("[Scene]: Failed with exception " + e + " On Region: " + RegionInfo.RegionName); 769 m_log.Error("[Scene]: Failed with exception " + e.ToString() + " On Region: " + RegionInfo.RegionName);
770
754 } 771 }
755 catch (Exception e) 772 catch (Exception e)
756 { 773 {
757 m_log.Error("[Scene]: Failed with exception " + e + " On Region: " + RegionInfo.RegionName); 774 m_log.Error("[Scene]: Failed with exception " + e.ToString() + " On Region: " + RegionInfo.RegionName);
758 } 775 }
759 finally 776 finally
760 { 777 {
761 updateLock.ReleaseMutex(); 778 updateLock.ReleaseMutex();
762 // Get actual time dilation 779 // Get actual time dilation
763 float tmpval = (m_timespan / (float) SinceLastFrame.TotalSeconds); 780 float tmpval = (m_timespan / (float)SinceLastFrame.TotalSeconds);
764 781
765 // If actual time dilation is greater then one, we're catching up, so subtract 782 // If actual time dilation is greater then one, we're catching up, so subtract
766 // the amount that's greater then 1 from the time dilation 783 // the amount that's greater then 1 from the time dilation
@@ -769,7 +786,7 @@ namespace OpenSim.Region.Environment.Scenes
769 tmpval = tmpval - (tmpval - 1.0f); 786 tmpval = tmpval - (tmpval - 1.0f);
770 } 787 }
771 m_timedilation = tmpval; 788 m_timedilation = tmpval;
772 789
773 m_lastupdate = DateTime.Now; 790 m_lastupdate = DateTime.Now;
774 } 791 }
775 } 792 }
@@ -839,10 +856,10 @@ namespace OpenSim.Region.Environment.Scenes
839 public void ExportWorldMap(string fileName) 856 public void ExportWorldMap(string fileName)
840 { 857 {
841 List<MapBlockData> mapBlocks = 858 List<MapBlockData> mapBlocks =
842 m_sceneGridService.RequestNeighbourMapBlocks((int) (RegionInfo.RegionLocX - 9), 859 m_sceneGridService.RequestNeighbourMapBlocks((int)(RegionInfo.RegionLocX - 9),
843 (int) (RegionInfo.RegionLocY - 9), 860 (int)(RegionInfo.RegionLocY - 9),
844 (int) (RegionInfo.RegionLocX + 9), 861 (int)(RegionInfo.RegionLocX + 9),
845 (int) (RegionInfo.RegionLocY + 9)); 862 (int)(RegionInfo.RegionLocY + 9));
846 List<AssetBase> textures = new List<AssetBase>(); 863 List<AssetBase> textures = new List<AssetBase>();
847 List<Image> bitImages = new List<Image>(); 864 List<Image> bitImages = new List<Image>();
848 865
@@ -877,8 +894,8 @@ namespace OpenSim.Region.Environment.Scenes
877 894
878 for (int i = 0; i < mapBlocks.Count; i++) 895 for (int i = 0; i < mapBlocks.Count; i++)
879 { 896 {
880 ushort x = (ushort) ((mapBlocks[i].X - RegionInfo.RegionLocX) + 10); 897 ushort x = (ushort)((mapBlocks[i].X - RegionInfo.RegionLocX) + 10);
881 ushort y = (ushort) ((mapBlocks[i].Y - RegionInfo.RegionLocY) + 10); 898 ushort y = (ushort)((mapBlocks[i].Y - RegionInfo.RegionLocY) + 10);
882 g.DrawImage(bitImages[i], (x * 128), (y * 128), 128, 128); 899 g.DrawImage(bitImages[i], (x * 128), (y * 128), 128, 128);
883 } 900 }
884 mapTexture.Save(fileName, ImageFormat.Jpeg); 901 mapTexture.Save(fileName, ImageFormat.Jpeg);
@@ -909,10 +926,11 @@ namespace OpenSim.Region.Environment.Scenes
909 { 926 {
910 Heightmap = new TerrainChannel(map); 927 Heightmap = new TerrainChannel(map);
911 } 928 }
929
912 } 930 }
913 catch (Exception e) 931 catch (Exception e)
914 { 932 {
915 m_log.Warn("[terrain]: Scene.cs: LoadWorldMap() - Failed with exception " + e); 933 m_log.Warn("[terrain]: Scene.cs: LoadWorldMap() - Failed with exception " + e.ToString());
916 } 934 }
917 } 935 }
918 936
@@ -973,7 +991,7 @@ namespace OpenSim.Region.Environment.Scenes
973 { 991 {
974 for (int y = 0; y < 256; y++) 992 for (int y = 0; y < 256; y++)
975 { 993 {
976 float hmval = (float) hm[x, y]; 994 float hmval = (float)hm[x, y];
977 if (hmval < low) 995 if (hmval < low)
978 low = hmval; 996 low = hmval;
979 if (hmval > high) 997 if (hmval > high)
@@ -1003,10 +1021,10 @@ namespace OpenSim.Region.Environment.Scenes
1003 //} 1021 //}
1004 //else 1022 //else
1005 //{ 1023 //{
1006 float tmpval = (float) hm[x, y]; 1024 float tmpval = (float)hm[x, y];
1007 heightvalue = (float) hm[x, y]; 1025 heightvalue = (float)hm[x, y];
1008 1026
1009 if (heightvalue > m_regInfo.EstateSettings.waterHeight) 1027 if ((float)heightvalue > m_regInfo.EstateSettings.waterHeight)
1010 { 1028 {
1011 // scale height value 1029 // scale height value
1012 heightvalue = low + mid * (heightvalue - low) / mid; 1030 heightvalue = low + mid * (heightvalue - low) / mid;
@@ -1018,7 +1036,7 @@ namespace OpenSim.Region.Environment.Scenes
1018 heightvalue = 0; 1036 heightvalue = 0;
1019 1037
1020 1038
1021 Color green = Color.FromArgb((int) heightvalue, 100, (int) heightvalue); 1039 Color green = Color.FromArgb((int)heightvalue, 100, (int)heightvalue);
1022 1040
1023 // Y flip the cordinates 1041 // Y flip the cordinates
1024 mapbmp.SetPixel(x, (256 - y) - 1, green); 1042 mapbmp.SetPixel(x, (256 - y) - 1, green);
@@ -1040,10 +1058,12 @@ namespace OpenSim.Region.Environment.Scenes
1040 if (heightvalue < 0) 1058 if (heightvalue < 0)
1041 heightvalue = 0; 1059 heightvalue = 0;
1042 1060
1043 Color water = Color.FromArgb((int) heightvalue, (int) heightvalue, 255); 1061 Color water = Color.FromArgb((int)heightvalue, (int)heightvalue, 255);
1044 mapbmp.SetPixel(x, (256 - y) - 1, water); 1062 mapbmp.SetPixel(x, (256 - y) - 1, water);
1045 } 1063 }
1046 //} 1064 //}
1065
1066
1047 } 1067 }
1048 //tc = System.Environment.TickCount - tc; 1068 //tc = System.Environment.TickCount - tc;
1049 //m_log.Info("[MAPTILE]: Completed One row in " + tc + " ms"); 1069 //m_log.Info("[MAPTILE]: Completed One row in " + tc + " ms");
@@ -1067,6 +1087,7 @@ namespace OpenSim.Region.Environment.Scenes
1067 asset.Type = 0; 1087 asset.Type = 0;
1068 asset.Temporary = temporary; 1088 asset.Temporary = temporary;
1069 AssetCache.AddAsset(asset); 1089 AssetCache.AddAsset(asset);
1090
1070 } 1091 }
1071 else 1092 else
1072 { 1093 {
@@ -1084,6 +1105,7 @@ namespace OpenSim.Region.Environment.Scenes
1084 AssetCache.AddAsset(asset); 1105 AssetCache.AddAsset(asset);
1085 } 1106 }
1086 } 1107 }
1108
1087 } 1109 }
1088 1110
1089 #endregion 1111 #endregion
@@ -1121,14 +1143,14 @@ namespace OpenSim.Region.Environment.Scenes
1121 { 1143 {
1122 AddEntityFromStorage(group); 1144 AddEntityFromStorage(group);
1123 SceneObjectPart rootPart = group.GetChildPart(group.UUID); 1145 SceneObjectPart rootPart = group.GetChildPart(group.UUID);
1124 rootPart.ObjectFlags &= ~(uint) LLObject.ObjectFlags.Scripted; 1146 rootPart.ObjectFlags &= ~(uint)LLObject.ObjectFlags.Scripted;
1125 rootPart.TrimPermissions(); 1147 rootPart.TrimPermissions();
1126 1148
1127 group.ApplyPhysics(m_physicalPrim); 1149 group.ApplyPhysics(m_physicalPrim);
1128 //rootPart.DoPhysicsPropertyUpdate(UsePhysics, true); 1150 //rootPart.DoPhysicsPropertyUpdate(UsePhysics, true);
1129 } 1151 }
1130 1152
1131 m_log.Info("[SCENE]: Loaded " + PrimsFromDB.Count + " SceneObject(s)"); 1153 m_log.Info("[SCENE]: Loaded " + PrimsFromDB.Count.ToString() + " SceneObject(s)");
1132 } 1154 }
1133 1155
1134 /// <summary> 1156 /// <summary>
@@ -1147,11 +1169,10 @@ namespace OpenSim.Region.Environment.Scenes
1147 return myID; 1169 return myID;
1148 } 1170 }
1149 1171
1150 public LLVector3 GetNewRezLocation(LLVector3 RayStart, LLVector3 RayEnd, LLUUID RayTargetID, LLQuaternion rot, byte bypassRayCast, 1172 public LLVector3 GetNewRezLocation(LLVector3 RayStart, LLVector3 RayEnd, LLUUID RayTargetID, LLQuaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, LLVector3 scale, bool FaceCenter)
1151 byte RayEndIsIntersection, bool frontFacesOnly, LLVector3 scale, bool FaceCenter)
1152 { 1173 {
1153 LLVector3 pos = LLVector3.Zero; 1174 LLVector3 pos = LLVector3.Zero;
1154 if (RayEndIsIntersection == 1) 1175 if (RayEndIsIntersection == (byte)1)
1155 { 1176 {
1156 pos = RayEnd; 1177 pos = RayEnd;
1157 return pos; 1178 return pos;
@@ -1159,7 +1180,7 @@ namespace OpenSim.Region.Environment.Scenes
1159 if (RayTargetID != LLUUID.Zero) 1180 if (RayTargetID != LLUUID.Zero)
1160 { 1181 {
1161 SceneObjectPart target = GetSceneObjectPart(RayTargetID); 1182 SceneObjectPart target = GetSceneObjectPart(RayTargetID);
1162 1183
1163 LLVector3 direction = LLVector3.Norm(RayEnd - RayStart); 1184 LLVector3 direction = LLVector3.Norm(RayEnd - RayStart);
1164 Vector3 AXOrigin = new Vector3(RayStart.X, RayStart.Y, RayStart.Z); 1185 Vector3 AXOrigin = new Vector3(RayStart.X, RayStart.Y, RayStart.Z);
1165 Vector3 AXdirection = new Vector3(direction.X, direction.Y, direction.Z); 1186 Vector3 AXdirection = new Vector3(direction.X, direction.Y, direction.Z);
@@ -1168,17 +1189,17 @@ namespace OpenSim.Region.Environment.Scenes
1168 { 1189 {
1169 pos = target.AbsolutePosition; 1190 pos = target.AbsolutePosition;
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()); 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());
1171 1192
1172 // TODO: Raytrace better here 1193 // TODO: Raytrace better here
1173 1194
1174 //EntityIntersection ei = m_innerScene.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection)); 1195 //EntityIntersection ei = m_innerScene.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection));
1175 Ray NewRay = new Ray(AXOrigin, AXdirection); 1196 Ray NewRay = new Ray(AXOrigin, AXdirection);
1176 1197
1177 // Ray Trace against target here 1198 // Ray Trace against target here
1178 EntityIntersection ei = target.TestIntersectionOBB(NewRay, new Quaternion(1, 0, 0, 0), frontFacesOnly, FaceCenter); 1199 EntityIntersection ei = target.TestIntersectionOBB(NewRay, new Quaternion(1,0,0,0), frontFacesOnly, FaceCenter);
1179 1200
1180 // Un-comment out the following line to Get Raytrace results printed to the console. 1201 // Un-comment out the following line to Get Raytrace results printed to the console.
1181 // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); 1202 // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString());
1182 float ScaleOffset = 0.5f; 1203 float ScaleOffset = 0.5f;
1183 1204
1184 // If we hit something 1205 // If we hit something
@@ -1194,12 +1215,13 @@ namespace OpenSim.Region.Environment.Scenes
1194 // Set the position to the intersection point 1215 // Set the position to the intersection point
1195 LLVector3 offset = (normal * (ScaleOffset / 2f)); 1216 LLVector3 offset = (normal * (ScaleOffset / 2f));
1196 pos = (intersectionpoint + offset); 1217 pos = (intersectionpoint + offset);
1197 1218
1198 // Un-offset the prim (it gets offset later by the consumer method) 1219 // Un-offset the prim (it gets offset later by the consumer method)
1199 pos.Z -= 0.25F; 1220 pos.Z -= 0.25F;
1200 } 1221
1201 1222 }
1202 1223
1224
1203 return pos; 1225 return pos;
1204 } 1226 }
1205 else 1227 else
@@ -1214,8 +1236,8 @@ namespace OpenSim.Region.Environment.Scenes
1214 if (ei.HitTF) 1236 if (ei.HitTF)
1215 { 1237 {
1216 pos = new LLVector3(ei.ipoint.x, ei.ipoint.y, ei.ipoint.z); 1238 pos = new LLVector3(ei.ipoint.x, ei.ipoint.y, ei.ipoint.z);
1217 } 1239 }
1218 1240
1219 return pos; 1241 return pos;
1220 } 1242 }
1221 } 1243 }
@@ -1231,8 +1253,8 @@ namespace OpenSim.Region.Environment.Scenes
1231 byte bypassRaycast, LLVector3 RayStart, LLUUID RayTargetID, 1253 byte bypassRaycast, LLVector3 RayStart, LLUUID RayTargetID,
1232 byte RayEndIsIntersection) 1254 byte RayEndIsIntersection)
1233 { 1255 {
1234 LLVector3 pos = GetNewRezLocation(RayStart, RayEnd, RayTargetID, rot, bypassRaycast, RayEndIsIntersection, true, new LLVector3(0.5f, 0.5f, 0.5f), 1256
1235 false); 1257 LLVector3 pos = GetNewRezLocation(RayStart, RayEnd, RayTargetID, rot, bypassRaycast, RayEndIsIntersection, true, new LLVector3(0.5f,0.5f,0.5f), false);
1236 1258
1237 if (PermissionsMngr.CanRezObject(ownerID, pos)) 1259 if (PermissionsMngr.CanRezObject(ownerID, pos))
1238 { 1260 {
@@ -1252,7 +1274,7 @@ namespace OpenSim.Region.Environment.Scenes
1252 SceneObjectPart rootPart = sceneOb.GetChildPart(sceneOb.UUID); 1274 SceneObjectPart rootPart = sceneOb.GetChildPart(sceneOb.UUID);
1253 // if grass or tree, make phantom 1275 // if grass or tree, make phantom
1254 //rootPart.TrimPermissions(); 1276 //rootPart.TrimPermissions();
1255 if ((rootPart.Shape.PCode == (byte) PCode.Grass) || (rootPart.Shape.PCode == (byte) PCode.Tree) || (rootPart.Shape.PCode == (byte) PCode.NewTree)) 1277 if ((rootPart.Shape.PCode == (byte)PCode.Grass) || (rootPart.Shape.PCode == (byte)PCode.Tree) || (rootPart.Shape.PCode == (byte)PCode.NewTree))
1256 { 1278 {
1257 rootPart.AddFlag(LLObject.ObjectFlags.Phantom); 1279 rootPart.AddFlag(LLObject.ObjectFlags.Phantom);
1258 //rootPart.ObjectFlags += (uint)LLObject.ObjectFlags.Phantom; 1280 //rootPart.ObjectFlags += (uint)LLObject.ObjectFlags.Phantom;
@@ -1267,13 +1289,13 @@ namespace OpenSim.Region.Environment.Scenes
1267 public SceneObjectGroup AddTree(LLVector3 scale, LLQuaternion rotation, LLVector3 position, 1289 public SceneObjectGroup AddTree(LLVector3 scale, LLQuaternion rotation, LLVector3 position,
1268 Tree treeType, bool newTree) 1290 Tree treeType, bool newTree)
1269 { 1291 {
1270 LLUUID uuid = RegionInfo.MasterAvatarAssignedUUID; 1292 LLUUID uuid = this.RegionInfo.MasterAvatarAssignedUUID;
1271 PrimitiveBaseShape treeShape = new PrimitiveBaseShape(); 1293 PrimitiveBaseShape treeShape = new PrimitiveBaseShape();
1272 treeShape.PathCurve = 16; 1294 treeShape.PathCurve = 16;
1273 treeShape.PathEnd = 49900; 1295 treeShape.PathEnd = 49900;
1274 treeShape.PCode = newTree ? (byte) PCode.NewTree : (byte) PCode.Tree; 1296 treeShape.PCode = newTree ? (byte)PCode.NewTree : (byte)PCode.Tree;
1275 treeShape.Scale = scale; 1297 treeShape.Scale = scale;
1276 treeShape.State = (byte) treeType; 1298 treeShape.State = (byte)treeType;
1277 return AddNewPrim(uuid, position, rotation, treeShape); 1299 return AddNewPrim(uuid, position, rotation, treeShape);
1278 } 1300 }
1279 1301
@@ -1338,11 +1360,12 @@ namespace OpenSim.Region.Environment.Scenes
1338 /// </summary> 1360 /// </summary>
1339 /// <param name="position">current position of Group</param> 1361 /// <param name="position">current position of Group</param>
1340 /// <param name="grp">Scene Object Group that we're crossing</param> 1362 /// <param name="grp">Scene Object Group that we're crossing</param>
1363
1341 public void CrossPrimGroupIntoNewRegion(LLVector3 position, SceneObjectGroup grp) 1364 public void CrossPrimGroupIntoNewRegion(LLVector3 position, SceneObjectGroup grp)
1342 { 1365 {
1343 m_log.Warn("Prim crossing: " + grp.UUID); 1366 m_log.Warn("Prim crossing: " + grp.UUID.ToString());
1344 int thisx = (int) RegionInfo.RegionLocX; 1367 int thisx = (int)RegionInfo.RegionLocX;
1345 int thisy = (int) RegionInfo.RegionLocY; 1368 int thisy = (int)RegionInfo.RegionLocY;
1346 1369
1347 ulong newRegionHandle = 0; 1370 ulong newRegionHandle = 0;
1348 LLVector3 pos = position; 1371 LLVector3 pos = position;
@@ -1351,44 +1374,43 @@ namespace OpenSim.Region.Environment.Scenes
1351 { 1374 {
1352 pos.X = ((pos.X - Constants.RegionSize)); 1375 pos.X = ((pos.X - Constants.RegionSize));
1353 1376
1354 newRegionHandle = Util.UIntsToLong((uint) ((thisx + 1) * Constants.RegionSize), (uint) (thisy * Constants.RegionSize)); 1377 newRegionHandle = Util.UIntsToLong((uint)((thisx + 1) * Constants.RegionSize), (uint)(thisy * Constants.RegionSize));
1355 1378
1356 // x + 1 1379 // x + 1
1357 } 1380 }
1358 else if (position.X < -0.1f) 1381 else if (position.X < -0.1f)
1359 { 1382 {
1360 pos.X = ((pos.X + Constants.RegionSize)); 1383 pos.X = ((pos.X + Constants.RegionSize));
1361 newRegionHandle = Util.UIntsToLong((uint) ((thisx - 1) * Constants.RegionSize), (uint) (thisy * Constants.RegionSize)); 1384 newRegionHandle = Util.UIntsToLong((uint)((thisx - 1) * Constants.RegionSize), (uint)(thisy * Constants.RegionSize));
1362 // x - 1 1385 // x - 1
1363 } 1386 }
1364 1387
1365 if (position.Y > Constants.RegionSize + 0.1f) 1388 if (position.Y > Constants.RegionSize + 0.1f)
1366 { 1389 {
1367 pos.Y = ((pos.Y - Constants.RegionSize)); 1390 pos.Y = ((pos.Y - Constants.RegionSize));
1368 newRegionHandle = Util.UIntsToLong((uint) (thisx * Constants.RegionSize), (uint) ((thisy + 1) * Constants.RegionSize)); 1391 newRegionHandle = Util.UIntsToLong((uint)(thisx * Constants.RegionSize), (uint)((thisy + 1) * Constants.RegionSize));
1369 // y + 1 1392 // y + 1
1370 } 1393 }
1371 else if (position.Y < -1f) 1394 else if (position.Y < -1f)
1372 { 1395 {
1373 pos.Y = ((pos.Y + Constants.RegionSize)); 1396 pos.Y = ((pos.Y + Constants.RegionSize));
1374 newRegionHandle = Util.UIntsToLong((uint) (thisx * Constants.RegionSize), (uint) ((thisy - 1) * Constants.RegionSize)); 1397 newRegionHandle = Util.UIntsToLong((uint)(thisx * Constants.RegionSize), (uint)((thisy - 1) * Constants.RegionSize));
1375 // y - 1 1398 // y - 1
1376 } 1399 }
1377 1400
1378 // Offset the positions for the new region across the border 1401 // Offset the positions for the new region across the border
1379 grp.OffsetForNewRegion(pos); 1402 grp.OffsetForNewRegion(pos);
1380 1403
1381 CrossPrimGroupIntoNewRegion(newRegionHandle, grp); 1404 CrossPrimGroupIntoNewRegion(newRegionHandle, grp);
1382 }
1383 1405
1406 }
1384 public void CrossPrimGroupIntoNewRegion(ulong newRegionHandle, SceneObjectGroup grp) 1407 public void CrossPrimGroupIntoNewRegion(ulong newRegionHandle, SceneObjectGroup grp)
1385 { 1408 {
1386 int primcrossingXMLmethod = 0; 1409 int primcrossingXMLmethod = 0;
1387 if (newRegionHandle != 0) 1410 if (newRegionHandle != 0)
1388 { 1411 {
1389 bool successYN = false; 1412 bool successYN = false;
1390 successYN = m_sceneGridService.PrimCrossToNeighboringRegion(newRegionHandle, grp.UUID, m_sceneXmlLoader.SavePrimGroupToXML2String(grp), 1413 successYN = m_sceneGridService.PrimCrossToNeighboringRegion(newRegionHandle, grp.UUID, m_sceneXmlLoader.SavePrimGroupToXML2String(grp), primcrossingXMLmethod);
1391 primcrossingXMLmethod);
1392 if (successYN) 1414 if (successYN)
1393 { 1415 {
1394 // We remove the object here 1416 // We remove the object here
@@ -1424,7 +1446,7 @@ namespace OpenSim.Region.Environment.Scenes
1424 SceneObjectPart RootPrim = GetSceneObjectPart(primID); 1446 SceneObjectPart RootPrim = GetSceneObjectPart(primID);
1425 if (RootPrim != null) 1447 if (RootPrim != null)
1426 { 1448 {
1427 if (RootPrim.Shape.PCode == (byte) PCode.Prim) 1449 if (RootPrim.Shape.PCode == (byte)PCode.Prim)
1428 { 1450 {
1429 SceneObjectGroup grp = RootPrim.ParentGroup; 1451 SceneObjectGroup grp = RootPrim.ParentGroup;
1430 if (grp != null) 1452 if (grp != null)
@@ -1440,10 +1462,12 @@ namespace OpenSim.Region.Environment.Scenes
1440 // with the deeded object, it goes back to them 1462 // with the deeded object, it goes back to them
1441 1463
1442 grp.SetFromAssetID(grp.RootPart.LastOwnerID); 1464 grp.SetFromAssetID(grp.RootPart.LastOwnerID);
1443 m_innerScene.AttachObject(sp.ControllingClient, grp.LocalId, 0, grp.GroupRotation, grp.AbsolutePosition); 1465 m_innerScene.AttachObject(sp.ControllingClient, grp.LocalId, (uint)0, grp.GroupRotation, grp.AbsolutePosition);
1444 } 1466 }
1445 } 1467 }
1446 } 1468 }
1469
1470
1447 } 1471 }
1448 } 1472 }
1449 return true; 1473 return true;
@@ -1452,6 +1476,7 @@ namespace OpenSim.Region.Environment.Scenes
1452 { 1476 {
1453 return false; 1477 return false;
1454 } 1478 }
1479
1455 } 1480 }
1456 1481
1457 #endregion 1482 #endregion
@@ -1466,9 +1491,9 @@ namespace OpenSim.Region.Environment.Scenes
1466 public override void AddNewClient(IClientAPI client, bool child) 1491 public override void AddNewClient(IClientAPI client, bool child)
1467 { 1492 {
1468 m_log.DebugFormat( 1493 m_log.DebugFormat(
1469 "[CONNECTION DEBUGGING]: Creating new client for {0} at {1}", 1494 "[CONNECTION DEBUGGING]: Creating new client for {0} at {1}",
1470 client.AgentId, RegionInfo.RegionName); 1495 client.AgentId, RegionInfo.RegionName);
1471 1496
1472 SubscribeToClientEvents(client); 1497 SubscribeToClientEvents(client);
1473 ScenePresence presence = null; 1498 ScenePresence presence = null;
1474 1499
@@ -1538,19 +1563,19 @@ namespace OpenSim.Region.Environment.Scenes
1538 client.OnObjectDuplicateOnRay += doObjectDuplicateOnRay; 1563 client.OnObjectDuplicateOnRay += doObjectDuplicateOnRay;
1539 client.OnUpdatePrimFlags += m_innerScene.UpdatePrimFlags; 1564 client.OnUpdatePrimFlags += m_innerScene.UpdatePrimFlags;
1540 client.OnRequestObjectPropertiesFamily += m_innerScene.RequestObjectPropertiesFamily; 1565 client.OnRequestObjectPropertiesFamily += m_innerScene.RequestObjectPropertiesFamily;
1541 client.OnParcelPropertiesRequest += LandChannel.handleParcelPropertiesRequest; 1566 client.OnParcelPropertiesRequest += new ParcelPropertiesRequest(LandChannel.handleParcelPropertiesRequest);
1542 client.OnParcelDivideRequest += LandChannel.handleParcelDivideRequest; 1567 client.OnParcelDivideRequest += new ParcelDivideRequest(LandChannel.handleParcelDivideRequest);
1543 client.OnParcelJoinRequest += LandChannel.handleParcelJoinRequest; 1568 client.OnParcelJoinRequest += new ParcelJoinRequest(LandChannel.handleParcelJoinRequest);
1544 client.OnParcelPropertiesUpdateRequest += 1569 client.OnParcelPropertiesUpdateRequest +=
1545 LandChannel.handleParcelPropertiesUpdateRequest; 1570 new ParcelPropertiesUpdateRequest(LandChannel.handleParcelPropertiesUpdateRequest);
1546 client.OnParcelSelectObjects += LandChannel.handleParcelSelectObjectsRequest; 1571 client.OnParcelSelectObjects += new ParcelSelectObjects(LandChannel.handleParcelSelectObjectsRequest);
1547 client.OnParcelObjectOwnerRequest += 1572 client.OnParcelObjectOwnerRequest +=
1548 LandChannel.handleParcelObjectOwnersRequest; 1573 new ParcelObjectOwnerRequest(LandChannel.handleParcelObjectOwnersRequest);
1549 client.OnParcelAccessListRequest += LandChannel.handleParcelAccessRequest; 1574 client.OnParcelAccessListRequest += new ParcelAccessListRequest(LandChannel.handleParcelAccessRequest);
1550 client.OnParcelAccessListUpdateRequest += 1575 client.OnParcelAccessListUpdateRequest +=
1551 LandChannel.handleParcelAccessUpdateRequest; 1576 new ParcelAccessListUpdateRequest(LandChannel.handleParcelAccessUpdateRequest);
1552 1577
1553 client.OnEstateOwnerMessage += m_estateManager.handleEstateOwnerMessage; 1578 client.OnEstateOwnerMessage += new EstateOwnerMessageRequest(m_estateManager.handleEstateOwnerMessage);
1554 client.OnRegionInfoRequest += m_estateManager.HandleRegionInfoRequest; 1579 client.OnRegionInfoRequest += m_estateManager.HandleRegionInfoRequest;
1555 client.OnEstateCovenantRequest += m_estateManager.HandleEstateCovenantRequest; 1580 client.OnEstateCovenantRequest += m_estateManager.HandleEstateCovenantRequest;
1556 client.OnRequestGodlikePowers += handleRequestGodlikePowers; 1581 client.OnRequestGodlikePowers += handleRequestGodlikePowers;
@@ -1591,38 +1616,41 @@ namespace OpenSim.Region.Environment.Scenes
1591 1616
1592 client.OnSetStartLocationRequest += SetHomeRezPoint; 1617 client.OnSetStartLocationRequest += SetHomeRezPoint;
1593 client.OnUndo += m_innerScene.HandleUndo; 1618 client.OnUndo += m_innerScene.HandleUndo;
1594 1619
1595 EventManager.TriggerOnNewClient(client); 1620 EventManager.TriggerOnNewClient(client);
1596 } 1621 }
1597
1598 public virtual void TeleportClientHome(LLUUID AgentId, IClientAPI client) 1622 public virtual void TeleportClientHome(LLUUID AgentId, IClientAPI client)
1599 { 1623 {
1600 UserProfileData UserProfile = CommsManager.UserService.GetUserProfile(AgentId); 1624 UserProfileData UserProfile = CommsManager.UserService.GetUserProfile(AgentId);
1601 if (UserProfile != null) 1625 if (UserProfile != null)
1602 { 1626 {
1603 ulong homeRegion = UserProfile.HomeRegion; 1627 ulong homeRegion = UserProfile.HomeRegion;
1604 LLVector3 homePostion = new LLVector3(UserProfile.HomeLocationX, UserProfile.HomeLocationY, UserProfile.HomeLocationZ); 1628 LLVector3 homePostion = new LLVector3(UserProfile.HomeLocationX,UserProfile.HomeLocationY,UserProfile.HomeLocationZ);
1605 LLVector3 homeLookat = new LLVector3(UserProfile.HomeLookAt); 1629 LLVector3 homeLookat = new LLVector3(UserProfile.HomeLookAt);
1606 RequestTeleportLocation(client, homeRegion, homePostion, homeLookat, 0); 1630 RequestTeleportLocation(client, homeRegion, homePostion,homeLookat,(uint)0);
1631
1607 } 1632 }
1608 }
1609 1633
1634
1635 }
1610 public void doObjectDuplicateOnRay(uint localID, uint dupeFlags, LLUUID AgentID, LLUUID GroupID, 1636 public void doObjectDuplicateOnRay(uint localID, uint dupeFlags, LLUUID AgentID, LLUUID GroupID,
1611 LLUUID RayTargetObj, LLVector3 RayEnd, LLVector3 RayStart, 1637 LLUUID RayTargetObj, LLVector3 RayEnd, LLVector3 RayStart,
1612 bool BypassRaycast, bool RayEndIsIntersection, bool CopyCenters, bool CopyRotates) 1638 bool BypassRaycast, bool RayEndIsIntersection, bool CopyCenters, bool CopyRotates)
1613 { 1639 {
1640
1614 LLVector3 pos = LLVector3.Zero; 1641 LLVector3 pos = LLVector3.Zero;
1615 bool frontFacesOnly = true; 1642 bool frontFacesOnly = true;
1616 1643
1617 SceneObjectPart target = GetSceneObjectPart(localID); 1644 SceneObjectPart target = GetSceneObjectPart(localID);
1618 1645
1619 if (target != null) 1646 if (target != null)
1620 { 1647 {
1648
1621 LLVector3 direction = LLVector3.Norm(RayEnd - RayStart); 1649 LLVector3 direction = LLVector3.Norm(RayEnd - RayStart);
1622 Vector3 AXOrigin = new Vector3(RayStart.X, RayStart.Y, RayStart.Z); 1650 Vector3 AXOrigin = new Vector3(RayStart.X, RayStart.Y, RayStart.Z);
1623 Vector3 AXdirection = new Vector3(direction.X, direction.Y, direction.Z); 1651 Vector3 AXdirection = new Vector3(direction.X, direction.Y, direction.Z);
1624 1652
1625 1653
1626 if (target != null) 1654 if (target != null)
1627 { 1655 {
1628 if (target.ParentGroup != null) 1656 if (target.ParentGroup != null)
@@ -1652,8 +1680,9 @@ namespace OpenSim.Region.Environment.Scenes
1652 if (scaleComponent.Z != 0) ScaleOffset = scale.Z; 1680 if (scaleComponent.Z != 0) ScaleOffset = scale.Z;
1653 ScaleOffset = Math.Abs(ScaleOffset); 1681 ScaleOffset = Math.Abs(ScaleOffset);
1654 LLVector3 intersectionpoint = new LLVector3(ei.ipoint.x, ei.ipoint.y, ei.ipoint.z); 1682 LLVector3 intersectionpoint = new LLVector3(ei.ipoint.x, ei.ipoint.y, ei.ipoint.z);
1655 1683
1656 1684
1685
1657 if (CopyCenters) 1686 if (CopyCenters)
1658 { 1687 {
1659 // now we cast a ray from inside the prim(absolute position) to one of it's faces along the face normal. 1688 // now we cast a ray from inside the prim(absolute position) to one of it's faces along the face normal.
@@ -1665,7 +1694,7 @@ namespace OpenSim.Region.Environment.Scenes
1665 if (ei2.HitTF) 1694 if (ei2.HitTF)
1666 { 1695 {
1667 //m_log.Info("[RAYTRACERESULTS]: Hit:" + ei2.HitTF.ToString() + " Point: " + ei2.ipoint.ToString() + " Normal: " + ei2.normal.ToString()); 1696 //m_log.Info("[RAYTRACERESULTS]: Hit:" + ei2.HitTF.ToString() + " Point: " + ei2.ipoint.ToString() + " Normal: " + ei2.normal.ToString());
1668 pos = new LLVector3(ei2.ipoint.x, ei2.ipoint.y, ei2.ipoint.z); 1697 pos = new LLVector3(ei2.ipoint.x,ei2.ipoint.y,ei2.ipoint.z);
1669 } 1698 }
1670 } 1699 }
1671 LLVector3 normal = new LLVector3(ei.normal.x, ei.normal.y, ei.normal.z); 1700 LLVector3 normal = new LLVector3(ei.normal.x, ei.normal.y, ei.normal.z);
@@ -1678,14 +1707,18 @@ namespace OpenSim.Region.Environment.Scenes
1678 m_innerScene.DuplicateObject(target.ParentGroup.LocalId, pos, target.GetEffectiveObjectFlags(), AgentID, GroupID); 1707 m_innerScene.DuplicateObject(target.ParentGroup.LocalId, pos, target.GetEffectiveObjectFlags(), AgentID, GroupID);
1679 } 1708 }
1680 1709
1681 1710
1682 return; 1711 return;
1683 } 1712 }
1684 return; 1713 return;
1685 } 1714 }
1715
1686 } 1716 }
1687 }
1688 1717
1718
1719
1720
1721 }
1689 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, LLVector3 position, LLVector3 lookAt, uint flags) 1722 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, LLVector3 position, LLVector3 lookAt, uint flags)
1690 { 1723 {
1691 UserProfileData UserProfile = CommsManager.UserService.GetUserProfile(remoteClient.AgentId); 1724 UserProfileData UserProfile = CommsManager.UserService.GetUserProfile(remoteClient.AgentId);
@@ -1698,22 +1731,22 @@ namespace OpenSim.Region.Environment.Scenes
1698 // We cast these to an int so as not to cause a breaking change with old regions 1731 // We cast these to an int so as not to cause a breaking change with old regions
1699 // Newer regions treat this as a float on the ExpectUser method.. so we need to wait a few 1732 // Newer regions treat this as a float on the ExpectUser method.. so we need to wait a few
1700 // releases before setting these to floats. (r4257) 1733 // releases before setting these to floats. (r4257)
1701 UserProfile.HomeLocationX = (int) position.X; 1734 UserProfile.HomeLocationX = (int)position.X;
1702 UserProfile.HomeLocationY = (int) position.Y; 1735 UserProfile.HomeLocationY = (int)position.Y;
1703 UserProfile.HomeLocationZ = (int) position.Z; 1736 UserProfile.HomeLocationZ = (int)position.Z;
1704 UserProfile.HomeLookAtX = (int) lookAt.X; 1737 UserProfile.HomeLookAtX = (int)lookAt.X;
1705 UserProfile.HomeLookAtY = (int) lookAt.Y; 1738 UserProfile.HomeLookAtY = (int)lookAt.Y;
1706 UserProfile.HomeLookAtZ = (int) lookAt.Z; 1739 UserProfile.HomeLookAtZ = (int)lookAt.Z;
1707 CommsManager.UserService.UpdateUserProfileProperties(UserProfile); 1740 CommsManager.UserService.UpdateUserProfileProperties(UserProfile);
1708 1741
1709 remoteClient.SendAgentAlertMessage("Set home to here if supported by login service", false); 1742 remoteClient.SendAgentAlertMessage("Set home to here if supported by login service",false);
1710 } 1743 }
1711 else 1744 else
1712 { 1745 {
1713 remoteClient.SendAgentAlertMessage("Set Home request Failed", false); 1746 remoteClient.SendAgentAlertMessage("Set Home request Failed",false);
1714 } 1747 }
1715 }
1716 1748
1749 }
1717 protected virtual ScenePresence CreateAndAddScenePresence(IClientAPI client, bool child) 1750 protected virtual ScenePresence CreateAndAddScenePresence(IClientAPI client, bool child)
1718 { 1751 {
1719 ScenePresence avatar = null; 1752 ScenePresence avatar = null;
@@ -1779,7 +1812,7 @@ namespace OpenSim.Region.Environment.Scenes
1779 m_sceneGridService.SendCloseChildAgentConnections(agentID, childknownRegions); 1812 m_sceneGridService.SendCloseChildAgentConnections(agentID, childknownRegions);
1780 1813
1781 RemoveCapsHandler(agentID); 1814 RemoveCapsHandler(agentID);
1782 1815
1783 CommsManager.UserProfileCacheService.RemoveUser(agentID); 1816 CommsManager.UserProfileCacheService.RemoveUser(agentID);
1784 } 1817 }
1785 1818
@@ -1792,21 +1825,21 @@ namespace OpenSim.Region.Environment.Scenes
1792 } 1825 }
1793 m_eventManager.TriggerOnRemovePresence(agentID); 1826 m_eventManager.TriggerOnRemovePresence(agentID);
1794 Broadcast(delegate(IClientAPI client) 1827 Broadcast(delegate(IClientAPI client)
1828 {
1829 try
1830 {
1831 client.SendKillObject(avatar.RegionHandle, avatar.LocalId);
1832 }
1833 catch (NullReferenceException)
1795 { 1834 {
1796 try 1835 //We can safely ignore null reference exceptions. It means the avatar are dead and cleaned up anyway.
1797 { 1836 }
1798 client.SendKillObject(avatar.RegionHandle, avatar.LocalId); 1837 });
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 });
1805 1838
1806 ForEachScenePresence( 1839 ForEachScenePresence(
1807 delegate(ScenePresence presence) { presence.CoarseLocationChange(); }); 1840 delegate(ScenePresence presence) { presence.CoarseLocationChange(); });
1808 1841
1809 IAgentAssetTransactions agentTransactions = RequestModuleInterface<IAgentAssetTransactions>(); 1842 IAgentAssetTransactions agentTransactions = this.RequestModuleInterface<IAgentAssetTransactions>();
1810 if (agentTransactions != null) 1843 if (agentTransactions != null)
1811 { 1844 {
1812 agentTransactions.RemoveAgentAssetTransactions(agentID); 1845 agentTransactions.RemoveAgentAssetTransactions(agentID);
@@ -1846,7 +1879,7 @@ namespace OpenSim.Region.Environment.Scenes
1846 } 1879 }
1847 catch (Exception e) 1880 catch (Exception e)
1848 { 1881 {
1849 m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e); 1882 m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString());
1850 } 1883 }
1851 1884
1852 // Remove client agent from profile, so new logins will work 1885 // Remove client agent from profile, so new logins will work
@@ -1866,12 +1899,14 @@ namespace OpenSim.Region.Environment.Scenes
1866 { 1899 {
1867 lock (av) 1900 lock (av)
1868 { 1901 {
1902
1869 for (int i = 0; i < regionslst.Count; i++) 1903 for (int i = 0; i < regionslst.Count; i++)
1870 { 1904 {
1871 av.KnownChildRegions.Remove(regionslst[i]); 1905 av.KnownChildRegions.Remove(regionslst[i]);
1872 } 1906 }
1873 } 1907 }
1874 } 1908 }
1909
1875 } 1910 }
1876 1911
1877 public override void CloseAllAgents(uint circuitcode) 1912 public override void CloseAllAgents(uint circuitcode)
@@ -1959,7 +1994,7 @@ namespace OpenSim.Region.Environment.Scenes
1959 if (regionHandle == m_regInfo.RegionHandle) 1994 if (regionHandle == m_regInfo.RegionHandle)
1960 { 1995 {
1961 capsPaths[agent.AgentID] = agent.CapsPath; 1996 capsPaths[agent.AgentID] = agent.CapsPath;
1962 1997
1963 if (!agent.child) 1998 if (!agent.child)
1964 { 1999 {
1965 AddCapsHandler(agent.AgentID); 2000 AddCapsHandler(agent.AgentID);
@@ -1968,26 +2003,26 @@ namespace OpenSim.Region.Environment.Scenes
1968 ILandObject land = LandChannel.getLandObject(agent.startpos.X, agent.startpos.Y); 2003 ILandObject land = LandChannel.getLandObject(agent.startpos.X, agent.startpos.Y);
1969 if (land != null) 2004 if (land != null)
1970 { 2005 {
1971 if (land.landData.landingType == 1 && land.landData.userLocation != LLVector3.Zero) 2006 if (land.landData.landingType == (byte)1 && land.landData.userLocation != LLVector3.Zero)
1972 { 2007 {
1973 agent.startpos = land.landData.userLocation; 2008 agent.startpos = land.landData.userLocation;
1974 } 2009 }
1975 } 2010 }
1976 } 2011 }
1977 2012
1978 m_log.DebugFormat( 2013 m_log.DebugFormat(
1979 "[CONNECTION DEBUGGING]: Creating new circuit code ({0}) for avatar {1} at {2}", 2014 "[CONNECTION DEBUGGING]: Creating new circuit code ({0}) for avatar {1} at {2}",
1980 agent.circuitcode, agent.AgentID, RegionInfo.RegionName); 2015 agent.circuitcode, agent.AgentID, RegionInfo.RegionName);
1981 2016
1982 m_authenticateHandler.AddNewCircuit(agent.circuitcode, agent); 2017 m_authenticateHandler.AddNewCircuit(agent.circuitcode, agent);
1983 } 2018 }
1984 else 2019 else
1985 { 2020 {
1986 m_log.WarnFormat( 2021 m_log.WarnFormat(
1987 "[CONNECTION DEBUGGING]: Skipping this region for welcoming avatar {0} [{1}] at {2}", 2022 "[CONNECTION DEBUGGING]: Skipping this region for welcoming avatar {0} [{1}] at {2}",
1988 agent.AgentID, regionHandle, RegionInfo.RegionName); 2023 agent.AgentID, regionHandle, RegionInfo.RegionName);
1989 } 2024 }
1990 } 2025 }
1991 2026
1992 /// <summary> 2027 /// <summary>
1993 /// Add a caps handler for the given agent. If the CAPS handler already exists for this agent, 2028 /// Add a caps handler for the given agent. If the CAPS handler already exists for this agent,
@@ -2000,18 +2035,18 @@ namespace OpenSim.Region.Environment.Scenes
2000 /// <param name="agentId"></param> 2035 /// <param name="agentId"></param>
2001 /// <param name="capsObjectPath"></param> 2036 /// <param name="capsObjectPath"></param>
2002 public void AddCapsHandler(LLUUID agentId) 2037 public void AddCapsHandler(LLUUID agentId)
2003 { 2038 {
2004 String capsObjectPath = GetCapsPath(agentId); 2039 String capsObjectPath = GetCapsPath(agentId);
2005 2040
2006 m_log.DebugFormat( 2041 m_log.DebugFormat(
2007 "[CAPS]: Setting up CAPS handler for root agent {0} in {1}", 2042 "[CAPS]: Setting up CAPS handler for root agent {0} in {1}",
2008 agentId, RegionInfo.RegionName); 2043 agentId, RegionInfo.RegionName);
2009 2044
2010 Caps cap = 2045 Caps cap =
2011 new Caps(AssetCache, m_httpListener, m_regInfo.ExternalHostName, m_httpListener.Port, 2046 new Caps(AssetCache, m_httpListener, m_regInfo.ExternalHostName, m_httpListener.Port,
2012 capsObjectPath, agentId, m_dumpAssetsToFile, RegionInfo.RegionName); 2047 capsObjectPath, agentId, m_dumpAssetsToFile, RegionInfo.RegionName);
2013 cap.RegisterHandlers(); 2048 cap.RegisterHandlers();
2014 2049
2015 EventManager.TriggerOnRegisterCaps(agentId, cap); 2050 EventManager.TriggerOnRegisterCaps(agentId, cap);
2016 2051
2017 cap.AddNewInventoryItem = AddInventoryItem; 2052 cap.AddNewInventoryItem = AddInventoryItem;
@@ -2020,7 +2055,7 @@ namespace OpenSim.Region.Environment.Scenes
2020 cap.CAPSFetchInventoryDescendents = CommsManager.UserProfileCacheService.HandleFetchInventoryDescendentsCAPS; 2055 cap.CAPSFetchInventoryDescendents = CommsManager.UserProfileCacheService.HandleFetchInventoryDescendentsCAPS;
2021 cap.GetClient = m_innerScene.GetControllingClient; 2056 cap.GetClient = m_innerScene.GetControllingClient;
2022 m_capsHandlers[agentId] = cap; 2057 m_capsHandlers[agentId] = cap;
2023 } 2058 }
2024 2059
2025 /// <summary> 2060 /// <summary>
2026 /// Remove the caps handler for a given agent. 2061 /// Remove the caps handler for a given agent.
@@ -2033,9 +2068,9 @@ namespace OpenSim.Region.Environment.Scenes
2033 if (m_capsHandlers.ContainsKey(agentId)) 2068 if (m_capsHandlers.ContainsKey(agentId))
2034 { 2069 {
2035 m_log.DebugFormat( 2070 m_log.DebugFormat(
2036 "[CAPS]: Removing CAPS handler for root agent {0} in {1}", 2071 "[CAPS]: Removing CAPS handler for root agent {0} in {1}",
2037 agentId, RegionInfo.RegionName); 2072 agentId, RegionInfo.RegionName);
2038 2073
2039 m_capsHandlers[agentId].DeregisterHandlers(); 2074 m_capsHandlers[agentId].DeregisterHandlers();
2040 EventManager.TriggerOnDeregisterCaps(agentId, m_capsHandlers[agentId]); 2075 EventManager.TriggerOnDeregisterCaps(agentId, m_capsHandlers[agentId]);
2041 2076
@@ -2070,7 +2105,7 @@ namespace OpenSim.Region.Environment.Scenes
2070 catch (Exception e) 2105 catch (Exception e)
2071 { 2106 {
2072 m_log.Info("[SCENE]: Unable to do Agent Crossing."); 2107 m_log.Info("[SCENE]: Unable to do Agent Crossing.");
2073 m_log.Debug("[SCENE]: " + e); 2108 m_log.Debug("[SCENE]: " + e.ToString());
2074 } 2109 }
2075 //m_innerScene.SwapRootChildAgent(false); 2110 //m_innerScene.SwapRootChildAgent(false);
2076 } 2111 }
@@ -2086,14 +2121,15 @@ namespace OpenSim.Region.Environment.Scenes
2086 // however to avoid a race condition crossing borders.. 2121 // however to avoid a race condition crossing borders..
2087 if (childAgentUpdate.IsChildAgent) 2122 if (childAgentUpdate.IsChildAgent)
2088 { 2123 {
2089 uint rRegionX = (uint) (cAgentData.regionHandle >> 40); 2124 uint rRegionX = (uint)(cAgentData.regionHandle >> 40);
2090 uint rRegionY = (((uint) (cAgentData.regionHandle)) >> 8); 2125 uint rRegionY = (((uint)(cAgentData.regionHandle)) >> 8);
2091 uint tRegionX = RegionInfo.RegionLocX; 2126 uint tRegionX = RegionInfo.RegionLocX;
2092 uint tRegionY = RegionInfo.RegionLocY; 2127 uint tRegionY = RegionInfo.RegionLocY;
2093 //Send Data to ScenePresence 2128 //Send Data to ScenePresence
2094 childAgentUpdate.ChildAgentDataUpdate(cAgentData, tRegionX, tRegionY, rRegionX, rRegionY); 2129 childAgentUpdate.ChildAgentDataUpdate(cAgentData, tRegionX, tRegionY, rRegionX, rRegionY);
2095 // Not Implemented: 2130 // Not Implemented:
2096 //TODO: Do we need to pass the message on to one of our neighbors? 2131 //TODO: Do we need to pass the message on to one of our neighbors?
2132
2097 } 2133 }
2098 return true; 2134 return true;
2099 } 2135 }
@@ -2121,7 +2157,7 @@ namespace OpenSim.Region.Environment.Scenes
2121 m_innerScene.removeUserCount(true); 2157 m_innerScene.removeUserCount(true);
2122 } 2158 }
2123 // Tell a single agent to disconnect from the region. 2159 // Tell a single agent to disconnect from the region.
2124 DisableSimulatorPacket disable = (DisableSimulatorPacket) PacketPool.Instance.GetPacket(PacketType.DisableSimulator); 2160 DisableSimulatorPacket disable = (DisableSimulatorPacket)PacketPool.Instance.GetPacket(PacketType.DisableSimulator);
2125 presence.ControllingClient.OutPacket(disable, ThrottleOutPacketType.Unknown); 2161 presence.ControllingClient.OutPacket(disable, ThrottleOutPacketType.Unknown);
2126 presence.ControllingClient.Close(true); 2162 presence.ControllingClient.Close(true);
2127 } 2163 }
@@ -2271,9 +2307,9 @@ namespace OpenSim.Region.Environment.Scenes
2271 /// <param name="mod"></param> 2307 /// <param name="mod"></param>
2272 public void RegisterModuleInterface<M>(M mod) 2308 public void RegisterModuleInterface<M>(M mod)
2273 { 2309 {
2274 if (!ModuleInterfaces.ContainsKey(typeof (M))) 2310 if (!ModuleInterfaces.ContainsKey(typeof(M)))
2275 { 2311 {
2276 ModuleInterfaces.Add(typeof (M), mod); 2312 ModuleInterfaces.Add(typeof(M), mod);
2277 } 2313 }
2278 } 2314 }
2279 2315
@@ -2283,9 +2319,9 @@ namespace OpenSim.Region.Environment.Scenes
2283 /// <returns></returns> 2319 /// <returns></returns>
2284 public T RequestModuleInterface<T>() 2320 public T RequestModuleInterface<T>()
2285 { 2321 {
2286 if (ModuleInterfaces.ContainsKey(typeof (T))) 2322 if (ModuleInterfaces.ContainsKey(typeof(T)))
2287 { 2323 {
2288 return (T) ModuleInterfaces[typeof (T)]; 2324 return (T)ModuleInterfaces[typeof(T)];
2289 } 2325 }
2290 else 2326 else
2291 { 2327 {
@@ -2300,12 +2336,14 @@ namespace OpenSim.Region.Environment.Scenes
2300 m_statsReporter.SetObjectCapacity(objects); 2336 m_statsReporter.SetObjectCapacity(objects);
2301 } 2337 }
2302 objectCapacity = objects; 2338 objectCapacity = objects;
2339
2303 } 2340 }
2304 2341
2305 public List<FriendListItem> GetFriendList(LLUUID avatarID) 2342 public List<FriendListItem> GetFriendList(LLUUID avatarID)
2306 { 2343 {
2307 return CommsManager.GetUserFriendList(avatarID); 2344 return CommsManager.GetUserFriendList(avatarID);
2308 } 2345 }
2346
2309 2347
2310 #endregion 2348 #endregion
2311 2349
@@ -2340,8 +2378,7 @@ namespace OpenSim.Region.Environment.Scenes
2340 } 2378 }
2341 } 2379 }
2342 2380
2343 public void SendDialogToUser(LLUUID avatarID, string objectName, LLUUID objectID, LLUUID ownerID, string message, LLUUID TextureID, int ch, 2381 public void SendDialogToUser(LLUUID avatarID, string objectName, LLUUID objectID, LLUUID ownerID, string message, LLUUID TextureID, int ch, string[] buttonlabels)
2344 string[] buttonlabels)
2345 { 2382 {
2346 if (m_scenePresences.ContainsKey(avatarID)) 2383 if (m_scenePresences.ContainsKey(avatarID))
2347 { 2384 {
@@ -2364,7 +2401,7 @@ namespace OpenSim.Region.Environment.Scenes
2364 } 2401 }
2365 return LLUUID.Zero; 2402 return LLUUID.Zero;
2366 } 2403 }
2367 2404
2368 2405
2369 /// <summary> 2406 /// <summary>
2370 /// This method is a way for the Friends Module to create an instant 2407 /// This method is a way for the Friends Module to create an instant
@@ -2399,7 +2436,6 @@ namespace OpenSim.Region.Environment.Scenes
2399 // TODO: m_sceneGridService.DoStuff; 2436 // TODO: m_sceneGridService.DoStuff;
2400 m_sceneGridService.RemoveUserFriend(ownerID, ExfriendID); 2437 m_sceneGridService.RemoveUserFriend(ownerID, ExfriendID);
2401 } 2438 }
2402
2403 public virtual List<FriendListItem> StoreGetFriendsForUser(LLUUID ownerID) 2439 public virtual List<FriendListItem> StoreGetFriendsForUser(LLUUID ownerID)
2404 { 2440 {
2405 // TODO: m_sceneGridService.DoStuff; 2441 // TODO: m_sceneGridService.DoStuff;
@@ -2412,13 +2448,11 @@ namespace OpenSim.Region.Environment.Scenes
2412 m_statsReporter.AddOutPackets(outPackets); 2448 m_statsReporter.AddOutPackets(outPackets);
2413 m_statsReporter.AddunAckedBytes(unAckedBytes); 2449 m_statsReporter.AddunAckedBytes(unAckedBytes);
2414 } 2450 }
2415
2416 public void AddAgentTime(int ms) 2451 public void AddAgentTime(int ms)
2417 { 2452 {
2418 m_statsReporter.addFrameMS(ms); 2453 m_statsReporter.addFrameMS(ms);
2419 m_statsReporter.addAgentMS(ms); 2454 m_statsReporter.addAgentMS(ms);
2420 } 2455 }
2421
2422 public void AddAgentUpdates(int count) 2456 public void AddAgentUpdates(int count)
2423 { 2457 {
2424 m_statsReporter.AddAgentUpdates(count); 2458 m_statsReporter.AddAgentUpdates(count);
@@ -2512,6 +2546,7 @@ namespace OpenSim.Region.Environment.Scenes
2512 /// <param name="Message">The Message being sent to the user</param> 2546 /// <param name="Message">The Message being sent to the user</param>
2513 public void SendRegionMessageFromEstateTools(LLUUID FromAvatarID, LLUUID fromSessionID, String FromAvatarName, String Message) 2547 public void SendRegionMessageFromEstateTools(LLUUID FromAvatarID, LLUUID fromSessionID, String FromAvatarName, String Message)
2514 { 2548 {
2549
2515 List<ScenePresence> presenceList = GetScenePresences(); 2550 List<ScenePresence> presenceList = GetScenePresences();
2516 2551
2517 foreach (ScenePresence presence in presenceList) 2552 foreach (ScenePresence presence in presenceList)
@@ -2531,7 +2566,11 @@ namespace OpenSim.Region.Environment.Scenes
2531 /// <param name="Message">The Message being sent to the user</param> 2566 /// <param name="Message">The Message being sent to the user</param>
2532 public void SendEstateMessageFromEstateTools(LLUUID FromAvatarID, LLUUID fromSessionID, String FromAvatarName, String Message) 2567 public void SendEstateMessageFromEstateTools(LLUUID FromAvatarID, LLUUID fromSessionID, String FromAvatarName, String Message)
2533 { 2568 {
2534 ClientManager.ForEachClient(delegate(IClientAPI controller) { controller.SendBlueBoxMessage(FromAvatarID, fromSessionID, FromAvatarName, Message); } 2569
2570 ClientManager.ForEachClient(delegate(IClientAPI controller)
2571 {
2572 controller.SendBlueBoxMessage(FromAvatarID, fromSessionID, FromAvatarName, Message);
2573 }
2535 ); 2574 );
2536 } 2575 }
2537 2576
@@ -2557,24 +2596,27 @@ namespace OpenSim.Region.Environment.Scenes
2557 if (agentID == kickUserID) 2596 if (agentID == kickUserID)
2558 { 2597 {
2559 ClientManager.ForEachClient(delegate(IClientAPI controller) 2598 ClientManager.ForEachClient(delegate(IClientAPI controller)
2560 { 2599 {
2561 if (controller.AgentId != godID) 2600 if (controller.AgentId != godID)
2562 controller.Kick(Helpers.FieldToUTF8String(reason)); 2601 controller.Kick(Helpers.FieldToUTF8String(reason));
2563 } 2602
2603
2604
2605 }
2564 ); 2606 );
2565 // This is a bit crude. It seems the client will be null before it actually stops the thread 2607 // This is a bit crude. It seems the client will be null before it actually stops the thread
2566 // The thread will kill itself eventually :/ 2608 // The thread will kill itself eventually :/
2567 // Is there another way to make sure *all* clients get this 'inter region' message? 2609 // Is there another way to make sure *all* clients get this 'inter region' message?
2568 ClientManager.ForEachClient(delegate(IClientAPI controller) 2610 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?
2569 { 2616 {
2570 ScenePresence p = GetScenePresence(controller.AgentId); 2617 controller.Close(true);
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 }
2577 } 2618 }
2619 }
2578 ); 2620 );
2579 } 2621 }
2580 else 2622 else
@@ -2605,6 +2647,7 @@ namespace OpenSim.Region.Environment.Scenes
2605 // Check for spoofing.. since this is permissions we're talking about here! 2647 // Check for spoofing.. since this is permissions we're talking about here!
2606 if ((controller.SessionId == sessionID) && (controller.AgentId == agentID)) 2648 if ((controller.SessionId == sessionID) && (controller.AgentId == agentID))
2607 { 2649 {
2650
2608 // Tell the object to do permission update 2651 // Tell the object to do permission update
2609 if (localId != 0) 2652 if (localId != 0)
2610 { 2653 {
@@ -2614,6 +2657,7 @@ namespace OpenSim.Region.Environment.Scenes
2614 chObjectGroup.UpdatePermissions(agentID, field, localId, mask, set); 2657 chObjectGroup.UpdatePermissions(agentID, field, localId, mask, set);
2615 } 2658 }
2616 } 2659 }
2660
2617 } 2661 }
2618 } 2662 }
2619 2663
@@ -2679,7 +2723,7 @@ namespace OpenSim.Region.Environment.Scenes
2679 { 2723 {
2680 if (ent is SceneObjectGroup) 2724 if (ent is SceneObjectGroup)
2681 { 2725 {
2682 ((SceneObjectGroup) ent).ScheduleGroupForFullUpdate(); 2726 ((SceneObjectGroup)ent).ScheduleGroupForFullUpdate();
2683 } 2727 }
2684 } 2728 }
2685 } 2729 }
@@ -2699,7 +2743,7 @@ namespace OpenSim.Region.Environment.Scenes
2699 { 2743 {
2700 if (ent is SceneObjectGroup) 2744 if (ent is SceneObjectGroup)
2701 { 2745 {
2702 SceneObjectPart part = ((SceneObjectGroup) ent).GetChildPart((ent).UUID); 2746 SceneObjectPart part = ((SceneObjectGroup)ent).GetChildPart(((SceneObjectGroup)ent).UUID);
2703 if (part != null) 2747 if (part != null)
2704 { 2748 {
2705 if (part.Name == cmdparams[0]) 2749 if (part.Name == cmdparams[0])
@@ -2823,8 +2867,8 @@ namespace OpenSim.Region.Environment.Scenes
2823 2867
2824 #region Script Engine 2868 #region Script Engine
2825 2869
2826 private readonly bool m_dumpAssetsToFile; 2870 private List<ScriptEngineInterface> ScriptEngines = new List<ScriptEngineInterface>();
2827 private readonly List<ScriptEngineInterface> ScriptEngines = new List<ScriptEngineInterface>(); 2871 private bool m_dumpAssetsToFile;
2828 2872
2829 /// <summary> 2873 /// <summary>
2830 /// 2874 ///
@@ -2838,11 +2882,13 @@ namespace OpenSim.Region.Environment.Scenes
2838 2882
2839 public void TriggerObjectChanged(uint localID, uint change) 2883 public void TriggerObjectChanged(uint localID, uint change)
2840 { 2884 {
2885
2841 m_eventManager.TriggerOnScriptChangedEvent(localID, change); 2886 m_eventManager.TriggerOnScriptChangedEvent(localID, change);
2842 } 2887 }
2843 2888
2844 public void TriggerAtTargetEvent(uint localID, uint handle, LLVector3 targetpos, LLVector3 currentpos) 2889 public void TriggerAtTargetEvent(uint localID, uint handle, LLVector3 targetpos, LLVector3 currentpos)
2845 { 2890 {
2891
2846 m_eventManager.TriggerAtTargetEvent(localID, handle, targetpos, currentpos); 2892 m_eventManager.TriggerAtTargetEvent(localID, handle, targetpos, currentpos);
2847 } 2893 }
2848 2894
@@ -2851,21 +2897,20 @@ namespace OpenSim.Region.Environment.Scenes
2851 m_eventManager.TriggerNotAtTargetEvent(localID); 2897 m_eventManager.TriggerNotAtTargetEvent(localID);
2852 } 2898 }
2853 2899
2854 private bool scriptDanger(SceneObjectPart part, LLVector3 pos) 2900 private bool scriptDanger(SceneObjectPart part,LLVector3 pos)
2855 { 2901 {
2856 ILandObject parcel = LandChannel.getLandObject(pos.X, pos.Y); 2902 ILandObject parcel = LandChannel.getLandObject(pos.X, pos.Y);
2857 if (part != null) 2903 if (part != null)
2858 { 2904 {
2859 if (parcel != null) 2905 if (parcel != null)
2860 { 2906 {
2861 if ((parcel.landData.landFlags & (uint) Parcel.ParcelFlags.AllowOtherScripts) != 0) 2907 if ((parcel.landData.landFlags & (uint)Parcel.ParcelFlags.AllowOtherScripts) != 0)
2862 { 2908 {
2863 return true; 2909 return true;
2864 } 2910 }
2865 else if ((parcel.landData.landFlags & (uint) Parcel.ParcelFlags.AllowGroupScripts) != 0) 2911 else if ((parcel.landData.landFlags & (uint)Parcel.ParcelFlags.AllowGroupScripts) != 0)
2866 { 2912 {
2867 if (part.OwnerID == parcel.landData.ownerID || (parcel.landData.isGroupOwned && part.GroupID == parcel.landData.groupID) || 2913 if (part.OwnerID == parcel.landData.ownerID || (parcel.landData.isGroupOwned && part.GroupID == parcel.landData.groupID) || PermissionsMngr.GenericEstatePermission(part.OwnerID))
2868 PermissionsMngr.GenericEstatePermission(part.OwnerID))
2869 { 2914 {
2870 return true; 2915 return true;
2871 } 2916 }
@@ -2873,7 +2918,7 @@ namespace OpenSim.Region.Environment.Scenes
2873 { 2918 {
2874 return false; 2919 return false;
2875 } 2920 }
2876 } 2921 }
2877 else 2922 else
2878 { 2923 {
2879 if (part.OwnerID == parcel.landData.ownerID) 2924 if (part.OwnerID == parcel.landData.ownerID)
@@ -2888,6 +2933,7 @@ namespace OpenSim.Region.Environment.Scenes
2888 } 2933 }
2889 else 2934 else
2890 { 2935 {
2936
2891 if (pos.X > 0f && pos.X < Constants.RegionSize && pos.Y > 0f && pos.Y < Constants.RegionSize) 2937 if (pos.X > 0f && pos.X < Constants.RegionSize && pos.Y > 0f && pos.Y < Constants.RegionSize)
2892 { 2938 {
2893 // The only time parcel != null when an object is inside a region is when 2939 // The only time parcel != null when an object is inside a region is when
@@ -2906,7 +2952,6 @@ namespace OpenSim.Region.Environment.Scenes
2906 return false; 2952 return false;
2907 } 2953 }
2908 } 2954 }
2909
2910 public bool scriptDanger(uint localID, LLVector3 pos) 2955 public bool scriptDanger(uint localID, LLVector3 pos)
2911 { 2956 {
2912 SceneObjectPart part = GetSceneObjectPart(localID); 2957 SceneObjectPart part = GetSceneObjectPart(localID);
@@ -2922,11 +2967,13 @@ namespace OpenSim.Region.Environment.Scenes
2922 2967
2923 public bool pipeEventsForScript(uint localID) 2968 public bool pipeEventsForScript(uint localID)
2924 { 2969 {
2970
2925 SceneObjectPart part = GetSceneObjectPart(localID); 2971 SceneObjectPart part = GetSceneObjectPart(localID);
2926 if (part != null) 2972 if (part != null)
2927 { 2973 {
2928 LLVector3 pos = part.GetWorldPosition(); 2974 LLVector3 pos = part.GetWorldPosition();
2929 return scriptDanger(part, pos); 2975 return scriptDanger(part, pos);
2976
2930 } 2977 }
2931 else 2978 else
2932 { 2979 {
@@ -3043,17 +3090,17 @@ namespace OpenSim.Region.Environment.Scenes
3043 } 3090 }
3044 catch (Exception e) 3091 catch (Exception e)
3045 { 3092 {
3046 m_log.Info("[BUG]: " + e); 3093 m_log.Info("[BUG]: " + e.ToString());
3047 } 3094 }
3048 } 3095 }
3049 } 3096 }
3050 3097
3051 /// <summary> 3098 /// <summary>
3052 /// Delete this object from the scene. 3099 /// Delete this object from the scene.
3053 /// </summary> 3100 /// </summary>
3054 /// <param name="group"></param> 3101 /// <param name="group"></param>
3055 public void DeleteSceneObjectGroup(SceneObjectGroup group) 3102 public void DeleteSceneObjectGroup(SceneObjectGroup group)
3056 { 3103 {
3057 SceneObjectPart rootPart = (group).GetChildPart(group.UUID); 3104 SceneObjectPart rootPart = (group).GetChildPart(group.UUID);
3058 if (rootPart.PhysActor != null) 3105 if (rootPart.PhysActor != null)
3059 { 3106 {
@@ -3070,15 +3117,15 @@ namespace OpenSim.Region.Environment.Scenes
3070 m_innerScene.RemoveAPrimCount(); 3117 m_innerScene.RemoveAPrimCount();
3071 } 3118 }
3072 group.DeleteParts(); 3119 group.DeleteParts();
3073 3120
3074 // In case anybody else retains a reference to this group, signal deletion by changing the name 3121 // In case anybody else retains a reference to this group, signal deletion by changing the name
3075 // to null. We can't zero out the UUID because this is taken from the root part, which has already 3122 // to null. We can't zero out the UUID because this is taken from the root part, which has already
3076 // been removed. 3123 // been removed.
3077 // FIXME: This is a really poor temporary solution, since it still leaves plenty of scope for race 3124 // FIXME: This is a really poor temporary solution, since it still leaves plenty of scope for race
3078 // conditions where a user deletes an entity while it is being stored. Really, the update 3125 // conditions where a user deletes an entity while it is being stored. Really, the update
3079 // code needs a redesign. 3126 // code needs a redesign.
3080 group.Name = null; 3127 group.Name = null;
3081 } 3128 }
3082 3129
3083 /// <summary> 3130 /// <summary>
3084 /// 3131 ///
@@ -3098,6 +3145,7 @@ namespace OpenSim.Region.Environment.Scenes
3098 // action(presence); 3145 // action(presence);
3099 // } 3146 // }
3100 // } 3147 // }
3148
3101 /// <summary> 3149 /// <summary>
3102 /// 3150 ///
3103 /// </summary> 3151 /// </summary>
@@ -3187,7 +3235,6 @@ namespace OpenSim.Region.Environment.Scenes
3187 } 3235 }
3188 return visualParams; 3236 return visualParams;
3189 } 3237 }
3190
3191 #endregion 3238 #endregion
3192 } 3239 }
3193} \ No newline at end of file 3240}
diff --git a/OpenSim/Region/Environment/Scenes/SceneBase.cs b/OpenSim/Region/Environment/Scenes/SceneBase.cs
index 435dc8b..d9dc1da 100644
--- a/OpenSim/Region/Environment/Scenes/SceneBase.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneBase.cs
@@ -40,11 +40,6 @@ 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
48 #region Events 43 #region Events
49 44
50 public event restart OnRestart; 45 public event restart OnRestart;
@@ -55,38 +50,41 @@ namespace OpenSim.Region.Environment.Scenes
55 50
56 private readonly ClientManager m_clientManager = new ClientManager(); 51 private readonly ClientManager m_clientManager = new ClientManager();
57 52
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
58 //public TerrainEngine Terrain; 62 //public TerrainEngine Terrain;
59 public ITerrainChannel Heightmap; 63 public ITerrainChannel Heightmap;
60 64
61 public ILandChannel LandChannel; 65 public ILandChannel LandChannel;
62 private AssetCache m_assetCache;
63 66
64
65 protected string m_datastore;
66 protected EventManager m_eventManager; 67 protected EventManager m_eventManager;
67 68
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
75 public EventManager EventManager 69 public EventManager EventManager
76 { 70 {
77 get { return m_eventManager; } 71 get { return m_eventManager; }
78 } 72 }
79 73
74
75 protected string m_datastore;
76
77 private uint m_nextLocalId = 8880000;
78
79 private AssetCache m_assetCache;
80
80 public AssetCache AssetCache 81 public AssetCache AssetCache
81 { 82 {
82 get { return m_assetCache; } 83 get { return m_assetCache; }
83 set { m_assetCache = value; } 84 set { m_assetCache = value; }
84 } 85 }
85 86
86 public ClientManager ClientManager 87 protected RegionStatus m_regStatus;
87 {
88 get { return m_clientManager; }
89 }
90 88
91 public RegionStatus Region_Status 89 public RegionStatus Region_Status
92 { 90 {
@@ -143,8 +141,6 @@ namespace OpenSim.Region.Environment.Scenes
143 141
144 #endregion 142 #endregion
145 143
146 #region IScene Members
147
148 /// <summary> 144 /// <summary>
149 /// 145 ///
150 /// </summary> 146 /// </summary>
@@ -159,18 +155,6 @@ namespace OpenSim.Region.Environment.Scenes
159 get { return m_nextLocalId++; } 155 get { return m_nextLocalId++; }
160 } 156 }
161 157
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
174 #region admin stuff 158 #region admin stuff
175 159
176 /// <summary> 160 /// <summary>
@@ -189,7 +173,6 @@ namespace OpenSim.Region.Environment.Scenes
189 { 173 {
190 return false; 174 return false;
191 } 175 }
192
193 public abstract bool OtherRegionUp(RegionInfo thisRegion); 176 public abstract bool OtherRegionUp(RegionInfo thisRegion);
194 177
195 public virtual string GetSimulatorVersion() 178 public virtual string GetSimulatorVersion()
@@ -212,10 +195,24 @@ namespace OpenSim.Region.Environment.Scenes
212 } 195 }
213 catch (Exception e) 196 catch (Exception e)
214 { 197 {
215 m_log.Error("[SCENE]: SceneBase.cs: Close() - Failed with exception " + e); 198 m_log.Error("[SCENE]: SceneBase.cs: Close() - Failed with exception " + e.ToString());
216 } 199 }
217 } 200 }
218 201
219 #endregion 202 #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 }
220 } 217 }
221} \ No newline at end of file 218}
diff --git a/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs
index b44847b..91bbdb7 100644
--- a/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs
@@ -43,47 +43,13 @@ 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
56 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 46 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;
68 47
69 protected CommunicationsManager m_commsProvider; 48 protected CommunicationsManager m_commsProvider;
70 protected RegionInfo m_regionInfo; 49 protected RegionInfo m_regionInfo;
71 50
72 protected RegionCommsListener regionCommsHost; 51 protected RegionCommsListener regionCommsHost;
73 52
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
87 public event AgentCrossing OnAvatarCrossingIntoRegion; 53 public event AgentCrossing OnAvatarCrossingIntoRegion;
88 public event ExpectUserDelegate OnExpectUser; 54 public event ExpectUserDelegate OnExpectUser;
89 public event ExpectPrimDelegate OnExpectPrim; 55 public event ExpectPrimDelegate OnExpectPrim;
@@ -93,6 +59,31 @@ namespace OpenSim.Region.Environment.Scenes
93 public event ChildAgentUpdate OnChildAgentUpdate; 59 public event ChildAgentUpdate OnChildAgentUpdate;
94 public event RemoveKnownRegionsFromAvatarList OnRemoveKnownRegionFromAvatar; 60 public event RemoveKnownRegionsFromAvatarList OnRemoveKnownRegionFromAvatar;
95 61
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
96 public void RegisterRegion(RegionInfo regionInfos) 87 public void RegisterRegion(RegionInfo regionInfos)
97 { 88 {
98 m_regionInfo = regionInfos; 89 m_regionInfo = regionInfos;
@@ -108,7 +99,7 @@ namespace OpenSim.Region.Environment.Scenes
108 regionCommsHost.OnAvatarCrossingIntoRegion += AgentCrossing; 99 regionCommsHost.OnAvatarCrossingIntoRegion += AgentCrossing;
109 regionCommsHost.OnCloseAgentConnection += CloseConnection; 100 regionCommsHost.OnCloseAgentConnection += CloseConnection;
110 regionCommsHost.OnRegionUp += newRegionUp; 101 regionCommsHost.OnRegionUp += newRegionUp;
111 regionCommsHost.OnChildAgentUpdate += ChildAgentUpdate; 102 regionCommsHost.OnChildAgentUpdate += ChildAgentUpdate;
112 } 103 }
113 else 104 else
114 { 105 {
@@ -131,6 +122,218 @@ namespace OpenSim.Region.Environment.Scenes
131 } 122 }
132 } 123 }
133 124
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
134 private void InformNeighborsThatRegionisUpCompleted(IAsyncResult iar) 337 private void InformNeighborsThatRegionisUpCompleted(IAsyncResult iar)
135 { 338 {
136 InformNeighbourThatRegionUpDelegate icon = (InformNeighbourThatRegionUpDelegate) iar.AsyncState; 339 InformNeighbourThatRegionUpDelegate icon = (InformNeighbourThatRegionUpDelegate) iar.AsyncState;
@@ -187,6 +390,8 @@ namespace OpenSim.Region.Environment.Scenes
187 //bool val = m_commsProvider.InterRegion.RegionUp(new SearializableRegionInfo(region)); 390 //bool val = m_commsProvider.InterRegion.RegionUp(new SearializableRegionInfo(region));
188 } 391 }
189 392
393 public delegate void SendChildAgentDataUpdateDelegate(ChildAgentDataUpdate cAgentData, ScenePresence presence);
394
190 /// <summary> 395 /// <summary>
191 /// This informs all neighboring regions about the settings of it's child agent. 396 /// This informs all neighboring regions about the settings of it's child agent.
192 /// Calls an asynchronous method to do so.. so it doesn't lag the sim. 397 /// Calls an asynchronous method to do so.. so it doesn't lag the sim.
@@ -217,6 +422,7 @@ namespace OpenSim.Region.Environment.Scenes
217 { 422 {
218 // We're ignoring a collection was modified error because this data gets old and outdated fast. 423 // We're ignoring a collection was modified error because this data gets old and outdated fast.
219 } 424 }
425
220 } 426 }
221 427
222 private void SendChildAgentDataUpdateCompleted(IAsyncResult iar) 428 private void SendChildAgentDataUpdateCompleted(IAsyncResult iar)
@@ -229,17 +435,20 @@ namespace OpenSim.Region.Environment.Scenes
229 { 435 {
230 // This assumes that we know what our neighbors are. 436 // This assumes that we know what our neighbors are.
231 SendChildAgentDataUpdateDelegate d = SendChildAgentDataUpdateAsync; 437 SendChildAgentDataUpdateDelegate d = SendChildAgentDataUpdateAsync;
232 d.BeginInvoke(cAgentData, presence, 438 d.BeginInvoke(cAgentData,presence,
233 SendChildAgentDataUpdateCompleted, 439 SendChildAgentDataUpdateCompleted,
234 d); 440 d);
235 } 441 }
236 442
443 public delegate void SendCloseChildAgentDelegate( LLUUID agentID, List<ulong> regionlst);
444
237 /// <summary> 445 /// <summary>
238 /// This Closes child agents on neighboring regions 446 /// This Closes child agents on neighboring regions
239 /// Calls an asynchronous method to do so.. so it doesn't lag the sim. 447 /// Calls an asynchronous method to do so.. so it doesn't lag the sim.
240 /// </summary> 448 /// </summary>
241 private void SendCloseChildAgentAsync(LLUUID agentID, List<ulong> regionlst) 449 private void SendCloseChildAgentAsync(LLUUID agentID, List<ulong> regionlst)
242 { 450 {
451
243 foreach (ulong regionHandle in regionlst) 452 foreach (ulong regionHandle in regionlst)
244 { 453 {
245 bool regionAccepted = m_commsProvider.InterRegion.TellRegionToCloseChildConnection(regionHandle, agentID); 454 bool regionAccepted = m_commsProvider.InterRegion.TellRegionToCloseChildConnection(regionHandle, agentID);
@@ -247,11 +456,14 @@ namespace OpenSim.Region.Environment.Scenes
247 if (regionAccepted) 456 if (regionAccepted)
248 { 457 {
249 m_log.Info("[INTERGRID]: Completed sending agent Close agent Request to neighbor"); 458 m_log.Info("[INTERGRID]: Completed sending agent Close agent Request to neighbor");
459
250 } 460 }
251 else 461 else
252 { 462 {
253 m_log.Info("[INTERGRID]: Failed sending agent Close agent Request to neighbor"); 463 m_log.Info("[INTERGRID]: Failed sending agent Close agent Request to neighbor");
464
254 } 465 }
466
255 } 467 }
256 // We remove the list of known regions from the agent's known region list through an event 468 // We remove the list of known regions from the agent's known region list through an event
257 // to scene, because, if an agent logged of, it's likely that there will be no scene presence 469 // to scene, because, if an agent logged of, it's likely that there will be no scene presence
@@ -265,7 +477,7 @@ namespace OpenSim.Region.Environment.Scenes
265 477
266 private void SendCloseChildAgentCompleted(IAsyncResult iar) 478 private void SendCloseChildAgentCompleted(IAsyncResult iar)
267 { 479 {
268 SendCloseChildAgentDelegate icon = (SendCloseChildAgentDelegate) iar.AsyncState; 480 SendCloseChildAgentDelegate icon = (SendCloseChildAgentDelegate)iar.AsyncState;
269 icon.EndInvoke(iar); 481 icon.EndInvoke(iar);
270 } 482 }
271 483
@@ -344,28 +556,28 @@ namespace OpenSim.Region.Environment.Scenes
344 // assume local regions are always up 556 // assume local regions are always up
345 destRegionUp = true; 557 destRegionUp = true;
346 } 558 }
347 if (destRegionUp) 559 if(destRegionUp)
348 { 560 {
349 avatar.Close(); 561 avatar.Close();
350 562
351 // Compared to ScenePresence.CrossToNewRegion(), there's no obvious code to handle a teleport 563 // Compared to ScenePresence.CrossToNewRegion(), there's no obvious code to handle a teleport
352 // failure at this point (unlike a border crossing failure). So perhaps this can never fail 564 // failure at this point (unlike a border crossing failure). So perhaps this can never fail
353 // once we reach here... 565 // once we reach here...
354 avatar.Scene.RemoveCapsHandler(avatar.UUID); 566 avatar.Scene.RemoveCapsHandler(avatar.UUID);
355 567
356 m_commsProvider.InterRegion.InformRegionOfChildAgent(regionHandle, agent); 568 m_commsProvider.InterRegion.InformRegionOfChildAgent(regionHandle, agent);
357 m_commsProvider.InterRegion.ExpectAvatarCrossing(regionHandle, avatar.ControllingClient.AgentId, 569 m_commsProvider.InterRegion.ExpectAvatarCrossing(regionHandle, avatar.ControllingClient.AgentId,
358 position, false); 570 position, false);
359 AgentCircuitData circuitdata = avatar.ControllingClient.RequestClientInfo(); 571 AgentCircuitData circuitdata = avatar.ControllingClient.RequestClientInfo();
360 572
361 // TODO Should construct this behind a method 573 // TODO Should construct this behind a method
362 string capsPath = 574 string capsPath =
363 "http://" + reg.ExternalHostName + ":" + reg.HttpPort 575 "http://" + reg.ExternalHostName + ":" + reg.HttpPort
364 + "/CAPS/" + circuitdata.CapsPath + "0000/"; 576 + "/CAPS/" + circuitdata.CapsPath + "0000/";
365 577
366 m_log.DebugFormat( 578 m_log.DebugFormat(
367 "[CAPS]: Sending new CAPS seed url {0} to client {1}", capsPath, avatar.UUID); 579 "[CAPS]: Sending new CAPS seed url {0} to client {1}", capsPath, avatar.UUID);
368 580
369 avatar.ControllingClient.SendRegionTeleport(regionHandle, 13, reg.ExternalEndPoint, 4, (1 << 4), 581 avatar.ControllingClient.SendRegionTeleport(regionHandle, 13, reg.ExternalEndPoint, 4, (1 << 4),
370 capsPath); 582 capsPath);
371 avatar.MakeChildAgent(); 583 avatar.MakeChildAgent();
@@ -375,13 +587,13 @@ namespace OpenSim.Region.Environment.Scenes
375 { 587 {
376 KillObject(avatar.LocalId); 588 KillObject(avatar.LocalId);
377 } 589 }
378 uint newRegionX = (uint) (regionHandle >> 40); 590 uint newRegionX = (uint)(regionHandle >> 40);
379 uint newRegionY = (((uint) (regionHandle)) >> 8); 591 uint newRegionY = (((uint)(regionHandle)) >> 8);
380 uint oldRegionX = (uint) (m_regionInfo.RegionHandle >> 40); 592 uint oldRegionX = (uint)(m_regionInfo.RegionHandle >> 40);
381 uint oldRegionY = (((uint) (m_regionInfo.RegionHandle)) >> 8); 593 uint oldRegionY = (((uint)(m_regionInfo.RegionHandle)) >> 8);
382 if (Util.fast_distance2d((int) (newRegionX - oldRegionX), (int) (newRegionY - oldRegionY)) > 3) 594 if (Util.fast_distance2d((int)(newRegionX - oldRegionX), (int)(newRegionY - oldRegionY)) > 3)
383 { 595 {
384 SendCloseChildAgentConnections(avatar.UUID, avatar.GetKnownRegionList()); 596 SendCloseChildAgentConnections(avatar.UUID,avatar.GetKnownRegionList());
385 } 597 }
386 } 598 }
387 else 599 else
@@ -416,7 +628,7 @@ namespace OpenSim.Region.Environment.Scenes
416 628
417 public void LogOffUser(LLUUID userid, LLUUID regionid, ulong regionhandle, float posx, float posy, float posz) 629 public void LogOffUser(LLUUID userid, LLUUID regionid, ulong regionhandle, float posx, float posy, float posz)
418 { 630 {
419 m_commsProvider.LogOffUser(userid, regionid, regionhandle, posx, posy, posz); 631 m_commsProvider.LogOffUser(userid, regionid, regionhandle, posx, posy, posz);
420 } 632 }
421 633
422 public void ClearUserAgent(LLUUID avatarID) 634 public void ClearUserAgent(LLUUID avatarID)
@@ -444,7 +656,7 @@ namespace OpenSim.Region.Environment.Scenes
444 return m_commsProvider.GetUserFriendList(friendlistowner); 656 return m_commsProvider.GetUserFriendList(friendlistowner);
445 } 657 }
446 658
447 public List<MapBlockData> RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY) 659 public List<MapBlockData> RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY)
448 { 660 {
449 return m_commsProvider.GridService.RequestNeighbourMapBlocks(minX, minY, maxX, maxY); 661 return m_commsProvider.GridService.RequestNeighbourMapBlocks(minX, minY, maxX, maxY);
450 } 662 }
@@ -453,213 +665,5 @@ namespace OpenSim.Region.Environment.Scenes
453 { 665 {
454 return m_commsProvider.GenerateAgentPickerRequestResponse(queryID, query); 666 return m_commsProvider.GenerateAgentPickerRequestResponse(queryID, query);
455 } 667 }
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
664 } 668 }
665} \ No newline at end of file 669}
diff --git a/OpenSim/Region/Environment/Scenes/SceneEvents.cs b/OpenSim/Region/Environment/Scenes/SceneEvents.cs
index 297d796..002fc5d 100644
--- a/OpenSim/Region/Environment/Scenes/SceneEvents.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneEvents.cs
@@ -38,186 +38,236 @@ namespace OpenSim.Region.Environment.Scenes
38 /// </summary> 38 /// </summary>
39 public class EventManager 39 public class EventManager
40 { 40 {
41 #region Delegates 41 public delegate void OnFrameDelegate();
42
43 public delegate void AvatarEnteringNewParcel(ScenePresence avatar, int localLandID, LLUUID regionID);
44 42
45 public delegate void ClientClosed(LLUUID clientID); 43 public event OnFrameDelegate OnFrame;
46 44
47 public delegate void ClientMovement(ScenePresence client); 45 public delegate void ClientMovement(ScenePresence client);
48 46
49 /// <summary> 47 public event ClientMovement OnClientMovement;
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);
54
55 public delegate void LandBuy(Object sender, LandBuyArgs e);
56
57 public delegate void LandObjectAdded(ILandObject newParcel);
58
59 public delegate void LandObjectRemoved(LLUUID globalID);
60
61 public delegate void MoneyTransferEvent(Object sender, MoneyTransferArgs e);
62
63 public delegate void NewGridInstantMessage(GridInstantMessage message);
64
65 public delegate void NewInventoryItemUploadComplete(LLUUID avatarID, LLUUID assetID, string name, int userlevel);
66
67 public delegate void NewRezScript(uint localID, LLUUID itemID, string script);
68 48
69 public delegate void ObjectDeGrabDelegate(uint localID, IClientAPI remoteClient); 49 public delegate void OnTerrainTickDelegate();
70 50
71 public delegate void ObjectGrabDelegate(uint localID, LLVector3 offsetPos, IClientAPI remoteClient); 51 public event OnTerrainTickDelegate OnTerrainTick;
72 52
73 public delegate void OnBackupDelegate(IRegionDataStore datastore); 53 public delegate void OnBackupDelegate(IRegionDataStore datastore);
74 54
75 public delegate void OnFrameDelegate(); 55 public event OnBackupDelegate OnBackup;
76 56
77 public delegate void OnNewClientDelegate(IClientAPI client); 57 public delegate void OnNewClientDelegate(IClientAPI client);
78 58
79 public delegate void OnNewPresenceDelegate(ScenePresence presence); 59 public event OnNewClientDelegate OnNewClient;
80
81 public delegate void OnParcelPrimCountAddDelegate(SceneObjectGroup obj);
82
83 public delegate void OnParcelPrimCountUpdateDelegate();
84 60
85 public delegate void OnPermissionErrorDelegate(LLUUID user, string reason); 61 public delegate void OnNewPresenceDelegate(ScenePresence presence);
86 62
87 public delegate void OnPluginConsoleDelegate(string[] args); 63 public event OnNewPresenceDelegate OnNewPresence;
88 64
89 public delegate void OnRemovePresenceDelegate(LLUUID agentId); 65 public delegate void OnRemovePresenceDelegate(LLUUID agentId);
90 66
91 public delegate void OnShutdownDelegate(); 67 public event OnRemovePresenceDelegate OnRemovePresence;
92
93 public delegate void OnTerrainTickDelegate();
94
95 /// <summary>
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);
101
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 68
153 public event ClientMovement OnClientMovement; 69 public delegate void OnParcelPrimCountUpdateDelegate();
154 70
155 public event OnTerrainTickDelegate OnTerrainTick; 71 public event OnParcelPrimCountUpdateDelegate OnParcelPrimCountUpdate;
156 72
157 public event OnBackupDelegate OnBackup; 73 public delegate void OnParcelPrimCountAddDelegate(SceneObjectGroup obj);
158 74
159 public event OnNewClientDelegate OnNewClient; 75 public event OnParcelPrimCountAddDelegate OnParcelPrimCountAdd;
160 76
161 public event OnNewPresenceDelegate OnNewPresence; 77 public delegate void OnPluginConsoleDelegate(string[] args);
162 78
163 public event OnRemovePresenceDelegate OnRemovePresence; 79 public event OnPluginConsoleDelegate OnPluginConsole;
164 80
165 public event OnParcelPrimCountUpdateDelegate OnParcelPrimCountUpdate; 81 public delegate void OnShutdownDelegate();
166 82
167 public event OnParcelPrimCountAddDelegate OnParcelPrimCountAdd; 83 public event OnShutdownDelegate OnShutdown;
168 84
169 public event OnPluginConsoleDelegate OnPluginConsole; 85 public delegate void ObjectGrabDelegate(uint localID, LLVector3 offsetPos, IClientAPI remoteClient);
86 public delegate void ObjectDeGrabDelegate(uint localID, IClientAPI remoteClient);
170 87
171 public event OnShutdownDelegate OnShutdown; 88 public delegate void OnPermissionErrorDelegate(LLUUID user, string reason);
172 89
173 public event ObjectGrabDelegate OnObjectGrab; 90 public event ObjectGrabDelegate OnObjectGrab;
174 public event ObjectDeGrabDelegate OnObjectDeGrab; 91 public event ObjectDeGrabDelegate OnObjectDeGrab;
175 92
176 public event OnPermissionErrorDelegate OnPermissionError; 93 public event OnPermissionErrorDelegate OnPermissionError;
177 94
95 public delegate void NewRezScript(uint localID, LLUUID itemID, string script);
96
178 public event NewRezScript OnRezScript; 97 public event NewRezScript OnRezScript;
179 98
99 public delegate void RemoveScript(uint localID, LLUUID itemID);
100
180 public event RemoveScript OnRemoveScript; 101 public event RemoveScript OnRemoveScript;
181 102
103 public delegate bool SceneGroupMoved(LLUUID groupID, LLVector3 delta);
104
182 public event SceneGroupMoved OnSceneGroupMove; 105 public event SceneGroupMoved OnSceneGroupMove;
183 106
107 public delegate void SceneGroupGrabed(LLUUID groupID, LLVector3 offset, LLUUID userID);
108
184 public event SceneGroupGrabed OnSceneGroupGrab; 109 public event SceneGroupGrabed OnSceneGroupGrab;
185 110
111 public delegate void LandObjectAdded(ILandObject newParcel);
112
186 public event LandObjectAdded OnLandObjectAdded; 113 public event LandObjectAdded OnLandObjectAdded;
187 114
115 public delegate void LandObjectRemoved(LLUUID globalID);
116
188 public event LandObjectRemoved OnLandObjectRemoved; 117 public event LandObjectRemoved OnLandObjectRemoved;
189 118
119 public delegate void AvatarEnteringNewParcel(ScenePresence avatar, int localLandID, LLUUID regionID);
120
190 public event AvatarEnteringNewParcel OnAvatarEnteringNewParcel; 121 public event AvatarEnteringNewParcel OnAvatarEnteringNewParcel;
191 122
192 123
124 public delegate void NewGridInstantMessage(GridInstantMessage message);
125
193 public event NewGridInstantMessage OnGridInstantMessageToIMModule; 126 public event NewGridInstantMessage OnGridInstantMessageToIMModule;
194 127
195 public event NewGridInstantMessage OnGridInstantMessageToFriendsModule; 128 public event NewGridInstantMessage OnGridInstantMessageToFriendsModule;
196 129
197 public event NewGridInstantMessage OnGridInstantMessageToGroupsModule; 130 public event NewGridInstantMessage OnGridInstantMessageToGroupsModule;
198 131
132 public delegate void ClientClosed(LLUUID clientID);
133
199 public event ClientClosed OnClientClosed; 134 public event ClientClosed OnClientClosed;
200 135
136 public delegate void ScriptChangedEvent(uint localID, uint change);
137
201 public event ScriptChangedEvent OnScriptChangedEvent; 138 public event ScriptChangedEvent OnScriptChangedEvent;
202 139
140 public delegate void ScriptAtTargetEvent(uint localID, uint handle, LLVector3 targetpos, LLVector3 atpos);
141
203 public event ScriptAtTargetEvent OnScriptAtTargetEvent; 142 public event ScriptAtTargetEvent OnScriptAtTargetEvent;
204 143
144 public delegate void ScriptNotAtTargetEvent(uint localID);
145
205 public event ScriptNotAtTargetEvent OnScriptNotAtTargetEvent; 146 public event ScriptNotAtTargetEvent OnScriptNotAtTargetEvent;
206 147
207 public event OnNewPresenceDelegate OnMakeChildAgent; 148 public event OnNewPresenceDelegate OnMakeChildAgent;
208 149
150 public delegate void NewInventoryItemUploadComplete(LLUUID avatarID, LLUUID assetID, string name, int userlevel);
151
209 public event NewInventoryItemUploadComplete OnNewInventoryItemUploadComplete; 152 public event NewInventoryItemUploadComplete OnNewInventoryItemUploadComplete;
210 153
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);
211 public event RegisterCapsEvent OnRegisterCaps; 160 public event RegisterCapsEvent OnRegisterCaps;
212 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);
213 public event DeregisterCapsEvent OnDeregisterCaps; 166 public event DeregisterCapsEvent OnDeregisterCaps;
214 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
228 public delegate void LandBuy(Object sender, LandBuyArgs e);
229
215 public event MoneyTransferEvent OnMoneyTransfer; 230 public event MoneyTransferEvent OnMoneyTransfer;
216 public event LandBuy OnLandBuy; 231 public event LandBuy OnLandBuy;
217 public event LandBuy OnValidateLandBuy; 232 public event LandBuy OnValidateLandBuy;
218 233
219 /* Designated Event Deletage Instances */ 234 /* Designated Event Deletage Instances */
220 235
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
221 public void TriggerOnScriptChangedEvent(uint localID, uint change) 271 public void TriggerOnScriptChangedEvent(uint localID, uint change)
222 { 272 {
223 handlerScriptChangedEvent = OnScriptChangedEvent; 273 handlerScriptChangedEvent = OnScriptChangedEvent;
@@ -293,7 +343,7 @@ namespace OpenSim.Region.Environment.Scenes
293 if (handlerParcelPrimCountUpdate != null) 343 if (handlerParcelPrimCountUpdate != null)
294 { 344 {
295 handlerParcelPrimCountUpdate(); 345 handlerParcelPrimCountUpdate();
296 } 346 }
297 } 347 }
298 348
299 public void TriggerMoneyTransfer(Object sender, MoneyTransferArgs e) 349 public void TriggerMoneyTransfer(Object sender, MoneyTransferArgs e)
@@ -442,6 +492,7 @@ namespace OpenSim.Region.Environment.Scenes
442 { 492 {
443 handlerGridInstantMessageToFriends(message); 493 handlerGridInstantMessageToFriends(message);
444 } 494 }
495
445 } 496 }
446 } 497 }
447 498
@@ -463,7 +514,7 @@ namespace OpenSim.Region.Environment.Scenes
463 } 514 }
464 } 515 }
465 516
466 public void TriggerOnRegisterCaps(LLUUID agentID, Caps caps) 517 public void TriggerOnRegisterCaps(LLUUID agentID, Caps caps)
467 { 518 {
468 handlerRegisterCaps = OnRegisterCaps; 519 handlerRegisterCaps = OnRegisterCaps;
469 if (handlerRegisterCaps != null) 520 if (handlerRegisterCaps != null)
@@ -472,7 +523,7 @@ namespace OpenSim.Region.Environment.Scenes
472 } 523 }
473 } 524 }
474 525
475 public void TriggerOnDeregisterCaps(LLUUID agentID, Caps caps) 526 public void TriggerOnDeregisterCaps(LLUUID agentID, Caps caps)
476 { 527 {
477 handlerDeregisterCaps = OnDeregisterCaps; 528 handlerDeregisterCaps = OnDeregisterCaps;
478 if (handlerDeregisterCaps != null) 529 if (handlerDeregisterCaps != null)
@@ -489,8 +540,7 @@ namespace OpenSim.Region.Environment.Scenes
489 handlerNewInventoryItemUpdateComplete(agentID, AssetID, AssetName, userlevel); 540 handlerNewInventoryItemUpdateComplete(agentID, AssetID, AssetName, userlevel);
490 } 541 }
491 } 542 }
492 543 public void TriggerLandBuy (Object sender, LandBuyArgs e)
493 public void TriggerLandBuy(Object sender, LandBuyArgs e)
494 { 544 {
495 handlerLandBuy = OnLandBuy; 545 handlerLandBuy = OnLandBuy;
496 if (handlerLandBuy != null) 546 if (handlerLandBuy != null)
@@ -498,7 +548,6 @@ namespace OpenSim.Region.Environment.Scenes
498 handlerLandBuy(sender, e); 548 handlerLandBuy(sender, e);
499 } 549 }
500 } 550 }
501
502 public void TriggerValidateLandBuy(Object sender, LandBuyArgs e) 551 public void TriggerValidateLandBuy(Object sender, LandBuyArgs e)
503 { 552 {
504 handlerValidateLandBuy = OnValidateLandBuy; 553 handlerValidateLandBuy = OnValidateLandBuy;
@@ -507,7 +556,7 @@ namespace OpenSim.Region.Environment.Scenes
507 handlerValidateLandBuy(sender, e); 556 handlerValidateLandBuy(sender, e);
508 } 557 }
509 } 558 }
510 559
511 public void TriggerAtTargetEvent(uint localID, uint handle, LLVector3 targetpos, LLVector3 currentpos) 560 public void TriggerAtTargetEvent(uint localID, uint handle, LLVector3 targetpos, LLVector3 currentpos)
512 { 561 {
513 handlerScriptAtTargetEvent = OnScriptAtTargetEvent; 562 handlerScriptAtTargetEvent = OnScriptAtTargetEvent;
@@ -525,67 +574,5 @@ namespace OpenSim.Region.Environment.Scenes
525 handlerScriptNotAtTargetEvent(localID); 574 handlerScriptNotAtTargetEvent(localID);
526 } 575 }
527 } 576 }
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
590 } 577 }
591} \ No newline at end of file 578}
diff --git a/OpenSim/Region/Environment/Scenes/SceneManager.cs b/OpenSim/Region/Environment/Scenes/SceneManager.cs
index 2325ed4..2dfea2a 100644
--- a/OpenSim/Region/Environment/Scenes/SceneManager.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneManager.cs
@@ -41,13 +41,10 @@ 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 readonly List<Scene> m_localScenes; 44 public event RestartSim OnRestartSim;
45 private Scene m_currentScene;
46 45
47 public SceneManager() 46 private readonly List<Scene> m_localScenes;
48 { 47 private Scene m_currentScene = null;
49 m_localScenes = new List<Scene>();
50 }
51 48
52 public List<Scene> Scenes 49 public List<Scene> Scenes
53 { 50 {
@@ -74,7 +71,10 @@ namespace OpenSim.Region.Environment.Scenes
74 } 71 }
75 } 72 }
76 73
77 public event RestartSim OnRestartSim; 74 public SceneManager()
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); 255 Console.WriteLine("Searching for Region: '{0}'", regionID.ToString());
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 { 330 {
331 List<ScenePresence> scenePresences = scene.GetScenePresences(); 331 List<ScenePresence> scenePresences = scene.GetScenePresences();
332 332
333 foreach (ScenePresence scenePresence in scenePresences) 333 foreach (ScenePresence scenePresence in scenePresences)
334 {
335 if (!scenePresence.IsChildAgent)
334 { 336 {
335 if (!scenePresence.IsChildAgent) 337 m_log.ErrorFormat("Packet debug for {0} {1} set to {2}",
336 { 338 scenePresence.Firstname,
337 m_log.ErrorFormat("Packet debug for {0} {1} set to {2}", 339 scenePresence.Lastname,
338 scenePresence.Firstname, 340 newDebug);
339 scenePresence.Lastname, 341
340 newDebug); 342 scenePresence.ControllingClient.SetDebug(newDebug);
341
342 scenePresence.ControllingClient.SetDebug(newDebug);
343 }
344 } 343 }
345 }); 344 }
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} \ No newline at end of file 456}
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.Inventory.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.Inventory.cs
index d051ed9..824a536 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.Inventory.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.Inventory.cs
@@ -49,6 +49,7 @@ namespace OpenSim.Region.Environment.Scenes
49 if (part != null) 49 if (part != null)
50 { 50 {
51 part.StartScript(itemID); 51 part.StartScript(itemID);
52
52 } 53 }
53 else 54 else
54 { 55 {
@@ -56,9 +57,9 @@ namespace OpenSim.Region.Environment.Scenes
56 "[PRIMINVENTORY]: " + 57 "[PRIMINVENTORY]: " +
57 "Couldn't find part {0} in object group {1}, {2} to start script with ID {3}", 58 "Couldn't find part {0} in object group {1}, {2} to start script with ID {3}",
58 localID, Name, UUID, itemID); 59 localID, Name, UUID, itemID);
59 } 60 }
60 } 61 }
61 62
62// /// Start a given script. 63// /// Start a given script.
63// /// </summary> 64// /// </summary>
64// /// <param name="localID"> 65// /// <param name="localID">
@@ -79,7 +80,7 @@ namespace OpenSim.Region.Environment.Scenes
79// localID, Name, UUID, itemID); 80// localID, Name, UUID, itemID);
80// } 81// }
81// } 82// }
82 83
83 /// <summary> 84 /// <summary>
84 /// Start the scripts contained in all the prims in this group. 85 /// Start the scripts contained in all the prims in this group.
85 /// </summary> 86 /// </summary>
@@ -105,7 +106,7 @@ namespace OpenSim.Region.Environment.Scenes
105 } 106 }
106 } 107 }
107 } 108 }
108 109
109 /// Start a given script. 110 /// Start a given script.
110 /// </summary> 111 /// </summary>
111 /// <param name="localID"> 112 /// <param name="localID">
@@ -125,9 +126,9 @@ namespace OpenSim.Region.Environment.Scenes
125 "[PRIMINVENTORY]: " + 126 "[PRIMINVENTORY]: " +
126 "Couldn't find part {0} in object group {1}, {2} to stop script with ID {3}", 127 "Couldn't find part {0} in object group {1}, {2} to stop script with ID {3}",
127 partID, Name, UUID, itemID); 128 partID, Name, UUID, itemID);
128 } 129 }
129 } 130 }
130 131
131 /// <summary> 132 /// <summary>
132 /// 133 ///
133 /// </summary> 134 /// </summary>
@@ -170,7 +171,7 @@ namespace OpenSim.Region.Environment.Scenes
170 localID, Name, UUID); 171 localID, Name, UUID);
171 } 172 }
172 } 173 }
173 174
174 /// <summary> 175 /// <summary>
175 /// Add an inventory item to a prim in this group. 176 /// Add an inventory item to a prim in this group.
176 /// </summary> 177 /// </summary>
@@ -179,7 +180,7 @@ namespace OpenSim.Region.Environment.Scenes
179 /// <param name="item"></param> 180 /// <param name="item"></param>
180 /// <param name="copyItemID">The item UUID that should be used by the new item.</param> 181 /// <param name="copyItemID">The item UUID that should be used by the new item.</param>
181 /// <returns></returns> 182 /// <returns></returns>
182 public bool AddInventoryItem(IClientAPI remoteClient, uint localID, 183 public bool AddInventoryItem(IClientAPI remoteClient, uint localID,
183 InventoryItemBase item, LLUUID copyItemID) 184 InventoryItemBase item, LLUUID copyItemID)
184 { 185 {
185 LLUUID newItemId = (copyItemID != LLUUID.Zero) ? copyItemID : item.ID; 186 LLUUID newItemId = (copyItemID != LLUUID.Zero) ? copyItemID : item.ID;
@@ -188,8 +189,8 @@ namespace OpenSim.Region.Environment.Scenes
188 if (part != null) 189 if (part != null)
189 { 190 {
190 TaskInventoryItem taskItem = new TaskInventoryItem(); 191 TaskInventoryItem taskItem = new TaskInventoryItem();
191 192
192 taskItem.ItemID = newItemId; 193 taskItem.ItemID = newItemId;
193 taskItem.AssetID = item.AssetID; 194 taskItem.AssetID = item.AssetID;
194 taskItem.Name = item.Name; 195 taskItem.Name = item.Name;
195 taskItem.Description = item.Description; 196 taskItem.Description = item.Description;
@@ -197,15 +198,15 @@ namespace OpenSim.Region.Environment.Scenes
197 taskItem.CreatorID = item.Creator; 198 taskItem.CreatorID = item.Creator;
198 taskItem.Type = item.AssetType; 199 taskItem.Type = item.AssetType;
199 taskItem.InvType = item.InvType; 200 taskItem.InvType = item.InvType;
200 201
201 taskItem.BaseMask = item.BasePermissions; 202 taskItem.BaseMask = item.BasePermissions;
202 taskItem.OwnerMask = item.CurrentPermissions; 203 taskItem.OwnerMask = item.CurrentPermissions;
203 // FIXME: ignoring group permissions for now as they aren't stored in item 204 // FIXME: ignoring group permissions for now as they aren't stored in item
204 taskItem.EveryoneMask = item.EveryOnePermissions; 205 taskItem.EveryoneMask = item.EveryOnePermissions;
205 taskItem.NextOwnerMask = item.NextPermissions; 206 taskItem.NextOwnerMask = item.NextPermissions;
206 207
207 part.AddInventoryItem(taskItem); 208 part.AddInventoryItem(taskItem);
208 209
209 return true; 210 return true;
210 } 211 }
211 else 212 else
@@ -218,7 +219,7 @@ namespace OpenSim.Region.Environment.Scenes
218 219
219 return false; 220 return false;
220 } 221 }
221 222
222 /// <summary> 223 /// <summary>
223 /// Returns an existing inventory item. Returns the original, so any changes will be live. 224 /// Returns an existing inventory item. Returns the original, so any changes will be live.
224 /// </summary> 225 /// </summary>
@@ -238,11 +239,11 @@ namespace OpenSim.Region.Environment.Scenes
238 "[PRIMINVENTORY]: " + 239 "[PRIMINVENTORY]: " +
239 "Couldn't find prim local ID {0} in prim {1}, {2} to get inventory item ID {3}", 240 "Couldn't find prim local ID {0} in prim {1}, {2} to get inventory item ID {3}",
240 primID, part.Name, part.UUID, itemID); 241 primID, part.Name, part.UUID, itemID);
241 } 242 }
242 243
243 return null; 244 return null;
244 } 245 }
245 246
246 /// <summary> 247 /// <summary>
247 /// Update an existing inventory item. 248 /// Update an existing inventory item.
248 /// </summary> 249 /// </summary>
@@ -254,8 +255,8 @@ namespace OpenSim.Region.Environment.Scenes
254 SceneObjectPart part = GetChildPart(item.ParentPartID); 255 SceneObjectPart part = GetChildPart(item.ParentPartID);
255 if (part != null) 256 if (part != null)
256 { 257 {
257 part.UpdateInventoryItem(item); 258 part.UpdateInventoryItem(item);
258 259
259 return true; 260 return true;
260 } 261 }
261 else 262 else
@@ -264,22 +265,22 @@ namespace OpenSim.Region.Environment.Scenes
264 "[PRIMINVENTORY]: " + 265 "[PRIMINVENTORY]: " +
265 "Couldn't find prim ID {0} to update item {1}, {2}", 266 "Couldn't find prim ID {0} to update item {1}, {2}",
266 item.ParentPartID, item.Name, item.ItemID); 267 item.ParentPartID, item.Name, item.ItemID);
267 } 268 }
268 269
269 return false; 270 return false;
270 } 271 }
271 272
272 public int RemoveInventoryItem(uint localID, LLUUID itemID) 273 public int RemoveInventoryItem(uint localID, LLUUID itemID)
273 { 274 {
274 SceneObjectPart part = GetChildPart(localID); 275 SceneObjectPart part = GetChildPart(localID);
275 if (part != null) 276 if (part != null)
276 { 277 {
277 int type = part.RemoveInventoryItem(itemID); 278 int type = part.RemoveInventoryItem(itemID);
278 279
279 return type; 280 return type;
280 } 281 }
281 282
282 return -1; 283 return -1;
283 } 284 }
284 } 285 }
285} \ No newline at end of file 286}
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
index 1ea2f24..5d39790 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 internal struct scriptPosTarget 75 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 readonly Dictionary<uint, scriptPosTarget> m_targets = new Dictionary<uint, scriptPosTarget>(); 85 private PrimCountTaintedDelegate handlerPrimCountTainted = null;
86 private PrimCountTaintedDelegate handlerPrimCountTainted;
87 86
88 /// <summary> 87 /// <summary>
89 /// Signal whether the non-inventory attributes of any prims in the group have changed 88 /// Signal whether the non-inventory attributes of any prims in the group have changed
90 /// since the group's last persistent backup 89 /// since the group's last persistent backup
91 /// </summary> 90 /// </summary>
92 public bool HasGroupChanged; 91 public bool HasGroupChanged = false;
92
93 93
94 94
95 private LLVector3 lastPhysGroupPos; 95 private LLVector3 lastPhysGroupPos;
@@ -104,8 +104,11 @@ 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 bool m_scriptListens_atTarget; 107 private Dictionary<uint, scriptPosTarget> m_targets = new Dictionary<uint, scriptPosTarget>();
108 private bool m_scriptListens_notAtTarget; 108
109 private bool m_scriptListens_atTarget = false;
110 private bool m_scriptListens_notAtTarget = false;
111
109 112
110 #region Properties 113 #region Properties
111 114
@@ -116,7 +119,7 @@ namespace OpenSim.Region.Environment.Scenes
116 /// think really there should be a list (or whatever) in each scenepresence 119 /// think really there should be a list (or whatever) in each scenepresence
117 /// saying what prim(s) that user has selected. 120 /// saying what prim(s) that user has selected.
118 /// </summary> 121 /// </summary>
119 protected bool m_isSelected; 122 protected bool m_isSelected = false;
120 123
121 /// <summary> 124 /// <summary>
122 /// 125 ///
@@ -183,6 +186,7 @@ namespace OpenSim.Region.Environment.Scenes
183 string.Format("[SCENE OBJECT GROUP]: Object {0} has no root part.", m_uuid)); 186 string.Format("[SCENE OBJECT GROUP]: Object {0} has no root part.", m_uuid));
184 } 187 }
185 188
189
186 190
187 return m_rootPart.GroupPosition; 191 return m_rootPart.GroupPosition;
188 } 192 }
@@ -202,7 +206,7 @@ namespace OpenSim.Region.Environment.Scenes
202 part.GroupPosition = val; 206 part.GroupPosition = val;
203 } 207 }
204 } 208 }
205 209
206 //if (m_rootPart.PhysActor != null) 210 //if (m_rootPart.PhysActor != null)
207 //{ 211 //{
208 //m_rootPart.PhysActor.Position = 212 //m_rootPart.PhysActor.Position =
@@ -212,7 +216,7 @@ namespace OpenSim.Region.Environment.Scenes
212 //} 216 //}
213 } 217 }
214 } 218 }
215 219
216 public override uint LocalId 220 public override uint LocalId
217 { 221 {
218 get 222 get
@@ -511,11 +515,10 @@ namespace OpenSim.Region.Environment.Scenes
511 m_scene.EventManager.OnBackup += ProcessBackup; 515 m_scene.EventManager.OnBackup += ProcessBackup;
512 } 516 }
513 } 517 }
514
515 public LLVector3 GroupScale() 518 public LLVector3 GroupScale()
516 { 519 {
517 LLVector3 minScale = new LLVector3(Constants.RegionSize, Constants.RegionSize, Constants.RegionSize); 520 LLVector3 minScale = new LLVector3(Constants.RegionSize,Constants.RegionSize,Constants.RegionSize);
518 LLVector3 maxScale = new LLVector3(0f, 0f, 0f); 521 LLVector3 maxScale = new LLVector3(0f,0f,0f);
519 LLVector3 finalScale = new LLVector3(0.5f, 0.5f, 0.5f); 522 LLVector3 finalScale = new LLVector3(0.5f, 0.5f, 0.5f);
520 523
521 lock (m_parts) 524 lock (m_parts)
@@ -538,8 +541,8 @@ namespace OpenSim.Region.Environment.Scenes
538 finalScale.Y = (minScale.Y > maxScale.Y) ? minScale.Y : maxScale.Y; 541 finalScale.Y = (minScale.Y > maxScale.Y) ? minScale.Y : maxScale.Y;
539 finalScale.Z = (minScale.Z > maxScale.Z) ? minScale.Z : maxScale.Z; 542 finalScale.Z = (minScale.Z > maxScale.Z) ? minScale.Z : maxScale.Z;
540 return finalScale; 543 return finalScale;
541 }
542 544
545 }
543 public EntityIntersection TestIntersection(Ray hRay, bool frontFacesOnly, bool faceCenters) 546 public EntityIntersection TestIntersection(Ray hRay, bool frontFacesOnly, bool faceCenters)
544 { 547 {
545 // We got a request from the inner_scene to raytrace along the Ray hRay 548 // We got a request from the inner_scene to raytrace along the Ray hRay
@@ -562,7 +565,7 @@ namespace OpenSim.Region.Environment.Scenes
562 // Telling the prim to raytrace. 565 // Telling the prim to raytrace.
563 //EntityIntersection inter = part.TestIntersection(hRay, parentrotation); 566 //EntityIntersection inter = part.TestIntersection(hRay, parentrotation);
564 567
565 EntityIntersection inter = part.TestIntersectionOBB(hRay, parentrotation, frontFacesOnly, faceCenters); 568 EntityIntersection inter = part.TestIntersectionOBB(hRay, parentrotation,frontFacesOnly, faceCenters);
566 569
567 // This may need to be updated to the maximum draw distance possible.. 570 // This may need to be updated to the maximum draw distance possible..
568 // We might (and probably will) be checking for prim creation from other sims 571 // We might (and probably will) be checking for prim creation from other sims
@@ -681,11 +684,12 @@ namespace OpenSim.Region.Environment.Scenes
681 DetachFromBackup(this); 684 DetachFromBackup(this);
682 m_rootPart.m_attachedAvatar = agentID; 685 m_rootPart.m_attachedAvatar = agentID;
683 686
684 687
685 if (m_rootPart.PhysActor != null) 688 if (m_rootPart.PhysActor != null)
686 { 689 {
687 m_scene.PhysicsScene.RemovePrim(m_rootPart.PhysActor); 690 m_scene.PhysicsScene.RemovePrim(m_rootPart.PhysActor);
688 m_rootPart.PhysActor = null; 691 m_rootPart.PhysActor = null;
692
689 } 693 }
690 694
691 AbsolutePosition = AttachOffset; 695 AbsolutePosition = AttachOffset;
@@ -705,28 +709,27 @@ namespace OpenSim.Region.Environment.Scenes
705 m_rootPart.ScheduleFullUpdate(); 709 m_rootPart.ScheduleFullUpdate();
706 } 710 }
707 } 711 }
708
709 public byte GetAttachmentPoint() 712 public byte GetAttachmentPoint()
710 { 713 {
711 if (m_rootPart != null) 714 if (m_rootPart != null)
712 { 715 {
713 return m_rootPart.Shape.State; 716 return m_rootPart.Shape.State;
714 } 717 }
715 return 0; 718 return (byte)0;
716 } 719 }
717 720
718 public void ClearPartAttachmentData() 721 public void ClearPartAttachmentData()
719 { 722 {
720 foreach (SceneObjectPart part in m_parts.Values) 723 foreach (SceneObjectPart part in m_parts.Values)
721 { 724 {
722 part.SetAttachmentPoint(0); 725 part.SetAttachmentPoint((Byte)0);
723 } 726 }
724 } 727 }
725 728
726 public void DetachToGround() 729 public void DetachToGround()
727 { 730 {
728 ScenePresence avatar = m_scene.GetScenePresence(m_rootPart.m_attachedAvatar); 731 ScenePresence avatar = m_scene.GetScenePresence(m_rootPart.m_attachedAvatar);
729 LLVector3 detachedpos = new LLVector3(127f, 127f, 127f); 732 LLVector3 detachedpos = new LLVector3(127f,127f,127f);
730 if (avatar != null) 733 if (avatar != null)
731 { 734 {
732 detachedpos = avatar.AbsolutePosition; 735 detachedpos = avatar.AbsolutePosition;
@@ -735,14 +738,14 @@ namespace OpenSim.Region.Environment.Scenes
735 AbsolutePosition = detachedpos; 738 AbsolutePosition = detachedpos;
736 m_rootPart.m_attachedAvatar = LLUUID.Zero; 739 m_rootPart.m_attachedAvatar = LLUUID.Zero;
737 m_rootPart.SetParentLocalId(0); 740 m_rootPart.SetParentLocalId(0);
738 m_rootPart.SetAttachmentPoint(0); 741 m_rootPart.SetAttachmentPoint((byte)0);
739 m_rootPart.m_IsAttachment = false; 742 m_rootPart.m_IsAttachment = false;
740 m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_scene.m_physicalPrim); 743 m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_scene.m_physicalPrim);
741 AttachToBackup(); 744 AttachToBackup();
742 m_rootPart.ScheduleFullUpdate(); 745 m_rootPart.ScheduleFullUpdate();
743 m_rootPart.ClearUndoState(); 746 m_rootPart.ClearUndoState();
747
744 } 748 }
745
746 public void DetachToInventoryPrep() 749 public void DetachToInventoryPrep()
747 { 750 {
748 ScenePresence avatar = m_scene.GetScenePresence(m_rootPart.m_attachedAvatar); 751 ScenePresence avatar = m_scene.GetScenePresence(m_rootPart.m_attachedAvatar);
@@ -752,7 +755,7 @@ namespace OpenSim.Region.Environment.Scenes
752 //detachedpos = avatar.AbsolutePosition; 755 //detachedpos = avatar.AbsolutePosition;
753 avatar.RemoveAttachment(this); 756 avatar.RemoveAttachment(this);
754 } 757 }
755 758
756 m_rootPart.m_attachedAvatar = LLUUID.Zero; 759 m_rootPart.m_attachedAvatar = LLUUID.Zero;
757 m_rootPart.SetParentLocalId(0); 760 m_rootPart.SetParentLocalId(0);
758 //m_rootPart.SetAttachmentPoint((byte)0); 761 //m_rootPart.SetAttachmentPoint((byte)0);
@@ -761,8 +764,8 @@ namespace OpenSim.Region.Environment.Scenes
761 //m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_scene.m_physicalPrim); 764 //m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_scene.m_physicalPrim);
762 //AttachToBackup(); 765 //AttachToBackup();
763 //m_rootPart.ScheduleFullUpdate(); 766 //m_rootPart.ScheduleFullUpdate();
767
764 } 768 }
765
766 /// <summary> 769 /// <summary>
767 /// 770 ///
768 /// </summary> 771 /// </summary>
@@ -823,6 +826,7 @@ namespace OpenSim.Region.Environment.Scenes
823 try 826 try
824 { 827 {
825 m_parts.Add(part.UUID, part); 828 m_parts.Add(part.UUID, part);
829
826 } 830 }
827 catch (Exception e) 831 catch (Exception e)
828 { 832 {
@@ -843,6 +847,7 @@ namespace OpenSim.Region.Environment.Scenes
843 if (part.UUID != m_rootPart.UUID) 847 if (part.UUID != m_rootPart.UUID)
844 { 848 {
845 part.ParentID = m_rootPart.LocalId; 849 part.ParentID = m_rootPart.LocalId;
850
846 } 851 }
847 } 852 }
848 } 853 }
@@ -855,10 +860,10 @@ namespace OpenSim.Region.Environment.Scenes
855 foreach (SceneObjectPart part in m_parts.Values) 860 foreach (SceneObjectPart part in m_parts.Values)
856 { 861 {
857 part.UUID = LLUUID.Random(); 862 part.UUID = LLUUID.Random();
863
858 } 864 }
859 } 865 }
860 } 866 }
861
862 // helper provided for parts. 867 // helper provided for parts.
863 public int GetSceneMaxUndo() 868 public int GetSceneMaxUndo()
864 { 869 {
@@ -866,7 +871,6 @@ namespace OpenSim.Region.Environment.Scenes
866 return m_scene.MaxUndoCount; 871 return m_scene.MaxUndoCount;
867 return 5; 872 return 5;
868 } 873 }
869
870 public void ResetChildPrimPhysicsPositions() 874 public void ResetChildPrimPhysicsPositions()
871 { 875 {
872 AbsolutePosition = AbsolutePosition; 876 AbsolutePosition = AbsolutePosition;
@@ -893,6 +897,7 @@ namespace OpenSim.Region.Environment.Scenes
893 { 897 {
894 SceneObjectPart part = GetChildPart(localId); 898 SceneObjectPart part = GetChildPart(localId);
895 OnGrabPart(part, offsetPos, remoteClient); 899 OnGrabPart(part, offsetPos, remoteClient);
900
896 } 901 }
897 } 902 }
898 903
@@ -900,6 +905,7 @@ namespace OpenSim.Region.Environment.Scenes
900 { 905 {
901 part.StoreUndoState(); 906 part.StoreUndoState();
902 part.OnGrab(offsetPos, remoteClient); 907 part.OnGrab(offsetPos, remoteClient);
908
903 } 909 }
904 910
905 public virtual void OnGrabGroup(LLVector3 offsetPos, IClientAPI remoteClient) 911 public virtual void OnGrabGroup(LLVector3 offsetPos, IClientAPI remoteClient)
@@ -963,19 +969,19 @@ namespace OpenSim.Region.Environment.Scenes
963 969
964 public void aggregateScriptEvents() 970 public void aggregateScriptEvents()
965 { 971 {
966 uint objectflagupdate = RootPart.GetEffectiveObjectFlags(); 972 uint objectflagupdate=(uint)RootPart.GetEffectiveObjectFlags();
967 973
968 scriptEvents aggregateScriptEvents = 0; 974 scriptEvents aggregateScriptEvents=0;
969 975
970 lock (m_parts) 976 lock (m_parts)
971 { 977 {
972 foreach (SceneObjectPart part in m_parts.Values) 978 foreach (SceneObjectPart part in m_parts.Values)
973 { 979 {
974 if (part == null) 980 if(part == null)
975 continue; 981 continue;
976 if (part != RootPart) 982 if(part != RootPart)
977 part.ObjectFlags = objectflagupdate; 983 part.ObjectFlags = objectflagupdate;
978 aggregateScriptEvents |= part.m_aggregateScriptEvents; 984 aggregateScriptEvents |= part.m_aggregateScriptEvents;
979 } 985 }
980 } 986 }
981 987
@@ -1059,139 +1065,6 @@ namespace OpenSim.Region.Environment.Scenes
1059 } 1065 }
1060 } 1066 }
1061 1067
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
1195 #region Events 1068 #region Events
1196 1069
1197 /// <summary> 1070 /// <summary>
@@ -1489,8 +1362,9 @@ namespace OpenSim.Region.Environment.Scenes
1489 { 1362 {
1490 m_parts.Add(newPart.UUID, newPart); 1363 m_parts.Add(newPart.UUID, newPart);
1491 } 1364 }
1492 1365
1493 SetPartAsNonRoot(newPart); 1366 SetPartAsNonRoot(newPart);
1367
1494 } 1368 }
1495 1369
1496 /// <summary> 1370 /// <summary>
@@ -1560,30 +1434,32 @@ namespace OpenSim.Region.Environment.Scenes
1560 /// </summary> 1434 /// </summary>
1561 public override void Update() 1435 public override void Update()
1562 { 1436 {
1437
1563 lock (m_parts) 1438 lock (m_parts)
1564 { 1439 {
1565 //if (m_rootPart.m_IsAttachment) 1440 //if (m_rootPart.m_IsAttachment)
1566 //{ 1441 //{
1567 //foreach (SceneObjectPart part in m_parts.Values) 1442 //foreach (SceneObjectPart part in m_parts.Values)
1568 //{ 1443 //{
1569 //part.SendScheduledUpdates(); 1444 //part.SendScheduledUpdates();
1445 //}
1446 //return;
1570 //} 1447 //}
1571 //return; 1448
1572 //}
1573
1574 if (Util.GetDistanceTo(lastPhysGroupPos, AbsolutePosition) > 0.02) 1449 if (Util.GetDistanceTo(lastPhysGroupPos, AbsolutePosition) > 0.02)
1575 { 1450 {
1576 m_rootPart.UpdateFlag = 1; 1451 m_rootPart.UpdateFlag = 1;
1577 lastPhysGroupPos = AbsolutePosition; 1452 lastPhysGroupPos = AbsolutePosition;
1578 } 1453 }
1579 //foreach (SceneObjectPart part in m_parts.Values) 1454 //foreach (SceneObjectPart part in m_parts.Values)
1580 //{ 1455 //{
1581 //if (part.UpdateFlag == 0) part.UpdateFlag = 1; 1456 //if (part.UpdateFlag == 0) part.UpdateFlag = 1;
1582 //} 1457 //}
1583
1584
1585 checkAtTargets();
1586 1458
1459
1460
1461 checkAtTargets();
1462
1587 1463
1588 if ((Math.Abs(lastPhysGroupRot.W - GroupRotation.W) > 0.1) 1464 if ((Math.Abs(lastPhysGroupRot.W - GroupRotation.W) > 0.1)
1589 || (Math.Abs(lastPhysGroupRot.X - GroupRotation.X) > 0.1) 1465 || (Math.Abs(lastPhysGroupRot.X - GroupRotation.X) > 0.1)
@@ -1887,7 +1763,7 @@ namespace OpenSim.Region.Environment.Scenes
1887 public void DelinkFromGroup(uint partID) 1763 public void DelinkFromGroup(uint partID)
1888 { 1764 {
1889 SceneObjectPart linkPart = GetChildPart(partID); 1765 SceneObjectPart linkPart = GetChildPart(partID);
1890 1766
1891 if (null != linkPart) 1767 if (null != linkPart)
1892 { 1768 {
1893 linkPart.ClearUndoState(); 1769 linkPart.ClearUndoState();
@@ -2072,10 +1948,10 @@ namespace OpenSim.Region.Environment.Scenes
2072 proper.ObjectData[0].FromTaskID = LLUUID.Zero; 1948 proper.ObjectData[0].FromTaskID = LLUUID.Zero;
2073 proper.ObjectData[0].GroupID = LLUUID.Zero; 1949 proper.ObjectData[0].GroupID = LLUUID.Zero;
2074 proper.ObjectData[0].InventorySerial = (short) m_rootPart.InventorySerial; 1950 proper.ObjectData[0].InventorySerial = (short) m_rootPart.InventorySerial;
2075 1951
2076 proper.ObjectData[0].LastOwnerID = m_rootPart.LastOwnerID; 1952 proper.ObjectData[0].LastOwnerID = m_rootPart.LastOwnerID;
2077// proper.ObjectData[0].LastOwnerID = LLUUID.Zero; 1953// proper.ObjectData[0].LastOwnerID = LLUUID.Zero;
2078 1954
2079 proper.ObjectData[0].ObjectID = UUID; 1955 proper.ObjectData[0].ObjectID = UUID;
2080 proper.ObjectData[0].OwnerID = m_rootPart.OwnerID; 1956 proper.ObjectData[0].OwnerID = m_rootPart.OwnerID;
2081 proper.ObjectData[0].TouchName = Helpers.StringToField(m_rootPart.TouchName); 1957 proper.ObjectData[0].TouchName = Helpers.StringToField(m_rootPart.TouchName);
@@ -2515,5 +2391,140 @@ namespace OpenSim.Region.Environment.Scenes
2515 } 2391 }
2516 2392
2517 #endregion 2393 #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 }
2518 } 2529 }
2519} \ No newline at end of file 2530}
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs
index c8a8f95..0215cec 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs
@@ -41,12 +41,7 @@ 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 readonly string m_inventoryFileName = String.Empty; 44 private 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;
50 45
51 /// <summary> 46 /// <summary>
52 /// The inventory folder for this prim 47 /// The inventory folder for this prim
@@ -54,17 +49,6 @@ namespace OpenSim.Region.Environment.Scenes
54 private LLUUID m_folderID = LLUUID.Zero; 49 private LLUUID m_folderID = LLUUID.Zero;
55 50
56 /// <summary> 51 /// <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>
68 /// Exposing this is not particularly good, but it's one of the least evils at the moment to see 52 /// Exposing this is not particularly good, but it's one of the least evils at the moment to see
69 /// folder id from prim inventory item data, since it's not (yet) actually stored with the prim. 53 /// folder id from prim inventory item data, since it's not (yet) actually stored with the prim.
70 /// </summary> 54 /// </summary>
@@ -74,12 +58,23 @@ namespace OpenSim.Region.Environment.Scenes
74 set { m_folderID = value; } 58 set { m_folderID = value; }
75 } 59 }
76 60
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
77 public uint InventorySerial 67 public uint InventorySerial
78 { 68 {
79 get { return m_inventorySerial; } 69 get { return m_inventorySerial; }
80 set { m_inventorySerial = value; } 70 set { m_inventorySerial = value; }
81 } 71 }
82 72
73 /// <summary>
74 /// Holds in memory prim inventory
75 /// </summary>
76 protected TaskInventoryDictionary m_taskInventory = new TaskInventoryDictionary();
77
83 public TaskInventoryDictionary TaskInventory 78 public TaskInventoryDictionary TaskInventory
84 { 79 {
85 get { return m_taskInventory; } 80 get { return m_taskInventory; }
@@ -87,6 +82,11 @@ namespace OpenSim.Region.Environment.Scenes
87 } 82 }
88 83
89 /// <summary> 84 /// <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,6 +226,7 @@ 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
229 } 230 }
230 else 231 else
231 { 232 {
@@ -262,7 +263,7 @@ namespace OpenSim.Region.Environment.Scenes
262 { 263 {
263 foreach (TaskInventoryItem item in m_taskInventory.Values) 264 foreach (TaskInventoryItem item in m_taskInventory.Values)
264 { 265 {
265 if (item.Name == name) 266 if(item.Name == name)
266 return true; 267 return true;
267 } 268 }
268 return false; 269 return false;
@@ -270,14 +271,14 @@ namespace OpenSim.Region.Environment.Scenes
270 271
271 private string FindAvailableInventoryName(string name) 272 private string FindAvailableInventoryName(string name)
272 { 273 {
273 if (!InventoryContainsName(name)) 274 if(!InventoryContainsName(name))
274 return name; 275 return name;
275 276
276 int suffix = 1; 277 int suffix=1;
277 while (suffix < 256) 278 while(suffix < 256)
278 { 279 {
279 string tryName = String.Format("{0} {1}", name, suffix); 280 string tryName=String.Format("{0} {1}", name, suffix);
280 if (!InventoryContainsName(tryName)) 281 if(!InventoryContainsName(tryName))
281 return tryName; 282 return tryName;
282 suffix++; 283 suffix++;
283 } 284 }
@@ -294,11 +295,11 @@ namespace OpenSim.Region.Environment.Scenes
294 item.CreationDate = 1000; 295 item.CreationDate = 1000;
295 item.ParentPartID = UUID; 296 item.ParentPartID = UUID;
296 297
297 string name = FindAvailableInventoryName(item.Name); 298 string name=FindAvailableInventoryName(item.Name);
298 if (name == String.Empty) 299 if(name == String.Empty)
299 return; 300 return;
300 301
301 item.Name = name; 302 item.Name=name;
302 303
303 lock (m_taskInventory) 304 lock (m_taskInventory)
304 { 305 {
@@ -346,7 +347,7 @@ namespace OpenSim.Region.Environment.Scenes
346// m_log.DebugFormat( 347// m_log.DebugFormat(
347// "[PRIM INVENTORY]: Retrieved task inventory item {0}, {1} from prim {2}, {3}", 348// "[PRIM INVENTORY]: Retrieved task inventory item {0}, {1} from prim {2}, {3}",
348// m_taskInventory[itemID].Name, itemID, Name, UUID); 349// m_taskInventory[itemID].Name, itemID, Name, UUID);
349 350
350 return m_taskInventory[itemID]; 351 return m_taskInventory[itemID];
351 } 352 }
352 else 353 else
@@ -427,6 +428,7 @@ namespace OpenSim.Region.Environment.Scenes
427 scriptcount++; 428 scriptcount++;
428 } 429 }
429 } 430 }
431
430 } 432 }
431 if (scriptcount <= 0) 433 if (scriptcount <= 0)
432 { 434 {
@@ -455,14 +457,14 @@ namespace OpenSim.Region.Environment.Scenes
455 /// <param name="client"></param> 457 /// <param name="client"></param>
456 /// <param name="localID"></param> 458 /// <param name="localID"></param>
457 public bool GetInventoryFileName(IClientAPI client, uint localID) 459 public bool GetInventoryFileName(IClientAPI client, uint localID)
458 { 460 {
459// m_log.DebugFormat( 461// m_log.DebugFormat(
460// "[PRIM INVENTORY]: Received request from client {0} for inventory file name of {1}, {2}", 462// "[PRIM INVENTORY]: Received request from client {0} for inventory file name of {1}, {2}",
461// client.AgentId, Name, UUID); 463// client.AgentId, Name, UUID);
462 464
463 if (m_inventorySerial > 0) 465 if (m_inventorySerial > 0)
464 { 466 {
465 client.SendTaskInventory(m_uuid, (short) m_inventorySerial, 467 client.SendTaskInventory(m_uuid, (short)m_inventorySerial,
466 Helpers.StringToField(m_inventoryFileName)); 468 Helpers.StringToField(m_inventoryFileName));
467 return true; 469 return true;
468 } 470 }
@@ -478,9 +480,9 @@ namespace OpenSim.Region.Environment.Scenes
478 /// </summary> 480 /// </summary>
479 /// <param name="xferManager"></param> 481 /// <param name="xferManager"></param>
480 public void RequestInventoryFile(IXfer xferManager) 482 public void RequestInventoryFile(IXfer xferManager)
481 { 483 {
482 byte[] fileData = new byte[0]; 484 byte[] fileData = new byte[0];
483 485
484 // Confusingly, the folder item has to be the object id, while the 'parent id' has to be zero. This matches 486 // Confusingly, the folder item has to be the object id, while the 'parent id' has to be zero. This matches
485 // what appears to happen in the Second Life protocol. If this isn't the case. then various functionality 487 // what appears to happen in the Second Life protocol. If this isn't the case. then various functionality
486 // isn't available (such as drag from prim inventory to agent inventory) 488 // isn't available (such as drag from prim inventory to agent inventory)
@@ -491,53 +493,53 @@ namespace OpenSim.Region.Environment.Scenes
491 foreach (TaskInventoryItem item in m_taskInventory.Values) 493 foreach (TaskInventoryItem item in m_taskInventory.Values)
492 { 494 {
493 invString.AddItemStart(); 495 invString.AddItemStart();
494 invString.AddNameValueLine("item_id", item.ItemID.ToString()); 496 invString.AddNameValueLine("item_id", item.ItemID.ToString());
495 invString.AddNameValueLine("parent_id", m_folderID.ToString()); 497 invString.AddNameValueLine("parent_id", m_folderID.ToString());
496 498
497 invString.AddPermissionsStart(); 499 invString.AddPermissionsStart();
498 500
499 // FIXME: Temporary until permissions are properly sorted. 501 // FIXME: Temporary until permissions are properly sorted.
500 invString.AddNameValueLine("base_mask", "7fffffff"); 502 invString.AddNameValueLine("base_mask", "7fffffff");
501 invString.AddNameValueLine("owner_mask", "7fffffff"); 503 invString.AddNameValueLine("owner_mask", "7fffffff");
502 invString.AddNameValueLine("group_mask", "7fffffff"); 504 invString.AddNameValueLine("group_mask", "7fffffff");
503 invString.AddNameValueLine("everyone_mask", "7fffffff"); 505 invString.AddNameValueLine("everyone_mask", "7fffffff");
504 invString.AddNameValueLine("next_owner_mask", "7fffffff"); 506 invString.AddNameValueLine("next_owner_mask", "7fffffff");
505 507
506// invString.AddNameValueLine("group_mask", "00000000"); 508// invString.AddNameValueLine("group_mask", "00000000");
507// invString.AddNameValueLine("everyone_mask", "00000000"); 509// invString.AddNameValueLine("everyone_mask", "00000000");
508// invString.AddNameValueLine("next_owner_mask", "00086000"); 510// invString.AddNameValueLine("next_owner_mask", "00086000");
509 511
510// invString.AddNameValueLine("base_mask", Helpers.UIntToHexString(item.BaseMask)); 512// invString.AddNameValueLine("base_mask", Helpers.UIntToHexString(item.BaseMask));
511// invString.AddNameValueLine("owner_mask", Helpers.UIntToHexString(item.OwnerMask)); 513// invString.AddNameValueLine("owner_mask", Helpers.UIntToHexString(item.OwnerMask));
512// invString.AddNameValueLine("group_mask", Helpers.UIntToHexString(item.GroupMask)); 514// invString.AddNameValueLine("group_mask", Helpers.UIntToHexString(item.GroupMask));
513// invString.AddNameValueLine("everyone_mask", Helpers.UIntToHexString(item.EveryoneMask)); 515// invString.AddNameValueLine("everyone_mask", Helpers.UIntToHexString(item.EveryoneMask));
514// invString.AddNameValueLine("next_owner_mask", Helpers.UIntToHexString(item.NextOwnerMask)); 516// invString.AddNameValueLine("next_owner_mask", Helpers.UIntToHexString(item.NextOwnerMask));
515 517
516 invString.AddNameValueLine("creator_id", item.CreatorID.ToString()); 518 invString.AddNameValueLine("creator_id", item.CreatorID.ToString());
517 invString.AddNameValueLine("owner_id", item.OwnerID.ToString()); 519 invString.AddNameValueLine("owner_id", item.OwnerID.ToString());
518 520
519 invString.AddNameValueLine("last_owner_id", item.LastOwnerID.ToString()); 521 invString.AddNameValueLine("last_owner_id", item.LastOwnerID.ToString());
520// invString.AddNameValueLine("last_owner_id", item.OwnerID.ToString()); 522// invString.AddNameValueLine("last_owner_id", item.OwnerID.ToString());
521 523
522 invString.AddNameValueLine("group_id", item.GroupID.ToString()); 524 invString.AddNameValueLine("group_id", item.GroupID.ToString());
523 invString.AddSectionEnd(); 525 invString.AddSectionEnd();
524 526
525 invString.AddNameValueLine("asset_id", item.AssetID.ToString()); 527 invString.AddNameValueLine("asset_id", item.AssetID.ToString());
526 invString.AddNameValueLine("type", TaskInventoryItem.Types[item.Type]); 528 invString.AddNameValueLine("type", TaskInventoryItem.Types[item.Type]);
527 invString.AddNameValueLine("inv_type", TaskInventoryItem.InvTypes[item.InvType]); 529 invString.AddNameValueLine("inv_type", TaskInventoryItem.InvTypes[item.InvType]);
528 invString.AddNameValueLine("flags", "00000000"); 530 invString.AddNameValueLine("flags", "00000000");
529 531
530 invString.AddSaleStart(); 532 invString.AddSaleStart();
531 invString.AddNameValueLine("sale_type", "not"); 533 invString.AddNameValueLine("sale_type", "not");
532 invString.AddNameValueLine("sale_price", "0"); 534 invString.AddNameValueLine("sale_price", "0");
533 invString.AddSectionEnd(); 535 invString.AddSectionEnd();
534 536
535 invString.AddNameValueLine("name", item.Name + "|"); 537 invString.AddNameValueLine("name", item.Name + "|");
536 invString.AddNameValueLine("desc", item.Description + "|"); 538 invString.AddNameValueLine("desc", item.Description + "|");
537 539
538 invString.AddNameValueLine("creation_date", item.CreationDate.ToString()); 540 invString.AddNameValueLine("creation_date", item.CreationDate.ToString());
539// invString.AddNameValueLine("creation_date", "1209151453"); 541// invString.AddNameValueLine("creation_date", "1209151453");
540 542
541 invString.AddSectionEnd(); 543 invString.AddSectionEnd();
542 } 544 }
543 } 545 }
@@ -569,8 +571,6 @@ namespace OpenSim.Region.Environment.Scenes
569 } 571 }
570 } 572 }
571 573
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,7 +629,5 @@ namespace OpenSim.Region.Environment.Scenes
629 { 629 {
630 } 630 }
631 } 631 }
632
633 #endregion
634 } 632 }
635} \ No newline at end of file 633}
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
index 3a9e1c2..3dbd809 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
@@ -56,7 +56,6 @@ namespace OpenSim.Region.Environment.Scenes
56 Something5 = 64, 56 Something5 = 64,
57 Something6 = 128 57 Something6 = 128
58 } 58 }
59
60 [Flags] 59 [Flags]
61 public enum Changed : uint 60 public enum Changed : uint
62 { 61 {
@@ -69,7 +68,6 @@ namespace OpenSim.Region.Environment.Scenes
69 ALLOWED_DROP = 64, 68 ALLOWED_DROP = 64,
70 OWNER = 128 69 OWNER = 128
71 } 70 }
72
73 [Flags] 71 [Flags]
74 public enum TextureAnimFlags : byte 72 public enum TextureAnimFlags : byte
75 { 73 {
@@ -83,36 +81,70 @@ namespace OpenSim.Region.Environment.Scenes
83 SCALE = 0x40 81 SCALE = 0x40
84 } 82 }
85 83
86 84
87 [Serializable] 85 [Serializable]
88 public partial class SceneObjectPart : IScriptHost, ISerializable 86 public partial class SceneObjectPart : IScriptHost, ISerializable
89 { 87 {
90 public uint Category;
91 public Int32 CreationDate;
92 [XmlIgnore] public LLUUID fromAssetID = LLUUID.Zero;
93 public LLUUID GroupID;
94 public LLUUID LastOwnerID;
95 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;
98
96 // TODO: This needs to be persisted in next XML version update! 99 // 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;
97 [XmlIgnore] private LLObject.ObjectFlags LocalFlags = LLObject.ObjectFlags.None; 103 [XmlIgnore] private LLObject.ObjectFlags LocalFlags = LLObject.ObjectFlags.None;
98 [XmlIgnore] public scriptEvents m_aggregateScriptEvents = 0;
99 104
100 105
106 [XmlIgnore] public bool m_IsAttachment = false;
107 [XmlIgnore] public uint m_attachmentPoint = (byte)0;
101 [XmlIgnore] public LLUUID m_attachedAvatar = LLUUID.Zero; 108 [XmlIgnore] public LLUUID m_attachedAvatar = LLUUID.Zero;
102 [XmlIgnore] public LLVector3 m_attachedPos = LLVector3.Zero; 109 [XmlIgnore] public LLVector3 m_attachedPos = LLVector3.Zero;
103 [XmlIgnore] public uint m_attachmentPoint = 0; 110 [XmlIgnore] public LLUUID fromAssetID = LLUUID.Zero;
104 [XmlIgnore] public bool m_IsAttachment; 111
112 [XmlIgnore] public bool m_undoing = false;
113
114 public Int32 CreationDate;
115 public uint ParentID = 0;
105 116
106 private PhysicsVector m_lastRotationalVelocity = PhysicsVector.Zero; 117 private PhysicsVector m_lastRotationalVelocity = PhysicsVector.Zero;
107 protected SceneObjectGroup m_parentGroup; 118 private Vector3 m_sitTargetPosition = new Vector3(0, 0, 0);
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
108 142
109 protected byte[] m_particleSystem = new byte[0]; 143 protected byte[] m_particleSystem = new byte[0];
110 [XmlIgnore] public PhysicsVector m_rotationAxis = new PhysicsVector(1f, 1f, 1f); 144
111 [XmlIgnore] private Dictionary<LLUUID, scriptEvents> m_scriptEvents = new Dictionary<LLUUID, scriptEvents>(); 145 [XmlIgnore] public uint TimeStampFull = 0;
112 public LLUUID m_sitTargetAvatar = LLUUID.Zero; 146 [XmlIgnore] public uint TimeStampTerse = 0;
113 private Quaternion m_sitTargetOrientation = new Quaternion(0, 0, 0, 1); 147 [XmlIgnore] public uint TimeStampLastActivity = 0; // Will be used for AutoReturn
114 private Vector3 m_sitTargetPosition = new Vector3(0, 0, 0);
115 [XmlIgnore] public bool m_undoing;
116 148
117 /// <summary> 149 /// <summary>
118 /// Only used internally to schedule client updates. 150 /// Only used internally to schedule client updates.
@@ -124,44 +156,24 @@ namespace OpenSim.Region.Environment.Scenes
124 /// </summary> 156 /// </summary>
125 private byte m_updateFlag; 157 private byte m_updateFlag;
126 158
127 public byte ObjectSaleType;
128 public LLUUID OwnerID;
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;
134
135 [XmlIgnore] public uint TimeStampFull;
136 [XmlIgnore] public uint TimeStampLastActivity; // Will be used for AutoReturn
137 [XmlIgnore] public uint TimeStampTerse;
138
139 #region Properties 159 #region Properties
140 160
141 public LLUUID CreatorID; 161 public LLUUID CreatorID;
142 protected LLVector3 m_acceleration;
143 protected LLVector3 m_angularVelocity;
144 private byte m_clickAction;
145 private Color m_color = Color.Black;
146 private string m_description = String.Empty;
147 protected LLVector3 m_groupPosition;
148 private int m_linkNum;
149 162
150 protected uint m_localId; 163 public LLUUID ObjectCreator
151 protected LLObject.MaterialType m_material = 0; 164 {
165 get { return CreatorID; }
166 }
152 167
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; 168 protected LLUUID m_uuid;
164 protected LLVector3 m_velocity; 169
170 public LLUUID UUID
171 {
172 get { return m_uuid; }
173 set { m_uuid = value; }
174 }
175
176 protected uint m_localId;
165 177
166 public uint LocalId 178 public uint LocalId
167 { 179 {
@@ -169,23 +181,145 @@ namespace OpenSim.Region.Environment.Scenes
169 set { m_localId = value; } 181 set { m_localId = value; }
170 } 182 }
171 183
172 public scriptEvents ScriptEvents 184 protected string m_name;
185
186 public virtual string Name
173 { 187 {
174 get { return m_aggregateScriptEvents; } 188 get { return m_name; }
189 set { m_name = value; }
175 } 190 }
176 191
192 public scriptEvents ScriptEvents
193 {
194 get { return m_aggregateScriptEvents; }
195 }
196
197 protected LLObject.MaterialType m_material = 0;
198
177 public byte Material 199 public byte Material
178 { 200 {
179 get { return (byte) m_material; } 201 get { return (byte) m_material; }
180 set { m_material = (LLObject.MaterialType) value; } 202 set { m_material = (LLObject.MaterialType) value; }
181 } 203 }
182 204
205 protected ulong m_regionHandle;
206
183 public ulong RegionHandle 207 public ulong RegionHandle
184 { 208 {
185 get { return m_regionHandle; } 209 get { return m_regionHandle; }
186 set { m_regionHandle = value; } 210 set { m_regionHandle = value; }
187 } 211 }
188 212
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
189 public LLVector3 GroupPosition 323 public LLVector3 GroupPosition
190 { 324 {
191 get 325 get
@@ -218,13 +352,16 @@ namespace OpenSim.Region.Environment.Scenes
218 { 352 {
219 try 353 try
220 { 354 {
355
221 // Root prim actually goes at Position 356 // Root prim actually goes at Position
222 if (ParentID == 0) 357 if (ParentID == 0)
223 { 358 {
224 PhysActor.Position = new PhysicsVector(value.X, value.Y, value.Z); 359 PhysActor.Position = new PhysicsVector(value.X, value.Y, value.Z);
360
225 } 361 }
226 else 362 else
227 { 363 {
364
228 // To move the child prim in respect to the group position and rotation we have to calculate 365 // To move the child prim in respect to the group position and rotation we have to calculate
229 366
230 LLVector3 resultingposition = GetWorldPosition(); 367 LLVector3 resultingposition = GetWorldPosition();
@@ -232,7 +369,7 @@ namespace OpenSim.Region.Environment.Scenes
232 LLQuaternion resultingrot = GetWorldRotation(); 369 LLQuaternion resultingrot = GetWorldRotation();
233 PhysActor.Orientation = new Quaternion(resultingrot.W, resultingrot.X, resultingrot.Y, resultingrot.Z); 370 PhysActor.Orientation = new Quaternion(resultingrot.W, resultingrot.X, resultingrot.Y, resultingrot.Z);
234 } 371 }
235 372
236 // Tell the physics engines that this prim changed. 373 // Tell the physics engines that this prim changed.
237 m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor); 374 m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor);
238 } 375 }
@@ -241,9 +378,14 @@ namespace OpenSim.Region.Environment.Scenes
241 Console.WriteLine(e.Message); 378 Console.WriteLine(e.Message);
242 } 379 }
243 } 380 }
381
244 } 382 }
245 } 383 }
246 384
385 private byte[] m_TextureAnimation;
386
387 protected LLVector3 m_offsetPosition;
388
247 public LLVector3 OffsetPosition 389 public LLVector3 OffsetPosition
248 { 390 {
249 get { return m_offsetPosition; } 391 get { return m_offsetPosition; }
@@ -251,19 +393,31 @@ namespace OpenSim.Region.Environment.Scenes
251 { 393 {
252 StoreUndoState(); 394 StoreUndoState();
253 m_offsetPosition = value; 395 m_offsetPosition = value;
254 try 396 try
255 { 397 {
256 // Hack to get the child prim to update world positions in the physics engine 398 // Hack to get the child prim to update world positions in the physics engine
257 ParentGroup.ResetChildPrimPhysicsPositions(); 399 ParentGroup.ResetChildPrimPhysicsPositions();
258 } 400
259 catch (NullReferenceException) 401 }
260 { 402 catch (NullReferenceException)
261 // Ignore, and skip over. 403 {
262 } 404 // Ignore, and skip over.
263 //m_log.Info("[PART]: OFFSET:" + m_offsetPosition.ToString()); 405 }
406 //m_log.Info("[PART]: OFFSET:" + m_offsetPosition.ToString());
264 } 407 }
265 } 408 }
266 409
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
267 public LLQuaternion RotationOffset 421 public LLQuaternion RotationOffset
268 { 422 {
269 get 423 get
@@ -312,9 +466,13 @@ namespace OpenSim.Region.Environment.Scenes
312 Console.WriteLine(ex.Message); 466 Console.WriteLine(ex.Message);
313 } 467 }
314 } 468 }
469
315 } 470 }
316 } 471 }
317 472
473 protected LLVector3 m_velocity;
474 protected LLVector3 m_rotationalvelocity;
475
318 /// <summary></summary> 476 /// <summary></summary>
319 public LLVector3 Velocity 477 public LLVector3 Velocity
320 { 478 {
@@ -335,8 +493,8 @@ namespace OpenSim.Region.Environment.Scenes
335 493
336 return m_velocity; 494 return m_velocity;
337 } 495 }
338 set 496 set {
339 { 497
340 m_velocity = value; 498 m_velocity = value;
341 if (PhysActor != null) 499 if (PhysActor != null)
342 { 500 {
@@ -346,6 +504,7 @@ namespace OpenSim.Region.Environment.Scenes
346 m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor); 504 m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor);
347 } 505 }
348 } 506 }
507
349 } 508 }
350 } 509 }
351 510
@@ -360,7 +519,7 @@ namespace OpenSim.Region.Environment.Scenes
360 { 519 {
361 if (PhysActor.IsPhysical) 520 if (PhysActor.IsPhysical)
362 { 521 {
363 m_rotationalvelocity.FromBytes(PhysActor.RotationalVelocity.GetBytes(), 0); 522 m_rotationalvelocity.FromBytes(PhysActor.RotationalVelocity.GetBytes(),0);
364 } 523 }
365 } 524 }
366 525
@@ -370,6 +529,8 @@ namespace OpenSim.Region.Environment.Scenes
370 } 529 }
371 530
372 531
532 protected LLVector3 m_angularVelocity;
533
373 /// <summary></summary> 534 /// <summary></summary>
374 public LLVector3 AngularVelocity 535 public LLVector3 AngularVelocity
375 { 536 {
@@ -377,6 +538,8 @@ namespace OpenSim.Region.Environment.Scenes
377 set { m_angularVelocity = value; } 538 set { m_angularVelocity = value; }
378 } 539 }
379 540
541 protected LLVector3 m_acceleration;
542
380 /// <summary></summary> 543 /// <summary></summary>
381 public LLVector3 Acceleration 544 public LLVector3 Acceleration
382 { 545 {
@@ -384,6 +547,16 @@ namespace OpenSim.Region.Environment.Scenes
384 set { m_acceleration = value; } 547 set { m_acceleration = value; }
385 } 548 }
386 549
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
387 public Color Color 560 public Color Color
388 { 561 {
389 get { return m_color; } 562 get { return m_color; }
@@ -391,7 +564,7 @@ namespace OpenSim.Region.Environment.Scenes
391 { 564 {
392 m_color = value; 565 m_color = value;
393 TriggerScriptChangedEvent(Changed.COLOR); 566 TriggerScriptChangedEvent(Changed.COLOR);
394 567
395 /* ScheduleFullUpdate() need not be called b/c after 568 /* ScheduleFullUpdate() need not be called b/c after
396 * setting the color, the text will be set, so then 569 * setting the color, the text will be set, so then
397 * ScheduleFullUpdate() will be called. */ 570 * ScheduleFullUpdate() will be called. */
@@ -399,6 +572,8 @@ namespace OpenSim.Region.Environment.Scenes
399 } 572 }
400 } 573 }
401 574
575 private string m_text = String.Empty;
576
402 public Vector3 SitTargetPosition 577 public Vector3 SitTargetPosition
403 { 578 {
404 get { return m_sitTargetPosition; } 579 get { return m_sitTargetPosition; }
@@ -412,93 +587,13 @@ namespace OpenSim.Region.Environment.Scenes
412 public string Text 587 public string Text
413 { 588 {
414 get { return m_text; } 589 get { return m_text; }
415 set { m_text = value; }
416 }
417
418 public int LinkNum
419 {
420 get { return m_linkNum; }
421 set
422 {
423 m_linkNum = value;
424 TriggerScriptChangedEvent(Changed.LINK);
425 }
426 }
427
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 590 set
448 { 591 {
449 StoreUndoState(); 592 m_text = value;
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 } 593 }
495 } 594 }
496 595
497 public string Description 596 private string m_sitName = String.Empty;
498 {
499 get { return m_description; }
500 set { m_description = value; }
501 }
502 597
503 public string SitName 598 public string SitName
504 { 599 {
@@ -506,113 +601,39 @@ namespace OpenSim.Region.Environment.Scenes
506 set { m_sitName = value; } 601 set { m_sitName = value; }
507 } 602 }
508 603
604 private string m_touchName = String.Empty;
605
509 public string TouchName 606 public string TouchName
510 { 607 {
511 get { return m_touchName; } 608 get { return m_touchName; }
512 set { m_touchName = value; } 609 set { m_touchName = value; }
513 } 610 }
514 611
515 public uint GetEffectiveObjectFlags() 612 private int m_linkNum = 0;
516 {
517 LLObject.ObjectFlags f = Flags;
518 if (m_parentGroup == null || m_parentGroup.RootPart == this)
519 f &= ~(LLObject.ObjectFlags.Touch | LLObject.ObjectFlags.Money);
520
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()
530 {
531 Quaternion parentRot = new Quaternion(
532 ParentGroup.RootPart.RotationOffset.W,
533 ParentGroup.RootPart.RotationOffset.X,
534 ParentGroup.RootPart.RotationOffset.Y,
535 ParentGroup.RootPart.RotationOffset.Z);
536
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);
548 }
549 613
550 /// <summary> 614 public int LinkNum
551 /// Gets the rotation of this prim offset by the group rotation
552 /// </summary>
553 /// <returns></returns>
554 public LLQuaternion GetWorldRotation()
555 { 615 {
556 Quaternion newRot; 616 get { return m_linkNum; }
557 617 set
558 if (LinkNum == 0) 618 {
559 { 619 m_linkNum = value;
560 newRot = new Quaternion(RotationOffset.W, RotationOffset.X, RotationOffset.Y, RotationOffset.Z); 620 TriggerScriptChangedEvent(Changed.LINK);
561 } 621
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 } 622 }
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 } 623 }
583 624
584 public void StoreUndoState() 625 private byte m_clickAction = 0;
626
627 public byte ClickAction
585 { 628 {
586 if (!m_undoing) 629 get { return m_clickAction; }
630 set
587 { 631 {
588 if (m_parentGroup != null) 632 m_clickAction = value;
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 }
608 } 633 }
609 } 634 }
610 635
611 public void ClearUndoState() 636 protected PrimitiveBaseShape m_shape;
612 {
613 m_undo.Clear();
614 StoreUndoState();
615 }
616 637
617 /// <summary> 638 /// <summary>
618 /// hook to the physics scene to apply impulse 639 /// hook to the physics scene to apply impulse
@@ -624,17 +645,20 @@ namespace OpenSim.Region.Environment.Scenes
624 public void ApplyImpulse(LLVector3 impulsei, bool localGlobalTF) 645 public void ApplyImpulse(LLVector3 impulsei, bool localGlobalTF)
625 { 646 {
626 PhysicsVector impulse = new PhysicsVector(impulsei.X, impulsei.Y, impulsei.Z); 647 PhysicsVector impulse = new PhysicsVector(impulsei.X, impulsei.Y, impulsei.Z);
627 648
628 if (localGlobalTF) 649 if (localGlobalTF)
629 { 650 {
651
630 LLQuaternion grot = GetWorldRotation(); 652 LLQuaternion grot = GetWorldRotation();
631 Quaternion AXgrot = new Quaternion(grot.W, grot.X, grot.Y, grot.Z); 653 Quaternion AXgrot = new Quaternion(grot.W,grot.X,grot.Y,grot.Z);
632 Vector3 AXimpulsei = new Vector3(impulsei.X, impulsei.Y, impulsei.Z); 654 Vector3 AXimpulsei = new Vector3(impulsei.X, impulsei.Y, impulsei.Z);
633 Vector3 newimpulse = AXgrot * AXimpulsei; 655 Vector3 newimpulse = AXgrot * AXimpulsei;
634 impulse = new PhysicsVector(newimpulse.x, newimpulse.y, newimpulse.z); 656 impulse = new PhysicsVector(newimpulse.x, newimpulse.y, newimpulse.z);
657
635 } 658 }
636 else 659 else
637 { 660 {
661
638 if (m_parentGroup != null) 662 if (m_parentGroup != null)
639 { 663 {
640 m_parentGroup.applyImpulse(impulse); 664 m_parentGroup.applyImpulse(impulse);
@@ -652,6 +676,7 @@ namespace OpenSim.Region.Environment.Scenes
652 { 676 {
653 StopMoveToTarget(); 677 StopMoveToTarget();
654 } 678 }
679
655 } 680 }
656 681
657 public void StopMoveToTarget() 682 public void StopMoveToTarget()
@@ -664,48 +689,56 @@ namespace OpenSim.Region.Environment.Scenes
664 if (m_parentGroup != null) 689 if (m_parentGroup != null)
665 { 690 {
666 if (m_parentGroup.Scene != null) 691 if (m_parentGroup.Scene != null)
667 m_parentGroup.Scene.TriggerObjectChanged(LocalId, (uint) val); 692 m_parentGroup.Scene.TriggerObjectChanged(LocalId, (uint)val);
668 } 693 }
669 }
670
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 694
679 public LLObject.ObjectFlags Flags = LLObject.ObjectFlags.None; 695 }
680 public uint GroupMask = (uint) PermissionMask.None;
681 public uint NextOwnerMask = (uint) PermissionMask.All;
682 public uint OwnerMask = (uint) PermissionMask.All;
683 696
684 public uint ObjectFlags 697 public PrimitiveBaseShape Shape
685 { 698 {
686 get { return (uint) Flags; } 699 get { return m_shape; }
687 set { Flags = (LLObject.ObjectFlags) value; } 700 set
701 {
702
703 m_shape = value;
704 TriggerScriptChangedEvent(Changed.SHAPE);
705 }
688 } 706 }
689 707
690 #endregion 708 public LLVector3 Scale
691
692 protected SceneObjectPart(SerializationInfo info, StreamingContext context)
693 { 709 {
694 //System.Console.WriteLine("SceneObjectPart Deserialize BGN"); 710 get { return m_shape.Scale; }
695 711 set
696 if (info == null)
697 { 712 {
698 throw new ArgumentNullException("info"); 713 StoreUndoState();
714 m_shape.Scale = value;
715 TriggerScriptChangedEvent(Changed.SCALE);
699 } 716 }
717 }
700 718
701 /* 719 public bool Stopped
702 m_queue = (Queue<SceneObjectPart>)info.GetValue("m_queue", typeof(Queue<SceneObjectPart>)); 720 {
703 m_ids = (List<LLUUID>)info.GetValue("m_ids", typeof(List<LLUUID>)); 721 get {
704 */ 722 double threshold = 0.02;
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 }
705 731
706 //System.Console.WriteLine("SceneObjectPart Deserialize END"); 732 #endregion
733
734 public LLUUID ObjectOwner
735 {
736 get { return OwnerID; }
707 } 737 }
708 738
739 // FIXME, TODO, ERROR: 'ParentGroup' can't be in here, move it out.
740 protected SceneObjectGroup m_parentGroup;
741
709 public SceneObjectGroup ParentGroup 742 public SceneObjectGroup ParentGroup
710 { 743 {
711 get { return m_parentGroup; } 744 get { return m_parentGroup; }
@@ -725,7 +758,7 @@ namespace OpenSim.Region.Environment.Scenes
725 public SceneObjectPart() 758 public SceneObjectPart()
726 { 759 {
727 // It's not necessary to persist this 760 // It's not necessary to persist this
728 m_inventoryFileName = "inventory_" + LLUUID.Random() + ".tmp"; 761 m_inventoryFileName = "inventory_" + LLUUID.Random().ToString() + ".tmp";
729 m_TextureAnimation = new byte[0]; 762 m_TextureAnimation = new byte[0];
730 } 763 }
731 764
@@ -757,13 +790,13 @@ namespace OpenSim.Region.Environment.Scenes
757 CreatorID = OwnerID; 790 CreatorID = OwnerID;
758 LastOwnerID = LLUUID.Zero; 791 LastOwnerID = LLUUID.Zero;
759 UUID = LLUUID.Random(); 792 UUID = LLUUID.Random();
760 LocalId = (localID); 793 LocalId = (uint) (localID);
761 Shape = shape; 794 Shape = shape;
762 // Todo: Add More Object Parameter from above! 795 // Todo: Add More Object Parameter from above!
763 OwnershipCost = 0; 796 OwnershipCost = 0;
764 ObjectSaleType = 0; 797 ObjectSaleType = (byte) 0;
765 SalePrice = 0; 798 SalePrice = 0;
766 Category = 0; 799 Category = (uint) 0;
767 LastOwnerID = CreatorID; 800 LastOwnerID = CreatorID;
768 // End Todo: /// 801 // End Todo: ///
769 GroupPosition = groupPosition; 802 GroupPosition = groupPosition;
@@ -774,20 +807,20 @@ namespace OpenSim.Region.Environment.Scenes
774 AngularVelocity = new LLVector3(0, 0, 0); 807 AngularVelocity = new LLVector3(0, 0, 0);
775 Acceleration = new LLVector3(0, 0, 0); 808 Acceleration = new LLVector3(0, 0, 0);
776 m_TextureAnimation = new byte[0]; 809 m_TextureAnimation = new byte[0];
777 m_inventoryFileName = "inventory_" + LLUUID.Random() + ".tmp"; 810 m_inventoryFileName = "inventory_" + LLUUID.Random().ToString() + ".tmp";
778 811
779 // Prims currently only contain a single folder (Contents). From looking at the Second Life protocol, 812 // Prims currently only contain a single folder (Contents). From looking at the Second Life protocol,
780 // this appears to have the same UUID (!) as the prim. If this isn't the case, one can't drag items from 813 // this appears to have the same UUID (!) as the prim. If this isn't the case, one can't drag items from
781 // the prim into an agent inventory (Linden client reports that the "Object not found for drop" in its log 814 // the prim into an agent inventory (Linden client reports that the "Object not found for drop" in its log
782 m_folderID = UUID; 815 m_folderID = UUID;
783 816
784 Flags = 0; 817 Flags = 0;
785 Flags |= LLObject.ObjectFlags.AllowInventoryDrop | 818 Flags |= LLObject.ObjectFlags.AllowInventoryDrop |
786 LLObject.ObjectFlags.CreateSelected; 819 LLObject.ObjectFlags.CreateSelected;
787 820
788 TrimPermissions(); 821 TrimPermissions();
789 //m_undo = new UndoStack<UndoState>(ParentGroup.GetSceneMaxUndo()); 822 //m_undo = new UndoStack<UndoState>(ParentGroup.GetSceneMaxUndo());
790 823
791 ScheduleFullUpdate(); 824 ScheduleFullUpdate();
792 } 825 }
793 826
@@ -813,149 +846,29 @@ namespace OpenSim.Region.Environment.Scenes
813 CreatorID = creatorID; 846 CreatorID = creatorID;
814 LastOwnerID = lastOwnerID; 847 LastOwnerID = lastOwnerID;
815 UUID = LLUUID.Random(); 848 UUID = LLUUID.Random();
816 LocalId = (localID); 849 LocalId = (uint) (localID);
817 Shape = shape; 850 Shape = shape;
818 OwnershipCost = 0; 851 OwnershipCost = 0;
819 ObjectSaleType = 0; 852 ObjectSaleType = (byte) 0;
820 SalePrice = 0; 853 SalePrice = 0;
821 Category = 0; 854 Category = (uint) 0;
822 LastOwnerID = CreatorID; 855 LastOwnerID = CreatorID;
823 OffsetPosition = position; 856 OffsetPosition = position;
824 RotationOffset = rotation; 857 RotationOffset = rotation;
825 ObjectFlags = flags; 858 ObjectFlags = flags;
826 859
827 // Since we don't store script state, this is only a 'temporary' objectflag now 860 // Since we don't store script state, this is only a 'temporary' objectflag now
828 // If the object is scripted, the script will get loaded and this will be set again 861 // If the object is scripted, the script will get loaded and this will be set again
829 ObjectFlags &= ~(uint) (LLObject.ObjectFlags.Scripted | LLObject.ObjectFlags.Touch); 862 ObjectFlags &= ~(uint)(LLObject.ObjectFlags.Scripted | LLObject.ObjectFlags.Touch);
830 863
831 TrimPermissions(); 864 TrimPermissions();
832 // ApplyPhysics(); 865 // ApplyPhysics();
833 866
834 ScheduleFullUpdate(); 867 ScheduleFullUpdate();
835 } 868 }
836 869
837 #endregion 870 #endregion
838 871
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
959 /// <summary> 872 /// <summary>
960 /// Restore this part from the serialized xml representation. 873 /// Restore this part from the serialized xml representation.
961 /// </summary> 874 /// </summary>
@@ -968,9 +881,10 @@ namespace OpenSim.Region.Environment.Scenes
968 881
969 return newobject; 882 return newobject;
970 } 883 }
971 884
972 public void ApplyPhysics(uint rootObjectFlags, bool m_physicalPrim) 885 public void ApplyPhysics(uint rootObjectFlags, bool m_physicalPrim)
973 { 886 {
887
974 bool isPhysical = (((rootObjectFlags & (uint) LLObject.ObjectFlags.Physics) != 0) && m_physicalPrim); 888 bool isPhysical = (((rootObjectFlags & (uint) LLObject.ObjectFlags.Physics) != 0) && m_physicalPrim);
975 bool isPhantom = ((rootObjectFlags & (uint) LLObject.ObjectFlags.Phantom) != 0); 889 bool isPhantom = ((rootObjectFlags & (uint) LLObject.ObjectFlags.Phantom) != 0);
976 890
@@ -988,7 +902,7 @@ namespace OpenSim.Region.Environment.Scenes
988 new PhysicsVector(Scale.X, Scale.Y, Scale.Z), 902 new PhysicsVector(Scale.X, Scale.Y, Scale.Z),
989 new Quaternion(RotationOffset.W, RotationOffset.X, 903 new Quaternion(RotationOffset.W, RotationOffset.X,
990 RotationOffset.Y, RotationOffset.Z), RigidBody); 904 RotationOffset.Y, RotationOffset.Z), RigidBody);
991 905
992 // Basic Physics returns null.. joy joy joy. 906 // Basic Physics returns null.. joy joy joy.
993 if (PhysActor != null) 907 if (PhysActor != null)
994 { 908 {
@@ -1004,15 +918,18 @@ namespace OpenSim.Region.Environment.Scenes
1004 OwnerMask = NextOwnerMask; 918 OwnerMask = NextOwnerMask;
1005 919
1006 TriggerScriptChangedEvent(Changed.OWNER); 920 TriggerScriptChangedEvent(Changed.OWNER);
921
1007 } 922 }
1008 923
1009 public void TrimPermissions() 924 public void TrimPermissions()
1010 { 925 {
1011 BaseMask &= (uint) PermissionMask.All; 926
1012 OwnerMask &= (uint) PermissionMask.All; 927 BaseMask &= (uint)PermissionMask.All;
1013 GroupMask &= (uint) PermissionMask.All; 928 OwnerMask &= (uint)PermissionMask.All;
1014 EveryoneMask &= (uint) PermissionMask.All; 929 GroupMask &= (uint)PermissionMask.All;
1015 NextOwnerMask &= (uint) PermissionMask.All; 930 EveryoneMask &= (uint)PermissionMask.All;
931 NextOwnerMask &= (uint)PermissionMask.All;
932
1016 } 933 }
1017 934
1018 /// <summary> 935 /// <summary>
@@ -1046,24 +963,25 @@ namespace OpenSim.Region.Environment.Scenes
1046 Vector3 rOrigin = iray.Origin; 963 Vector3 rOrigin = iray.Origin;
1047 Vector3 rDirection = iray.Direction; 964 Vector3 rDirection = iray.Direction;
1048 965
966
1049 967
1050 //rDirection = rDirection.Normalize(); 968 //rDirection = rDirection.Normalize();
1051 // Buidling the first part of the Quadratic equation 969 // Buidling the first part of the Quadratic equation
1052 Vector3 r2ndDirection = rDirection * rDirection; 970 Vector3 r2ndDirection = rDirection*rDirection;
1053 float itestPart1 = r2ndDirection.x + r2ndDirection.y + r2ndDirection.z; 971 float itestPart1 = r2ndDirection.x + r2ndDirection.y + r2ndDirection.z;
1054 972
1055 // Buidling the second part of the Quadratic equation 973 // Buidling the second part of the Quadratic equation
1056 Vector3 tmVal2 = rOrigin - vAbsolutePosition; 974 Vector3 tmVal2 = rOrigin - vAbsolutePosition;
1057 Vector3 r2Direction = rDirection * 2.0f; 975 Vector3 r2Direction = rDirection*2.0f;
1058 Vector3 tmVal3 = r2Direction * tmVal2; 976 Vector3 tmVal3 = r2Direction*tmVal2;
1059 977
1060 float itestPart2 = tmVal3.x + tmVal3.y + tmVal3.z; 978 float itestPart2 = tmVal3.x + tmVal3.y + tmVal3.z;
1061 979
1062 // Buidling the third part of the Quadratic equation 980 // Buidling the third part of the Quadratic equation
1063 Vector3 tmVal4 = rOrigin * rOrigin; 981 Vector3 tmVal4 = rOrigin*rOrigin;
1064 Vector3 tmVal5 = vAbsolutePosition * vAbsolutePosition; 982 Vector3 tmVal5 = vAbsolutePosition*vAbsolutePosition;
1065 983
1066 Vector3 tmVal6 = vAbsolutePosition * rOrigin; 984 Vector3 tmVal6 = vAbsolutePosition*rOrigin;
1067 985
1068 986
1069 // Set Radius to the largest dimention of the prim 987 // Set Radius to the largest dimention of the prim
@@ -1085,21 +1003,21 @@ namespace OpenSim.Region.Environment.Scenes
1085 //radius = radius; 1003 //radius = radius;
1086 1004
1087 float itestPart3 = tmVal4.x + tmVal4.y + tmVal4.z + tmVal5.x + tmVal5.y + tmVal5.z - 1005 float itestPart3 = tmVal4.x + tmVal4.y + tmVal4.z + tmVal5.x + tmVal5.y + tmVal5.z -
1088 (2.0f * (tmVal6.x + tmVal6.y + tmVal6.z + (radius * radius))); 1006 (2.0f*(tmVal6.x + tmVal6.y + tmVal6.z + (radius*radius)));
1089 1007
1090 // Yuk Quadradrics.. Solve first 1008 // Yuk Quadradrics.. Solve first
1091 float rootsqr = (itestPart2 * itestPart2) - (4.0f * itestPart1 * itestPart3); 1009 float rootsqr = (itestPart2*itestPart2) - (4.0f*itestPart1*itestPart3);
1092 if (rootsqr < 0.0f) 1010 if (rootsqr < 0.0f)
1093 { 1011 {
1094 // No intersection 1012 // No intersection
1095 return returnresult; 1013 return returnresult;
1096 } 1014 }
1097 float root = ((-itestPart2) - (float) Math.Sqrt(rootsqr)) / (itestPart1 * 2.0f); 1015 float root = ((-itestPart2) - (float) Math.Sqrt((double) rootsqr))/(itestPart1*2.0f);
1098 1016
1099 if (root < 0.0f) 1017 if (root < 0.0f)
1100 { 1018 {
1101 // perform second quadratic root solution 1019 // perform second quadratic root solution
1102 root = ((-itestPart2) + (float) Math.Sqrt(rootsqr)) / (itestPart1 * 2.0f); 1020 root = ((-itestPart2) + (float) Math.Sqrt((double) rootsqr))/(itestPart1*2.0f);
1103 1021
1104 // is there any intersection? 1022 // is there any intersection?
1105 if (root < 0.0f) 1023 if (root < 0.0f)
@@ -1112,8 +1030,8 @@ namespace OpenSim.Region.Environment.Scenes
1112 // We got an intersection. putting together an EntityIntersection object with the 1030 // We got an intersection. putting together an EntityIntersection object with the
1113 // intersection information 1031 // intersection information
1114 Vector3 ipoint = 1032 Vector3 ipoint =
1115 new Vector3(iray.Origin.x + (iray.Direction.x * root), iray.Origin.y + (iray.Direction.y * root), 1033 new Vector3(iray.Origin.x + (iray.Direction.x*root), iray.Origin.y + (iray.Direction.y*root),
1116 iray.Origin.z + (iray.Direction.z * root)); 1034 iray.Origin.z + (iray.Direction.z*root));
1117 1035
1118 returnresult.HitTF = true; 1036 returnresult.HitTF = true;
1119 returnresult.ipoint = ipoint; 1037 returnresult.ipoint = ipoint;
@@ -1174,7 +1092,7 @@ namespace OpenSim.Region.Environment.Scenes
1174 1092
1175 // Variables prefixed with AX are Axiom.Math copies of the LL variety. 1093 // Variables prefixed with AX are Axiom.Math copies of the LL variety.
1176 1094
1177 Quaternion AXrot = new Quaternion(rot.W, rot.X, rot.Y, rot.Z); 1095 Quaternion AXrot = new Quaternion(rot.W,rot.X,rot.Y,rot.Z);
1178 AXrot.Normalize(); 1096 AXrot.Normalize();
1179 1097
1180 Vector3 AXpos = new Vector3(pos.X, pos.Y, pos.Z); 1098 Vector3 AXpos = new Vector3(pos.X, pos.Y, pos.Z);
@@ -1183,33 +1101,31 @@ namespace OpenSim.Region.Environment.Scenes
1183 // it's different for each vertex because we've got to rotate it 1101 // it's different for each vertex because we've got to rotate it
1184 // to get the world position of the vertex to produce the Oriented Bounding Box 1102 // to get the world position of the vertex to produce the Oriented Bounding Box
1185 1103
1186 Vector3 tScale = new Vector3(); 1104 Vector3 tScale = new Vector3();
1187 1105
1188 Vector3 AXscale = new Vector3(m_shape.Scale.X * 0.5f, m_shape.Scale.Y * 0.5f, m_shape.Scale.Z * 0.5f); 1106 Vector3 AXscale = new Vector3(m_shape.Scale.X * 0.5f, m_shape.Scale.Y * 0.5f, m_shape.Scale.Z * 0.5f);
1189 1107
1190 //Vector3 pScale = (AXscale) - (AXrot.Inverse() * (AXscale)); 1108 //Vector3 pScale = (AXscale) - (AXrot.Inverse() * (AXscale));
1191 //Vector3 nScale = (AXscale * -1) - (AXrot.Inverse() * (AXscale * -1)); 1109 //Vector3 nScale = (AXscale * -1) - (AXrot.Inverse() * (AXscale * -1));
1192 1110
1193 // rScale is the rotated offset to find a vertex based on the scale and the world rotation. 1111 // rScale is the rotated offset to find a vertex based on the scale and the world rotation.
1194 Vector3 rScale = new Vector3(); 1112 Vector3 rScale = new Vector3();
1195 1113
1196 // Get Vertexes for Faces Stick them into ABCD for each Face 1114 // Get Vertexes for Faces Stick them into ABCD for each Face
1197 // Form: Face<vertex>[face] that corresponds to the below diagram 1115 // Form: Face<vertex>[face] that corresponds to the below diagram
1198
1199 #region ABCD Face Vertex Map Comment Diagram 1116 #region ABCD Face Vertex Map Comment Diagram
1200
1201 // A _________ B 1117 // A _________ B
1202 // | | 1118 // | |
1203 // | 4 top | 1119 // | 4 top |
1204 // |_________| 1120 // |_________|
1205 // C D 1121 // C D
1206 1122
1207 // A _________ B 1123 // A _________ B
1208 // | Back | 1124 // | Back |
1209 // | 3 | 1125 // | 3 |
1210 // |_________| 1126 // |_________|
1211 // C D 1127 // C D
1212 1128
1213 // A _________ B B _________ A 1129 // A _________ B B _________ A
1214 // | Left | | Right | 1130 // | Left | | Right |
1215 // | 0 | | 2 | 1131 // | 0 | | 2 |
@@ -1227,15 +1143,13 @@ namespace OpenSim.Region.Environment.Scenes
1227 // | 5 bot | 1143 // | 5 bot |
1228 // |_________| 1144 // |_________|
1229 // A B 1145 // A B
1230
1231 #endregion 1146 #endregion
1232 1147
1233 #region Plane Decomposition of Oriented Bounding Box 1148 #region Plane Decomposition of Oriented Bounding Box
1234
1235 tScale = new Vector3(AXscale.x, -AXscale.y, AXscale.z); 1149 tScale = new Vector3(AXscale.x, -AXscale.y, AXscale.z);
1236 rScale = ((AXrot * tScale)); 1150 rScale = ((AXrot * tScale));
1237 vertexes[0] = (new Vector3((pos.X + rScale.x), (pos.Y + rScale.y), (pos.Z + rScale.z))); 1151 vertexes[0] = (new Vector3((pos.X + rScale.x), (pos.Y + rScale.y), (pos.Z + rScale.z)));
1238 // vertexes[0].x = pos.X + vertexes[0].x; 1152 // vertexes[0].x = pos.X + vertexes[0].x;
1239 //vertexes[0].y = pos.Y + vertexes[0].y; 1153 //vertexes[0].y = pos.Y + vertexes[0].y;
1240 //vertexes[0].z = pos.Z + vertexes[0].z; 1154 //vertexes[0].z = pos.Z + vertexes[0].z;
1241 1155
@@ -1247,8 +1161,8 @@ namespace OpenSim.Region.Environment.Scenes
1247 rScale = ((AXrot * tScale)); 1161 rScale = ((AXrot * tScale));
1248 vertexes[1] = (new Vector3((pos.X + rScale.x), (pos.Y + rScale.y), (pos.Z + rScale.z))); 1162 vertexes[1] = (new Vector3((pos.X + rScale.x), (pos.Y + rScale.y), (pos.Z + rScale.z)));
1249 1163
1250 // vertexes[1].x = pos.X + vertexes[1].x; 1164 // vertexes[1].x = pos.X + vertexes[1].x;
1251 // vertexes[1].y = pos.Y + vertexes[1].y; 1165 // vertexes[1].y = pos.Y + vertexes[1].y;
1252 //vertexes[1].z = pos.Z + vertexes[1].z; 1166 //vertexes[1].z = pos.Z + vertexes[1].z;
1253 1167
1254 FaceB[0] = vertexes[1]; 1168 FaceB[0] = vertexes[1];
@@ -1273,8 +1187,8 @@ namespace OpenSim.Region.Environment.Scenes
1273 vertexes[3] = (new Vector3((pos.X + rScale.x), (pos.Y + rScale.y), (pos.Z + rScale.z))); 1187 vertexes[3] = (new Vector3((pos.X + rScale.x), (pos.Y + rScale.y), (pos.Z + rScale.z)));
1274 1188
1275 //vertexes[3].x = pos.X + vertexes[3].x; 1189 //vertexes[3].x = pos.X + vertexes[3].x;
1276 // vertexes[3].y = pos.Y + vertexes[3].y; 1190 // vertexes[3].y = pos.Y + vertexes[3].y;
1277 // vertexes[3].z = pos.Z + vertexes[3].z; 1191 // vertexes[3].z = pos.Z + vertexes[3].z;
1278 1192
1279 FaceD[0] = vertexes[3]; 1193 FaceD[0] = vertexes[3];
1280 FaceC[1] = vertexes[3]; 1194 FaceC[1] = vertexes[3];
@@ -1284,9 +1198,9 @@ namespace OpenSim.Region.Environment.Scenes
1284 rScale = ((AXrot * tScale)); 1198 rScale = ((AXrot * tScale));
1285 vertexes[4] = (new Vector3((pos.X + rScale.x), (pos.Y + rScale.y), (pos.Z + rScale.z))); 1199 vertexes[4] = (new Vector3((pos.X + rScale.x), (pos.Y + rScale.y), (pos.Z + rScale.z)));
1286 1200
1287 // vertexes[4].x = pos.X + vertexes[4].x; 1201 // vertexes[4].x = pos.X + vertexes[4].x;
1288 // vertexes[4].y = pos.Y + vertexes[4].y; 1202 // vertexes[4].y = pos.Y + vertexes[4].y;
1289 // vertexes[4].z = pos.Z + vertexes[4].z; 1203 // vertexes[4].z = pos.Z + vertexes[4].z;
1290 1204
1291 FaceB[1] = vertexes[4]; 1205 FaceB[1] = vertexes[4];
1292 FaceA[2] = vertexes[4]; 1206 FaceA[2] = vertexes[4];
@@ -1296,9 +1210,9 @@ namespace OpenSim.Region.Environment.Scenes
1296 rScale = ((AXrot * tScale)); 1210 rScale = ((AXrot * tScale));
1297 vertexes[5] = (new Vector3((pos.X + rScale.x), (pos.Y + rScale.y), (pos.Z + rScale.z))); 1211 vertexes[5] = (new Vector3((pos.X + rScale.x), (pos.Y + rScale.y), (pos.Z + rScale.z)));
1298 1212
1299 // vertexes[5].x = pos.X + vertexes[5].x; 1213 // vertexes[5].x = pos.X + vertexes[5].x;
1300 // vertexes[5].y = pos.Y + vertexes[5].y; 1214 // vertexes[5].y = pos.Y + vertexes[5].y;
1301 // vertexes[5].z = pos.Z + vertexes[5].z; 1215 // vertexes[5].z = pos.Z + vertexes[5].z;
1302 1216
1303 FaceD[1] = vertexes[5]; 1217 FaceD[1] = vertexes[5];
1304 FaceC[2] = vertexes[5]; 1218 FaceC[2] = vertexes[5];
@@ -1308,9 +1222,9 @@ namespace OpenSim.Region.Environment.Scenes
1308 rScale = ((AXrot * tScale)); 1222 rScale = ((AXrot * tScale));
1309 vertexes[6] = (new Vector3((pos.X + rScale.x), (pos.Y + rScale.y), (pos.Z + rScale.z))); 1223 vertexes[6] = (new Vector3((pos.X + rScale.x), (pos.Y + rScale.y), (pos.Z + rScale.z)));
1310 1224
1311 // vertexes[6].x = pos.X + vertexes[6].x; 1225 // vertexes[6].x = pos.X + vertexes[6].x;
1312 // vertexes[6].y = pos.Y + vertexes[6].y; 1226 // vertexes[6].y = pos.Y + vertexes[6].y;
1313 // vertexes[6].z = pos.Z + vertexes[6].z; 1227 // vertexes[6].z = pos.Z + vertexes[6].z;
1314 1228
1315 FaceB[2] = vertexes[6]; 1229 FaceB[2] = vertexes[6];
1316 FaceA[3] = vertexes[6]; 1230 FaceA[3] = vertexes[6];
@@ -1320,36 +1234,35 @@ namespace OpenSim.Region.Environment.Scenes
1320 rScale = ((AXrot * tScale)); 1234 rScale = ((AXrot * tScale));
1321 vertexes[7] = (new Vector3((pos.X + rScale.x), (pos.Y + rScale.y), (pos.Z + rScale.z))); 1235 vertexes[7] = (new Vector3((pos.X + rScale.x), (pos.Y + rScale.y), (pos.Z + rScale.z)));
1322 1236
1323 // vertexes[7].x = pos.X + vertexes[7].x; 1237 // vertexes[7].x = pos.X + vertexes[7].x;
1324 // vertexes[7].y = pos.Y + vertexes[7].y; 1238 // vertexes[7].y = pos.Y + vertexes[7].y;
1325 // vertexes[7].z = pos.Z + vertexes[7].z; 1239 // vertexes[7].z = pos.Z + vertexes[7].z;
1326 1240
1327 FaceD[2] = vertexes[7]; 1241 FaceD[2] = vertexes[7];
1328 FaceC[3] = vertexes[7]; 1242 FaceC[3] = vertexes[7];
1329 FaceD[5] = vertexes[7]; 1243 FaceD[5] = vertexes[7];
1330
1331 #endregion 1244 #endregion
1332 1245
1333 // Get our plane normals 1246 // Get our plane normals
1334 for (int i = 0; i < 6; i++) 1247 for (int i = 0; i < 6; i++)
1335 { 1248 {
1336 //m_log.Info("[FACECALCULATION]: FaceA[" + i + "]=" + FaceA[i] + " FaceB[" + i + "]=" + FaceB[i] + " FaceC[" + i + "]=" + FaceC[i] + " FaceD[" + i + "]=" + FaceD[i]); 1249 //m_log.Info("[FACECALCULATION]: FaceA[" + i + "]=" + FaceA[i] + " FaceB[" + i + "]=" + FaceB[i] + " FaceC[" + i + "]=" + FaceC[i] + " FaceD[" + i + "]=" + FaceD[i]);
1337 1250
1338 // Our Plane direction 1251 // Our Plane direction
1339 AmBa = FaceA[i] - FaceB[i]; 1252 AmBa = FaceA[i] - FaceB[i];
1340 AmBb = FaceB[i] - FaceC[i]; 1253 AmBb = FaceB[i] - FaceC[i];
1341 1254
1342 cross = AmBb.Cross(AmBa); 1255 cross = AmBb.Cross(AmBa);
1343 1256
1344 // normalize the cross product to get the normal. 1257 // normalize the cross product to get the normal.
1345 normals[i] = cross / cross.Length; 1258 normals[i] = cross / cross.Length;
1346 1259
1347 //m_log.Info("[NORMALS]: normals[ " + i + "]" + normals[i].ToString()); 1260 //m_log.Info("[NORMALS]: normals[ " + i + "]" + normals[i].ToString());
1348 //distance[i] = (normals[i].x * AmBa.x + normals[i].y * AmBa.y + normals[i].z * AmBa.z) * -1; 1261 //distance[i] = (normals[i].x * AmBa.x + normals[i].y * AmBa.y + normals[i].z * AmBa.z) * -1;
1349 } 1262 }
1350 1263
1351 EntityIntersection returnresult = new EntityIntersection(); 1264 EntityIntersection returnresult = new EntityIntersection();
1352 1265
1353 returnresult.distance = 1024; 1266 returnresult.distance = 1024;
1354 float c = 0; 1267 float c = 0;
1355 float a = 0; 1268 float a = 0;
@@ -1357,59 +1270,57 @@ namespace OpenSim.Region.Environment.Scenes
1357 Vector3 q = new Vector3(); 1270 Vector3 q = new Vector3();
1358 1271
1359 #region OBB Version 2 Experiment 1272 #region OBB Version 2 Experiment
1360
1361 //float fmin = 999999; 1273 //float fmin = 999999;
1362 //float fmax = -999999; 1274 //float fmax = -999999;
1363 //float s = 0; 1275 //float s = 0;
1364 1276
1365 //for (int i=0;i<6;i++) 1277 //for (int i=0;i<6;i++)
1366 //{ 1278 //{
1367 //s = iray.Direction.Dot(normals[i]); 1279 //s = iray.Direction.Dot(normals[i]);
1368 //d = normals[i].Dot(FaceB[i]); 1280 //d = normals[i].Dot(FaceB[i]);
1369 1281
1370 //if (s == 0) 1282 //if (s == 0)
1371 //{ 1283 //{
1372 //if (iray.Origin.Dot(normals[i]) > d) 1284 //if (iray.Origin.Dot(normals[i]) > d)
1373 //{ 1285 //{
1374 //return returnresult; 1286 //return returnresult;
1375 //} 1287 //}
1376 // else 1288 // else
1377 //{ 1289 //{
1378 //continue; 1290 //continue;
1379 //} 1291 //}
1380 //} 1292 //}
1381 //a = (d - iray.Origin.Dot(normals[i])) / s; 1293 //a = (d - iray.Origin.Dot(normals[i])) / s;
1382 //if ( iray.Direction.Dot(normals[i]) < 0) 1294 //if ( iray.Direction.Dot(normals[i]) < 0)
1383 //{ 1295 //{
1384 //if (a > fmax) 1296 //if (a > fmax)
1385 //{ 1297 //{
1386 //if (a > fmin) 1298 //if (a > fmin)
1387 //{ 1299 //{
1388 //return returnresult; 1300 //return returnresult;
1389 //} 1301 //}
1390 //fmax = a; 1302 //fmax = a;
1391 //} 1303 //}
1392 1304
1393 //} 1305 //}
1394 //else 1306 //else
1395 //{ 1307 //{
1396 //if (a < fmin) 1308 //if (a < fmin)
1397 //{ 1309 //{
1398 //if (a < 0 || a < fmax) 1310 //if (a < 0 || a < fmax)
1399 //{ 1311 //{
1400 //return returnresult; 1312 //return returnresult;
1401 //} 1313 //}
1402 //fmin = a; 1314 //fmin = a;
1403 //} 1315 //}
1404 //} 1316 //}
1405 //} 1317 //}
1406 //if (fmax > 0) 1318 //if (fmax > 0)
1407 // a= fmax; 1319 // a= fmax;
1408 //else 1320 //else
1409 // a=fmin; 1321 // a=fmin;
1410 1322
1411 //q = iray.Origin + a * iray.Direction; 1323 //q = iray.Origin + a * iray.Direction;
1412
1413 #endregion 1324 #endregion
1414 1325
1415 // Loop over faces (6 of them) 1326 // Loop over faces (6 of them)
@@ -1430,6 +1341,7 @@ namespace OpenSim.Region.Environment.Scenes
1430 // If the normal is pointing outside the object 1341 // If the normal is pointing outside the object
1431 if (iray.Direction.Dot(normals[i]) < 0 || !frontFacesOnly) 1342 if (iray.Direction.Dot(normals[i]) < 0 || !frontFacesOnly)
1432 { 1343 {
1344
1433 if (faceCenters) 1345 if (faceCenters)
1434 { 1346 {
1435 q = AXpos + a * AAfacenormals[i]; //(FaceA[i] + FaceB[i] + FaceC[1] + FaceD[i]) / 4f; 1347 q = AXpos + a * AAfacenormals[i]; //(FaceA[i] + FaceB[i] + FaceC[1] + FaceD[i]) / 4f;
@@ -1439,13 +1351,13 @@ namespace OpenSim.Region.Environment.Scenes
1439 q = iray.Origin + a * iray.Direction; 1351 q = iray.Origin + a * iray.Direction;
1440 } 1352 }
1441 1353
1442 float distance2 = (float) GetDistanceTo(q, AXpos); 1354 float distance2 = (float)GetDistanceTo(q, AXpos);
1443 // Is this the closest hit to the object's origin? 1355 // Is this the closest hit to the object's origin?
1444 if (faceCenters) 1356 if (faceCenters)
1445 { 1357 {
1446 distance2 = (float) GetDistanceTo(q, iray.Origin); 1358 distance2 = (float)GetDistanceTo(q, iray.Origin);
1447 } 1359 }
1448 1360
1449 1361
1450 if (distance2 < returnresult.distance) 1362 if (distance2 < returnresult.distance)
1451 { 1363 {
@@ -1456,12 +1368,14 @@ namespace OpenSim.Region.Environment.Scenes
1456 //m_log.Info("[POINT]: " + q.ToString()); 1368 //m_log.Info("[POINT]: " + q.ToString());
1457 returnresult.normal = normals[i]; 1369 returnresult.normal = normals[i];
1458 returnresult.AAfaceNormal = AAfacenormals[i]; 1370 returnresult.AAfaceNormal = AAfacenormals[i];
1371
1459 } 1372 }
1460 } 1373 }
1374
1461 } 1375 }
1462 return returnresult; 1376 return returnresult;
1463 } 1377 }
1464 1378
1465 // Use this for attachments! LocalID should be avatar's localid 1379 // Use this for attachments! LocalID should be avatar's localid
1466 public void SetParentLocalId(uint localID) 1380 public void SetParentLocalId(uint localID)
1467 { 1381 {
@@ -1471,14 +1385,14 @@ namespace OpenSim.Region.Environment.Scenes
1471 public void SetAttachmentPoint(uint AttachmentPoint) 1385 public void SetAttachmentPoint(uint AttachmentPoint)
1472 { 1386 {
1473 m_attachmentPoint = AttachmentPoint; 1387 m_attachmentPoint = AttachmentPoint;
1474 1388
1475 // save the attachment point. 1389 // save the attachment point.
1476 //if (AttachmentPoint != 0) 1390 //if (AttachmentPoint != 0)
1477 //{ 1391 //{
1478 m_shape.State = (byte) AttachmentPoint; 1392 m_shape.State = (byte)AttachmentPoint;
1479 //} 1393 //}
1394
1480 } 1395 }
1481
1482 /// <summary> 1396 /// <summary>
1483 /// 1397 ///
1484 /// </summary> 1398 /// </summary>
@@ -1500,12 +1414,13 @@ namespace OpenSim.Region.Environment.Scenes
1500 PhysActor.Buoyancy = fvalue; 1414 PhysActor.Buoyancy = fvalue;
1501 } 1415 }
1502 } 1416 }
1503 1417
1504 public void SetAxisRotation(int axis, int rotate) 1418 public void SetAxisRotation(int axis, int rotate)
1505 { 1419 {
1506 if (m_parentGroup != null) 1420 if (m_parentGroup != null)
1507 { 1421 {
1508 m_parentGroup.SetAxisRotation(axis, rotate); 1422 m_parentGroup.SetAxisRotation(axis, rotate);
1423
1509 } 1424 }
1510 } 1425 }
1511 1426
@@ -1527,9 +1442,10 @@ namespace OpenSim.Region.Environment.Scenes
1527 { 1442 {
1528 PhysActor.FloatOnWater = false; 1443 PhysActor.FloatOnWater = false;
1529 } 1444 }
1445
1530 } 1446 }
1531 } 1447 }
1532 1448
1533 1449
1534 public LLVector3 GetSitTargetPositionLL() 1450 public LLVector3 GetSitTargetPositionLL()
1535 { 1451 {
@@ -1600,403 +1516,66 @@ namespace OpenSim.Region.Environment.Scenes
1600 return part; 1516 return part;
1601 } 1517 }
1602 1518
1603 /// <summary> 1519 #region Copying
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.
1606 /// </summary>
1607 /// <param name="linkNum">Link number for the part</param>
1608 public void ResetIDs(int linkNum)
1609 {
1610 UUID = LLUUID.Random();
1611 LinkNum = linkNum;
1612
1613 ResetInventoryIDs();
1614 }
1615
1616 public void UpdatePermissions(LLUUID AgentID, byte field, uint localID, uint mask, byte addRemTF)
1617 {
1618 bool set = addRemTF == 1;
1619
1620 // Are we the owner?
1621 if (AgentID == OwnerID)
1622 {
1623 switch (field)
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();
1639
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();
1817 }
1818
1819 #endregion
1820
1821 #region Client Update Methods
1822
1823 /// <summary>
1824 /// Tell all scene presences that they should send updates for this part to their clients
1825 /// </summary>
1826 public void AddFullUpdateToAllAvatars()
1827 {
1828 List<ScenePresence> avatars = m_parentGroup.GetScenePresences();
1829 for (int i = 0; i < avatars.Count; i++)
1830 {
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 1520
1890 /// <summary> 1521 /// <summary>
1891 /// Sends a full update to the client 1522 /// Duplicates this part.
1892 /// </summary> 1523 /// </summary>
1893 /// <param name="remoteClient"></param> 1524 /// <returns></returns>
1894 /// <param name="lPos"></param> 1525 public SceneObjectPart Copy(uint localID, LLUUID AgentID, LLUUID GroupID, int linkNum)
1895 /// <param name="clientFlags"></param>
1896 public void SendFullUpdateToClient(IClientAPI remoteClient, LLVector3 lPos, uint clientFlags)
1897 { 1526 {
1898 LLQuaternion lRot; 1527 SceneObjectPart dupe = (SceneObjectPart) MemberwiseClone();
1899 lRot = RotationOffset; 1528 dupe.m_shape = m_shape.Copy();
1900 clientFlags &= ~(uint) LLObject.ObjectFlags.CreateSelected; 1529 dupe.m_regionHandle = m_regionHandle;
1901 1530 dupe.UUID = LLUUID.Random();
1902 if (remoteClient.AgentId == OwnerID) 1531 dupe.LocalId = localID;
1903 { 1532 dupe.OwnerID = AgentID;
1904 if ((uint) (Flags & LLObject.ObjectFlags.CreateSelected) != 0) 1533 dupe.GroupID = GroupID;
1905 { 1534 dupe.GroupPosition = new LLVector3(GroupPosition.X, GroupPosition.Y, GroupPosition.Z);
1906 clientFlags |= (uint) LLObject.ObjectFlags.CreateSelected; 1535 dupe.OffsetPosition = new LLVector3(OffsetPosition.X, OffsetPosition.Y, OffsetPosition.Z);
1907 Flags &= ~LLObject.ObjectFlags.CreateSelected; 1536 dupe.RotationOffset =
1908 } 1537 new LLQuaternion(RotationOffset.X, RotationOffset.Y, RotationOffset.Z, RotationOffset.W);
1909 } 1538 dupe.Velocity = new LLVector3(0, 0, 0);
1910 1539 dupe.Acceleration = new LLVector3(0, 0, 0);
1540 dupe.AngularVelocity = new LLVector3(0, 0, 0);
1541 dupe.ObjectFlags = ObjectFlags;
1911 1542
1912 byte[] color = new[] {m_color.R, m_color.G, m_color.B, m_color.A}; 1543 dupe.OwnershipCost = OwnershipCost;
1913 remoteClient.SendPrimitiveToClient(m_regionHandle, (ushort) (m_parentGroup.GetTimeDilation() * ushort.MaxValue), LocalId, m_shape, lPos, clientFlags, 1544 dupe.ObjectSaleType = ObjectSaleType;
1914 m_uuid, 1545 dupe.SalePrice = SalePrice;
1915 OwnerID, 1546 dupe.Category = Category;
1916 m_text, color, ParentID, m_particleSystem, lRot, m_clickAction, m_TextureAnimation, m_IsAttachment, 1547
1917 m_attachmentPoint, fromAssetID); 1548 dupe.TaskInventory = (TaskInventoryDictionary)dupe.TaskInventory.Clone();
1918 } 1549
1550 dupe.ResetIDs(linkNum);
1919 1551
1920 /// Terse updates 1552 // This may be wrong... it might have to be applied in SceneObjectGroup to the object that's being duplicated.
1921 public void AddTerseUpdateToAllAvatars() 1553 dupe.LastOwnerID = ObjectOwner;
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 1554
1930 public void AddTerseUpdateToAvatar(ScenePresence presence) 1555 byte[] extraP = new byte[Shape.ExtraParams.Length];
1931 { 1556 Array.Copy(Shape.ExtraParams, extraP, extraP.Length);
1932 presence.QueuePartForUpdate(this); 1557 dupe.Shape.ExtraParams = extraP;
1933 } 1558 bool UsePhysics = ((dupe.ObjectFlags & (uint) LLObject.ObjectFlags.Physics) != 0);
1559 dupe.DoPhysicsPropertyUpdate(UsePhysics, true);
1934 1560
1935 /// <summary> 1561 return dupe;
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 } 1562 }
1946 1563
1564 #endregion
1565
1947 /// <summary> 1566 /// <summary>
1948 /// Send a terse update to the client. 1567 /// Reset LLUUIDs for this part. This involves generate this part's own LLUUID and
1568 /// generating new LLUUIDs for all the items in the inventory.
1949 /// </summary> 1569 /// </summary>
1950 /// <param name="remoteClient"></param> 1570 /// <param name="linkNum">Link number for the part</param>
1951 public void SendTerseUpdate(IClientAPI remoteClient) 1571 public void ResetIDs(int linkNum)
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 { 1572 {
1976 LLQuaternion mRot = RotationOffset; 1573 UUID = LLUUID.Random();
1977 if (m_IsAttachment) 1574 LinkNum = linkNum;
1978 { 1575
1979 remoteClient.SendPrimTerseUpdate(m_regionHandle, (ushort) (m_parentGroup.GetTimeDilation() * ushort.MaxValue), LocalId, lPos, mRot, 1576 ResetInventoryIDs();
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 }
1996 } 1577 }
1997 1578
1998 #endregion
1999
2000 #region Update Scheduling 1579 #region Update Scheduling
2001 1580
2002 /// <summary> 1581 /// <summary>
@@ -2017,9 +1596,9 @@ namespace OpenSim.Region.Environment.Scenes
2017 m_parentGroup.HasGroupChanged = true; 1596 m_parentGroup.HasGroupChanged = true;
2018 m_parentGroup.QueueForUpdateCheck(); 1597 m_parentGroup.QueueForUpdateCheck();
2019 } 1598 }
2020 1599
2021 int timeNow = Util.UnixTimeSinceEpoch(); 1600 int timeNow = Util.UnixTimeSinceEpoch();
2022 1601
2023 // If multiple updates are scheduled on the same second, we still need to perform all of them 1602 // If multiple updates are scheduled on the same second, we still need to perform all of them
2024 // So we'll force the issue by bumping up the timestamp so that later processing sees these need 1603 // So we'll force the issue by bumping up the timestamp so that later processing sees these need
2025 // to be performed. 1604 // to be performed.
@@ -2029,11 +1608,11 @@ namespace OpenSim.Region.Environment.Scenes
2029 } 1608 }
2030 else 1609 else
2031 { 1610 {
2032 TimeStampFull = (uint) timeNow; 1611 TimeStampFull = (uint)timeNow;
2033 } 1612 }
2034 1613
2035 m_updateFlag = 2; 1614 m_updateFlag = 2;
2036 1615
2037// m_log.DebugFormat( 1616// m_log.DebugFormat(
2038// "[SCENE OBJECT PART]: Scheduling full update for {0}, {1} at {2}", 1617// "[SCENE OBJECT PART]: Scheduling full update for {0}, {1} at {2}",
2039// UUID, Name, TimeStampFull); 1618// UUID, Name, TimeStampFull);
@@ -2156,13 +1735,15 @@ namespace OpenSim.Region.Environment.Scenes
2156 1735
2157 public void UpdatePrimFlags(ushort type, bool inUse, byte[] data) 1736 public void UpdatePrimFlags(ushort type, bool inUse, byte[] data)
2158 { 1737 {
1738
1739
2159 //m_log.Info("TSomething1:" + ((type & (ushort)ExtraParamType.Something1) == (ushort)ExtraParamType.Something1)); 1740 //m_log.Info("TSomething1:" + ((type & (ushort)ExtraParamType.Something1) == (ushort)ExtraParamType.Something1));
2160 //m_log.Info("TSomething2:" + ((type & (ushort)ExtraParamType.Something2) == (ushort)ExtraParamType.Something2)); 1741 //m_log.Info("TSomething2:" + ((type & (ushort)ExtraParamType.Something2) == (ushort)ExtraParamType.Something2));
2161 //m_log.Info("TSomething3:" + ((type & (ushort)ExtraParamType.Something3) == (ushort)ExtraParamType.Something3)); 1742 //m_log.Info("TSomething3:" + ((type & (ushort)ExtraParamType.Something3) == (ushort)ExtraParamType.Something3));
2162 //m_log.Info("TSomething4:" + ((type & (ushort)ExtraParamType.Something4) == (ushort)ExtraParamType.Something4)); 1743 //m_log.Info("TSomething4:" + ((type & (ushort)ExtraParamType.Something4) == (ushort)ExtraParamType.Something4));
2163 //m_log.Info("TSomething5:" + ((type & (ushort)ExtraParamType.Something5) == (ushort)ExtraParamType.Something5)); 1744 //m_log.Info("TSomething5:" + ((type & (ushort)ExtraParamType.Something5) == (ushort)ExtraParamType.Something5));
2164 //m_log.Info("TSomething6:" + ((type & (ushort)ExtraParamType.Something6) == (ushort)ExtraParamType.Something6)); 1745 //m_log.Info("TSomething6:" + ((type & (ushort)ExtraParamType.Something6) == (ushort)ExtraParamType.Something6));
2165 1746
2166 bool usePhysics = false; 1747 bool usePhysics = false;
2167 bool IsTemporary = false; 1748 bool IsTemporary = false;
2168 bool IsPhantom = false; 1749 bool IsPhantom = false;
@@ -2170,7 +1751,7 @@ namespace OpenSim.Region.Environment.Scenes
2170 bool wasUsingPhysics = ((ObjectFlags & (uint) LLObject.ObjectFlags.Physics) != 0); 1751 bool wasUsingPhysics = ((ObjectFlags & (uint) LLObject.ObjectFlags.Physics) != 0);
2171 //bool IsLocked = false; 1752 //bool IsLocked = false;
2172 int i = 0; 1753 int i = 0;
2173 1754
2174 1755
2175 try 1756 try
2176 { 1757 {
@@ -2254,7 +1835,6 @@ namespace OpenSim.Region.Environment.Scenes
2254 // System.Console.WriteLine("Update: PHY:" + UsePhysics.ToString() + ", T:" + IsTemporary.ToString() + ", PHA:" + IsPhantom.ToString() + " S:" + CastsShadows.ToString()); 1835 // System.Console.WriteLine("Update: PHY:" + UsePhysics.ToString() + ", T:" + IsTemporary.ToString() + ", PHA:" + IsPhantom.ToString() + " S:" + CastsShadows.ToString());
2255 ScheduleFullUpdate(); 1836 ScheduleFullUpdate();
2256 } 1837 }
2257
2258 public void ScriptSetPhysicsStatus(bool UsePhysics) 1838 public void ScriptSetPhysicsStatus(bool UsePhysics)
2259 { 1839 {
2260 if (m_parentGroup != null) 1840 if (m_parentGroup != null)
@@ -2262,7 +1842,6 @@ namespace OpenSim.Region.Environment.Scenes
2262 m_parentGroup.ScriptSetPhysicsStatus(UsePhysics); 1842 m_parentGroup.ScriptSetPhysicsStatus(UsePhysics);
2263 } 1843 }
2264 } 1844 }
2265
2266 public void ScriptSetPhantomStatus(bool Phantom) 1845 public void ScriptSetPhantomStatus(bool Phantom)
2267 { 1846 {
2268 if (m_parentGroup != null) 1847 if (m_parentGroup != null)
@@ -2270,7 +1849,6 @@ namespace OpenSim.Region.Environment.Scenes
2270 m_parentGroup.ScriptSetPhantomStatus(Phantom); 1849 m_parentGroup.ScriptSetPhantomStatus(Phantom);
2271 } 1850 }
2272 } 1851 }
2273
2274 public void DoPhysicsPropertyUpdate(bool UsePhysics, bool isNew) 1852 public void DoPhysicsPropertyUpdate(bool UsePhysics, bool isNew)
2275 { 1853 {
2276 if (PhysActor != null) 1854 if (PhysActor != null)
@@ -2319,6 +1897,7 @@ namespace OpenSim.Region.Environment.Scenes
2319 PhysActor.link(ParentGroup.RootPart.PhysActor); 1897 PhysActor.link(ParentGroup.RootPart.PhysActor);
2320 } 1898 }
2321 } 1899 }
1900
2322 } 1901 }
2323 } 1902 }
2324 } 1903 }
@@ -2332,13 +1911,13 @@ namespace OpenSim.Region.Environment.Scenes
2332 int i = 0; 1911 int i = 0;
2333 uint length = (uint) data.Length; 1912 uint length = (uint) data.Length;
2334 m_shape.ExtraParams[i++] = 1; 1913 m_shape.ExtraParams[i++] = 1;
2335 m_shape.ExtraParams[i++] = (byte) (type % 256); 1914 m_shape.ExtraParams[i++] = (byte) (type%256);
2336 m_shape.ExtraParams[i++] = (byte) ((type >> 8) % 256); 1915 m_shape.ExtraParams[i++] = (byte) ((type >> 8)%256);
2337 1916
2338 m_shape.ExtraParams[i++] = (byte) (length % 256); 1917 m_shape.ExtraParams[i++] = (byte) (length%256);
2339 m_shape.ExtraParams[i++] = (byte) ((length >> 8) % 256); 1918 m_shape.ExtraParams[i++] = (byte) ((length >> 8)%256);
2340 m_shape.ExtraParams[i++] = (byte) ((length >> 16) % 256); 1919 m_shape.ExtraParams[i++] = (byte) ((length >> 16)%256);
2341 m_shape.ExtraParams[i++] = (byte) ((length >> 24) % 256); 1920 m_shape.ExtraParams[i++] = (byte) ((length >> 24)%256);
2342 Array.Copy(data, 0, m_shape.ExtraParams, i, data.Length); 1921 Array.Copy(data, 0, m_shape.ExtraParams, i, data.Length);
2343 1922
2344 ScheduleFullUpdate(); 1923 ScheduleFullUpdate();
@@ -2416,14 +1995,14 @@ namespace OpenSim.Region.Environment.Scenes
2416 1995
2417 public byte ConvertScriptUintToByte(uint indata) 1996 public byte ConvertScriptUintToByte(uint indata)
2418 { 1997 {
2419 byte outdata = (byte) TextureAnimFlags.NONE; 1998 byte outdata = (byte)TextureAnimFlags.NONE;
2420 if ((indata & 1) != 0) outdata |= (byte) TextureAnimFlags.ANIM_ON; 1999 if ((indata & 1) != 0) outdata |= (byte)TextureAnimFlags.ANIM_ON;
2421 if ((indata & 2) != 0) outdata |= (byte) TextureAnimFlags.LOOP; 2000 if ((indata & 2) != 0) outdata |= (byte)TextureAnimFlags.LOOP;
2422 if ((indata & 4) != 0) outdata |= (byte) TextureAnimFlags.REVERSE; 2001 if ((indata & 4) != 0) outdata |= (byte)TextureAnimFlags.REVERSE;
2423 if ((indata & 8) != 0) outdata |= (byte) TextureAnimFlags.PING_PONG; 2002 if ((indata & 8) != 0) outdata |= (byte)TextureAnimFlags.PING_PONG;
2424 if ((indata & 16) != 0) outdata |= (byte) TextureAnimFlags.SMOOTH; 2003 if ((indata & 16) != 0) outdata |= (byte)TextureAnimFlags.SMOOTH;
2425 if ((indata & 32) != 0) outdata |= (byte) TextureAnimFlags.ROTATE; 2004 if ((indata & 32) != 0) outdata |= (byte)TextureAnimFlags.ROTATE;
2426 if ((indata & 64) != 0) outdata |= (byte) TextureAnimFlags.SCALE; 2005 if ((indata & 64) != 0) outdata |= (byte)TextureAnimFlags.SCALE;
2427 return outdata; 2006 return outdata;
2428 } 2007 }
2429 2008
@@ -2435,17 +2014,13 @@ namespace OpenSim.Region.Environment.Scenes
2435 // The flags don't like conversion from uint to byte, so we have to do 2014 // The flags don't like conversion from uint to byte, so we have to do
2436 // it the crappy way. See the above function :( 2015 // it the crappy way. See the above function :(
2437 2016
2438 data[pos] = ConvertScriptUintToByte(pTexAnim.Flags); 2017 data[pos] = ConvertScriptUintToByte(pTexAnim.Flags); pos++;
2439 pos++; 2018 data[pos] = (byte)pTexAnim.Face; pos++;
2440 data[pos] = (byte) pTexAnim.Face; 2019 data[pos] = (byte)pTexAnim.SizeX; pos++;
2441 pos++; 2020 data[pos] = (byte)pTexAnim.SizeY; pos++;
2442 data[pos] = (byte) pTexAnim.SizeX;
2443 pos++;
2444 data[pos] = (byte) pTexAnim.SizeY;
2445 pos++;
2446 2021
2447 Helpers.FloatToBytes(pTexAnim.Start).CopyTo(data, pos); 2022 Helpers.FloatToBytes(pTexAnim.Start).CopyTo(data, pos);
2448 Helpers.FloatToBytes(pTexAnim.Length).CopyTo(data, pos + 4); 2023 Helpers.FloatToBytes(pTexAnim.Length ).CopyTo(data, pos + 4);
2449 Helpers.FloatToBytes(pTexAnim.Rate).CopyTo(data, pos + 8); 2024 Helpers.FloatToBytes(pTexAnim.Rate).CopyTo(data, pos + 8);
2450 2025
2451 m_TextureAnimation = data; 2026 m_TextureAnimation = data;
@@ -2496,7 +2071,6 @@ namespace OpenSim.Region.Environment.Scenes
2496 #endregion 2071 #endregion
2497 2072
2498 #region Sound 2073 #region Sound
2499
2500 public void PreloadSound(string sound) 2074 public void PreloadSound(string sound)
2501 { 2075 {
2502 LLUUID ownerID = OwnerID; 2076 LLUUID ownerID = OwnerID;
@@ -2522,7 +2096,7 @@ namespace OpenSim.Region.Environment.Scenes
2522 foreach (ScenePresence p in avatarts) 2096 foreach (ScenePresence p in avatarts)
2523 { 2097 {
2524 // TODO: some filtering by distance of avatar 2098 // TODO: some filtering by distance of avatar
2525 2099
2526 p.ControllingClient.SendPreLoadSound(objectID, objectID, soundID); 2100 p.ControllingClient.SendPreLoadSound(objectID, objectID, soundID);
2527 } 2101 }
2528 } 2102 }
@@ -2537,7 +2111,7 @@ namespace OpenSim.Region.Environment.Scenes
2537 List<ScenePresence> avatarts = m_parentGroup.Scene.GetAvatars(); 2111 List<ScenePresence> avatarts = m_parentGroup.Scene.GetAvatars();
2538 foreach (ScenePresence p in avatarts) 2112 foreach (ScenePresence p in avatarts)
2539 { 2113 {
2540 p.ControllingClient.SendAttachedSoundGainChange(UUID, (float) volume); 2114 p.ControllingClient.SendAttachedSoundGainChange(UUID, (float)volume);
2541 } 2115 }
2542 } 2116 }
2543 2117
@@ -2563,7 +2137,7 @@ namespace OpenSim.Region.Environment.Scenes
2563 SceneObjectPart op = this; 2137 SceneObjectPart op = this;
2564 foreach (KeyValuePair<LLUUID, TaskInventoryItem> item in op.TaskInventory) 2138 foreach (KeyValuePair<LLUUID, TaskInventoryItem> item in op.TaskInventory)
2565 { 2139 {
2566 if (item.Value.Name == sound && item.Value.Type == (int) AssetType.Sound) 2140 if (item.Value.Name == sound && item.Value.Type == (int)AssetType.Sound)
2567 { 2141 {
2568 soundID = item.Value.ItemID; 2142 soundID = item.Value.ItemID;
2569 break; 2143 break;
@@ -2571,26 +2145,26 @@ namespace OpenSim.Region.Environment.Scenes
2571 } 2145 }
2572 } 2146 }
2573 2147
2574 if (soundID == LLUUID.Zero) 2148 if(soundID == LLUUID.Zero)
2575 return; 2149 return;
2576 2150
2577 List<ScenePresence> avatarts = m_parentGroup.Scene.GetAvatars(); 2151 List<ScenePresence> avatarts = m_parentGroup.Scene.GetAvatars();
2578 foreach (ScenePresence p in avatarts) 2152 foreach (ScenePresence p in avatarts)
2579 { 2153 {
2580 double dis = Util.GetDistanceTo(p.AbsolutePosition, position); 2154 double dis=Util.GetDistanceTo(p.AbsolutePosition, position);
2581 if (dis > 100.0) // Max audio distance 2155 if(dis > 100.0) // Max audio distance
2582 continue; 2156 continue;
2583 2157
2584 // Scale by distance 2158 // Scale by distance
2585 volume *= ((100.0 - dis) / 100.0); 2159 volume*=((100.0-dis)/100.0);
2586 2160
2587 if (triggered) 2161 if (triggered)
2588 { 2162 {
2589 p.ControllingClient.SendTriggeredSound(soundID, ownerID, objectID, parentID, regionHandle, position, (float) volume); 2163 p.ControllingClient.SendTriggeredSound(soundID, ownerID, objectID, parentID, regionHandle, position, (float)volume);
2590 } 2164 }
2591 else 2165 else
2592 { 2166 {
2593 p.ControllingClient.SendPlayAttachedSound(soundID, objectID, ownerID, (float) volume, flags); 2167 p.ControllingClient.SendPlayAttachedSound(soundID, objectID, ownerID, (float)volume, flags);
2594 } 2168 }
2595 } 2169 }
2596 } 2170 }
@@ -2607,57 +2181,513 @@ namespace OpenSim.Region.Environment.Scenes
2607 { 2181 {
2608 StoreUndoState(); 2182 StoreUndoState();
2609 m_shape.Scale = scale; 2183 m_shape.Scale = scale;
2610 2184
2611 ScheduleFullUpdate(); 2185 ScheduleFullUpdate();
2612 } 2186 }
2613 2187
2614 #endregion 2188 #endregion
2615 2189
2616 #region Copying 2190 public void UpdatePermissions(LLUUID AgentID, byte field, uint localID, uint mask, byte addRemTF)
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 }
2617 2243
2244 #region Client Update Methods
2245
2618 /// <summary> 2246 /// <summary>
2619 /// Duplicates this part. 2247 /// Tell all scene presences that they should send updates for this part to their clients
2620 /// </summary> 2248 /// </summary>
2621 /// <returns></returns> 2249 public void AddFullUpdateToAllAvatars()
2622 public SceneObjectPart Copy(uint localID, LLUUID AgentID, LLUUID GroupID, int linkNum)
2623 { 2250 {
2624 SceneObjectPart dupe = (SceneObjectPart) MemberwiseClone(); 2251 List<ScenePresence> avatars = m_parentGroup.GetScenePresences();
2625 dupe.m_shape = m_shape.Copy(); 2252 for (int i = 0; i < avatars.Count; i++)
2626 dupe.m_regionHandle = m_regionHandle; 2253 {
2627 dupe.UUID = LLUUID.Random(); 2254 avatars[i].QueuePartForUpdate(this);
2628 dupe.LocalId = localID; 2255 }
2629 dupe.OwnerID = AgentID; 2256 }
2630 dupe.GroupID = GroupID;
2631 dupe.GroupPosition = new LLVector3(GroupPosition.X, GroupPosition.Y, GroupPosition.Z);
2632 dupe.OffsetPosition = new LLVector3(OffsetPosition.X, OffsetPosition.Y, OffsetPosition.Z);
2633 dupe.RotationOffset =
2634 new LLQuaternion(RotationOffset.X, RotationOffset.Y, RotationOffset.Z, RotationOffset.W);
2635 dupe.Velocity = new LLVector3(0, 0, 0);
2636 dupe.Acceleration = new LLVector3(0, 0, 0);
2637 dupe.AngularVelocity = new LLVector3(0, 0, 0);
2638 dupe.ObjectFlags = ObjectFlags;
2639 2257
2640 dupe.OwnershipCost = OwnershipCost; 2258 public void SendFullUpdateToAllClientsExcept(LLUUID agentID)
2641 dupe.ObjectSaleType = ObjectSaleType; 2259 {
2642 dupe.SalePrice = SalePrice; 2260 List<ScenePresence> avatars = m_parentGroup.GetScenePresences();
2643 dupe.Category = Category; 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
2644 2272
2645 dupe.TaskInventory = (TaskInventoryDictionary) dupe.TaskInventory.Clone(); 2273 public void AddFullUpdateToAvatar(ScenePresence presence)
2274 {
2275 presence.QueuePartForUpdate(this);
2276 }
2646 2277
2647 dupe.ResetIDs(linkNum); 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 }
2648 2291
2649 // This may be wrong... it might have to be applied in SceneObjectGroup to the object that's being duplicated. 2292 /// <summary>
2650 dupe.LastOwnerID = ObjectOwner; 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 }
2651 2300
2652 byte[] extraP = new byte[Shape.ExtraParams.Length]; 2301 /// <summary>
2653 Array.Copy(Shape.ExtraParams, extraP, extraP.Length); 2302 /// Sends a full update to the client
2654 dupe.Shape.ExtraParams = extraP; 2303 /// </summary>
2655 bool UsePhysics = ((dupe.ObjectFlags & (uint) LLObject.ObjectFlags.Physics) != 0); 2304 /// <param name="remoteClient"></param>
2656 dupe.DoPhysicsPropertyUpdate(UsePhysics, true); 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;
2657 2324
2658 return dupe; 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
2368 /// <summary>
2369 /// Send a terse update to the client.
2370 /// </summary>
2371 /// <param name="remoteClient"></param>
2372 public void SendTerseUpdate(IClientAPI remoteClient)
2373 {
2374 m_parentGroup.SendPartTerseUpdate(remoteClient, this);
2375 }
2376
2377 public void SendTerseUpdateToClient(IClientAPI remoteClient)
2378 {
2379 LLVector3 lPos;
2380 lPos = OffsetPosition;
2381 LLQuaternion mRot = RotationOffset;
2382 if ((ObjectFlags & (uint) LLObject.ObjectFlags.Physics) == 0)
2383 {
2384 remoteClient.SendPrimTerseUpdate(m_regionHandle, (ushort)(m_parentGroup.GetTimeDilation() * (float)ushort.MaxValue), LocalId, lPos, mRot, Shape.State, fromAssetID);
2385 }
2386 else
2387 {
2388 remoteClient.SendPrimTerseUpdate(m_regionHandle, (ushort)(m_parentGroup.GetTimeDilation() * (float)ushort.MaxValue), LocalId, lPos, mRot, Velocity,
2389 RotationalVelocity);
2390 //System.Console.WriteLine("LID: " + LocalID + " RVel:" + RotationalVelocity.ToString() + " TD: " + ((ushort)(m_parentGroup.Scene.TimeDilation * 500000f)).ToString() + ":" + m_parentGroup.Scene.TimeDilation.ToString());
2391 }
2392 }
2393
2394 public void SendTerseUpdateToClient(IClientAPI remoteClient, LLVector3 lPos)
2395 {
2396 LLQuaternion mRot = RotationOffset;
2397 if (m_IsAttachment)
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
2416 #endregion
2417
2418 public virtual void UpdateMovement()
2419 {
2420 }
2421
2422 #region Events
2423
2424 public void PhysicsRequestingTerseUpdate()
2425 {
2426 if (PhysActor != null)
2427 {
2428 LLVector3 newpos = new LLVector3(PhysActor.Position.GetBytes(), 0);
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
2438 //SendTerseUpdateToAllClients();
2659 } 2439 }
2660 2440
2661 #endregion 2441 #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 }
2662 } 2692 }
2663} \ No newline at end of file 2693}
diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs
index 4cdf7f1..74e9cdc 100644
--- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs
@@ -40,111 +40,117 @@ 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 50
51 #region Delegates
52
53 public delegate void SignificantClientMovement(IClientAPI remote_client);
54
55 #endregion
56
57 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 51 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
58 52
59 public static AvatarAnimations Animations = new AvatarAnimations(); 53 public static AvatarAnimations Animations = new AvatarAnimations();
60 public static byte[] DefaultTexture; 54 public static byte[] DefaultTexture;
61 private readonly Vector3[] Dir_Vectors = new Vector3[6];
62 private readonly uint m_AgentControlFlags = 0;
63 55
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; 56 public LLUUID currentParcelUUID = LLUUID.Zero;
74 private SignificantClientMovement handlerSignificantClientMovement; //OnSignificantClientMovement; 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;
75 61
76 public bool IsRestrictedToRegion; 62 private bool m_updateflag = false;
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
72 private int m_perfMonMS = 0;
73
74 private bool m_setAlwaysRun = false;
75
76 private Quaternion m_bodyRot;
77
78 public bool IsRestrictedToRegion = false;
77 79
78 public string JID = string.Empty; 80 public string JID = string.Empty;
79 public Vector3 lastKnownAllowedPosition;
80 81
81 // Agent moves with a PID controller causing a force to be exerted. 82 // Agent moves with a PID controller causing a force to be exerted.
82 private LLVector3 lastPhysPos; 83 private bool m_newForce = false;
83 protected AvatarAppearance m_appearance; 84 private bool m_newCoarseLocations = true;
85 private bool m_gotAllObjectsInScene = false;
84 86
85 protected List<SceneObjectGroup> m_attachments = new List<SceneObjectGroup>(); 87 private LLVector3 m_lastVelocity = LLVector3.Zero;
88
89 // Default AV Height
86 private float m_avHeight = 127.0f; 90 private float m_avHeight = 127.0f;
87 private Quaternion m_bodyRot; 91
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();
88 97
89 // Position of agent's camera in world (region cordinates) 98 // Position of agent's camera in world (region cordinates)
99 protected Vector3 m_CameraCenter = new Vector3(0, 0, 0);
90 100
91 // Use these three vectors to figure out what the agent is looking at 101 // Use these three vectors to figure out what the agent is looking at
92 // Convert it to a Matrix and/or Quaternion 102 // Convert it to a Matrix and/or Quaternion
93 protected Vector3 m_CameraAtAxis = new Vector3(0, 0, 0); 103 protected Vector3 m_CameraAtAxis = new Vector3(0, 0, 0);
94 protected Vector3 m_CameraCenter = new Vector3(0, 0, 0);
95 protected Vector3 m_CameraLeftAxis = new Vector3(0, 0, 0); 104 protected Vector3 m_CameraLeftAxis = new Vector3(0, 0, 0);
96 protected Vector3 m_CameraUpAxis = new Vector3(0, 0, 0); 105 protected Vector3 m_CameraUpAxis = new Vector3(0, 0, 0);
97 protected float m_DrawDistance; 106 private uint m_AgentControlFlags = (uint) 0;
98 private float m_godlevel; 107 private LLQuaternion m_headrotation = new LLQuaternion();
99 private bool m_gotAllObjectsInScene; 108 private byte m_state = (byte) 0;
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;
114 109
115 //Reuse the LLVector3 instead of creating a new one on the UpdateMovement method 110 //Reuse the LLVector3 instead of creating a new one on the UpdateMovement method
116 private LLVector3 movementvector; 111 private LLVector3 movementvector = new LLVector3();
117 112
118 /// <summary> 113 private List<LLUUID> m_knownPrimUUID = new List<LLUUID>();
119 /// Position at which a significant movement was made
120 /// </summary>
121 private LLVector3 posLastSignificantMove;
122 114
123 public bool sentMessageAboutRestrictedParcelFlyingDown; 115 // Agent's Draw distance.
116 protected float m_DrawDistance = 0f;
124 117
125 #region Properties 118 protected AvatarAppearance m_appearance;
126 119
127 private readonly string m_firstname; 120 protected List<SceneObjectGroup> m_attachments = new List<SceneObjectGroup>();
128 private readonly string m_lastname; 121
129 private readonly ulong m_regionHandle; 122 //neighbouring regions we have enabled a child agent in
130 protected bool m_allowMovement = true; 123 private readonly List<ulong> m_knownChildRegions = new List<ulong>();
124
125 private SignificantClientMovement handlerSignificantClientMovement = null; //OnSignificantClientMovement;
131 126
132 /// <summary> 127 /// <summary>
133 /// This works out to be the ClientView object associated with this avatar, or it's UDP connection manager 128 /// Implemented Control Flags
134 /// </summary> 129 /// </summary>
135 private IClientAPI m_controllingClient; 130 private enum Dir_ControlFlags
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 }
136 140
137 /// <summary> 141 /// <summary>
138 /// If this is true, agent doesn't have a representation in this scene. 142 /// Position at which a significant movement was made
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
142 /// </summary> 143 /// </summary>
143 private bool m_isChildAgent = true; 144 private LLVector3 posLastSignificantMove = new LLVector3();
144 145
145 private uint m_parentID; 146 public delegate void SignificantClientMovement(IClientAPI remote_client);
146 protected LLVector3 m_parentPosition; 147
147 protected PhysicsActor m_physicsActor; 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
153 #region Properties
148 154
149 /// <summary> 155 /// <summary>
150 /// Physical scene representation of this Avatar. 156 /// Physical scene representation of this Avatar.
@@ -161,6 +167,16 @@ namespace OpenSim.Region.Environment.Scenes
161 get { return m_movementflag; } 167 get { return m_movementflag; }
162 } 168 }
163 169
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
164 180
165 public bool Updated 181 public bool Updated
166 { 182 {
@@ -168,6 +184,8 @@ namespace OpenSim.Region.Environment.Scenes
168 get { return m_updateflag; } 184 get { return m_updateflag; }
169 } 185 }
170 186
187 private readonly ulong m_regionHandle;
188
171 public ulong RegionHandle 189 public ulong RegionHandle
172 { 190 {
173 get { return m_regionHandle; } 191 get { return m_regionHandle; }
@@ -178,11 +196,15 @@ namespace OpenSim.Region.Environment.Scenes
178 get { return m_CameraCenter; } 196 get { return m_CameraCenter; }
179 } 197 }
180 198
199 private readonly string m_firstname;
200
181 public string Firstname 201 public string Firstname
182 { 202 {
183 get { return m_firstname; } 203 get { return m_firstname; }
184 } 204 }
185 205
206 private readonly string m_lastname;
207
186 public string Lastname 208 public string Lastname
187 { 209 {
188 get { return m_lastname; } 210 get { return m_lastname; }
@@ -193,18 +215,29 @@ namespace OpenSim.Region.Environment.Scenes
193 get { return m_DrawDistance; } 215 get { return m_DrawDistance; }
194 } 216 }
195 217
218 protected bool m_allowMovement = true;
219
196 public bool AllowMovement 220 public bool AllowMovement
197 { 221 {
198 get { return m_allowMovement; } 222 get { return m_allowMovement; }
199 set { m_allowMovement = value; } 223 set { m_allowMovement = value; }
200 } 224 }
201 225
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
202 public IClientAPI ControllingClient 233 public IClientAPI ControllingClient
203 { 234 {
204 get { return m_controllingClient; } 235 get { return m_controllingClient; }
205 set { m_controllingClient = value; } 236 set { m_controllingClient = value; }
206 } 237 }
207 238
239 protected LLVector3 m_parentPosition = new LLVector3();
240
208 /// <summary> 241 /// <summary>
209 /// Absolute position of this avatar in 'region cordinates' 242 /// Absolute position of this avatar in 'region cordinates'
210 /// </summary> 243 /// </summary>
@@ -239,7 +272,7 @@ namespace OpenSim.Region.Environment.Scenes
239 } 272 }
240 273
241 m_pos = value; 274 m_pos = value;
242 m_parentPosition = new LLVector3(0, 0, 0); 275 m_parentPosition=new LLVector3(0, 0, 0);
243 } 276 }
244 } 277 }
245 278
@@ -280,12 +313,22 @@ namespace OpenSim.Region.Environment.Scenes
280 } 313 }
281 } 314 }
282 315
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
283 public bool IsChildAgent 324 public bool IsChildAgent
284 { 325 {
285 get { return m_isChildAgent; } 326 get { return m_isChildAgent; }
286 set { m_isChildAgent = value; } 327 set { m_isChildAgent = value; }
287 } 328 }
288 329
330 private uint m_parentID = 0;
331
289 public uint ParentID 332 public uint ParentID
290 { 333 {
291 get { return m_parentID; } 334 get { return m_parentID; }
@@ -300,16 +343,6 @@ namespace OpenSim.Region.Environment.Scenes
300 get { return m_knownChildRegions; } 343 get { return m_knownChildRegions; }
301 } 344 }
302 345
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
313 #endregion 346 #endregion
314 347
315 #region Constructor(s) 348 #region Constructor(s)
@@ -387,360 +420,6 @@ namespace OpenSim.Region.Environment.Scenes
387 420
388 #endregion 421 #endregion
389 422
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
744 /// <summary> 423 /// <summary>
745 /// Add the part to the queue of parts for which we need to send an update to the client 424 /// Add the part to the queue of parts for which we need to send an update to the client
746 /// </summary> 425 /// </summary>
@@ -778,12 +457,12 @@ namespace OpenSim.Region.Environment.Scenes
778 if (!m_gotAllObjectsInScene) 457 if (!m_gotAllObjectsInScene)
779 { 458 {
780 if (!m_isChildAgent || m_scene.m_seeIntoRegionFromNeighbor) 459 if (!m_isChildAgent || m_scene.m_seeIntoRegionFromNeighbor)
781 { 460 {
782 m_scene.SendAllSceneObjectsToClient(this); 461 m_scene.SendAllSceneObjectsToClient(this);
783 m_gotAllObjectsInScene = true; 462 m_gotAllObjectsInScene = true;
784 } 463 }
785 } 464 }
786 465
787 if (m_partsUpdateQueue.Count > 0) 466 if (m_partsUpdateQueue.Count > 0)
788 { 467 {
789 bool runUpdate = true; 468 bool runUpdate = true;
@@ -802,7 +481,7 @@ namespace OpenSim.Region.Environment.Scenes
802// m_log.DebugFormat( 481// m_log.DebugFormat(
803// "[SCENE PRESENCE]: Fully updating prim {0}, {1} - part timestamp {2}", 482// "[SCENE PRESENCE]: Fully updating prim {0}, {1} - part timestamp {2}",
804// part.Name, part.UUID, part.TimeStampFull); 483// part.Name, part.UUID, part.TimeStampFull);
805 484
806 part.SendFullUpdate(ControllingClient, GenerateClientFlags(part.UUID)); 485 part.SendFullUpdate(ControllingClient, GenerateClientFlags(part.UUID));
807 486
808 // We'll update to the part's timestamp rather than the current time to 487 // We'll update to the part's timestamp rather than the current time to
@@ -818,7 +497,7 @@ namespace OpenSim.Region.Environment.Scenes
818// m_log.DebugFormat( 497// m_log.DebugFormat(
819// "[SCENE PRESENCE]: Tersely updating prim {0}, {1} - part timestamp {2}", 498// "[SCENE PRESENCE]: Tersely updating prim {0}, {1} - part timestamp {2}",
820// part.Name, part.UUID, part.TimeStampTerse); 499// part.Name, part.UUID, part.TimeStampTerse);
821 500
822 part.SendTerseUpdate(ControllingClient); 501 part.SendTerseUpdate(ControllingClient);
823 502
824 update.LastTerseUpdateTime = part.TimeStampTerse; 503 update.LastTerseUpdateTime = part.TimeStampTerse;
@@ -851,235 +530,6 @@ namespace OpenSim.Region.Environment.Scenes
851 AddNewMovement(position, rotation); 530 AddNewMovement(position, rotation);
852 } 531 }
853 532
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
1083 #region Status Methods 533 #region Status Methods
1084 534
1085 /// <summary> 535 /// <summary>
@@ -1092,7 +542,7 @@ namespace OpenSim.Region.Environment.Scenes
1092// m_log.DebugFormat( 542// m_log.DebugFormat(
1093// "[SCENEPRESENCE]: Upgrading child agent {0}, {1} to a root agent in {2}", 543// "[SCENEPRESENCE]: Upgrading child agent {0}, {1} to a root agent in {2}",
1094// Name, UUID, m_scene.RegionInfo.RegionName); 544// Name, UUID, m_scene.RegionInfo.RegionName);
1095 545
1096 m_isChildAgent = false; 546 m_isChildAgent = false;
1097 547
1098 AbsolutePosition = pos; 548 AbsolutePosition = pos;
@@ -1108,7 +558,7 @@ namespace OpenSim.Region.Environment.Scenes
1108 //{ 558 //{
1109 m_scene.SendAllSceneObjectsToClient(this); 559 m_scene.SendAllSceneObjectsToClient(this);
1110 m_scene.LandChannel.sendLandUpdate(this, true); 560 m_scene.LandChannel.sendLandUpdate(this, true);
1111 561
1112 //m_gotAllObjectsInScene = true; 562 //m_gotAllObjectsInScene = true;
1113 //} 563 //}
1114 } 564 }
@@ -1122,9 +572,9 @@ namespace OpenSim.Region.Environment.Scenes
1122 /// </summary> 572 /// </summary>
1123 public void MakeChildAgent() 573 public void MakeChildAgent()
1124 { 574 {
1125 if (m_animations.Count > 0) 575 if(m_animations.Count > 0)
1126 { 576 {
1127 LLUUID movement = m_animations[0]; 577 LLUUID movement=m_animations[0];
1128 578
1129 m_animations.Clear(); 579 m_animations.Clear();
1130 m_animationSeqs.Clear(); 580 m_animationSeqs.Clear();
@@ -1134,7 +584,7 @@ namespace OpenSim.Region.Environment.Scenes
1134// m_log.DebugFormat( 584// m_log.DebugFormat(
1135// "[SCENEPRESENCE]: Downgrading child agent {0}, {1} to a root agent in {2}", 585// "[SCENEPRESENCE]: Downgrading child agent {0}, {1} to a root agent in {2}",
1136// Name, UUID, m_scene.RegionInfo.RegionName); 586// Name, UUID, m_scene.RegionInfo.RegionName);
1137 587
1138 Velocity = new LLVector3(0, 0, 0); 588 Velocity = new LLVector3(0, 0, 0);
1139 m_isChildAgent = true; 589 m_isChildAgent = true;
1140 m_scene.SwapRootAgentCount(true); 590 m_scene.SwapRootAgentCount(true);
@@ -1391,8 +841,9 @@ namespace OpenSim.Region.Environment.Scenes
1391 ((flags & (uint) AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)); 841 ((flags & (uint) AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0));
1392 842
1393 // Are the collision requirements fulfilled? 843 // Are the collision requirements fulfilled?
1394 bool colliding = m_physicsActor.IsColliding; 844 bool colliding = (m_physicsActor.IsColliding == true);
1395 845
846
1396 847
1397 if (m_physicsActor.Flying && colliding && controlland) 848 if (m_physicsActor.Flying && colliding && controlland)
1398 { 849 {
@@ -1406,9 +857,9 @@ namespace OpenSim.Region.Environment.Scenes
1406 UpdateMovementAnimations(update_movementflag); 857 UpdateMovementAnimations(update_movementflag);
1407 } 858 }
1408 } 859 }
1409 860
1410 m_scene.EventManager.TriggerOnClientMovement(this); 861 m_scene.EventManager.TriggerOnClientMovement(this);
1411 862
1412 m_scene.AddAgentTime(System.Environment.TickCount - m_perfMonMS); 863 m_scene.AddAgentTime(System.Environment.TickCount - m_perfMonMS);
1413 } 864 }
1414 865
@@ -1435,9 +886,9 @@ namespace OpenSim.Region.Environment.Scenes
1435 AddToPhysicalScene(); 886 AddToPhysicalScene();
1436 } 887 }
1437 888
1438 m_pos += m_parentPosition + new LLVector3(0.0f, 0.0f, 2.0f * m_sitAvatarHeight); 889 m_pos += m_parentPosition + new LLVector3(0.0f, 0.0f, 2.0f*m_sitAvatarHeight);
1439 m_parentPosition = new LLVector3(); 890 m_parentPosition = new LLVector3();
1440 891
1441 m_parentID = 0; 892 m_parentID = 0;
1442 SendFullUpdateToAllClients(); 893 SendFullUpdateToAllClients();
1443 894
@@ -1540,7 +991,7 @@ namespace OpenSim.Region.Environment.Scenes
1540 } 991 }
1541 else 992 else
1542 { 993 {
1543 m_log.Warn("Sit requested on unknown object: " + targetID); 994 m_log.Warn("Sit requested on unknown object: " + targetID.ToString());
1544 } 995 }
1545 SendSitResponse(remoteClient, targetID, offset); 996 SendSitResponse(remoteClient, targetID, offset);
1546 } 997 }
@@ -1602,11 +1053,11 @@ namespace OpenSim.Region.Environment.Scenes
1602 1053
1603 public void AddAnimation(LLUUID animID) 1054 public void AddAnimation(LLUUID animID)
1604 { 1055 {
1605 if (m_isChildAgent) 1056 if(m_isChildAgent)
1606 return; 1057 return;
1607 1058
1608 // Don't let this animation become the movement animation 1059 // Don't let this animation become the movement animation
1609 if (m_animations.Count < 1) 1060 if(m_animations.Count < 1)
1610 SetMovementAnimation(Animations.AnimsLLUUID["STAND"]); 1061 SetMovementAnimation(Animations.AnimsLLUUID["STAND"]);
1611 1062
1612 if (!m_animations.Contains(animID)) 1063 if (!m_animations.Contains(animID))
@@ -1619,7 +1070,7 @@ namespace OpenSim.Region.Environment.Scenes
1619 1070
1620 public void RemoveAnimation(LLUUID animID) 1071 public void RemoveAnimation(LLUUID animID)
1621 { 1072 {
1622 if (m_isChildAgent) 1073 if(m_isChildAgent)
1623 return; 1074 return;
1624 1075
1625 if (m_animations.Contains(animID)) 1076 if (m_animations.Contains(animID))
@@ -1633,11 +1084,11 @@ namespace OpenSim.Region.Environment.Scenes
1633 // What a HACK!! Anim list really needs to be an object! 1084 // What a HACK!! Anim list really needs to be an object!
1634 int idx; 1085 int idx;
1635 1086
1636 for (idx = 0; idx < m_animations.Count; idx++) 1087 for(idx=0;idx < m_animations.Count;idx++)
1637 { 1088 {
1638 if (m_animations[idx] == animID) 1089 if(m_animations[idx] == animID)
1639 { 1090 {
1640 int seq = m_animationSeqs[idx]; 1091 int seq=m_animationSeqs[idx];
1641 1092
1642 m_animations.Remove(animID); 1093 m_animations.Remove(animID);
1643 m_animationSeqs.Remove(seq); 1094 m_animationSeqs.Remove(seq);
@@ -1666,7 +1117,7 @@ namespace OpenSim.Region.Environment.Scenes
1666 /// </summary> 1117 /// </summary>
1667 protected void SetMovementAnimation(LLUUID anim) 1118 protected void SetMovementAnimation(LLUUID anim)
1668 { 1119 {
1669 if (m_animations.Count < 1) 1120 if(m_animations.Count < 1)
1670 { 1121 {
1671 m_animations.Add(Animations.AnimsLLUUID["STAND"]); 1122 m_animations.Add(Animations.AnimsLLUUID["STAND"]);
1672 m_animationSeqs.Add(1); 1123 m_animationSeqs.Add(1);
@@ -1699,6 +1150,8 @@ namespace OpenSim.Region.Environment.Scenes
1699 /// </summary> 1150 /// </summary>
1700 protected void UpdateMovementAnimations(bool update_movementflag) 1151 protected void UpdateMovementAnimations(bool update_movementflag)
1701 { 1152 {
1153
1154
1702 if (update_movementflag) 1155 if (update_movementflag)
1703 { 1156 {
1704 // Are we moving? 1157 // Are we moving?
@@ -1731,8 +1184,7 @@ namespace OpenSim.Region.Environment.Scenes
1731 SetMovementAnimation(Animations.AnimsLLUUID["JUMP"]); 1184 SetMovementAnimation(Animations.AnimsLLUUID["JUMP"]);
1732 } 1185 }
1733 catch (KeyNotFoundException) 1186 catch (KeyNotFoundException)
1734 { 1187 { }
1735 }
1736 } 1188 }
1737 else if (m_setAlwaysRun) 1189 else if (m_setAlwaysRun)
1738 { 1190 {
@@ -1742,8 +1194,7 @@ namespace OpenSim.Region.Environment.Scenes
1742 SetMovementAnimation(Animations.AnimsLLUUID["RUN"]); 1194 SetMovementAnimation(Animations.AnimsLLUUID["RUN"]);
1743 } 1195 }
1744 catch (KeyNotFoundException) 1196 catch (KeyNotFoundException)
1745 { 1197 { }
1746 }
1747 } 1198 }
1748 else 1199 else
1749 { 1200 {
@@ -1753,8 +1204,8 @@ namespace OpenSim.Region.Environment.Scenes
1753 SetMovementAnimation(Animations.AnimsLLUUID["WALK"]); 1204 SetMovementAnimation(Animations.AnimsLLUUID["WALK"]);
1754 } 1205 }
1755 catch (KeyNotFoundException) 1206 catch (KeyNotFoundException)
1756 { 1207 { }
1757 } 1208
1758 } 1209 }
1759 } 1210 }
1760 else 1211 else
@@ -1788,14 +1239,15 @@ namespace OpenSim.Region.Environment.Scenes
1788 // We're not moving.. and we're not doing anything.. so play the stand animation 1239 // We're not moving.. and we're not doing anything.. so play the stand animation
1789 try 1240 try
1790 { 1241 {
1242
1791 SetMovementAnimation(Animations.AnimsLLUUID["STAND"]); 1243 SetMovementAnimation(Animations.AnimsLLUUID["STAND"]);
1792 } 1244 }
1793 catch (KeyNotFoundException) 1245 catch (KeyNotFoundException)
1794 { 1246 { }
1795 }
1796 } 1247 }
1797 } 1248 }
1798 } 1249 }
1250
1799 } 1251 }
1800 1252
1801 /// <summary> 1253 /// <summary>
@@ -1810,13 +1262,13 @@ namespace OpenSim.Region.Environment.Scenes
1810 } 1262 }
1811 1263
1812 m_perfMonMS = System.Environment.TickCount; 1264 m_perfMonMS = System.Environment.TickCount;
1813 1265
1814 m_rotation = rotation; 1266 m_rotation = rotation;
1815 NewForce newVelocity = new NewForce(); 1267 NewForce newVelocity = new NewForce();
1816 Vector3 direc = rotation * vec; 1268 Vector3 direc = rotation*vec;
1817 direc.Normalize(); 1269 direc.Normalize();
1818 1270
1819 direc *= 0.03f * 128f; 1271 direc *= 0.03f*128f;
1820 if (m_physicsActor.Flying) 1272 if (m_physicsActor.Flying)
1821 { 1273 {
1822 direc *= 4; 1274 direc *= 4;
@@ -1848,8 +1300,7 @@ namespace OpenSim.Region.Environment.Scenes
1848 SetMovementAnimation(Animations.AnimsLLUUID["JUMP"]); 1300 SetMovementAnimation(Animations.AnimsLLUUID["JUMP"]);
1849 } 1301 }
1850 catch (KeyNotFoundException) 1302 catch (KeyNotFoundException)
1851 { 1303 { }
1852 }
1853 } 1304 }
1854 } 1305 }
1855 } 1306 }
@@ -1895,18 +1346,23 @@ namespace OpenSim.Region.Environment.Scenes
1895 m_updateCount = 0; 1346 m_updateCount = 0;
1896 } 1347 }
1897 } 1348 }
1898 else if ((Util.GetDistanceTo(lastPhysPos, AbsolutePosition) > 0.02) || (Util.GetDistanceTo(m_lastVelocity, m_velocity) > 0.02)) 1349 else if ((Util.GetDistanceTo(lastPhysPos, AbsolutePosition) > 0.02) || (Util.GetDistanceTo(m_lastVelocity, m_velocity) > 0.02)) // physics-related movement
1899 // physics-related movement
1900 { 1350 {
1351
1352
1901 // Send Terse Update to all clients updates lastPhysPos and m_lastVelocity 1353 // Send Terse Update to all clients updates lastPhysPos and m_lastVelocity
1902 // doing the above assures us that we know what we sent the clients last 1354 // doing the above assures us that we know what we sent the clients last
1903 SendTerseUpdateToAllClients(); 1355 SendTerseUpdateToAllClients();
1904 m_updateCount = 0; 1356 m_updateCount = 0;
1357
1358
1359
1905 } 1360 }
1906 1361
1907 // followed suggestion from mic bowman. reversed the two lines below. 1362 // followed suggestion from mic bowman. reversed the two lines below.
1908 CheckForBorderCrossing(); 1363 CheckForBorderCrossing();
1909 CheckForSignificantMovement(); // sends update to the modules. 1364 CheckForSignificantMovement(); // sends update to the modules.
1365
1910 } 1366 }
1911 } 1367 }
1912 1368
@@ -1925,7 +1381,7 @@ namespace OpenSim.Region.Environment.Scenes
1925 LLVector3 pos = m_pos; 1381 LLVector3 pos = m_pos;
1926 LLVector3 vel = Velocity; 1382 LLVector3 vel = Velocity;
1927 LLQuaternion rot = new LLQuaternion(m_bodyRot.x, m_bodyRot.y, m_bodyRot.z, m_bodyRot.w); 1383 LLQuaternion rot = new LLQuaternion(m_bodyRot.x, m_bodyRot.y, m_bodyRot.z, m_bodyRot.w);
1928 remoteClient.SendAvatarTerseUpdate(m_regionHandle, (ushort) (m_scene.TimeDilation * ushort.MaxValue), LocalId, new LLVector3(pos.X, pos.Y, pos.Z), 1384 remoteClient.SendAvatarTerseUpdate(m_regionHandle, (ushort)(m_scene.TimeDilation * (float)ushort.MaxValue), LocalId, new LLVector3(pos.X, pos.Y, pos.Z),
1929 new LLVector3(vel.X, vel.Y, vel.Z), rot); 1385 new LLVector3(vel.X, vel.Y, vel.Z), rot);
1930 1386
1931 m_scene.AddAgentTime(System.Environment.TickCount - m_perfMonMS); 1387 m_scene.AddAgentTime(System.Environment.TickCount - m_perfMonMS);
@@ -1945,6 +1401,7 @@ namespace OpenSim.Region.Environment.Scenes
1945 lastPhysPos = AbsolutePosition; 1401 lastPhysPos = AbsolutePosition;
1946 1402
1947 m_scene.AddAgentTime(System.Environment.TickCount - m_perfMonMS); 1403 m_scene.AddAgentTime(System.Environment.TickCount - m_perfMonMS);
1404
1948 } 1405 }
1949 1406
1950 public void SendCoarseLocations() 1407 public void SendCoarseLocations()
@@ -2040,15 +1497,15 @@ namespace OpenSim.Region.Environment.Scenes
2040 /// </summary> 1497 /// </summary>
2041 public void SendAppearanceToAllOtherAgents() 1498 public void SendAppearanceToAllOtherAgents()
2042 { 1499 {
2043 m_perfMonMS = System.Environment.TickCount; 1500 m_perfMonMS=System.Environment.TickCount;
2044 1501
2045 m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence) 1502 m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence)
1503 {
1504 if (scenePresence.UUID != UUID)
2046 { 1505 {
2047 if (scenePresence.UUID != UUID) 1506 m_appearance.SendAppearanceToOtherAgent(scenePresence);
2048 { 1507 }
2049 m_appearance.SendAppearanceToOtherAgent(scenePresence); 1508 });
2050 }
2051 });
2052 m_scene.AddAgentTime(System.Environment.TickCount - m_perfMonMS); 1509 m_scene.AddAgentTime(System.Environment.TickCount - m_perfMonMS);
2053 } 1510 }
2054 1511
@@ -2077,7 +1534,7 @@ namespace OpenSim.Region.Environment.Scenes
2077 /// <param name="seqs"></param> 1534 /// <param name="seqs"></param>
2078 public void SendAnimPack(LLUUID[] animations, int[] seqs) 1535 public void SendAnimPack(LLUUID[] animations, int[] seqs)
2079 { 1536 {
2080 if (m_isChildAgent) 1537 if(m_isChildAgent)
2081 return; 1538 return;
2082 1539
2083 m_scene.Broadcast( 1540 m_scene.Broadcast(
@@ -2113,10 +1570,10 @@ namespace OpenSim.Region.Environment.Scenes
2113 } 1570 }
2114 1571
2115 // Minimum Draw distance is 64 meters, the Radius of the draw distance sphere is 32m 1572 // Minimum Draw distance is 64 meters, the Radius of the draw distance sphere is 32m
2116 if (Util.GetDistanceTo(AbsolutePosition, m_LastChildAgentUpdatePosition) > 32) 1573 if (Util.GetDistanceTo(AbsolutePosition,m_LastChildAgentUpdatePosition) > 32)
2117 { 1574 {
2118 ChildAgentDataUpdate cadu = new ChildAgentDataUpdate(); 1575 ChildAgentDataUpdate cadu = new ChildAgentDataUpdate();
2119 cadu.ActiveGroupID = LLUUID.Zero.UUID; 1576 cadu.ActiveGroupID=LLUUID.Zero.UUID;
2120 cadu.AgentID = UUID.UUID; 1577 cadu.AgentID = UUID.UUID;
2121 cadu.alwaysrun = m_setAlwaysRun; 1578 cadu.alwaysrun = m_setAlwaysRun;
2122 cadu.AVHeight = m_avHeight; 1579 cadu.AVHeight = m_avHeight;
@@ -2128,8 +1585,8 @@ namespace OpenSim.Region.Environment.Scenes
2128 cadu.Position = new sLLVector3(AbsolutePosition); 1585 cadu.Position = new sLLVector3(AbsolutePosition);
2129 cadu.regionHandle = m_scene.RegionInfo.RegionHandle; 1586 cadu.regionHandle = m_scene.RegionInfo.RegionHandle;
2130 cadu.throttles = ControllingClient.GetThrottlesPacked(1f); 1587 cadu.throttles = ControllingClient.GetThrottlesPacked(1f);
2131 cadu.Velocity = new sLLVector3(Velocity); 1588 cadu.Velocity = new sLLVector3(Velocity);
2132 m_scene.SendOutChildAgentUpdates(cadu, this); 1589 m_scene.SendOutChildAgentUpdates(cadu,this);
2133 m_LastChildAgentUpdatePosition.X = AbsolutePosition.X; 1590 m_LastChildAgentUpdatePosition.X = AbsolutePosition.X;
2134 m_LastChildAgentUpdatePosition.Y = AbsolutePosition.Y; 1591 m_LastChildAgentUpdatePosition.Y = AbsolutePosition.Y;
2135 m_LastChildAgentUpdatePosition.Z = AbsolutePosition.Z; 1592 m_LastChildAgentUpdatePosition.Z = AbsolutePosition.Z;
@@ -2149,9 +1606,9 @@ namespace OpenSim.Region.Environment.Scenes
2149 LLVector3 vel = Velocity; 1606 LLVector3 vel = Velocity;
2150 1607
2151 float timeStep = 0.1f; 1608 float timeStep = 0.1f;
2152 pos2.X = pos2.X + (vel.X * timeStep); 1609 pos2.X = pos2.X + (vel.X*timeStep);
2153 pos2.Y = pos2.Y + (vel.Y * timeStep); 1610 pos2.Y = pos2.Y + (vel.Y*timeStep);
2154 pos2.Z = pos2.Z + (vel.Z * timeStep); 1611 pos2.Z = pos2.Z + (vel.Z*timeStep);
2155 1612
2156 if ((pos2.X < 0) || (pos2.X > Constants.RegionSize)) 1613 if ((pos2.X < 0) || (pos2.X > Constants.RegionSize))
2157 { 1614 {
@@ -2206,10 +1663,10 @@ namespace OpenSim.Region.Environment.Scenes
2206 } 1663 }
2207 1664
2208 LLVector3 vel = m_velocity; 1665 LLVector3 vel = m_velocity;
2209 ulong neighbourHandle = Helpers.UIntsToLong((neighbourx * Constants.RegionSize), (neighboury * Constants.RegionSize)); 1666 ulong neighbourHandle = Helpers.UIntsToLong((uint)(neighbourx * Constants.RegionSize), (uint)(neighboury * Constants.RegionSize));
2210 SimpleRegionInfo neighbourRegion = m_scene.RequestNeighbouringRegionInfo(neighbourHandle); 1667 SimpleRegionInfo neighbourRegion = m_scene.RequestNeighbouringRegionInfo(neighbourHandle);
2211 if (neighbourRegion != null) 1668 if (neighbourRegion != null)
2212 { 1669 {
2213 // When the neighbour is informed of the border crossing, it will set up CAPS handlers for the avatar 1670 // When the neighbour is informed of the border crossing, it will set up CAPS handlers for the avatar
2214 // This means we need to remove the current caps handler here and possibly compensate later, 1671 // This means we need to remove the current caps handler here and possibly compensate later,
2215 // in case both scenes are being hosted on the same region server. Messy 1672 // in case both scenes are being hosted on the same region server. Messy
@@ -2219,17 +1676,17 @@ namespace OpenSim.Region.Environment.Scenes
2219 m_scene.InformNeighbourOfCrossing(neighbourHandle, m_controllingClient.AgentId, newpos, 1676 m_scene.InformNeighbourOfCrossing(neighbourHandle, m_controllingClient.AgentId, newpos,
2220 m_physicsActor.Flying); 1677 m_physicsActor.Flying);
2221 if (res) 1678 if (res)
2222 { 1679 {
2223 AgentCircuitData circuitdata = m_controllingClient.RequestClientInfo(); 1680 AgentCircuitData circuitdata = m_controllingClient.RequestClientInfo();
2224 1681
2225 // TODO Should construct this behind a method 1682 // TODO Should construct this behind a method
2226 string capsPath = 1683 string capsPath =
2227 "http://" + neighbourRegion.ExternalHostName + ":" + neighbourRegion.HttpPort 1684 "http://" + neighbourRegion.ExternalHostName + ":" + neighbourRegion.HttpPort
2228 + "/CAPS/" + circuitdata.CapsPath + "0000/"; 1685 + "/CAPS/" + circuitdata.CapsPath + "0000/";
2229 1686
2230 m_log.DebugFormat( 1687 m_log.DebugFormat(
2231 "[CAPS]: Sending new CAPS seed url {0} to client {1}", capsPath, m_uuid); 1688 "[CAPS]: Sending new CAPS seed url {0} to client {1}", capsPath, m_uuid);
2232 1689
2233 m_controllingClient.CrossRegion(neighbourHandle, newpos, vel, neighbourRegion.ExternalEndPoint, 1690 m_controllingClient.CrossRegion(neighbourHandle, newpos, vel, neighbourRegion.ExternalEndPoint,
2234 capsPath); 1691 capsPath);
2235 MakeChildAgent(); 1692 MakeChildAgent();
@@ -2246,40 +1703,128 @@ namespace OpenSim.Region.Environment.Scenes
2246 1703
2247 #endregion 1704 #endregion
2248 1705
2249 #region Nested type: Dir_ControlFlags 1706 /// <summary>
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 }
2250 1736
2251 /// <summary> 1737 /// <summary>
2252 /// Implemented Control Flags 1738 /// This updates important decision making data about a child agent
1739 /// The main purpose is to figure out what objects to send to a child agent that's in a neighboring region
2253 /// </summary> 1740 /// </summary>
2254 private enum Dir_ControlFlags 1741 public void ChildAgentDataUpdate(ChildAgentDataUpdate cAgentData, uint tRegionX, uint tRegionY, uint rRegionX, uint rRegionY)
2255 { 1742 {
2256 DIR_CONTROL_FLAG_FORWARD = AgentManager.ControlFlags.AGENT_CONTROL_AT_POS, 1743 //
2257 DIR_CONTROL_FLAG_BACK = AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG, 1744 int shiftx = ((int)rRegionX - (int)tRegionX) * (int)Constants.RegionSize;
2258 DIR_CONTROL_FLAG_LEFT = AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS, 1745 int shifty = ((int)rRegionY - (int)tRegionY) * (int)Constants.RegionSize;
2259 DIR_CONTROL_FLAG_RIGHT = AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG, 1746
2260 DIR_CONTROL_FLAG_UP = AgentManager.ControlFlags.AGENT_CONTROL_UP_POS, 1747 m_DrawDistance = cAgentData.drawdistance;
2261 DIR_CONTROL_FLAG_DOWN = AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG, 1748 m_pos = new LLVector3(cAgentData.Position.x + shiftx, cAgentData.Position.y + shifty, cAgentData.Position.z);
2262 DIR_CONTROL_FLAG_DOWN_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG 1749
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;
2263 } 1768 }
2264 1769
2265 #endregion 1770 /// <summary>
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 }
2266 1807
2267 #region Nested type: NewForce 1808 static ScenePresence()
1809 {
1810 LLObject.TextureEntry textu = AvatarAppearance.GetDefaultTextureEntry();
1811 DefaultTexture = textu.ToBytes();
1812 }
2268 1813
2269 [Serializable] 1814 [Serializable]
2270 public class NewForce 1815 public class NewForce
2271 { 1816 {
2272 public float X; 1817 public float X;
2273 public float Y; 1818 public float Y;
2274 public float Z; 1819 public float Z;
2275 }
2276 1820
2277 #endregion 1821 public NewForce()
2278 1822 {
2279 #region Nested type: ScenePartUpdate 1823 }
1824 }
2280 1825
2281 [Serializable] 1826 [Serializable]
2282 public class ScenePartUpdate : ISerializable 1827 public class ScenePartUpdate : ISerializable
2283 { 1828 {
2284 public LLUUID FullID; 1829 public LLUUID FullID;
2285 public uint LastFullUpdateTime; 1830 public uint LastFullUpdateTime;
@@ -2301,17 +1846,15 @@ namespace OpenSim.Region.Environment.Scenes
2301 throw new ArgumentNullException("info"); 1846 throw new ArgumentNullException("info");
2302 } 1847 }
2303 1848
2304 FullID = new LLUUID((Guid) info.GetValue("FullID", typeof (Guid))); 1849 FullID = new LLUUID((Guid)info.GetValue("FullID", typeof(Guid)));
2305 LastFullUpdateTime = (uint) info.GetValue("LastFullUpdateTime", typeof (uint)); 1850 LastFullUpdateTime = (uint)info.GetValue("LastFullUpdateTime", typeof(uint));
2306 LastTerseUpdateTime = (uint) info.GetValue("LastTerseUpdateTime", typeof (uint)); 1851 LastTerseUpdateTime = (uint)info.GetValue("LastTerseUpdateTime", typeof(uint));
2307 1852
2308 //System.Console.WriteLine("ScenePartUpdate Deserialize END"); 1853 //System.Console.WriteLine("ScenePartUpdate Deserialize END");
2309 } 1854 }
2310 1855
2311 #region ISerializable Members
2312
2313 [SecurityPermission(SecurityAction.LinkDemand, 1856 [SecurityPermission(SecurityAction.LinkDemand,
2314 Flags = SecurityPermissionFlag.SerializationFormatter)] 1857 Flags = SecurityPermissionFlag.SerializationFormatter)]
2315 public virtual void GetObjectData( 1858 public virtual void GetObjectData(
2316 SerializationInfo info, StreamingContext context) 1859 SerializationInfo info, StreamingContext context)
2317 { 1860 {
@@ -2324,10 +1867,473 @@ namespace OpenSim.Region.Environment.Scenes
2324 info.AddValue("LastFullUpdateTime", LastFullUpdateTime); 1867 info.AddValue("LastFullUpdateTime", LastFullUpdateTime);
2325 info.AddValue("LastTerseUpdateTime", LastTerseUpdateTime); 1868 info.AddValue("LastTerseUpdateTime", LastTerseUpdateTime);
2326 } 1869 }
1870 }
2327 1871
2328 #endregion 1872 public override void SetText(string text, Vector3 color, double alpha)
1873 {
1874 throw new Exception("Can't set Text on avatar.");
2329 } 1875 }
2330 1876
2331 #endregion 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
1935 RemoveFromPhysicalScene();
1936 GC.Collect();
1937 }
1938
1939 public ScenePresence()
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 }
2332 } 2338 }
2333} \ No newline at end of file 2339}
diff --git a/OpenSim/Region/Environment/Scenes/SceneXmlLoader.cs b/OpenSim/Region/Environment/Scenes/SceneXmlLoader.cs
index 386d87b..8390f64 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 Scene m_parentScene;
43 protected RegionInfo m_regInfo; 42 protected RegionInfo m_regInfo;
43 protected Scene m_parentScene;
44 44
45 public SceneXmlLoader(Scene parentScene, InnerScene innerScene, RegionInfo regionInfo) 45 public SceneXmlLoader(Scene parentScene, InnerScene innerScene, RegionInfo regionInfo)
46 { 46 {
@@ -136,13 +136,14 @@ 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
139 } 140 }
140 141
141 public void LoadGroupFromXml2String(string xmlString) 142 public void LoadGroupFromXml2String(string xmlString)
142 { 143 {
143 XmlDocument doc = new XmlDocument(); 144 XmlDocument doc = new XmlDocument();
144 XmlNode rootNode; 145 XmlNode rootNode;
145 146
146 XmlTextReader reader = new XmlTextReader(new StringReader(xmlString)); 147 XmlTextReader reader = new XmlTextReader(new StringReader(xmlString));
147 reader.WhitespaceHandling = WhitespaceHandling.None; 148 reader.WhitespaceHandling = WhitespaceHandling.None;
148 doc.Load(reader); 149 doc.Load(reader);
@@ -152,6 +153,7 @@ namespace OpenSim.Region.Environment.Scenes
152 { 153 {
153 CreatePrimFromXml(aPrimNode.OuterXml); 154 CreatePrimFromXml(aPrimNode.OuterXml);
154 } 155 }
156
155 } 157 }
156 158
157 public void LoadPrimsFromXml2(string fileName) 159 public void LoadPrimsFromXml2(string fileName)
@@ -204,7 +206,7 @@ namespace OpenSim.Region.Environment.Scenes
204 rootPart.PhysActor.LocalID = rootPart.LocalId; 206 rootPart.PhysActor.LocalID = rootPart.LocalId;
205 rootPart.DoPhysicsPropertyUpdate(UsePhysics, true); 207 rootPart.DoPhysicsPropertyUpdate(UsePhysics, true);
206 } 208 }
207 rootPart.Velocity = receivedVelocity; 209 rootPart.Velocity = receivedVelocity;
208 } 210 }
209 211
210 obj.ScheduleGroupForFullUpdate(); 212 obj.ScheduleGroupForFullUpdate();
@@ -232,4 +234,4 @@ namespace OpenSim.Region.Environment.Scenes
232 file.Close(); 234 file.Close();
233 } 235 }
234 } 236 }
235} \ No newline at end of file 237}
diff --git a/OpenSim/Region/Environment/Scenes/Scripting/IScriptHost.cs b/OpenSim/Region/Environment/Scenes/Scripting/IScriptHost.cs
index ccb2aa7..dbe2516 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} \ No newline at end of file 47}
diff --git a/OpenSim/Region/Environment/Scenes/Scripting/NullScriptHost.cs b/OpenSim/Region/Environment/Scenes/Scripting/NullScriptHost.cs
index a37ce53..4b1b56a 100644
--- a/OpenSim/Region/Environment/Scenes/Scripting/NullScriptHost.cs
+++ b/OpenSim/Region/Environment/Scenes/Scripting/NullScriptHost.cs
@@ -33,9 +33,7 @@ namespace OpenSim.Region.Environment.Scenes.Scripting
33{ 33{
34 public class NullScriptHost : IScriptHost 34 public class NullScriptHost : IScriptHost
35 { 35 {
36 private readonly LLVector3 m_pos = new LLVector3(128, 128, 30); 36 private LLVector3 m_pos = new LLVector3(128, 128, 30);
37
38 #region IScriptHost Members
39 37
40 public string Name 38 public string Name
41 { 39 {
@@ -85,7 +83,5 @@ namespace OpenSim.Region.Environment.Scenes.Scripting
85 { 83 {
86 Console.WriteLine("Tried to SetText [{0}] on NullScriptHost", text); 84 Console.WriteLine("Tried to SetText [{0}] on NullScriptHost", text);
87 } 85 }
88
89 #endregion
90 } 86 }
91} \ No newline at end of file 87}
diff --git a/OpenSim/Region/Environment/Scenes/Scripting/ScriptEngineInterface.cs b/OpenSim/Region/Environment/Scenes/Scripting/ScriptEngineInterface.cs
index cb0e1e8..b1ee519 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} \ No newline at end of file 38}
diff --git a/OpenSim/Region/Environment/Scenes/Scripting/ScriptEngineLoader.cs b/OpenSim/Region/Environment/Scenes/Scripting/ScriptEngineLoader.cs
index 0048e6b..6216e2c 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); 54 e.StackTrace.ToString());
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} \ No newline at end of file 119}
diff --git a/OpenSim/Region/Environment/Scenes/SimStatsReporter.cs b/OpenSim/Region/Environment/Scenes/SimStatsReporter.cs
index 1f02f23..a53bfcd 100644
--- a/OpenSim/Region/Environment/Scenes/SimStatsReporter.cs
+++ b/OpenSim/Region/Environment/Scenes/SimStatsReporter.cs
@@ -34,68 +34,105 @@ namespace OpenSim.Region.Environment.Scenes
34{ 34{
35 public class SimStatsReporter 35 public class SimStatsReporter
36 { 36 {
37 #region Delegates
38
39 public delegate void SendStatResult(SimStatsPacket pack); 37 public delegate void SendStatResult(SimStatsPacket pack);
40 38
41 #endregion 39 public event SendStatResult OnSendStatsResult;
42 40
43 private readonly Timer m_report = new Timer(); 41 private SendStatResult handlerSendStatResult = null;
44 private readonly SimStatsPacket.RegionBlock rb = new SimStatsPacket.RegionBlock();
45 private readonly RegionInfo ReportingRegion;
46 private readonly SimStatsPacket.StatBlock[] sb = new SimStatsPacket.StatBlock[21];
47 private readonly SimStatsPacket statpack = (SimStatsPacket) PacketPool.Instance.GetPacket(PacketType.SimStats);
48
49 private SendStatResult handlerSendStatResult;
50 private int m_activePrim;
51 private int m_activeScripts;
52 private int m_agentMS;
53
54 private int m_agentUpdates;
55 private int m_childAgents;
56 private int m_fps;
57
58 private int m_frameMS;
59 private int m_imageMS;
60 private int m_inPacketsPerSecond;
61 private int m_netMS;
62 private int m_numPrim;
63 private int m_otherMS;
64 private int m_outPacketsPerSecond;
65 private int m_pendingDownloads;
66 private int m_pendingUploads;
67 private float m_pfps;
68 private int m_physicsMS;
69 private int m_rootAgents;
70 private int m_scriptLinesPerSecond;
71 private float m_timeDilation;
72 private int m_unAckedBytes;
73 42
74 private int objectCapacity = 45000; 43 private enum Stats : uint
75 private float statsUpdateFactor; 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
68 // Havok4 related... May or may not be in upcoming LLclients
69 // (kelly added them sometime late in January 2008)
70 NumRCCSLODReduced = 25,
71 NumRCCSFixed = 26
72 }
73
74 // Sending a stats update every 3 seconds
76 private int statsUpdatesEveryMS = 3000; 75 private int statsUpdatesEveryMS = 3000;
76 private float statsUpdateFactor = 0;
77 private float m_timeDilation = 0;
78 private int m_fps = 0;
79 private float m_pfps = 0;
80 private int m_agentUpdates = 0;
81
82 private int m_frameMS = 0;
83 private int m_netMS = 0;
84 private int m_agentMS = 0;
85 private int m_physicsMS = 0;
86 private int m_imageMS = 0;
87 private int m_otherMS = 0;
88
89//Ckrinke: (3-21-08) Comment out to remove a compiler warning. Bring back into play when needed.
90//Ckrinke private int m_scriptMS = 0;
91
92 private int m_rootAgents = 0;
93 private int m_childAgents = 0;
94 private int m_numPrim = 0;
95 private int m_inPacketsPerSecond = 0;
96 private int m_outPacketsPerSecond = 0;
97 private int m_activePrim = 0;
98 private int m_unAckedBytes = 0;
99 private int m_pendingDownloads = 0;
100 private int m_pendingUploads = 0;
101 private int m_activeScripts = 0;
102 private int m_scriptLinesPerSecond = 0;
103
104 private int objectCapacity = 45000;
105
106
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();
77 115
78 116
79 public SimStatsReporter(RegionInfo regionData) 117 public SimStatsReporter(RegionInfo regionData)
80 { 118 {
81 statsUpdateFactor = (statsUpdatesEveryMS / 1000); 119
120 statsUpdateFactor = (float)(statsUpdatesEveryMS / 1000);
82 ReportingRegion = regionData; 121 ReportingRegion = regionData;
83 for (int i = 0; i < 21; i++) 122 for (int i = 0; i<21;i++)
84 { 123 {
85 sb[i] = new SimStatsPacket.StatBlock(); 124 sb[i] = new SimStatsPacket.StatBlock();
86 } 125 }
87 m_report.AutoReset = true; 126 m_report.AutoReset = true;
88 m_report.Interval = statsUpdatesEveryMS; 127 m_report.Interval = statsUpdatesEveryMS;
89 m_report.Elapsed += statsHeartBeat; 128 m_report.Elapsed += new ElapsedEventHandler(statsHeartBeat);
90 m_report.Enabled = true; 129 m_report.Enabled = true;
91 } 130 }
92 131
93 public event SendStatResult OnSendStatsResult;
94
95 public void SetUpdateMS(int ms) 132 public void SetUpdateMS(int ms)
96 { 133 {
97 statsUpdatesEveryMS = ms; 134 statsUpdatesEveryMS = ms;
98 statsUpdateFactor = (statsUpdatesEveryMS / 1000); 135 statsUpdateFactor = (float)(statsUpdatesEveryMS / 1000);
99 m_report.Interval = statsUpdatesEveryMS; 136 m_report.Interval = statsUpdatesEveryMS;
100 } 137 }
101 138
@@ -106,8 +143,8 @@ namespace OpenSim.Region.Environment.Scenes
106 lock (m_report) 143 lock (m_report)
107 { 144 {
108 // Packet is already initialized and ready for data insert 145 // Packet is already initialized and ready for data insert
109 146
110 147
111 statpack.Region = rb; 148 statpack.Region = rb;
112 statpack.Region.RegionX = ReportingRegion.RegionLocX; 149 statpack.Region.RegionX = ReportingRegion.RegionLocX;
113 statpack.Region.RegionY = ReportingRegion.RegionLocY; 150 statpack.Region.RegionY = ReportingRegion.RegionLocY;
@@ -117,102 +154,102 @@ namespace OpenSim.Region.Environment.Scenes
117 } 154 }
118 catch (Exception) 155 catch (Exception)
119 { 156 {
120 statpack.Region.RegionFlags = 0; 157 statpack.Region.RegionFlags = (uint) 0;
121 } 158 }
122 statpack.Region.ObjectCapacity = (uint) objectCapacity; 159 statpack.Region.ObjectCapacity = (uint) objectCapacity;
123 160
124 #region various statistic googly moogly 161#region various statistic googly moogly
125 162
126 // Our FPS is actually 10fps, so multiplying by 5 to get the amount that people expect there 163 // Our FPS is actually 10fps, so multiplying by 5 to get the amount that people expect there
127 // 0-50 is pretty close to 0-45 164 // 0-50 is pretty close to 0-45
128 float simfps = ((m_fps * 5)); 165 float simfps = (int) ((m_fps * 5));
129 166
130 //if (simfps > 45) 167 //if (simfps > 45)
131 //simfps = simfps - (simfps - 45); 168 //simfps = simfps - (simfps - 45);
132 //if (simfps < 0) 169 //if (simfps < 0)
133 //simfps = 0; 170 //simfps = 0;
134 171
135 // 172 //
136 float physfps = ((m_pfps / 1000)); 173 float physfps = ((m_pfps / 1000));
137 174
138 //if (physfps > 600) 175 //if (physfps > 600)
139 //physfps = physfps - (physfps - 600); 176 //physfps = physfps - (physfps - 600);
140 177
141 if (physfps < 0) 178 if (physfps < 0)
142 physfps = 0; 179 physfps = 0;
143 180
144 #endregion 181#endregion
145 182
146 //Our time dilation is 0.91 when we're running a full speed, 183 //Our time dilation is 0.91 when we're running a full speed,
147 // therefore to make sure we get an appropriate range, 184 // therefore to make sure we get an appropriate range,
148 // we have to factor in our error. (0.10f * statsUpdateFactor) 185 // we have to factor in our error. (0.10f * statsUpdateFactor)
149 // multiplies the fix for the error times the amount of times it'll occur a second 186 // multiplies the fix for the error times the amount of times it'll occur a second
150 // / 10 divides the value by the number of times the sim heartbeat runs (10fps) 187 // / 10 divides the value by the number of times the sim heartbeat runs (10fps)
151 // Then we divide the whole amount by the amount of seconds pass in between stats updates. 188 // Then we divide the whole amount by the amount of seconds pass in between stats updates.
152 189
153 sb[0].StatID = (uint) Stats.TimeDilation; 190 sb[0].StatID = (uint) Stats.TimeDilation;
154 sb[0].StatValue = m_timeDilation; //((((m_timeDilation + (0.10f * statsUpdateFactor)) /10) / statsUpdateFactor)); 191 sb[0].StatValue = m_timeDilation ; //((((m_timeDilation + (0.10f * statsUpdateFactor)) /10) / statsUpdateFactor));
155 192
156 sb[1].StatID = (uint) Stats.SimFPS; 193 sb[1].StatID = (uint) Stats.SimFPS;
157 sb[1].StatValue = simfps / statsUpdateFactor; 194 sb[1].StatValue = simfps/statsUpdateFactor;
158 195
159 sb[2].StatID = (uint) Stats.PhysicsFPS; 196 sb[2].StatID = (uint) Stats.PhysicsFPS;
160 sb[2].StatValue = physfps / statsUpdateFactor; 197 sb[2].StatValue = physfps / statsUpdateFactor;
161 198
162 sb[3].StatID = (uint) Stats.AgentUpdates; 199 sb[3].StatID = (uint) Stats.AgentUpdates;
163 sb[3].StatValue = (m_agentUpdates / statsUpdateFactor); 200 sb[3].StatValue = (m_agentUpdates / statsUpdateFactor);
164 201
165 sb[4].StatID = (uint) Stats.Agents; 202 sb[4].StatID = (uint) Stats.Agents;
166 sb[4].StatValue = m_rootAgents; 203 sb[4].StatValue = m_rootAgents;
167 204
168 sb[5].StatID = (uint) Stats.ChildAgents; 205 sb[5].StatID = (uint) Stats.ChildAgents;
169 sb[5].StatValue = m_childAgents; 206 sb[5].StatValue = m_childAgents;
170 207
171 sb[6].StatID = (uint) Stats.TotalPrim; 208 sb[6].StatID = (uint) Stats.TotalPrim;
172 sb[6].StatValue = m_numPrim; 209 sb[6].StatValue = m_numPrim;
173 210
174 sb[7].StatID = (uint) Stats.ActivePrim; 211 sb[7].StatID = (uint) Stats.ActivePrim;
175 sb[7].StatValue = m_activePrim; 212 sb[7].StatValue = m_activePrim;
176 213
177 sb[8].StatID = (uint) Stats.FrameMS; 214 sb[8].StatID = (uint)Stats.FrameMS;
178 sb[8].StatValue = m_frameMS / statsUpdateFactor; 215 sb[8].StatValue = m_frameMS / statsUpdateFactor;
179 216
180 sb[9].StatID = (uint) Stats.NetMS; 217 sb[9].StatID = (uint)Stats.NetMS;
181 sb[9].StatValue = m_netMS / statsUpdateFactor; 218 sb[9].StatValue = m_netMS / statsUpdateFactor;
182 219
183 sb[10].StatID = (uint) Stats.PhysicsMS; 220 sb[10].StatID = (uint)Stats.PhysicsMS;
184 sb[10].StatValue = m_physicsMS / statsUpdateFactor; 221 sb[10].StatValue = m_physicsMS / statsUpdateFactor;
185 222
186 sb[11].StatID = (uint) Stats.ImageMS; 223 sb[11].StatID = (uint)Stats.ImageMS ;
187 sb[11].StatValue = m_imageMS / statsUpdateFactor; 224 sb[11].StatValue = m_imageMS / statsUpdateFactor;
188 225
189 sb[12].StatID = (uint) Stats.OtherMS; 226 sb[12].StatID = (uint)Stats.OtherMS;
190 sb[12].StatValue = m_otherMS / statsUpdateFactor; 227 sb[12].StatValue = m_otherMS / statsUpdateFactor;
191 228
192 sb[13].StatID = (uint) Stats.InPacketsPerSecond; 229 sb[13].StatID = (uint)Stats.InPacketsPerSecond;
193 sb[13].StatValue = (m_inPacketsPerSecond); 230 sb[13].StatValue = (m_inPacketsPerSecond);
194 231
195 sb[14].StatID = (uint) Stats.OutPacketsPerSecond; 232 sb[14].StatID = (uint)Stats.OutPacketsPerSecond;
196 sb[14].StatValue = (m_outPacketsPerSecond / statsUpdateFactor); 233 sb[14].StatValue = (m_outPacketsPerSecond / statsUpdateFactor);
197 234
198 sb[15].StatID = (uint) Stats.UnAckedBytes; 235 sb[15].StatID = (uint)Stats.UnAckedBytes;
199 sb[15].StatValue = m_unAckedBytes; 236 sb[15].StatValue = m_unAckedBytes;
200 237
201 sb[16].StatID = (uint) Stats.AgentMS; 238 sb[16].StatID = (uint)Stats.AgentMS;
202 sb[16].StatValue = m_agentMS / statsUpdateFactor; 239 sb[16].StatValue = m_agentMS / statsUpdateFactor;
203 240
204 sb[17].StatID = (uint) Stats.PendingDownloads; 241 sb[17].StatID = (uint)Stats.PendingDownloads;
205 sb[17].StatValue = m_pendingDownloads; 242 sb[17].StatValue = m_pendingDownloads;
206 243
207 sb[18].StatID = (uint) Stats.PendingUploads; 244 sb[18].StatID = (uint)Stats.PendingUploads;
208 sb[18].StatValue = m_pendingUploads; 245 sb[18].StatValue = m_pendingUploads;
209 246
210 sb[19].StatID = (uint) Stats.ActiveScripts; 247 sb[19].StatID = (uint)Stats.ActiveScripts;
211 sb[19].StatValue = m_activeScripts; 248 sb[19].StatValue = m_activeScripts;
212 249
213 sb[20].StatID = (uint) Stats.ScriptLinesPerSecond; 250 sb[20].StatID = (uint)Stats.ScriptLinesPerSecond;
214 sb[20].StatValue = m_scriptLinesPerSecond / statsUpdateFactor; 251 sb[20].StatValue = m_scriptLinesPerSecond / statsUpdateFactor;
215 252
216 statpack.Stat = sb; 253 statpack.Stat = sb;
217 254
218 handlerSendStatResult = OnSendStatsResult; 255 handlerSendStatResult = OnSendStatsResult;
@@ -223,7 +260,7 @@ namespace OpenSim.Region.Environment.Scenes
223 resetvalues(); 260 resetvalues();
224 } 261 }
225 } 262 }
226 263
227 private void resetvalues() 264 private void resetvalues()
228 { 265 {
229 m_timeDilation = 0; 266 m_timeDilation = 0;
@@ -247,7 +284,6 @@ namespace OpenSim.Region.Environment.Scenes
247 } 284 }
248 285
249 # region methods called from Scene 286 # region methods called from Scene
250
251 // The majority of these functions are additive 287 // The majority of these functions are additive
252 // so that you can easily change the amount of 288 // so that you can easily change the amount of
253 // seconds in between sim stats updates 289 // seconds in between sim stats updates
@@ -256,10 +292,10 @@ namespace OpenSim.Region.Environment.Scenes
256 { 292 {
257 //float tdsetting = td; 293 //float tdsetting = td;
258 //if (tdsetting > 1.0f) 294 //if (tdsetting > 1.0f)
259 //tdsetting = (tdsetting - (tdsetting - 0.91f)); 295 //tdsetting = (tdsetting - (tdsetting - 0.91f));
260 296
261 //if (tdsetting < 0) 297 //if (tdsetting < 0)
262 //tdsetting = 0.0f; 298 //tdsetting = 0.0f;
263 m_timeDilation = td; 299 m_timeDilation = td;
264 } 300 }
265 301
@@ -317,35 +353,30 @@ namespace OpenSim.Region.Environment.Scenes
317 { 353 {
318 m_frameMS += ms; 354 m_frameMS += ms;
319 } 355 }
320
321 public void addNetMS(int ms) 356 public void addNetMS(int ms)
322 { 357 {
323 m_netMS += ms; 358 m_netMS += ms;
324 } 359 }
325
326 public void addAgentMS(int ms) 360 public void addAgentMS(int ms)
327 { 361 {
328 m_agentMS += ms; 362 m_agentMS += ms;
329 } 363 }
330
331 public void addPhysicsMS(int ms) 364 public void addPhysicsMS(int ms)
332 { 365 {
333 m_physicsMS += ms; 366 m_physicsMS += ms;
334 } 367 }
335
336 public void addImageMS(int ms) 368 public void addImageMS(int ms)
337 { 369 {
338 m_imageMS += ms; 370 m_imageMS += ms;
339 } 371 }
340
341 public void addOtherMS(int ms) 372 public void addOtherMS(int ms)
342 { 373 {
343 m_otherMS += ms; 374 m_otherMS += ms;
344 } 375 }
345 376
346// private static readonly log4net.ILog m_log 377// private static readonly log4net.ILog m_log
347// = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); 378// = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
348 379
349 public void addPendingDownload(int count) 380 public void addPendingDownload(int count)
350 { 381 {
351 m_pendingDownloads += count; 382 m_pendingDownloads += count;
@@ -368,40 +399,5 @@ namespace OpenSim.Region.Environment.Scenes
368 } 399 }
369 400
370 #endregion 401 #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
406 } 402 }
407} \ No newline at end of file 403}
diff --git a/OpenSim/Region/Environment/Scenes/UndoState.cs b/OpenSim/Region/Environment/Scenes/UndoState.cs
index f16bb34..daabd8d 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 LLQuaternion Rotation = LLQuaternion.Identity;
36 public LLVector3 Scale = LLVector3.Zero; 35 public LLVector3 Scale = LLVector3.Zero;
36 public LLQuaternion Rotation = LLQuaternion.Identity;
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,20 +50,18 @@ namespace OpenSim.Region.Environment.Scenes
50 { 50 {
51 Position = part.AbsolutePosition; 51 Position = part.AbsolutePosition;
52 Rotation = part.RotationOffset; 52 Rotation = part.RotationOffset;
53
53 } 54 }
54 else 55 else
55 { 56 {
56 Position = part.GroupPosition; 57 Position = part.GroupPosition;
57 Rotation = part.RotationOffset; 58 Rotation = part.RotationOffset;
58 Scale = part.Shape.Scale; 59 Scale = part.Shape.Scale;
60
59 } 61 }
60 } 62 }
61 } 63 }
62 64
63 public UndoState()
64 {
65 }
66
67 public bool Compare(SceneObjectPart part) 65 public bool Compare(SceneObjectPart part)
68 { 66 {
69 if (part != null) 67 if (part != null)
@@ -81,6 +79,7 @@ namespace OpenSim.Region.Environment.Scenes
81 return true; 79 return true;
82 else 80 else
83 return false; 81 return false;
82
84 } 83 }
85 } 84 }
86 return false; 85 return false;
@@ -91,7 +90,7 @@ namespace OpenSim.Region.Environment.Scenes
91 if (part != null) 90 if (part != null)
92 { 91 {
93 part.m_undoing = true; 92 part.m_undoing = true;
94 93
95 if (part.ParentID == 0) 94 if (part.ParentID == 0)
96 { 95 {
97 part.ParentGroup.AbsolutePosition = Position; 96 part.ParentGroup.AbsolutePosition = Position;
@@ -106,7 +105,12 @@ namespace OpenSim.Region.Environment.Scenes
106 part.ScheduleTerseUpdate(); 105 part.ScheduleTerseUpdate();
107 } 106 }
108 part.m_undoing = false; 107 part.m_undoing = false;
108
109 } 109 }
110 } 110 }
111
112 public UndoState()
113 {
114 }
111 } 115 }
112} \ No newline at end of file 116}
diff --git a/OpenSim/Region/Environment/StorageManager.cs b/OpenSim/Region/Environment/StorageManager.cs
index 2178b5e..b9a42a2 100644
--- a/OpenSim/Region/Environment/StorageManager.cs
+++ b/OpenSim/Region/Environment/StorageManager.cs
@@ -36,7 +36,12 @@ 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 readonly IRegionDataStore m_dataStore; 39 private IRegionDataStore m_dataStore;
40
41 public IRegionDataStore DataStore
42 {
43 get { return m_dataStore; }
44 }
40 45
41 public StorageManager(IRegionDataStore storage) 46 public StorageManager(IRegionDataStore storage)
42 { 47 {
@@ -69,10 +74,5 @@ namespace OpenSim.Region.Environment
69 74
70 //TODO: Add checking and warning to make sure it initialised. 75 //TODO: Add checking and warning to make sure it initialised.
71 } 76 }
72
73 public IRegionDataStore DataStore
74 {
75 get { return m_dataStore; }
76 }
77 } 77 }
78} \ No newline at end of file 78}
diff --git a/OpenSim/Region/Environment/Types/BasicQuadTreeNode.cs b/OpenSim/Region/Environment/Types/BasicQuadTreeNode.cs
index 41f17e5..24ce94b 100644
--- a/OpenSim/Region/Environment/Types/BasicQuadTreeNode.cs
+++ b/OpenSim/Region/Environment/Types/BasicQuadTreeNode.cs
@@ -33,15 +33,16 @@ namespace OpenSim.Region.Environment.Types
33{ 33{
34 public class BasicQuadTreeNode 34 public class BasicQuadTreeNode
35 { 35 {
36 private readonly short m_height; 36 private List<SceneObjectGroup> m_objects = new List<SceneObjectGroup>();
37 private readonly short m_leftX; 37 private BasicQuadTreeNode[] m_childNodes = null;
38 private readonly short m_leftY; 38 private BasicQuadTreeNode m_parent = null;
39 private readonly List<SceneObjectGroup> m_objects = new List<SceneObjectGroup>(); 39
40 private readonly BasicQuadTreeNode m_parent; 40 private short m_leftX;
41 private short m_leftY;
42 private short m_width;
43 private short m_height;
41 //private int m_quadNumber; 44 //private int m_quadNumber;
42 private readonly string m_quadID; 45 private string m_quadID;
43 private readonly short m_width;
44 private BasicQuadTreeNode[] m_childNodes;
45 46
46 public BasicQuadTreeNode(BasicQuadTreeNode parent, string quadID, short leftX, short leftY, short width, 47 public BasicQuadTreeNode(BasicQuadTreeNode parent, string quadID, short leftX, short leftY, short width,
47 short height) 48 short height)
@@ -66,9 +67,9 @@ namespace OpenSim.Region.Environment.Types
66 } 67 }
67 else 68 else
68 { 69 {
69 if (obj.AbsolutePosition.X < (m_leftX + (m_width / 2))) 70 if (obj.AbsolutePosition.X < (m_leftX + (m_width/2)))
70 { 71 {
71 if (obj.AbsolutePosition.Y < (m_leftY + (m_height / 2))) 72 if (obj.AbsolutePosition.Y < (m_leftY + (m_height/2)))
72 { 73 {
73 m_childNodes[0].AddObject(obj); 74 m_childNodes[0].AddObject(obj);
74 } 75 }
@@ -79,7 +80,7 @@ namespace OpenSim.Region.Environment.Types
79 } 80 }
80 else 81 else
81 { 82 {
82 if (obj.AbsolutePosition.Y < (m_leftY + (m_height / 2))) 83 if (obj.AbsolutePosition.Y < (m_leftY + (m_height/2)))
83 { 84 {
84 m_childNodes[1].AddObject(obj); 85 m_childNodes[1].AddObject(obj);
85 } 86 }
@@ -97,17 +98,17 @@ namespace OpenSim.Region.Environment.Types
97 { 98 {
98 m_childNodes = new BasicQuadTreeNode[4]; 99 m_childNodes = new BasicQuadTreeNode[4];
99 m_childNodes[0] = 100 m_childNodes[0] =
100 new BasicQuadTreeNode(this, m_quadID + "1/", m_leftX, m_leftY, (short) (m_width / 2), 101 new BasicQuadTreeNode(this, m_quadID + "1/", m_leftX, m_leftY, (short) (m_width/2),
101 (short) (m_height / 2)); 102 (short) (m_height/2));
102 m_childNodes[1] = 103 m_childNodes[1] =
103 new BasicQuadTreeNode(this, m_quadID + "2/", (short) (m_leftX + (m_width / 2)), m_leftY, 104 new BasicQuadTreeNode(this, m_quadID + "2/", (short) (m_leftX + (m_width/2)), m_leftY,
104 (short) (m_width / 2), (short) (m_height / 2)); 105 (short) (m_width/2), (short) (m_height/2));
105 m_childNodes[2] = 106 m_childNodes[2] =
106 new BasicQuadTreeNode(this, m_quadID + "3/", m_leftX, (short) (m_leftY + (m_height / 2)), 107 new BasicQuadTreeNode(this, m_quadID + "3/", m_leftX, (short) (m_leftY + (m_height/2)),
107 (short) (m_width / 2), (short) (m_height / 2)); 108 (short) (m_width/2), (short) (m_height/2));
108 m_childNodes[3] = 109 m_childNodes[3] =
109 new BasicQuadTreeNode(this, m_quadID + "4/", (short) (m_leftX + (m_width / 2)), 110 new BasicQuadTreeNode(this, m_quadID + "4/", (short) (m_leftX + (m_width/2)),
110 (short) (m_height + (m_height / 2)), (short) (m_width / 2), (short) (m_height / 2)); 111 (short) (m_height + (m_height/2)), (short) (m_width/2), (short) (m_height/2));
111 } 112 }
112 else 113 else
113 { 114 {
@@ -126,9 +127,9 @@ namespace OpenSim.Region.Environment.Types
126 } 127 }
127 else 128 else
128 { 129 {
129 if (x < m_leftX + (m_width / 2)) 130 if (x < m_leftX + (m_width/2))
130 { 131 {
131 if (y < m_leftY + (m_height / 2)) 132 if (y < m_leftY + (m_height/2))
132 { 133 {
133 return m_childNodes[0].GetObjectsFrom(x, y); 134 return m_childNodes[0].GetObjectsFrom(x, y);
134 } 135 }
@@ -139,7 +140,7 @@ namespace OpenSim.Region.Environment.Types
139 } 140 }
140 else 141 else
141 { 142 {
142 if (y < m_leftY + (m_height / 2)) 143 if (y < m_leftY + (m_height/2))
143 { 144 {
144 return m_childNodes[1].GetObjectsFrom(x, y); 145 return m_childNodes[1].GetObjectsFrom(x, y);
145 } 146 }
@@ -180,9 +181,9 @@ namespace OpenSim.Region.Environment.Types
180 } 181 }
181 else 182 else
182 { 183 {
183 if (x < m_leftX + (m_width / 2)) 184 if (x < m_leftX + (m_width/2))
184 { 185 {
185 if (y < m_leftY + (m_height / 2)) 186 if (y < m_leftY + (m_height/2))
186 { 187 {
187 return m_childNodes[0].GetNodeID(x, y); 188 return m_childNodes[0].GetNodeID(x, y);
188 } 189 }
@@ -193,7 +194,7 @@ namespace OpenSim.Region.Environment.Types
193 } 194 }
194 else 195 else
195 { 196 {
196 if (y < m_leftY + (m_height / 2)) 197 if (y < m_leftY + (m_height/2))
197 { 198 {
198 return m_childNodes[1].GetNodeID(x, y); 199 return m_childNodes[1].GetNodeID(x, y);
199 } 200 }
@@ -265,4 +266,4 @@ namespace OpenSim.Region.Environment.Types
265 return retVal; 266 return retVal;
266 } 267 }
267 } 268 }
268} \ No newline at end of file 269}
diff --git a/OpenSim/Region/Environment/Types/UpdateQueue.cs b/OpenSim/Region/Environment/Types/UpdateQueue.cs
index 24fe116..ec1ffd2 100644
--- a/OpenSim/Region/Environment/Types/UpdateQueue.cs
+++ b/OpenSim/Region/Environment/Types/UpdateQueue.cs
@@ -34,70 +34,26 @@ 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 readonly List<LLUUID> m_ids; 40 private Queue<SceneObjectPart> m_queue;
41 private readonly Queue<SceneObjectPart> m_queue;
42 41
43 private readonly object m_syncObject = new object(); 42 private List<LLUUID> m_ids;
44 43
45 public UpdateQueue() 44 private object m_syncObject = new object();
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 }
70 45
71 public int Count 46 public int Count
72 { 47 {
73 get { return m_queue.Count; } 48 get { return m_queue.Count; }
74 } 49 }
75 50
76 #region ISerializable Members 51 public UpdateQueue()
77
78 [SecurityPermission(SecurityAction.LinkDemand,
79 Flags = SecurityPermissionFlag.SerializationFormatter)]
80 public virtual void GetObjectData(
81 SerializationInfo info, StreamingContext context)
82 { 52 {
83 if (info == null) 53 m_queue = new Queue<SceneObjectPart>();
84 { 54 m_ids = new List<LLUUID>();
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);
97 } 55 }
98 56
99 #endregion
100
101 public void Clear() 57 public void Clear()
102 { 58 {
103 lock (m_syncObject) 59 lock (m_syncObject)
@@ -133,5 +89,46 @@ namespace OpenSim.Region.Environment.Types
133 89
134 return part; 90 return part;
135 } 91 }
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 }
136 } 133 }
137} \ No newline at end of file 134}