aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs4
-rw-r--r--OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs216
-rw-r--r--OpenSim/Data/MSSQL/MSSQLAssetData.cs2
-rw-r--r--OpenSim/Grid/AssetServer/Main.cs81
-rw-r--r--OpenSim/Grid/AssetServer/Properties/AssemblyInfo.cs2
-rw-r--r--OpenSim/Grid/AssetServer/RestService.cs42
-rw-r--r--OpenSim/Grid/GridServer/GridManager.cs185
-rw-r--r--OpenSim/Grid/GridServer/GridServerBase.cs60
-rw-r--r--OpenSim/Grid/GridServer/IGridPlugin.cs2
-rw-r--r--OpenSim/Grid/GridServer/Program.cs2
-rw-r--r--OpenSim/Grid/GridServer/Properties/AssemblyInfo.cs2
-rw-r--r--OpenSim/Grid/InventoryServer/GridInventoryService.cs50
-rw-r--r--OpenSim/Grid/InventoryServer/InventoryManager.cs18
-rw-r--r--OpenSim/Grid/InventoryServer/Main.cs65
-rw-r--r--OpenSim/Grid/MessagingServer/Main.cs78
-rw-r--r--OpenSim/Grid/MessagingServer/MessageService.cs151
-rw-r--r--OpenSim/Grid/MessagingServer/PresenceInformer.cs11
-rw-r--r--OpenSim/Grid/MessagingServer/UserPresenceData.cs10
-rw-r--r--OpenSim/Grid/MessagingServer/WorkUnitBase.cs2
-rw-r--r--OpenSim/Grid/MessagingServer/WorkUnitPresenceUpdate.cs2
-rw-r--r--OpenSim/Grid/MessagingServer/XMPPHTTPService.cs24
-rw-r--r--OpenSim/Grid/ScriptServer/Application.cs6
-rw-r--r--OpenSim/Grid/ScriptServer/FakeScene.cs4
-rw-r--r--OpenSim/Grid/ScriptServer/Properties/AssemblyInfo.cs2
-rw-r--r--OpenSim/Grid/ScriptServer/RemotingObject.cs6
-rw-r--r--OpenSim/Grid/ScriptServer/RemotingServer.cs9
-rw-r--r--OpenSim/Grid/ScriptServer/ScriptServer/Region/RegionBase.cs5
-rw-r--r--OpenSim/Grid/ScriptServer/ScriptServer/Region/RegionConnectionManager.cs2
-rw-r--r--OpenSim/Grid/ScriptServer/ScriptServer/RegionCommManager.cs6
-rw-r--r--OpenSim/Grid/ScriptServer/ScriptServer/ScriptEngineLoader.cs6
-rw-r--r--OpenSim/Grid/ScriptServer/ScriptServer/ScriptEnginesManager.cs6
-rw-r--r--OpenSim/Grid/ScriptServer/ScriptServerMain.cs16
-rw-r--r--OpenSim/Grid/UserServer/Main.cs145
-rw-r--r--OpenSim/Grid/UserServer/MessageServersConnector.cs70
-rw-r--r--OpenSim/Grid/UserServer/Properties/AssemblyInfo.cs2
-rw-r--r--OpenSim/Grid/UserServer/UserLoginService.cs118
-rw-r--r--OpenSim/Grid/UserServer/UserManager.cs132
-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
-rw-r--r--ThirdParty/3Di/LoadBalancer/LoadBalancerPlugin.cs60
-rw-r--r--ThirdParty/3Di/LoadBalancer/TcpClient.cs24
-rw-r--r--ThirdParty/3Di/LoadBalancer/TcpServer.cs14
-rw-r--r--ThirdParty/3Di/RegionProxy/RegionProxyPlugin.cs8
117 files changed, 4836 insertions, 4739 deletions
diff --git a/OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs b/OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs
index 7e498d6..dd3f4b3 100644
--- a/OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs
+++ b/OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs
@@ -68,7 +68,7 @@ namespace OpenSim.ApplicationPlugins.LoadRegions
68 68
69 for (int i = 0; i < regionsToLoad.Length; i++) 69 for (int i = 0; i < regionsToLoad.Length; i++)
70 { 70 {
71 m_log.Debug("[LOADREGIONS]: Creating Region: " + regionsToLoad[i].RegionName + " (ThreadID: " + Thread.CurrentThread.ManagedThreadId + 71 m_log.Debug("[LOADREGIONS]: Creating Region: " + regionsToLoad[i].RegionName + " (ThreadID: " + Thread.CurrentThread.ManagedThreadId.ToString() +
72 ")"); 72 ")");
73 openSim.CreateRegion(regionsToLoad[i], true); 73 openSim.CreateRegion(regionsToLoad[i], true);
74 } 74 }
@@ -106,7 +106,7 @@ namespace OpenSim.ApplicationPlugins.LoadRegions
106 if (regionhandle == regionsToLoad[i].RegionHandle) 106 if (regionhandle == regionsToLoad[i].RegionHandle)
107 { 107 {
108 m_log.Debug("[LOADREGIONS]: Creating Region: " + regionsToLoad[i].RegionName + " (ThreadID: " + 108 m_log.Debug("[LOADREGIONS]: Creating Region: " + regionsToLoad[i].RegionName + " (ThreadID: " +
109 Thread.CurrentThread.ManagedThreadId + ")"); 109 Thread.CurrentThread.ManagedThreadId.ToString() + ")");
110 openSim.CreateRegion(regionsToLoad[i], true); 110 openSim.CreateRegion(regionsToLoad[i], true);
111 } 111 }
112 } 112 }
diff --git a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
index b7067e7..e540e4d 100644
--- a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
+++ b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
@@ -54,13 +54,11 @@ namespace OpenSim.ApplicationPlugins.RemoteController
54 private BaseHttpServer m_httpd; 54 private BaseHttpServer m_httpd;
55 private string requiredPassword = String.Empty; 55 private string requiredPassword = String.Empty;
56 56
57 #region IApplicationPlugin Members
58
59 public void Initialise(OpenSimMain openSim) 57 public void Initialise(OpenSimMain openSim)
60 { 58 {
61 try 59 try
62 { 60 {
63 if (openSim.ConfigSource.Configs["RemoteAdmin"] != null && 61 if (openSim.ConfigSource.Configs["RemoteAdmin"] != null &&
64 openSim.ConfigSource.Configs["RemoteAdmin"].GetBoolean("enabled", false)) 62 openSim.ConfigSource.Configs["RemoteAdmin"].GetBoolean("enabled", false))
65 { 63 {
66 m_log.Info("[RADMIN]: Remote Admin Plugin Enabled"); 64 m_log.Info("[RADMIN]: Remote Admin Plugin Enabled");
@@ -84,12 +82,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController
84 } 82 }
85 } 83 }
86 84
87 public void Close()
88 {
89 }
90
91 #endregion
92
93 public XmlRpcResponse XmlRpcRestartMethod(XmlRpcRequest request) 85 public XmlRpcResponse XmlRpcRestartMethod(XmlRpcRequest request)
94 { 86 {
95 XmlRpcResponse response = new XmlRpcResponse(); 87 XmlRpcResponse response = new XmlRpcResponse();
@@ -98,14 +90,13 @@ namespace OpenSim.ApplicationPlugins.RemoteController
98 Hashtable responseData = new Hashtable(); 90 Hashtable responseData = new Hashtable();
99 91
100 m_log.Info("[RADMIN]: Request to restart Region."); 92 m_log.Info("[RADMIN]: Request to restart Region.");
101 try 93 try {
102 { 94 checkStringParameters(request, new string[] { "password", "regionID" });
103 checkStringParameters(request, new[] {"password", "regionID"});
104 95
105 if (requiredPassword != String.Empty && 96 if (requiredPassword != String.Empty &&
106 (!requestData.Contains("password") || (string) requestData["password"] != requiredPassword)) 97 (!requestData.Contains("password") || (string) requestData["password"] != requiredPassword))
107 throw new Exception("wrong password"); 98 throw new Exception("wrong password");
108 99
109 LLUUID regionID = new LLUUID((string) requestData["regionID"]); 100 LLUUID regionID = new LLUUID((string) requestData["regionID"]);
110 101
111 responseData["accepted"] = "true"; 102 responseData["accepted"] = "true";
@@ -115,11 +106,11 @@ namespace OpenSim.ApplicationPlugins.RemoteController
115 106
116 if (!m_app.SceneManager.TryGetScene(regionID, out rebootedScene)) 107 if (!m_app.SceneManager.TryGetScene(regionID, out rebootedScene))
117 throw new Exception("region not found"); 108 throw new Exception("region not found");
118 109
119 responseData["rebooting"] = "true"; 110 responseData["rebooting"] = "true";
120 rebootedScene.Restart(30); 111 rebootedScene.Restart(30);
121 } 112 }
122 catch (Exception e) 113 catch(Exception e)
123 { 114 {
124 m_log.ErrorFormat("[RADMIN]: Restart region: failed: {0}", e.Message); 115 m_log.ErrorFormat("[RADMIN]: Restart region: failed: {0}", e.Message);
125 m_log.DebugFormat("[RADMIN]: Restart region: failed: {0}", e.ToString()); 116 m_log.DebugFormat("[RADMIN]: Restart region: failed: {0}", e.ToString());
@@ -139,14 +130,13 @@ namespace OpenSim.ApplicationPlugins.RemoteController
139 Hashtable requestData = (Hashtable) request.Params[0]; 130 Hashtable requestData = (Hashtable) request.Params[0];
140 Hashtable responseData = new Hashtable(); 131 Hashtable responseData = new Hashtable();
141 132
142 try 133 try {
143 { 134 checkStringParameters(request, new string[] { "password", "message" });
144 checkStringParameters(request, new[] {"password", "message"});
145 135
146 if (requiredPassword != String.Empty && 136 if (requiredPassword != String.Empty &&
147 (!requestData.Contains("password") || (string) requestData["password"] != requiredPassword)) 137 (!requestData.Contains("password") || (string) requestData["password"] != requiredPassword))
148 throw new Exception("wrong password"); 138 throw new Exception("wrong password");
149 139
150 string message = (string) requestData["message"]; 140 string message = (string) requestData["message"];
151 m_log.InfoFormat("[RADMIN]: Broadcasting: {0}", message); 141 m_log.InfoFormat("[RADMIN]: Broadcasting: {0}", message);
152 142
@@ -155,7 +145,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
155 145
156 m_app.SceneManager.SendGeneralMessage(message); 146 m_app.SceneManager.SendGeneralMessage(message);
157 } 147 }
158 catch (Exception e) 148 catch(Exception e)
159 { 149 {
160 m_log.ErrorFormat("[RADMIN]: Broadcasting: failed: {0}", e.Message); 150 m_log.ErrorFormat("[RADMIN]: Broadcasting: failed: {0}", e.Message);
161 m_log.DebugFormat("[RADMIN]: Broadcasting: failed: {0}", e.ToString()); 151 m_log.DebugFormat("[RADMIN]: Broadcasting: failed: {0}", e.ToString());
@@ -172,25 +162,24 @@ namespace OpenSim.ApplicationPlugins.RemoteController
172 public XmlRpcResponse XmlRpcLoadHeightmapMethod(XmlRpcRequest request) 162 public XmlRpcResponse XmlRpcLoadHeightmapMethod(XmlRpcRequest request)
173 { 163 {
174 XmlRpcResponse response = new XmlRpcResponse(); 164 XmlRpcResponse response = new XmlRpcResponse();
175 Hashtable requestData = (Hashtable) request.Params[0]; 165 Hashtable requestData = (Hashtable)request.Params[0];
176 166
177 m_log.DebugFormat("[RADMIN]: Load Terrain: XmlRpc {0}", request.ToString()); 167 m_log.DebugFormat("[RADMIN]: Load Terrain: XmlRpc {0}", request.ToString());
178 foreach (string k in requestData.Keys) 168 foreach (string k in requestData.Keys)
179 { 169 {
180 m_log.DebugFormat("[RADMIN]: Load Terrain: XmlRpc {0}: >{1}< {2}", 170 m_log.DebugFormat("[RADMIN]: Load Terrain: XmlRpc {0}: >{1}< {2}",
181 k, requestData[k], ((string) requestData[k]).Length); 171 k, (string)requestData[k], ((string)requestData[k]).Length);
182 } 172 }
183 173
184 Hashtable responseData = new Hashtable(); 174 Hashtable responseData = new Hashtable();
185 try 175 try {
186 { 176 checkStringParameters(request, new string[] { "password", "filename", "regionid"});
187 checkStringParameters(request, new[] {"password", "filename", "regionid"});
188 177
189 if (requiredPassword != String.Empty && 178 if (requiredPassword != String.Empty &&
190 (!requestData.Contains("password") || (string) requestData["password"] != requiredPassword)) 179 (!requestData.Contains("password") || (string)requestData["password"] != requiredPassword))
191 throw new Exception("wrong password"); 180 throw new Exception("wrong password");
192 181
193 string file = (string) requestData["filename"]; 182 string file = (string)requestData["filename"];
194 LLUUID regionID = (string) requestData["regionid"]; 183 LLUUID regionID = (string) requestData["regionid"];
195 m_log.InfoFormat("[RADMIN]: Terrain Loading: {0}", file); 184 m_log.InfoFormat("[RADMIN]: Terrain Loading: {0}", file);
196 185
@@ -209,7 +198,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
209 198
210 response.Value = responseData; 199 response.Value = responseData;
211 } 200 }
212 catch (Exception e) 201 catch (Exception e)
213 { 202 {
214 m_log.ErrorFormat("[RADMIN] Terrain Loading: failed: {0}", e.Message); 203 m_log.ErrorFormat("[RADMIN] Terrain Loading: failed: {0}", e.Message);
215 m_log.DebugFormat("[RADMIN] Terrain Loading: failed: {0}", e.ToString()); 204 m_log.DebugFormat("[RADMIN] Terrain Loading: failed: {0}", e.ToString());
@@ -228,8 +217,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
228 Hashtable requestData = (Hashtable) request.Params[0]; 217 Hashtable requestData = (Hashtable) request.Params[0];
229 Hashtable responseData = new Hashtable(); 218 Hashtable responseData = new Hashtable();
230 219
231 try 220 try {
232 {
233 if (requiredPassword != String.Empty && 221 if (requiredPassword != String.Empty &&
234 (!requestData.Contains("password") || (string) requestData["password"] != requiredPassword)) 222 (!requestData.Contains("password") || (string) requestData["password"] != requiredPassword))
235 throw new Exception("wrong password"); 223 throw new Exception("wrong password");
@@ -239,14 +227,14 @@ namespace OpenSim.ApplicationPlugins.RemoteController
239 227
240 int timeout = 2000; 228 int timeout = 2000;
241 229
242 if (requestData.ContainsKey("shutdown") && 230 if (requestData.ContainsKey("shutdown") &&
243 ((string) requestData["shutdown"] == "delayed") && 231 ((string) requestData["shutdown"] == "delayed") &&
244 requestData.ContainsKey("milliseconds")) 232 requestData.ContainsKey("milliseconds"))
245 { 233 {
246 timeout = (Int32) requestData["milliseconds"]; 234 timeout = (Int32) requestData["milliseconds"];
247 m_app.SceneManager.SendGeneralMessage("Region is going down in " + ((timeout / 1000)) + 235 m_app.SceneManager.SendGeneralMessage("Region is going down in " + ((int) (timeout/1000)).ToString() +
248 " second(s). Please save what you are doing and log out."); 236 " second(s). Please save what you are doing and log out.");
249 } 237 }
250 else 238 else
251 { 239 {
252 m_app.SceneManager.SendGeneralMessage("Region is going down now."); 240 m_app.SceneManager.SendGeneralMessage("Region is going down now.");
@@ -255,12 +243,12 @@ namespace OpenSim.ApplicationPlugins.RemoteController
255 // Perform shutdown 243 // Perform shutdown
256 Timer shutdownTimer = new Timer(timeout); // Wait before firing 244 Timer shutdownTimer = new Timer(timeout); // Wait before firing
257 shutdownTimer.AutoReset = false; 245 shutdownTimer.AutoReset = false;
258 shutdownTimer.Elapsed += shutdownTimer_Elapsed; 246 shutdownTimer.Elapsed += new ElapsedEventHandler(shutdownTimer_Elapsed);
259 shutdownTimer.Start(); 247 shutdownTimer.Start();
260 248
261 responseData["success"] = "true"; 249 responseData["success"] = "true";
262 } 250 }
263 catch (Exception e) 251 catch (Exception e)
264 { 252 {
265 m_log.ErrorFormat("[RADMIN] Shutdown: failed: {0}", e.Message); 253 m_log.ErrorFormat("[RADMIN] Shutdown: failed: {0}", e.Message);
266 m_log.DebugFormat("[RADMIN] Shutdown: failed: {0}", e.ToString()); 254 m_log.DebugFormat("[RADMIN] Shutdown: failed: {0}", e.ToString());
@@ -284,9 +272,9 @@ namespace OpenSim.ApplicationPlugins.RemoteController
284 Hashtable requestData = (Hashtable) request.Params[0]; 272 Hashtable requestData = (Hashtable) request.Params[0];
285 foreach (string p in param) 273 foreach (string p in param)
286 { 274 {
287 if (!requestData.Contains(p)) 275 if (!requestData.Contains(p))
288 throw new Exception(String.Format("missing string parameter {0}", p)); 276 throw new Exception(String.Format("missing string parameter {0}", p));
289 if (String.IsNullOrEmpty((string) requestData[p])) 277 if (String.IsNullOrEmpty((string)requestData[p]))
290 throw new Exception(String.Format("parameter {0} is empty", p)); 278 throw new Exception(String.Format("parameter {0} is empty", p));
291 } 279 }
292 } 280 }
@@ -296,7 +284,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
296 Hashtable requestData = (Hashtable) request.Params[0]; 284 Hashtable requestData = (Hashtable) request.Params[0];
297 foreach (string p in param) 285 foreach (string p in param)
298 { 286 {
299 if (!requestData.Contains(p)) 287 if (!requestData.Contains(p))
300 throw new Exception(String.Format("missing integer parameter {0}", p)); 288 throw new Exception(String.Format("missing integer parameter {0}", p));
301 } 289 }
302 } 290 }
@@ -357,35 +345,31 @@ namespace OpenSim.ApplicationPlugins.RemoteController
357 Hashtable requestData = (Hashtable) request.Params[0]; 345 Hashtable requestData = (Hashtable) request.Params[0];
358 Hashtable responseData = new Hashtable(); 346 Hashtable responseData = new Hashtable();
359 347
360 try 348 try {
361 { 349 checkStringParameters(request, new string[] { "password",
362 checkStringParameters(request, new[] 350 "region_name",
363 { 351 "region_master_first", "region_master_last",
364 "password", 352 "region_master_password",
365 "region_name", 353 "listen_ip", "external_address"});
366 "region_master_first", "region_master_last", 354 checkIntegerParams(request, new string[] { "region_x", "region_y", "listen_port"});
367 "region_master_password",
368 "listen_ip", "external_address"
369 });
370 checkIntegerParams(request, new[] {"region_x", "region_y", "listen_port"});
371 355
372 // check password 356 // check password
373 if (!String.IsNullOrEmpty(requiredPassword) && 357 if (!String.IsNullOrEmpty(requiredPassword) &&
374 (string) requestData["password"] != requiredPassword) throw new Exception("wrong password"); 358 (string)requestData["password"] != requiredPassword) throw new Exception("wrong password");
375 359
376 // extract or generate region ID now 360 // extract or generate region ID now
377 Scene scene = null; 361 Scene scene = null;
378 LLUUID regionID = LLUUID.Zero; 362 LLUUID regionID = LLUUID.Zero;
379 if (requestData.ContainsKey("region_id") && 363 if (requestData.ContainsKey("region_id") &&
380 !String.IsNullOrEmpty((string) requestData["region_id"])) 364 !String.IsNullOrEmpty((string)requestData["region_id"]))
381 { 365 {
382 regionID = (string) requestData["region_id"]; 366 regionID = (string) requestData["region_id"];
383 if (m_app.SceneManager.TryGetScene(regionID, out scene)) 367 if (m_app.SceneManager.TryGetScene(regionID, out scene))
384 throw new Exception(String.Format("region UUID already in use by region {0}, UUID {1}, <{2},{3}>", 368 throw new Exception(String.Format("region UUID already in use by region {0}, UUID {1}, <{2},{3}>",
385 scene.RegionInfo.RegionName, scene.RegionInfo.RegionID, 369 scene.RegionInfo.RegionName, scene.RegionInfo.RegionID,
386 scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY)); 370 scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY));
387 } 371 }
388 else 372 else
389 { 373 {
390 regionID = LLUUID.Random(); 374 regionID = LLUUID.Random();
391 m_log.DebugFormat("[RADMIN] CreateRegion: new region UUID {0}", regionID); 375 m_log.DebugFormat("[RADMIN] CreateRegion: new region UUID {0}", regionID);
@@ -401,7 +385,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
401 385
402 // check for collisions: region name, region UUID, 386 // check for collisions: region name, region UUID,
403 // region location 387 // region location
404 if (m_app.SceneManager.TryGetScene(region.RegionName, out scene)) 388 if (m_app.SceneManager.TryGetScene(region.RegionName, out scene))
405 throw new Exception(String.Format("region name already in use by region {0}, UUID {1}, <{2},{3}>", 389 throw new Exception(String.Format("region name already in use by region {0}, UUID {1}, <{2},{3}>",
406 scene.RegionInfo.RegionName, scene.RegionInfo.RegionID, 390 scene.RegionInfo.RegionName, scene.RegionInfo.RegionID,
407 scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY)); 391 scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY));
@@ -411,46 +395,46 @@ namespace OpenSim.ApplicationPlugins.RemoteController
411 region.RegionLocX, region.RegionLocY, 395 region.RegionLocX, region.RegionLocY,
412 scene.RegionInfo.RegionName, scene.RegionInfo.RegionID, 396 scene.RegionInfo.RegionName, scene.RegionInfo.RegionID,
413 scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY)); 397 scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY));
414 398
415 // Security risk [and apparently not used] 399 // Security risk [and apparently not used]
416 // if (requestData.ContainsKey("datastore")) 400 // if (requestData.ContainsKey("datastore"))
417 // region.DataStore = (string) requestData["datastore"]; 401 // region.DataStore = (string) requestData["datastore"];
418 402
419 region.InternalEndPoint = 403 region.InternalEndPoint =
420 new IPEndPoint(IPAddress.Parse((string) requestData["listen_ip"]), 0); 404 new IPEndPoint(IPAddress.Parse((string) requestData["listen_ip"]), 0);
421 405
422 region.InternalEndPoint.Port = (Int32) requestData["listen_port"]; 406 region.InternalEndPoint.Port = (Int32) requestData["listen_port"];
423 if (0 == region.InternalEndPoint.Port) throw new Exception("listen_port is 0"); 407 if (0 == region.InternalEndPoint.Port) throw new Exception("listen_port is 0");
424 if (m_app.SceneManager.TryGetScene(region.InternalEndPoint, out scene)) 408 if (m_app.SceneManager.TryGetScene(region.InternalEndPoint, out scene))
425 throw new Exception(String.Format("region internal IP {0} and port {1} already in use by region {2}, UUID {3}, <{4},{5}>", 409 throw new Exception(String.Format("region internal IP {0} and port {1} already in use by region {2}, UUID {3}, <{4},{5}>",
426 region.InternalEndPoint.Address, 410 region.InternalEndPoint.Address,
427 region.InternalEndPoint.Port, 411 region.InternalEndPoint.Port,
428 scene.RegionInfo.RegionName, scene.RegionInfo.RegionID, 412 scene.RegionInfo.RegionName, scene.RegionInfo.RegionID,
429 scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY)); 413 scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY));
430 414
431 415
432 region.ExternalHostName = (string) requestData["external_address"]; 416 region.ExternalHostName = (string) requestData["external_address"];
433 417
434 region.MasterAvatarFirstName = (string) requestData["region_master_first"]; 418 region.MasterAvatarFirstName = (string) requestData["region_master_first"];
435 region.MasterAvatarLastName = (string) requestData["region_master_last"]; 419 region.MasterAvatarLastName = (string) requestData["region_master_last"];
436 region.MasterAvatarSandboxPassword = (string) requestData["region_master_password"]; 420 region.MasterAvatarSandboxPassword = (string) requestData["region_master_password"];
437 421
438 bool persist = Convert.ToBoolean((string) requestData["persist"]); 422 bool persist = Convert.ToBoolean((string)requestData["persist"]);
439 if (persist) 423 if (persist)
440 { 424 {
441 string regionConfigPath = Path.Combine(Path.Combine(Util.configDir(), "Regions"), 425 string regionConfigPath = Path.Combine(Path.Combine(Util.configDir(), "Regions"),
442 String.Format("{0}x{1}-{2}.xml", 426 String.Format("{0}x{1}-{2}.xml",
443 region.RegionLocX, 427 region.RegionLocX.ToString(),
444 region.RegionLocY, 428 region.RegionLocY.ToString(),
445 regionID)); 429 regionID.ToString()));
446 m_log.DebugFormat("[RADMIN] CreateRegion: persisting region {0} to {1}", 430 m_log.DebugFormat("[RADMIN] CreateRegion: persisting region {0} to {1}",
447 region.RegionID, regionConfigPath); 431 region.RegionID, regionConfigPath);
448 region.SaveRegionToFile("dynamic region", regionConfigPath); 432 region.SaveRegionToFile("dynamic region", regionConfigPath);
449 } 433 }
450 434
451 m_app.CreateRegion(region); 435 m_app.CreateRegion(region);
452 436
453 responseData["success"] = "true"; 437 responseData["success"] = "true";
454 responseData["region_name"] = region.RegionName; 438 responseData["region_name"] = region.RegionName;
455 responseData["region_uuid"] = region.RegionID.ToString(); 439 responseData["region_uuid"] = region.RegionID.ToString();
456 440
@@ -513,52 +497,48 @@ namespace OpenSim.ApplicationPlugins.RemoteController
513 Hashtable requestData = (Hashtable) request.Params[0]; 497 Hashtable requestData = (Hashtable) request.Params[0];
514 Hashtable responseData = new Hashtable(); 498 Hashtable responseData = new Hashtable();
515 499
516 try 500 try
517 { 501 {
518 // check completeness 502 // check completeness
519 checkStringParameters(request, new[] 503 checkStringParameters(request, new string[] { "password", "user_firstname",
520 { 504 "user_lastname", "user_password" });
521 "password", "user_firstname", 505 checkIntegerParams(request, new string[] { "start_region_x", "start_region_y" });
522 "user_lastname", "user_password"
523 });
524 checkIntegerParams(request, new[] {"start_region_x", "start_region_y"});
525 506
526 // check password 507 // check password
527 if (!String.IsNullOrEmpty(requiredPassword) && 508 if (!String.IsNullOrEmpty(requiredPassword) &&
528 (string) requestData["password"] != requiredPassword) throw new Exception("wrong password"); 509 (string)requestData["password"] != requiredPassword) throw new Exception("wrong password");
529 510
530 // do the job 511 // do the job
531 string firstname = (string) requestData["user_firstname"]; 512 string firstname = (string) requestData["user_firstname"];
532 string lastname = (string) requestData["user_lastname"]; 513 string lastname = (string) requestData["user_lastname"];
533 string passwd = (string) requestData["user_password"]; 514 string passwd = (string) requestData["user_password"];
534 uint regX = Convert.ToUInt32((Int32) requestData["start_region_x"]); 515 uint regX = Convert.ToUInt32((Int32)requestData["start_region_x"]);
535 uint regY = Convert.ToUInt32((Int32) requestData["start_region_y"]); 516 uint regY = Convert.ToUInt32((Int32)requestData["start_region_y"]);
536 517
537 UserProfileData userProfile = m_app.CommunicationsManager.UserService.GetUserProfile(firstname, lastname); 518 UserProfileData userProfile = m_app.CommunicationsManager.UserService.GetUserProfile(firstname, lastname);
538 if (null != userProfile) 519 if (null != userProfile)
539 throw new Exception(String.Format("avatar {0} {1} already exists", firstname, lastname)); 520 throw new Exception(String.Format("avatar {0} {1} already exists", firstname, lastname));
540 521
541 LLUUID userID = m_app.CreateUser(firstname, lastname, passwd, regX, regY); 522 LLUUID userID = m_app.CreateUser(firstname, lastname, passwd, regX, regY);
542 523
543 if (userID == LLUUID.Zero) 524 if (userID == LLUUID.Zero) throw new Exception(String.Format("failed to create new user {0} {1}",
544 throw new Exception(String.Format("failed to create new user {0} {1}", 525 firstname, lastname));
545 firstname, lastname)); 526
546 527 responseData["success"] = "true";
547 responseData["success"] = "true";
548 responseData["avatar_uuid"] = userID.ToString(); 528 responseData["avatar_uuid"] = userID.ToString();
549 529
550 response.Value = responseData; 530 response.Value = responseData;
551 531
552 m_log.InfoFormat("[RADMIN]: CreateUser: User {0} {1} created, UUID {2}", firstname, lastname, userID); 532 m_log.InfoFormat("[RADMIN]: CreateUser: User {0} {1} created, UUID {2}", firstname, lastname, userID);
553 } 533 }
554 catch (Exception e) 534 catch (Exception e)
555 { 535 {
556 m_log.ErrorFormat("[RADMIN] CreateUser: failed: {0}", e.Message); 536 m_log.ErrorFormat("[RADMIN] CreateUser: failed: {0}", e.Message);
557 m_log.DebugFormat("[RADMIN] CreateUser: failed: {0}", e.ToString()); 537 m_log.DebugFormat("[RADMIN] CreateUser: failed: {0}", e.ToString());
558 538
559 responseData["success"] = "false"; 539 responseData["success"] = "false";
560 responseData["avatar_uuid"] = LLUUID.Zero.ToString(); 540 responseData["avatar_uuid"] = LLUUID.Zero.ToString();
561 responseData["error"] = e.Message; 541 responseData["error"] = e.Message;
562 542
563 response.Value = responseData; 543 response.Value = responseData;
564 } 544 }
@@ -573,33 +553,33 @@ namespace OpenSim.ApplicationPlugins.RemoteController
573 Hashtable requestData = (Hashtable) request.Params[0]; 553 Hashtable requestData = (Hashtable) request.Params[0];
574 Hashtable responseData = new Hashtable(); 554 Hashtable responseData = new Hashtable();
575 555
576 try 556 try
577 { 557 {
578 // check completeness 558 // check completeness
579 foreach (string p in new[] {"password", "filename"}) 559 foreach (string p in new string[] { "password", "filename" })
580 { 560 {
581 if (!requestData.Contains(p)) 561 if (!requestData.Contains(p))
582 throw new Exception(String.Format("missing parameter {0}", p)); 562 throw new Exception(String.Format("missing parameter {0}", p));
583 if (String.IsNullOrEmpty((string) requestData[p])) 563 if (String.IsNullOrEmpty((string)requestData[p]))
584 throw new Exception(String.Format("parameter {0} is empty")); 564 throw new Exception(String.Format("parameter {0} is empty"));
585 } 565 }
586 566
587 // check password 567 // check password
588 if (!String.IsNullOrEmpty(requiredPassword) && 568 if (!String.IsNullOrEmpty(requiredPassword) &&
589 (string) requestData["password"] != requiredPassword) throw new Exception("wrong password"); 569 (string)requestData["password"] != requiredPassword) throw new Exception("wrong password");
590 570
591 string filename = (string) requestData["filename"]; 571 string filename = (string)requestData["filename"];
592 if (requestData.Contains("region_uuid")) 572 if (requestData.Contains("region_uuid"))
593 { 573 {
594 LLUUID region_uuid = (string) requestData["region_uuid"]; 574 LLUUID region_uuid = (string)requestData["region_uuid"];
595 if (!m_app.SceneManager.TrySetCurrentScene(region_uuid)) 575 if (!m_app.SceneManager.TrySetCurrentScene(region_uuid))
596 throw new Exception(String.Format("failed to switch to region {0}", region_uuid)); 576 throw new Exception(String.Format("failed to switch to region {0}", region_uuid.ToString()));
597 m_log.InfoFormat("[RADMIN] Switched to region {0}", region_uuid.ToString()); 577 m_log.InfoFormat("[RADMIN] Switched to region {0}", region_uuid.ToString());
598 } 578 }
599 else if (requestData.Contains("region_name")) 579 else if (requestData.Contains("region_name"))
600 { 580 {
601 string region_name = (string) requestData["region_name"]; 581 string region_name = (string)requestData["region_name"];
602 if (!m_app.SceneManager.TrySetCurrentScene(region_name)) 582 if (!m_app.SceneManager.TrySetCurrentScene(region_name))
603 throw new Exception(String.Format("failed to switch to region {0}", region_name)); 583 throw new Exception(String.Format("failed to switch to region {0}", region_name));
604 m_log.InfoFormat("[RADMIN] Switched to region {0}", region_name); 584 m_log.InfoFormat("[RADMIN] Switched to region {0}", region_name);
605 } 585 }
@@ -608,23 +588,27 @@ namespace OpenSim.ApplicationPlugins.RemoteController
608 responseData["switched"] = "true"; 588 responseData["switched"] = "true";
609 589
610 m_app.SceneManager.LoadCurrentSceneFromXml(filename, true, new LLVector3(0, 0, 0)); 590 m_app.SceneManager.LoadCurrentSceneFromXml(filename, true, new LLVector3(0, 0, 0));
611 responseData["loaded"] = "true"; 591 responseData["loaded"] = "true";
612 592
613 response.Value = responseData; 593 response.Value = responseData;
614 } 594 }
615 catch (Exception e) 595 catch (Exception e)
616 { 596 {
617 m_log.InfoFormat("[RADMIN] LoadXml: {0}", e.Message); 597 m_log.InfoFormat("[RADMIN] LoadXml: {0}", e.Message);
618 m_log.DebugFormat("[RADMIN] LoadXml: {0}", e.ToString()); 598 m_log.DebugFormat("[RADMIN] LoadXml: {0}", e.ToString());
619 599
620 responseData["loaded"] = "false"; 600 responseData["loaded"] = "false";
621 responseData["switched"] = "false"; 601 responseData["switched"] = "false";
622 responseData["error"] = e.Message; 602 responseData["error"] = e.Message;
623 603
624 response.Value = responseData; 604 response.Value = responseData;
625 } 605 }
626 606
627 return response; 607 return response;
628 } 608 }
609
610 public void Close()
611 {
612 }
629 } 613 }
630} \ No newline at end of file 614} \ No newline at end of file
diff --git a/OpenSim/Data/MSSQL/MSSQLAssetData.cs b/OpenSim/Data/MSSQL/MSSQLAssetData.cs
index 5b4fa4e..5ae60a1 100644
--- a/OpenSim/Data/MSSQL/MSSQLAssetData.cs
+++ b/OpenSim/Data/MSSQL/MSSQLAssetData.cs
@@ -70,7 +70,7 @@ namespace OpenSim.Data.MSSQL
70 70
71 override public AssetBase FetchAsset(LLUUID assetID) 71 override public AssetBase FetchAsset(LLUUID assetID)
72 { 72 {
73 AssetBase asset; 73 AssetBase asset = null;
74 74
75 Dictionary<string, string> param = new Dictionary<string, string>(); 75 Dictionary<string, string> param = new Dictionary<string, string>();
76 param["id"] = assetID.ToString(); 76 param["id"] = assetID.ToString();
diff --git a/OpenSim/Grid/AssetServer/Main.cs b/OpenSim/Grid/AssetServer/Main.cs
index c26c506..26f4bc8 100644
--- a/OpenSim/Grid/AssetServer/Main.cs
+++ b/OpenSim/Grid/AssetServer/Main.cs
@@ -46,48 +46,14 @@ namespace OpenSim.Grid.AssetServer
46 { 46 {
47 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 47 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
48 48
49 public static OpenAsset_Main assetserver; 49 public AssetConfig m_config;
50 50
51 public static OpenAsset_Main assetserver;
52
51 // Temporarily hardcoded - should be a plugin 53 // Temporarily hardcoded - should be a plugin
52 protected IAssetLoader assetLoader = new AssetLoaderFileSystem(); 54 protected IAssetLoader assetLoader = new AssetLoaderFileSystem();
53 55
54 private IAssetProvider m_assetProvider; 56 private IAssetProvider m_assetProvider;
55 public AssetConfig m_config;
56
57 public OpenAsset_Main()
58 {
59 m_console = new ConsoleBase("OpenAsset", this);
60
61 MainConsole.Instance = m_console;
62 }
63
64 #region conscmd_callback Members
65
66 public override void RunCmd(string cmd, string[] cmdparams)
67 {
68 base.RunCmd(cmd, cmdparams);
69
70 switch (cmd)
71 {
72 case "help":
73 m_console.Notice(
74 @"shutdown - shutdown this asset server (USE CAUTION!)
75 stats - statistical information for this server");
76
77 break;
78
79 case "stats":
80 m_console.Notice("STATS", Environment.NewLine + StatsManager.AssetStats.Report());
81 break;
82
83 case "shutdown":
84 m_console.Close();
85 Environment.Exit(0);
86 break;
87 }
88 }
89
90 #endregion
91 57
92 [STAThread] 58 [STAThread]
93 public static void Main(string[] args) 59 public static void Main(string[] args)
@@ -112,6 +78,13 @@ namespace OpenSim.Grid.AssetServer
112 } 78 }
113 } 79 }
114 80
81 public OpenAsset_Main()
82 {
83 m_console = new ConsoleBase("OpenAsset", this);
84
85 MainConsole.Instance = m_console;
86 }
87
115 public void Startup() 88 public void Startup()
116 { 89 {
117 m_config = new AssetConfig("ASSET SERVER", (Path.Combine(Util.configDir(), "AssetServer_Config.xml"))); 90 m_config = new AssetConfig("ASSET SERVER", (Path.Combine(Util.configDir(), "AssetServer_Config.xml")));
@@ -187,18 +160,42 @@ namespace OpenSim.Grid.AssetServer
187 catch (Exception e) 160 catch (Exception e)
188 { 161 {
189 m_log.Warn("[ASSET]: setupDB() - Exception occured"); 162 m_log.Warn("[ASSET]: setupDB() - Exception occured");
190 m_log.Warn("[ASSET]: " + e); 163 m_log.Warn("[ASSET]: " + e.ToString());
191 } 164 }
192 } 165 }
193 166
194 public void LoadDefaultAssets() 167 public void LoadDefaultAssets()
195 { 168 {
196 assetLoader.ForEachDefaultXmlAsset(StoreAsset); 169 assetLoader.ForEachDefaultXmlAsset(StoreAsset);
197 } 170 }
198 171
199 protected void StoreAsset(AssetBase asset) 172 protected void StoreAsset(AssetBase asset)
200 { 173 {
201 m_assetProvider.CreateAsset(asset); 174 m_assetProvider.CreateAsset(asset);
202 } 175 }
176
177 public override void RunCmd(string cmd, string[] cmdparams)
178 {
179 base.RunCmd(cmd, cmdparams);
180
181 switch (cmd)
182 {
183 case "help":
184 m_console.Notice(
185 @"shutdown - shutdown this asset server (USE CAUTION!)
186 stats - statistical information for this server");
187
188 break;
189
190 case "stats":
191 m_console.Notice("STATS", Environment.NewLine + StatsManager.AssetStats.Report());
192 break;
193
194 case "shutdown":
195 m_console.Close();
196 Environment.Exit(0);
197 break;
198 }
199 }
203 } 200 }
204} \ No newline at end of file 201}
diff --git a/OpenSim/Grid/AssetServer/Properties/AssemblyInfo.cs b/OpenSim/Grid/AssetServer/Properties/AssemblyInfo.cs
index 3bae064..6f219a6 100644
--- a/OpenSim/Grid/AssetServer/Properties/AssemblyInfo.cs
+++ b/OpenSim/Grid/AssetServer/Properties/AssemblyInfo.cs
@@ -60,4 +60,4 @@ using System.Runtime.InteropServices;
60// 60//
61 61
62[assembly : AssemblyVersion("1.0.0.0")] 62[assembly : AssemblyVersion("1.0.0.0")]
63[assembly : AssemblyFileVersion("1.0.0.0")] \ No newline at end of file 63[assembly : AssemblyFileVersion("1.0.0.0")]
diff --git a/OpenSim/Grid/AssetServer/RestService.cs b/OpenSim/Grid/AssetServer/RestService.cs
index 93f86b8..ece826e 100644
--- a/OpenSim/Grid/AssetServer/RestService.cs
+++ b/OpenSim/Grid/AssetServer/RestService.cs
@@ -43,8 +43,8 @@ namespace OpenSim.Grid.AssetServer
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 45
46 private readonly IAssetProvider m_assetProvider;
47 private OpenAsset_Main m_assetManager; 46 private OpenAsset_Main m_assetManager;
47 private IAssetProvider m_assetProvider;
48 48
49 /// <summary> 49 /// <summary>
50 /// Constructor. 50 /// Constructor.
@@ -58,28 +58,28 @@ namespace OpenSim.Grid.AssetServer
58 m_assetManager = assetManager; 58 m_assetManager = assetManager;
59 m_assetProvider = assetProvider; 59 m_assetProvider = assetProvider;
60 } 60 }
61 61
62 public override byte[] Handle(string path, Stream request) 62 public override byte[] Handle(string path, Stream request)
63 { 63 {
64 string param = GetParam(path); 64 string param = GetParam(path);
65 byte[] result = new byte[] {}; 65 byte[] result = new byte[] {};
66 66
67 string[] p = param.Split(new[] {'/', '?', '&'}, StringSplitOptions.RemoveEmptyEntries); 67 string[] p = param.Split(new char[] {'/', '?', '&'}, StringSplitOptions.RemoveEmptyEntries);
68 68
69 if (p.Length > 0) 69 if (p.Length > 0)
70 { 70 {
71 LLUUID assetID = null; 71 LLUUID assetID = null;
72 72
73 if (!LLUUID.TryParse(p[0], out assetID)) 73 if (!LLUUID.TryParse(p[0], out assetID))
74 { 74 {
75 m_log.InfoFormat( 75 m_log.InfoFormat(
76 "[REST]: GET:/asset ignoring request with malformed UUID {0}", p[0]); 76 "[REST]: GET:/asset ignoring request with malformed UUID {0}", p[0]);
77 return result; 77 return result;
78 } 78 }
79 79
80 if (StatsManager.AssetStats != null) 80 if (StatsManager.AssetStats != null)
81 StatsManager.AssetStats.AddRequest(); 81 StatsManager.AssetStats.AddRequest();
82 82
83 AssetBase asset = m_assetProvider.FetchAsset(assetID); 83 AssetBase asset = m_assetProvider.FetchAsset(assetID);
84 if (asset != null) 84 if (asset != null)
85 { 85 {
@@ -94,39 +94,32 @@ namespace OpenSim.Grid.AssetServer
94 //StreamReader sr = new StreamReader(ms); 94 //StreamReader sr = new StreamReader(ms);
95 95
96 result = ms.GetBuffer(); 96 result = ms.GetBuffer();
97 97
98 m_log.InfoFormat( 98 m_log.InfoFormat(
99 "[REST]: GET:/asset found {0} with name {1}, size {2} bytes", 99 "[REST]: GET:/asset found {0} with name {1}, size {2} bytes",
100 assetID, asset.Name, result.Length); 100 assetID, asset.Name, result.Length);
101 101
102 Array.Resize(ref result, (int) ms.Length); 102 Array.Resize<byte>(ref result, (int) ms.Length);
103 } 103 }
104 else 104 else
105 { 105 {
106 if (StatsManager.AssetStats != null) 106 if (StatsManager.AssetStats != null)
107 StatsManager.AssetStats.AddNotFoundRequest(); 107 StatsManager.AssetStats.AddNotFoundRequest();
108 108
109 m_log.InfoFormat("[REST]: GET:/asset failed to find {0}", assetID); 109 m_log.InfoFormat("[REST]: GET:/asset failed to find {0}", assetID);
110 } 110 }
111 } 111 }
112 112
113 return result; 113 return result;
114 } 114 }
115 } 115 }
116 116
117 public class PostAssetStreamHandler : BaseStreamHandler 117 public class PostAssetStreamHandler : BaseStreamHandler
118 { 118 {
119 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 119 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
120 120
121 private readonly IAssetProvider m_assetProvider;
122 private OpenAsset_Main m_assetManager; 121 private OpenAsset_Main m_assetManager;
123 122 private IAssetProvider m_assetProvider;
124 public PostAssetStreamHandler(OpenAsset_Main assetManager, IAssetProvider assetProvider)
125 : base("POST", "/assets")
126 {
127 m_assetManager = assetManager;
128 m_assetProvider = assetProvider;
129 }
130 123
131 public override byte[] Handle(string path, Stream request) 124 public override byte[] Handle(string path, Stream request)
132 { 125 {
@@ -146,5 +139,12 @@ namespace OpenSim.Grid.AssetServer
146 139
147 return new byte[] {}; 140 return new byte[] {};
148 } 141 }
142
143 public PostAssetStreamHandler(OpenAsset_Main assetManager, IAssetProvider assetProvider)
144 : base("POST", "/assets")
145 {
146 m_assetManager = assetManager;
147 m_assetProvider = assetProvider;
148 }
149 } 149 }
150} \ No newline at end of file 150}
diff --git a/OpenSim/Grid/GridServer/GridManager.cs b/OpenSim/Grid/GridServer/GridManager.cs
index 32f002a..7eb9c34 100644
--- a/OpenSim/Grid/GridServer/GridManager.cs
+++ b/OpenSim/Grid/GridServer/GridManager.cs
@@ -44,11 +44,11 @@ namespace OpenSim.Grid.GridServer
44 { 44 {
45 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 45 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
46 46
47 private readonly Dictionary<string, ILogData> _logplugins = new Dictionary<string, ILogData>(); 47 private Dictionary<string, IGridData> _plugins = new Dictionary<string, IGridData>();
48 private Dictionary<string, ILogData> _logplugins = new Dictionary<string, ILogData>();
48 49
49 // This is here so that the grid server can hand out MessageServer settings to regions on registration 50 // This is here so that the grid server can hand out MessageServer settings to regions on registration
50 private readonly List<MessageServerInfo> _MessageServers = new List<MessageServerInfo>(); 51 private List<MessageServerInfo> _MessageServers = new List<MessageServerInfo>();
51 private readonly Dictionary<string, IGridData> _plugins = new Dictionary<string, IGridData>();
52 52
53 public GridConfig Config; 53 public GridConfig Config;
54 54
@@ -72,7 +72,7 @@ namespace OpenSim.Grid.GridServer
72 if (typeInterface != null) 72 if (typeInterface != null)
73 { 73 {
74 IGridData plug = 74 IGridData plug =
75 (IGridData) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); 75 (IGridData)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
76 plug.Initialise(); 76 plug.Initialise();
77 _plugins.Add(plug.getName(), plug); 77 _plugins.Add(plug.getName(), plug);
78 m_log.Info("[DATA]: Added IGridData Interface"); 78 m_log.Info("[DATA]: Added IGridData Interface");
@@ -84,7 +84,7 @@ namespace OpenSim.Grid.GridServer
84 if (typeInterface != null) 84 if (typeInterface != null)
85 { 85 {
86 ILogData plug = 86 ILogData plug =
87 (ILogData) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); 87 (ILogData)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
88 plug.Initialise(); 88 plug.Initialise();
89 _logplugins.Add(plug.getName(), plug); 89 _logplugins.Add(plug.getName(), plug);
90 m_log.Info("[DATA]: Added ILogData Interface"); 90 m_log.Info("[DATA]: Added ILogData Interface");
@@ -152,7 +152,7 @@ namespace OpenSim.Grid.GridServer
152 } 152 }
153 catch 153 catch
154 { 154 {
155 m_log.Warn("[storage]: Unable to find region " + handle + " via " + kvp.Key); 155 m_log.Warn("[storage]: Unable to find region " + handle.ToString() + " via " + kvp.Key);
156 } 156 }
157 } 157 }
158 return null; 158 return null;
@@ -218,20 +218,20 @@ namespace OpenSim.Grid.GridServer
218 { 218 {
219 if ( 219 if (
220 GetRegion( 220 GetRegion(
221 Util.UIntsToLong((uint) ((central_region.regionLocX + x) * Constants.RegionSize), 221 Util.UIntsToLong((uint)((central_region.regionLocX + x) * Constants.RegionSize),
222 (uint) (central_region.regionLocY + y) * Constants.RegionSize)) != null) 222 (uint)(central_region.regionLocY + y) * Constants.RegionSize)) != null)
223 { 223 {
224 neighbour = 224 neighbour =
225 GetRegion( 225 GetRegion(
226 Util.UIntsToLong((uint) ((central_region.regionLocX + x) * Constants.RegionSize), 226 Util.UIntsToLong((uint)((central_region.regionLocX + x) * Constants.RegionSize),
227 (uint) (central_region.regionLocY + y) * Constants.RegionSize)); 227 (uint)(central_region.regionLocY + y) * Constants.RegionSize));
228 228
229 response += "<neighbour>"; 229 response += "<neighbour>";
230 response += "<sim_ip>" + neighbour.serverIP + "</sim_ip>"; 230 response += "<sim_ip>" + neighbour.serverIP + "</sim_ip>";
231 response += "<sim_port>" + neighbour.serverPort + "</sim_port>"; 231 response += "<sim_port>" + neighbour.serverPort.ToString() + "</sim_port>";
232 response += "<locx>" + neighbour.regionLocX + "</locx>"; 232 response += "<locx>" + neighbour.regionLocX.ToString() + "</locx>";
233 response += "<locy>" + neighbour.regionLocY + "</locy>"; 233 response += "<locy>" + neighbour.regionLocY.ToString() + "</locy>";
234 response += "<regionhandle>" + neighbour.regionHandle + "</regionhandle>"; 234 response += "<regionhandle>" + neighbour.regionHandle.ToString() + "</regionhandle>";
235 response += "</neighbour>"; 235 response += "</neighbour>";
236 } 236 }
237 } 237 }
@@ -287,10 +287,10 @@ namespace OpenSim.Grid.GridServer
287 RegionProfileData sim; 287 RegionProfileData sim;
288 RegionProfileData existingSim; 288 RegionProfileData existingSim;
289 289
290 Hashtable requestData = (Hashtable) request.Params[0]; 290 Hashtable requestData = (Hashtable)request.Params[0];
291 LLUUID uuid; 291 LLUUID uuid;
292 292
293 if (!requestData.ContainsKey("UUID") || !LLUUID.TryParse((string) requestData["UUID"], out uuid)) 293 if (!requestData.ContainsKey("UUID") || !LLUUID.TryParse((string)requestData["UUID"], out uuid))
294 { 294 {
295 m_log.Info("[GRID]: Region connected without a UUID, ignoring."); 295 m_log.Info("[GRID]: Region connected without a UUID, ignoring.");
296 return ErrorResponse("No UUID passed to grid server - unable to connect you"); 296 return ErrorResponse("No UUID passed to grid server - unable to connect you");
@@ -303,7 +303,7 @@ namespace OpenSim.Grid.GridServer
303 catch (FormatException e) 303 catch (FormatException e)
304 { 304 {
305 m_log.Info("[GRID]: Invalid login parameters, ignoring."); 305 m_log.Info("[GRID]: Invalid login parameters, ignoring.");
306 return ErrorResponse("Wrong format in login parameters. Please verify parameters." + e); 306 return ErrorResponse("Wrong format in login parameters. Please verify parameters." + e.ToString() );
307 } 307 }
308 308
309 existingSim = GetRegion(sim.regionHandle); 309 existingSim = GetRegion(sim.regionHandle);
@@ -329,7 +329,7 @@ namespace OpenSim.Grid.GridServer
329 { 329 {
330 DataResponse insertResponse; 330 DataResponse insertResponse;
331 331
332 if (existingSim == null) 332 if( existingSim == null )
333 { 333 {
334 insertResponse = kvp.Value.AddProfile(sim); 334 insertResponse = kvp.Value.AddProfile(sim);
335 } 335 }
@@ -348,20 +348,20 @@ namespace OpenSim.Grid.GridServer
348 break; 348 break;
349 case DataResponse.RESPONSE_INVALIDCREDENTIALS: 349 case DataResponse.RESPONSE_INVALIDCREDENTIALS:
350 m_log.Warn("[storage]: " + 350 m_log.Warn("[storage]: " +
351 "New sim creation failed (Invalid Credentials): " + sim.regionName); 351 "New sim creation failed (Invalid Credentials): " + sim.regionName);
352 break; 352 break;
353 case DataResponse.RESPONSE_AUTHREQUIRED: 353 case DataResponse.RESPONSE_AUTHREQUIRED:
354 m_log.Warn("[storage]: " + 354 m_log.Warn("[storage]: " +
355 "New sim creation failed (Authentication Required): " + 355 "New sim creation failed (Authentication Required): " +
356 sim.regionName); 356 sim.regionName);
357 break; 357 break;
358 } 358 }
359 } 359 }
360 catch (Exception e) 360 catch (Exception e)
361 { 361 {
362 m_log.Warn("[storage]: " + 362 m_log.Warn("[storage]: " +
363 "Unable to add region " + sim.UUID + " via " + kvp.Key); 363 "Unable to add region " + sim.UUID.ToString() + " via " + kvp.Key);
364 m_log.Warn("[storage]: " + e); 364 m_log.Warn("[storage]: " + e.ToString());
365 } 365 }
366 } 366 }
367 367
@@ -375,8 +375,7 @@ namespace OpenSim.Grid.GridServer
375 { 375 {
376 m_log.Warn("[grid]: Authentication failed when trying to add new region " + sim.regionName + 376 m_log.Warn("[grid]: Authentication failed when trying to add new region " + sim.regionName +
377 " at location " + sim.regionLocX + 377 " at location " + sim.regionLocX +
378 " " + sim.regionLocY + " with TheSim.regionRecvKey " + sim.regionRecvKey + "(" + Config.SimSendKey + 378 " " + sim.regionLocY + " with TheSim.regionRecvKey " + sim.regionRecvKey + "(" + Config.SimSendKey + ") and TheSim.regionRecvKey " + sim.regionSendKey + "(" + Config.SimRecvKey + ") ");
379 ") and TheSim.regionRecvKey " + sim.regionSendKey + "(" + Config.SimRecvKey + ") ");
380 } 379 }
381 else 380 else
382 { 381 {
@@ -390,8 +389,7 @@ namespace OpenSim.Grid.GridServer
390 } 389 }
391 else 390 else
392 { 391 {
393 m_log.Warn("[grid]: Failed to add new region " + sim.regionName + " at location " + sim.regionLocX + " " + sim.regionLocY + 392 m_log.Warn("[grid]: Failed to add new region " + sim.regionName + " at location " + sim.regionLocX + " " + sim.regionLocY + " currently occupied by " + existingSim.regionName);
394 " currently occupied by " + existingSim.regionName);
395 return ErrorResponse("Another region already exists at that location. Try another"); 393 return ErrorResponse("Another region already exists at that location. Try another");
396 } 394 }
397 } 395 }
@@ -466,7 +464,7 @@ namespace OpenSim.Grid.GridServer
466 foreach (KeyValuePair<ulong, RegionProfileData> aSim in neighbours) 464 foreach (KeyValuePair<ulong, RegionProfileData> aSim in neighbours)
467 { 465 {
468 NeighbourBlock = new Hashtable(); 466 NeighbourBlock = new Hashtable();
469 NeighbourBlock["sim_ip"] = Util.GetHostFromDNS(aSim.Value.serverIP).ToString(); 467 NeighbourBlock["sim_ip"] = Util.GetHostFromDNS(aSim.Value.serverIP.ToString()).ToString();
470 NeighbourBlock["sim_port"] = aSim.Value.serverPort.ToString(); 468 NeighbourBlock["sim_port"] = aSim.Value.serverPort.ToString();
471 NeighbourBlock["region_locx"] = aSim.Value.regionLocX.ToString(); 469 NeighbourBlock["region_locx"] = aSim.Value.regionLocX.ToString();
472 NeighbourBlock["region_locy"] = aSim.Value.regionLocY.ToString(); 470 NeighbourBlock["region_locy"] = aSim.Value.regionLocY.ToString();
@@ -487,13 +485,13 @@ namespace OpenSim.Grid.GridServer
487 { 485 {
488 if ( 486 if (
489 GetRegion( 487 GetRegion(
490 Helpers.UIntsToLong((uint) ((sim.regionLocX + x) * Constants.RegionSize), 488 Helpers.UIntsToLong((uint)((sim.regionLocX + x) * Constants.RegionSize),
491 (uint) (sim.regionLocY + y) * Constants.RegionSize)) != null) 489 (uint)(sim.regionLocY + y) * Constants.RegionSize)) != null)
492 { 490 {
493 neighbour = 491 neighbour =
494 GetRegion( 492 GetRegion(
495 Helpers.UIntsToLong((uint) ((sim.regionLocX + x) * Constants.RegionSize), 493 Helpers.UIntsToLong((uint)((sim.regionLocX + x) * Constants.RegionSize),
496 (uint) (sim.regionLocY + y) * Constants.RegionSize)); 494 (uint)(sim.regionLocY + y) * Constants.RegionSize));
497 495
498 NeighbourBlock = new Hashtable(); 496 NeighbourBlock = new Hashtable();
499 NeighbourBlock["sim_ip"] = Util.GetHostFromDNS(neighbour.serverIP).ToString(); 497 NeighbourBlock["sim_ip"] = Util.GetHostFromDNS(neighbour.serverIP).ToString();
@@ -521,26 +519,27 @@ namespace OpenSim.Grid.GridServer
521 RegionProfileData sim; 519 RegionProfileData sim;
522 sim = new RegionProfileData(); 520 sim = new RegionProfileData();
523 521
524 sim.UUID = new LLUUID((string) requestData["UUID"]); 522 sim.UUID = new LLUUID((string)requestData["UUID"]);
525 sim.originUUID = new LLUUID((string) requestData["originUUID"]); 523 sim.originUUID = new LLUUID((string)requestData["originUUID"]);
526 524
527 sim.regionRecvKey = String.Empty; 525 sim.regionRecvKey = String.Empty;
528 sim.regionSendKey = String.Empty; 526 sim.regionSendKey = String.Empty;
529 527
530 if (requestData.ContainsKey("region_secret")) 528 if (requestData.ContainsKey("region_secret"))
531 { 529 {
532 string regionsecret = (string) requestData["region_secret"]; 530 string regionsecret = (string)requestData["region_secret"];
533 if (regionsecret.Length > 0) 531 if (regionsecret.Length > 0)
534 sim.regionSecret = regionsecret; 532 sim.regionSecret = regionsecret;
535 else 533 else
536 sim.regionSecret = Config.SimRecvKey; 534 sim.regionSecret = Config.SimRecvKey;
535
537 } 536 }
538 else 537 else
539 { 538 {
540 sim.regionSecret = Config.SimRecvKey; 539 sim.regionSecret = Config.SimRecvKey;
541 } 540 }
542 541
543 542
544 sim.regionDataURI = String.Empty; 543 sim.regionDataURI = String.Empty;
545 sim.regionAssetURI = Config.DefaultAssetServer; 544 sim.regionAssetURI = Config.DefaultAssetServer;
546 sim.regionAssetRecvKey = Config.AssetRecvKey; 545 sim.regionAssetRecvKey = Config.AssetRecvKey;
@@ -549,16 +548,16 @@ namespace OpenSim.Grid.GridServer
549 sim.regionUserSendKey = Config.UserSendKey; 548 sim.regionUserSendKey = Config.UserSendKey;
550 sim.regionUserRecvKey = Config.UserRecvKey; 549 sim.regionUserRecvKey = Config.UserRecvKey;
551 550
552 sim.serverIP = (string) requestData["sim_ip"]; 551 sim.serverIP = (string)requestData["sim_ip"];
553 sim.serverPort = Convert.ToUInt32((string) requestData["sim_port"]); 552 sim.serverPort = Convert.ToUInt32((string)requestData["sim_port"]);
554 sim.httpPort = Convert.ToUInt32((string) requestData["http_port"]); 553 sim.httpPort = Convert.ToUInt32((string)requestData["http_port"]);
555 sim.remotingPort = Convert.ToUInt32((string) requestData["remoting_port"]); 554 sim.remotingPort = Convert.ToUInt32((string)requestData["remoting_port"]);
556 sim.regionLocX = Convert.ToUInt32((string) requestData["region_locx"]); 555 sim.regionLocX = Convert.ToUInt32((string)requestData["region_locx"]);
557 sim.regionLocY = Convert.ToUInt32((string) requestData["region_locy"]); 556 sim.regionLocY = Convert.ToUInt32((string)requestData["region_locy"]);
558 sim.regionLocZ = 0; 557 sim.regionLocZ = 0;
559 558
560 LLUUID textureID; 559 LLUUID textureID;
561 if (LLUUID.TryParse((string) requestData["map-image-id"], out textureID)) 560 if (LLUUID.TryParse((string)requestData["map-image-id"], out textureID))
562 { 561 {
563 sim.regionMapTextureID = textureID; 562 sim.regionMapTextureID = textureID;
564 } 563 }
@@ -571,23 +570,21 @@ namespace OpenSim.Grid.GridServer
571 // 570 //
572 // this particular section of the mod attempts to receive a value from the region's xml file by way of 571 // this particular section of the mod attempts to receive a value from the region's xml file by way of
573 // OSG1GridServices for the region's owner 572 // OSG1GridServices for the region's owner
574 sim.owner_uuid = (string) requestData["master_avatar_uuid"]; 573 sim.owner_uuid = (string)requestData["master_avatar_uuid"];
575 574
576 try 575 try
577 { 576 {
578 sim.regionRecvKey = (string) requestData["recvkey"]; 577 sim.regionRecvKey = (string)requestData["recvkey"];
579 sim.regionSendKey = (string) requestData["authkey"]; 578 sim.regionSendKey = (string)requestData["authkey"];
580 }
581 catch (KeyNotFoundException)
582 {
583 } 579 }
580 catch (KeyNotFoundException) { }
584 581
585 sim.regionHandle = Helpers.UIntsToLong((sim.regionLocX * Constants.RegionSize), (sim.regionLocY * Constants.RegionSize)); 582 sim.regionHandle = Helpers.UIntsToLong((sim.regionLocX * Constants.RegionSize), (sim.regionLocY * Constants.RegionSize));
586 sim.serverURI = (string) requestData["server_uri"]; 583 sim.serverURI = (string)requestData["server_uri"];
587 584
588 sim.httpServerURI = "http://" + sim.serverIP + ":" + sim.httpPort + "/"; 585 sim.httpServerURI = "http://" + sim.serverIP + ":" + sim.httpPort + "/";
589 586
590 sim.regionName = (string) requestData["sim_name"]; 587 sim.regionName = (string)requestData["sim_name"];
591 return sim; 588 return sim;
592 } 589 }
593 590
@@ -607,7 +604,7 @@ namespace OpenSim.Grid.GridServer
607 604
608 //RegionProfileData TheSim = null; 605 //RegionProfileData TheSim = null;
609 string uuid; 606 string uuid;
610 Hashtable requestData = (Hashtable) request.Params[0]; 607 Hashtable requestData = (Hashtable)request.Params[0];
611 608
612 if (requestData.ContainsKey("UUID")) 609 if (requestData.ContainsKey("UUID"))
613 { 610 {
@@ -627,7 +624,7 @@ namespace OpenSim.Grid.GridServer
627 //OpenSim.Data.MySQL.MySQLGridData dbengine = new OpenSim.Data.MySQL.MySQLGridData(); 624 //OpenSim.Data.MySQL.MySQLGridData dbengine = new OpenSim.Data.MySQL.MySQLGridData();
628 try 625 try
629 { 626 {
630 MySQLGridData mysqldata = (MySQLGridData) (kvp.Value); 627 MySQLGridData mysqldata = (MySQLGridData)(kvp.Value);
631 //DataResponse insertResponse = mysqldata.DeleteProfile(TheSim); 628 //DataResponse insertResponse = mysqldata.DeleteProfile(TheSim);
632 DataResponse insertResponse = mysqldata.DeleteProfile(uuid); 629 DataResponse insertResponse = mysqldata.DeleteProfile(uuid);
633 switch (insertResponse) 630 switch (insertResponse)
@@ -667,22 +664,22 @@ namespace OpenSim.Grid.GridServer
667 /// <returns></returns> 664 /// <returns></returns>
668 public XmlRpcResponse XmlRpcSimulatorDataRequestMethod(XmlRpcRequest request) 665 public XmlRpcResponse XmlRpcSimulatorDataRequestMethod(XmlRpcRequest request)
669 { 666 {
670 Hashtable requestData = (Hashtable) request.Params[0]; 667 Hashtable requestData = (Hashtable)request.Params[0];
671 Hashtable responseData = new Hashtable(); 668 Hashtable responseData = new Hashtable();
672 RegionProfileData simData = null; 669 RegionProfileData simData = null;
673 if (requestData.ContainsKey("region_UUID")) 670 if (requestData.ContainsKey("region_UUID"))
674 { 671 {
675 simData = GetRegion(new LLUUID((string) requestData["region_UUID"])); 672 simData = GetRegion(new LLUUID((string)requestData["region_UUID"]));
676 } 673 }
677 else if (requestData.ContainsKey("region_handle")) 674 else if (requestData.ContainsKey("region_handle"))
678 { 675 {
679 //CFK: The if/else below this makes this message redundant. 676 //CFK: The if/else below this makes this message redundant.
680 //CFK: Console.WriteLine("requesting data for region " + (string) requestData["region_handle"]); 677 //CFK: Console.WriteLine("requesting data for region " + (string) requestData["region_handle"]);
681 simData = GetRegion(Convert.ToUInt64((string) requestData["region_handle"])); 678 simData = GetRegion(Convert.ToUInt64((string)requestData["region_handle"]));
682 } 679 }
683 else if (requestData.ContainsKey("region_name_search")) 680 else if (requestData.ContainsKey("region_name_search"))
684 { 681 {
685 simData = GetRegion((string) requestData["region_name_search"]); 682 simData = GetRegion((string)requestData["region_name_search"]);
686 } 683 }
687 684
688 if (simData == null) 685 if (simData == null)
@@ -693,8 +690,8 @@ namespace OpenSim.Grid.GridServer
693 } 690 }
694 else 691 else
695 { 692 {
696 m_log.Info("[DATA]: found " + simData.regionName + " regionHandle = " + 693 m_log.Info("[DATA]: found " + (string)simData.regionName + " regionHandle = " +
697 (string) requestData["region_handle"]); 694 (string)requestData["region_handle"]);
698 responseData["sim_ip"] = Util.GetHostFromDNS(simData.serverIP).ToString(); 695 responseData["sim_ip"] = Util.GetHostFromDNS(simData.serverIP).ToString();
699 responseData["sim_port"] = simData.serverPort.ToString(); 696 responseData["sim_port"] = simData.serverPort.ToString();
700 responseData["server_uri"] = simData.serverURI; 697 responseData["server_uri"] = simData.serverURI;
@@ -716,22 +713,22 @@ namespace OpenSim.Grid.GridServer
716 { 713 {
717 int xmin = 980, ymin = 980, xmax = 1020, ymax = 1020; 714 int xmin = 980, ymin = 980, xmax = 1020, ymax = 1020;
718 715
719 Hashtable requestData = (Hashtable) request.Params[0]; 716 Hashtable requestData = (Hashtable)request.Params[0];
720 if (requestData.ContainsKey("xmin")) 717 if (requestData.ContainsKey("xmin"))
721 { 718 {
722 xmin = (Int32) requestData["xmin"]; 719 xmin = (Int32)requestData["xmin"];
723 } 720 }
724 if (requestData.ContainsKey("ymin")) 721 if (requestData.ContainsKey("ymin"))
725 { 722 {
726 ymin = (Int32) requestData["ymin"]; 723 ymin = (Int32)requestData["ymin"];
727 } 724 }
728 if (requestData.ContainsKey("xmax")) 725 if (requestData.ContainsKey("xmax"))
729 { 726 {
730 xmax = (Int32) requestData["xmax"]; 727 xmax = (Int32)requestData["xmax"];
731 } 728 }
732 if (requestData.ContainsKey("ymax")) 729 if (requestData.ContainsKey("ymax"))
733 { 730 {
734 ymax = (Int32) requestData["ymax"]; 731 ymax = (Int32)requestData["ymax"];
735 } 732 }
736 //CFK: The second log is more meaningful and either standard or fast generally occurs. 733 //CFK: The second log is more meaningful and either standard or fast generally occurs.
737 //CFK: m_log.Info("[MAP]: World map request for range (" + xmin + "," + ymin + ")..(" + xmax + "," + ymax + ")"); 734 //CFK: m_log.Info("[MAP]: World map request for range (" + xmin + "," + ymin + ")..(" + xmax + "," + ymax + ")");
@@ -746,15 +743,15 @@ namespace OpenSim.Grid.GridServer
746 if (fastMode) 743 if (fastMode)
747 { 744 {
748 Dictionary<ulong, RegionProfileData> neighbours = 745 Dictionary<ulong, RegionProfileData> neighbours =
749 GetRegions((uint) xmin, (uint) ymin, (uint) xmax, (uint) ymax); 746 GetRegions((uint)xmin, (uint)ymin, (uint)xmax, (uint)ymax);
750 747
751 foreach (KeyValuePair<ulong, RegionProfileData> aSim in neighbours) 748 foreach (KeyValuePair<ulong, RegionProfileData> aSim in neighbours)
752 { 749 {
753 Hashtable simProfileBlock = new Hashtable(); 750 Hashtable simProfileBlock = new Hashtable();
754 simProfileBlock["x"] = aSim.Value.regionLocX.ToString(); 751 simProfileBlock["x"] = aSim.Value.regionLocX.ToString();
755 simProfileBlock["y"] = aSim.Value.regionLocY.ToString(); 752 simProfileBlock["y"] = aSim.Value.regionLocY.ToString();
756 Console.WriteLine("send neighbour info for " + aSim.Value.regionLocX + " , " + 753 Console.WriteLine("send neighbour info for " + aSim.Value.regionLocX.ToString() + " , " +
757 aSim.Value.regionLocY); 754 aSim.Value.regionLocY.ToString());
758 simProfileBlock["name"] = aSim.Value.regionName; 755 simProfileBlock["name"] = aSim.Value.regionName;
759 simProfileBlock["access"] = 21; 756 simProfileBlock["access"] = 21;
760 simProfileBlock["region-flags"] = 512; 757 simProfileBlock["region-flags"] = 512;
@@ -764,15 +761,15 @@ namespace OpenSim.Grid.GridServer
764 761
765 // For Sugilite compatibility 762 // For Sugilite compatibility
766 simProfileBlock["regionhandle"] = aSim.Value.regionHandle.ToString(); 763 simProfileBlock["regionhandle"] = aSim.Value.regionHandle.ToString();
767 simProfileBlock["sim_ip"] = aSim.Value.serverIP; 764 simProfileBlock["sim_ip"] = aSim.Value.serverIP.ToString();
768 simProfileBlock["sim_port"] = aSim.Value.serverPort.ToString(); 765 simProfileBlock["sim_port"] = aSim.Value.serverPort.ToString();
769 simProfileBlock["sim_uri"] = aSim.Value.serverURI; 766 simProfileBlock["sim_uri"] = aSim.Value.serverURI.ToString();
770 simProfileBlock["uuid"] = aSim.Value.UUID.ToString(); 767 simProfileBlock["uuid"] = aSim.Value.UUID.ToString();
771 simProfileBlock["remoting_port"] = aSim.Value.remotingPort; 768 simProfileBlock["remoting_port"] = aSim.Value.remotingPort;
772 769
773 simProfileList.Add(simProfileBlock); 770 simProfileList.Add(simProfileBlock);
774 } 771 }
775 m_log.Info("[MAP]: Fast map " + simProfileList.Count + 772 m_log.Info("[MAP]: Fast map " + simProfileList.Count.ToString() +
776 " regions @ (" + xmin + "," + ymin + ")..(" + xmax + "," + ymax + ")"); 773 " regions @ (" + xmin + "," + ymin + ")..(" + xmax + "," + ymax + ")");
777 } 774 }
778 else 775 else
@@ -782,7 +779,7 @@ namespace OpenSim.Grid.GridServer
782 { 779 {
783 for (int y = ymin; y < ymax + 1; y++) 780 for (int y = ymin; y < ymax + 1; y++)
784 { 781 {
785 ulong regHandle = Helpers.UIntsToLong((uint) (x * Constants.RegionSize), (uint) (y * Constants.RegionSize)); 782 ulong regHandle = Helpers.UIntsToLong((uint)(x * Constants.RegionSize), (uint)(y * Constants.RegionSize));
786 simProfile = GetRegion(regHandle); 783 simProfile = GetRegion(regHandle);
787 if (simProfile != null) 784 if (simProfile != null)
788 { 785 {
@@ -798,16 +795,16 @@ namespace OpenSim.Grid.GridServer
798 795
799 // For Sugilite compatibility 796 // For Sugilite compatibility
800 simProfileBlock["regionhandle"] = simProfile.regionHandle.ToString(); 797 simProfileBlock["regionhandle"] = simProfile.regionHandle.ToString();
801 simProfileBlock["sim_ip"] = simProfile.serverIP; 798 simProfileBlock["sim_ip"] = simProfile.serverIP.ToString();
802 simProfileBlock["sim_port"] = simProfile.serverPort.ToString(); 799 simProfileBlock["sim_port"] = simProfile.serverPort.ToString();
803 simProfileBlock["sim_uri"] = simProfile.serverURI; 800 simProfileBlock["sim_uri"] = simProfile.serverURI.ToString();
804 simProfileBlock["uuid"] = simProfile.UUID.ToString(); 801 simProfileBlock["uuid"] = simProfile.UUID.ToString();
805 802
806 simProfileList.Add(simProfileBlock); 803 simProfileList.Add(simProfileBlock);
807 } 804 }
808 } 805 }
809 } 806 }
810 m_log.Info("[MAP]: Std map " + simProfileList.Count + 807 m_log.Info("[MAP]: Std map " + simProfileList.Count.ToString() +
811 " regions @ (" + xmin + "," + ymin + ")..(" + xmax + "," + ymax + ")"); 808 " regions @ (" + xmin + "," + ymin + ")..(" + xmax + "," + ymax + ")");
812 } 809 }
813 810
@@ -863,12 +860,12 @@ namespace OpenSim.Grid.GridServer
863 respstring = "<Root>"; 860 respstring = "<Root>";
864 respstring += "<authkey>" + TheSim.regionSendKey + "</authkey>"; 861 respstring += "<authkey>" + TheSim.regionSendKey + "</authkey>";
865 respstring += "<sim>"; 862 respstring += "<sim>";
866 respstring += "<uuid>" + TheSim.UUID + "</uuid>"; 863 respstring += "<uuid>" + TheSim.UUID.ToString() + "</uuid>";
867 respstring += "<regionname>" + TheSim.regionName + "</regionname>"; 864 respstring += "<regionname>" + TheSim.regionName + "</regionname>";
868 respstring += "<sim_ip>" + Util.GetHostFromDNS(TheSim.serverIP) + "</sim_ip>"; 865 respstring += "<sim_ip>" + Util.GetHostFromDNS(TheSim.serverIP).ToString() + "</sim_ip>";
869 respstring += "<sim_port>" + TheSim.serverPort + "</sim_port>"; 866 respstring += "<sim_port>" + TheSim.serverPort.ToString() + "</sim_port>";
870 respstring += "<region_locx>" + TheSim.regionLocX + "</region_locx>"; 867 respstring += "<region_locx>" + TheSim.regionLocX.ToString() + "</region_locx>";
871 respstring += "<region_locy>" + TheSim.regionLocY + "</region_locy>"; 868 respstring += "<region_locy>" + TheSim.regionLocY.ToString() + "</region_locy>";
872 respstring += "<estate_id>1</estate_id>"; 869 respstring += "<estate_id>1</estate_id>";
873 respstring += "</sim>"; 870 respstring += "</sim>";
874 respstring += "</Root>"; 871 respstring += "</Root>";
@@ -949,12 +946,12 @@ namespace OpenSim.Grid.GridServer
949 break; 946 break;
950 947
951 case "region_locx": 948 case "region_locx":
952 theSim.regionLocX = Convert.ToUInt32(simnode.ChildNodes[i].InnerText); 949 theSim.regionLocX = Convert.ToUInt32((string)simnode.ChildNodes[i].InnerText);
953 theSim.regionHandle = Helpers.UIntsToLong((theSim.regionLocX * Constants.RegionSize), (theSim.regionLocY * Constants.RegionSize)); 950 theSim.regionHandle = Helpers.UIntsToLong((theSim.regionLocX * Constants.RegionSize), (theSim.regionLocY * Constants.RegionSize));
954 break; 951 break;
955 952
956 case "region_locy": 953 case "region_locy":
957 theSim.regionLocY = Convert.ToUInt32(simnode.ChildNodes[i].InnerText); 954 theSim.regionLocY = Convert.ToUInt32((string)simnode.ChildNodes[i].InnerText);
958 theSim.regionHandle = Helpers.UIntsToLong((theSim.regionLocX * Constants.RegionSize), (theSim.regionLocY * Constants.RegionSize)); 955 theSim.regionHandle = Helpers.UIntsToLong((theSim.regionLocX * Constants.RegionSize), (theSim.regionLocY * Constants.RegionSize));
959 break; 956 break;
960 } 957 }
@@ -1008,28 +1005,28 @@ namespace OpenSim.Grid.GridServer
1008 catch (Exception e) 1005 catch (Exception e)
1009 { 1006 {
1010 m_log.Warn("[GRID]: GetRegionPlugin Handle " + kvp.Key + " unable to add new sim: " + 1007 m_log.Warn("[GRID]: GetRegionPlugin Handle " + kvp.Key + " unable to add new sim: " +
1011 e); 1008 e.ToString());
1012 } 1009 }
1013 } 1010 }
1014 return "OK"; 1011 return "OK";
1015 } 1012 }
1016 catch (Exception e) 1013 catch (Exception e)
1017 { 1014 {
1018 return "ERROR! Could not save to database! (" + e + ")"; 1015 return "ERROR! Could not save to database! (" + e.ToString() + ")";
1019 } 1016 }
1020 } 1017 }
1021 1018
1022 public XmlRpcResponse XmlRPCRegisterMessageServer(XmlRpcRequest request) 1019 public XmlRpcResponse XmlRPCRegisterMessageServer(XmlRpcRequest request)
1023 { 1020 {
1024 XmlRpcResponse response = new XmlRpcResponse(); 1021 XmlRpcResponse response = new XmlRpcResponse();
1025 Hashtable requestData = (Hashtable) request.Params[0]; 1022 Hashtable requestData = (Hashtable)request.Params[0];
1026 Hashtable responseData = new Hashtable(); 1023 Hashtable responseData = new Hashtable();
1027 1024
1028 if (requestData.Contains("uri")) 1025 if (requestData.Contains("uri"))
1029 { 1026 {
1030 string URI = (string) requestData["URI"]; 1027 string URI = (string)requestData["URI"];
1031 string sendkey = (string) requestData["sendkey"]; 1028 string sendkey = (string)requestData["sendkey"];
1032 string recvkey = (string) requestData["recvkey"]; 1029 string recvkey = (string)requestData["recvkey"];
1033 MessageServerInfo m = new MessageServerInfo(); 1030 MessageServerInfo m = new MessageServerInfo();
1034 m.URI = URI; 1031 m.URI = URI;
1035 m.sendkey = sendkey; 1032 m.sendkey = sendkey;
@@ -1045,14 +1042,14 @@ namespace OpenSim.Grid.GridServer
1045 public XmlRpcResponse XmlRPCDeRegisterMessageServer(XmlRpcRequest request) 1042 public XmlRpcResponse XmlRPCDeRegisterMessageServer(XmlRpcRequest request)
1046 { 1043 {
1047 XmlRpcResponse response = new XmlRpcResponse(); 1044 XmlRpcResponse response = new XmlRpcResponse();
1048 Hashtable requestData = (Hashtable) request.Params[0]; 1045 Hashtable requestData = (Hashtable)request.Params[0];
1049 Hashtable responseData = new Hashtable(); 1046 Hashtable responseData = new Hashtable();
1050 1047
1051 if (requestData.Contains("uri")) 1048 if (requestData.Contains("uri"))
1052 { 1049 {
1053 string URI = (string) requestData["uri"]; 1050 string URI = (string)requestData["uri"];
1054 string sendkey = (string) requestData["sendkey"]; 1051 string sendkey = (string)requestData["sendkey"];
1055 string recvkey = (string) requestData["recvkey"]; 1052 string recvkey = (string)requestData["recvkey"];
1056 MessageServerInfo m = new MessageServerInfo(); 1053 MessageServerInfo m = new MessageServerInfo();
1057 m.URI = URI; 1054 m.URI = URI;
1058 m.sendkey = sendkey; 1055 m.sendkey = sendkey;
@@ -1065,4 +1062,4 @@ namespace OpenSim.Grid.GridServer
1065 return response; 1062 return response;
1066 } 1063 }
1067 } 1064 }
1068} \ No newline at end of file 1065}
diff --git a/OpenSim/Grid/GridServer/GridServerBase.cs b/OpenSim/Grid/GridServer/GridServerBase.cs
index ac33a6c..2feaac3 100644
--- a/OpenSim/Grid/GridServer/GridServerBase.cs
+++ b/OpenSim/Grid/GridServer/GridServerBase.cs
@@ -44,34 +44,6 @@ namespace OpenSim.Grid.GridServer
44 protected GridManager m_gridManager; 44 protected GridManager m_gridManager;
45 protected List<IGridPlugin> m_plugins = new List<IGridPlugin>(); 45 protected List<IGridPlugin> m_plugins = new List<IGridPlugin>();
46 46
47 public GridServerBase()
48 {
49 m_console = new ConsoleBase("OpenGrid", this);
50 MainConsole.Instance = m_console;
51 }
52
53 #region conscmd_callback Members
54
55 public override void RunCmd(string cmd, string[] cmdparams)
56 {
57 base.RunCmd(cmd, cmdparams);
58
59 switch (cmd)
60 {
61 case "help":
62 m_console.Notice("shutdown - shutdown the grid (USE CAUTION!)");
63 break;
64
65 case "shutdown":
66 foreach (IGridPlugin plugin in m_plugins) plugin.Close();
67 m_console.Close();
68 Environment.Exit(0);
69 break;
70 }
71 }
72
73 #endregion
74
75 public void Work() 47 public void Work()
76 { 48 {
77 m_console.Notice("Enter help for a list of commands\n"); 49 m_console.Notice("Enter help for a list of commands\n");
@@ -82,6 +54,12 @@ namespace OpenSim.Grid.GridServer
82 } 54 }
83 } 55 }
84 56
57 public GridServerBase()
58 {
59 m_console = new ConsoleBase("OpenGrid", this);
60 MainConsole.Instance = m_console;
61 }
62
85 public void managercallback(string cmd) 63 public void managercallback(string cmd)
86 { 64 {
87 switch (cmd) 65 switch (cmd)
@@ -105,14 +83,14 @@ namespace OpenSim.Grid.GridServer
105 83
106 AddHttpHandlers(); 84 AddHttpHandlers();
107 85
108 LoadGridPlugins(); 86 LoadGridPlugins( );
109 87
110 m_httpServer.Start(); 88 m_httpServer.Start();
111 89
112 m_console.Status("[GRID]: Starting sim status checker"); 90 m_console.Status("[GRID]: Starting sim status checker");
113 91
114 Timer simCheckTimer = new Timer(3600000 * 3); // 3 Hours between updates. 92 Timer simCheckTimer = new Timer(3600000 * 3); // 3 Hours between updates.
115 simCheckTimer.Elapsed += CheckSims; 93 simCheckTimer.Elapsed += new ElapsedEventHandler(CheckSims);
116 simCheckTimer.Enabled = true; 94 simCheckTimer.Enabled = true;
117 } 95 }
118 96
@@ -144,7 +122,7 @@ namespace OpenSim.Grid.GridServer
144 foreach (TypeExtensionNode node in nodes) 122 foreach (TypeExtensionNode node in nodes)
145 { 123 {
146 m_console.Status("[GRIDPLUGINS]: Loading OpenSim plugin " + node.Path); 124 m_console.Status("[GRIDPLUGINS]: Loading OpenSim plugin " + node.Path);
147 IGridPlugin plugin = (IGridPlugin) node.CreateInstance(); 125 IGridPlugin plugin = (IGridPlugin)node.CreateInstance();
148 plugin.Initialise(this); 126 plugin.Initialise(this);
149 m_plugins.Add(plugin); 127 m_plugins.Add(plugin);
150 } 128 }
@@ -199,5 +177,23 @@ namespace OpenSim.Grid.GridServer
199 } 177 }
200 */ 178 */
201 } 179 }
180
181 public override void RunCmd(string cmd, string[] cmdparams)
182 {
183 base.RunCmd(cmd, cmdparams);
184
185 switch (cmd)
186 {
187 case "help":
188 m_console.Notice("shutdown - shutdown the grid (USE CAUTION!)");
189 break;
190
191 case "shutdown":
192 foreach (IGridPlugin plugin in m_plugins) plugin.Close();
193 m_console.Close();
194 Environment.Exit(0);
195 break;
196 }
197 }
202 } 198 }
203} \ No newline at end of file 199}
diff --git a/OpenSim/Grid/GridServer/IGridPlugin.cs b/OpenSim/Grid/GridServer/IGridPlugin.cs
index 40d208c..fbadfce 100644
--- a/OpenSim/Grid/GridServer/IGridPlugin.cs
+++ b/OpenSim/Grid/GridServer/IGridPlugin.cs
@@ -38,4 +38,4 @@ namespace OpenSim.Grid.GridServer
38 void Initialise(GridServerBase gridServer); 38 void Initialise(GridServerBase gridServer);
39 void Close(); 39 void Close();
40 } 40 }
41} \ No newline at end of file 41}
diff --git a/OpenSim/Grid/GridServer/Program.cs b/OpenSim/Grid/GridServer/Program.cs
index 06d8e3d..6eb4e15 100644
--- a/OpenSim/Grid/GridServer/Program.cs
+++ b/OpenSim/Grid/GridServer/Program.cs
@@ -50,4 +50,4 @@ namespace OpenSim.Grid.GridServer
50 } 50 }
51 } 51 }
52 } 52 }
53} \ No newline at end of file 53}
diff --git a/OpenSim/Grid/GridServer/Properties/AssemblyInfo.cs b/OpenSim/Grid/GridServer/Properties/AssemblyInfo.cs
index 2b07547..1468edd 100644
--- a/OpenSim/Grid/GridServer/Properties/AssemblyInfo.cs
+++ b/OpenSim/Grid/GridServer/Properties/AssemblyInfo.cs
@@ -60,4 +60,4 @@ using System.Runtime.InteropServices;
60// 60//
61 61
62[assembly : AssemblyVersion("1.0.0.0")] 62[assembly : AssemblyVersion("1.0.0.0")]
63[assembly : AssemblyFileVersion("1.0.0.0")] \ No newline at end of file 63[assembly : AssemblyFileVersion("1.0.0.0")]
diff --git a/OpenSim/Grid/InventoryServer/GridInventoryService.cs b/OpenSim/Grid/InventoryServer/GridInventoryService.cs
index c3e3a28..db9a864 100644
--- a/OpenSim/Grid/InventoryServer/GridInventoryService.cs
+++ b/OpenSim/Grid/InventoryServer/GridInventoryService.cs
@@ -40,7 +40,7 @@ namespace OpenSim.Grid.InventoryServer
40 /// </summary> 40 /// </summary>
41 public class GridInventoryService : InventoryServiceBase 41 public class GridInventoryService : InventoryServiceBase
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 public override void RequestInventoryForUser(LLUUID userID, InventoryReceiptCallback callback) 46 public override void RequestInventoryForUser(LLUUID userID, InventoryReceiptCallback callback)
@@ -55,7 +55,7 @@ namespace OpenSim.Grid.InventoryServer
55 /// <param name="itemsList"></param> 55 /// <param name="itemsList"></param>
56 /// <returns>true if the inventory was retrieved, false otherwise</returns> 56 /// <returns>true if the inventory was retrieved, false otherwise</returns>
57 private bool GetUsersInventory(LLUUID userID, out List<InventoryFolderBase> folderList, 57 private bool GetUsersInventory(LLUUID userID, out List<InventoryFolderBase> folderList,
58 out List<InventoryItemBase> itemsList) 58 out List<InventoryItemBase> itemsList)
59 { 59 {
60 List<InventoryFolderBase> allFolders = GetInventorySkeleton(userID); 60 List<InventoryFolderBase> allFolders = GetInventorySkeleton(userID);
61 List<InventoryItemBase> allItems = new List<InventoryItemBase>(); 61 List<InventoryItemBase> allItems = new List<InventoryItemBase>();
@@ -109,28 +109,28 @@ namespace OpenSim.Grid.InventoryServer
109 { 109 {
110 // uncomment me to simulate an overloaded inventory server 110 // uncomment me to simulate an overloaded inventory server
111 //Thread.Sleep(20000); 111 //Thread.Sleep(20000);
112 112
113 LLUUID userID = new LLUUID(rawUserID); 113 LLUUID userID = new LLUUID(rawUserID);
114 114
115 m_log.InfoFormat("[GRID AGENT INVENTORY]: Processing request for inventory of {0}", userID); 115 m_log.InfoFormat("[GRID AGENT INVENTORY]: Processing request for inventory of {0}", userID);
116 116
117 InventoryCollection invCollection = new InventoryCollection(); 117 InventoryCollection invCollection = new InventoryCollection();
118 118
119 List<InventoryFolderBase> allFolders = GetInventorySkeleton(userID); 119 List<InventoryFolderBase> allFolders = GetInventorySkeleton(userID);
120 120
121 if (null == allFolders) 121 if (null == allFolders)
122 { 122 {
123 m_log.WarnFormat("[GRID AGENT INVENTORY]: No inventory found for user {0}", rawUserID); 123 m_log.WarnFormat("[GRID AGENT INVENTORY]: No inventory found for user {0}", rawUserID);
124 124
125 return invCollection; 125 return invCollection;
126 } 126 }
127 127
128 List<InventoryItemBase> allItems = new List<InventoryItemBase>(); 128 List<InventoryItemBase> allItems = new List<InventoryItemBase>();
129 129
130 foreach (InventoryFolderBase folder in allFolders) 130 foreach (InventoryFolderBase folder in allFolders)
131 { 131 {
132 List<InventoryItemBase> items = RequestFolderItems(folder.ID); 132 List<InventoryItemBase> items = RequestFolderItems(folder.ID);
133 133
134 if (items != null) 134 if (items != null)
135 { 135 {
136 allItems.InsertRange(0, items); 136 allItems.InsertRange(0, items);
@@ -138,9 +138,9 @@ namespace OpenSim.Grid.InventoryServer
138 } 138 }
139 139
140 invCollection.UserID = userID; 140 invCollection.UserID = userID;
141 invCollection.Folders = allFolders; 141 invCollection.Folders = allFolders;
142 invCollection.Items = allItems; 142 invCollection.Items = allItems;
143 143
144// foreach (InventoryFolderBase folder in invCollection.Folders) 144// foreach (InventoryFolderBase folder in invCollection.Folders)
145// { 145// {
146// m_log.DebugFormat("[GRID AGENT INVENTORY]: Sending back folder {0} {1}", folder.Name, folder.ID); 146// m_log.DebugFormat("[GRID AGENT INVENTORY]: Sending back folder {0} {1}", folder.Name, folder.ID);
@@ -150,14 +150,14 @@ namespace OpenSim.Grid.InventoryServer
150// { 150// {
151// m_log.DebugFormat("[GRID AGENT INVENTORY]: Sending back item {0} {1}, folder {2}", item.Name, item.ID, item.Folder); 151// m_log.DebugFormat("[GRID AGENT INVENTORY]: Sending back item {0} {1}, folder {2}", item.Name, item.ID, item.Folder);
152// } 152// }
153 153
154 m_log.InfoFormat( 154 m_log.InfoFormat(
155 "[GRID AGENT INVENTORY]: Sending back inventory response to user {0} containing {1} folders and {2} items", 155 "[GRID AGENT INVENTORY]: Sending back inventory response to user {0} containing {1} folders and {2} items",
156 invCollection.UserID, invCollection.Folders.Count, invCollection.Items.Count); 156 invCollection.UserID, invCollection.Folders.Count, invCollection.Items.Count);
157 157
158 return invCollection; 158 return invCollection;
159 } 159 }
160 160
161 /// <summary> 161 /// <summary>
162 /// Guid to UUID wrapper for same name IInventoryServices method 162 /// Guid to UUID wrapper for same name IInventoryServices method
163 /// </summary> 163 /// </summary>
@@ -166,10 +166,10 @@ namespace OpenSim.Grid.InventoryServer
166 public List<InventoryFolderBase> GetInventorySkeleton(Guid rawUserID) 166 public List<InventoryFolderBase> GetInventorySkeleton(Guid rawUserID)
167 { 167 {
168 //Thread.Sleep(10000); 168 //Thread.Sleep(10000);
169 169
170 LLUUID userID = new LLUUID(rawUserID); 170 LLUUID userID = new LLUUID(rawUserID);
171 return GetInventorySkeleton(userID); 171 return GetInventorySkeleton(userID);
172 } 172 }
173 173
174 /// <summary> 174 /// <summary>
175 /// Create an inventory for the given user. 175 /// Create an inventory for the given user.
@@ -196,11 +196,11 @@ namespace OpenSim.Grid.InventoryServer
196 { 196 {
197 MoveFolder(folder); 197 MoveFolder(folder);
198 } 198 }
199 199
200 public override void PurgeInventoryFolder(LLUUID userID, InventoryFolderBase folder) 200 public override void PurgeInventoryFolder(LLUUID userID, InventoryFolderBase folder)
201 { 201 {
202 PurgeFolder(folder); 202 PurgeFolder(folder);
203 } 203 }
204 204
205 public override void AddNewInventoryItem(LLUUID userID, InventoryItemBase item) 205 public override void AddNewInventoryItem(LLUUID userID, InventoryItemBase item)
206 { 206 {
@@ -230,15 +230,15 @@ namespace OpenSim.Grid.InventoryServer
230 MoveExistingInventoryFolder(folder); 230 MoveExistingInventoryFolder(folder);
231 return true; 231 return true;
232 } 232 }
233 233
234 public bool PurgeInventoryFolder(InventoryFolderBase folder) 234 public bool PurgeInventoryFolder(InventoryFolderBase folder)
235 { 235 {
236 m_log.InfoFormat( 236 m_log.InfoFormat(
237 "[GRID AGENT INVENTORY]: Purging folder {0} {1} of its contents", folder.Name, folder.ID); 237 "[GRID AGENT INVENTORY]: Purging folder {0} {1} of its contents", folder.Name, folder.ID);
238 238
239 PurgeInventoryFolder(folder.Owner, folder); 239 PurgeInventoryFolder(folder.Owner, folder);
240 return true; 240 return true;
241 } 241 }
242 242
243 public bool AddInventoryItem(InventoryItemBase item) 243 public bool AddInventoryItem(InventoryItemBase item)
244 { 244 {
@@ -267,4 +267,4 @@ namespace OpenSim.Grid.InventoryServer
267 return true; 267 return true;
268 } 268 }
269 } 269 }
270} \ No newline at end of file 270}
diff --git a/OpenSim/Grid/InventoryServer/InventoryManager.cs b/OpenSim/Grid/InventoryServer/InventoryManager.cs
index 350a618..5c65317 100644
--- a/OpenSim/Grid/InventoryServer/InventoryManager.cs
+++ b/OpenSim/Grid/InventoryServer/InventoryManager.cs
@@ -54,7 +54,7 @@ namespace OpenSim.Grid.InventoryServer
54 Assembly pluginAssembly = Assembly.LoadFrom(FileName); 54 Assembly pluginAssembly = Assembly.LoadFrom(FileName);
55 55
56 m_log.Info("[" + OpenInventory_Main.LogName + "]: " + 56 m_log.Info("[" + OpenInventory_Main.LogName + "]: " +
57 "Invenstorage: Found " + pluginAssembly.GetTypes().Length + " interfaces."); 57 "Invenstorage: Found " + pluginAssembly.GetTypes().Length + " interfaces.");
58 foreach (Type pluginType in pluginAssembly.GetTypes()) 58 foreach (Type pluginType in pluginAssembly.GetTypes())
59 { 59 {
60 if (!pluginType.IsAbstract) 60 if (!pluginType.IsAbstract)
@@ -68,7 +68,7 @@ namespace OpenSim.Grid.InventoryServer
68 plug.Initialise(dbconnect); 68 plug.Initialise(dbconnect);
69 _databasePlugin = plug; 69 _databasePlugin = plug;
70 m_log.Info("[" + OpenInventory_Main.LogName + "]: " + 70 m_log.Info("[" + OpenInventory_Main.LogName + "]: " +
71 "Invenstorage: Added IInventoryData Interface"); 71 "Invenstorage: Added IInventoryData Interface");
72 break; 72 break;
73 } 73 }
74 } 74 }
@@ -136,12 +136,10 @@ namespace OpenSim.Grid.InventoryServer
136 return fixupFolder(inventory.root, null); 136 return fixupFolder(inventory.root, null);
137 } 137 }
138 138
139 #region Nested type: GetInventory
140
141 public class GetInventory : BaseStreamHandler 139 public class GetInventory : BaseStreamHandler
142 { 140 {
143 private readonly SerializableInventory _inventory; 141 private SerializableInventory _inventory;
144 private readonly InventoryManager _manager; 142 private InventoryManager _manager;
145 143
146 public GetInventory(InventoryManager manager) 144 public GetInventory(InventoryManager manager)
147 : base("GET", "/inventory") 145 : base("GET", "/inventory")
@@ -183,7 +181,7 @@ namespace OpenSim.Grid.InventoryServer
183 { 181 {
184 byte[] result = new byte[] {}; 182 byte[] result = new byte[] {};
185 183
186 string[] parms = path.Split(new[] {'/'}, StringSplitOptions.RemoveEmptyEntries); 184 string[] parms = path.Split(new char[] {'/'}, StringSplitOptions.RemoveEmptyEntries);
187 if (parms.Length > 1) 185 if (parms.Length > 1)
188 { 186 {
189 if (string.Compare(parms[1], "library", true) == 0) 187 if (string.Compare(parms[1], "library", true) == 0)
@@ -192,7 +190,7 @@ namespace OpenSim.Grid.InventoryServer
192 saveInventoryToStream(_inventory, ms); 190 saveInventoryToStream(_inventory, ms);
193 191
194 result = ms.GetBuffer(); 192 result = ms.GetBuffer();
195 Array.Resize(ref result, (int) ms.Length); 193 Array.Resize<byte>(ref result, (int) ms.Length);
196 } 194 }
197 else if (string.Compare(parms[1], "user", true) == 0) 195 else if (string.Compare(parms[1], "user", true) == 0)
198 { 196 {
@@ -205,7 +203,5 @@ namespace OpenSim.Grid.InventoryServer
205 return result; 203 return result;
206 } 204 }
207 } 205 }
208
209 #endregion
210 } 206 }
211} \ No newline at end of file 207}
diff --git a/OpenSim/Grid/InventoryServer/Main.cs b/OpenSim/Grid/InventoryServer/Main.cs
index 453d64d..870997b 100644
--- a/OpenSim/Grid/InventoryServer/Main.cs
+++ b/OpenSim/Grid/InventoryServer/Main.cs
@@ -40,38 +40,13 @@ namespace OpenSim.Grid.InventoryServer
40{ 40{
41 public class OpenInventory_Main : BaseOpenSimServer, conscmd_callback 41 public class OpenInventory_Main : BaseOpenSimServer, conscmd_callback
42 { 42 {
43 public const string LogName = "INVENTORY";
44 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 43 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
45 44
46 private InventoryConfig m_config;
47 private InventoryManager m_inventoryManager; 45 private InventoryManager m_inventoryManager;
46 private InventoryConfig m_config;
48 private GridInventoryService m_inventoryService; 47 private GridInventoryService m_inventoryService;
49 48
50 public OpenInventory_Main() 49 public const string LogName = "INVENTORY";
51 {
52 m_console = new ConsoleBase(LogName, this);
53 MainConsole.Instance = m_console;
54 }
55
56 #region conscmd_callback Members
57
58 public override void RunCmd(string cmd, string[] cmdparams)
59 {
60 base.RunCmd(cmd, cmdparams);
61
62 switch (cmd)
63 {
64 case "add-user":
65 m_inventoryService.CreateUsersInventory(LLUUID.Random().UUID);
66 break;
67 case "shutdown":
68 m_console.Close();
69 Environment.Exit(0);
70 break;
71 }
72 }
73
74 #endregion
75 50
76 [STAThread] 51 [STAThread]
77 public static void Main(string[] args) 52 public static void Main(string[] args)
@@ -84,6 +59,12 @@ namespace OpenSim.Grid.InventoryServer
84 theServer.Work(); 59 theServer.Work();
85 } 60 }
86 61
62 public OpenInventory_Main()
63 {
64 m_console = new ConsoleBase(LogName, this);
65 MainConsole.Instance = m_console;
66 }
67
87 public void Startup() 68 public void Startup()
88 { 69 {
89 m_log.Info("Initialising inventory manager..."); 70 m_log.Info("Initialising inventory manager...");
@@ -94,7 +75,7 @@ namespace OpenSim.Grid.InventoryServer
94 m_inventoryService.AddPlugin(m_config.DatabaseProvider, m_config.DatabaseConnect); 75 m_inventoryService.AddPlugin(m_config.DatabaseProvider, m_config.DatabaseConnect);
95 76
96 m_log.Info("[" + LogName + "]: Starting HTTP server ..."); 77 m_log.Info("[" + LogName + "]: Starting HTTP server ...");
97 78
98 m_httpServer = new BaseHttpServer(m_config.HttpPort); 79 m_httpServer = new BaseHttpServer(m_config.HttpPort);
99 AddHttpHandlers(); 80 AddHttpHandlers();
100 m_httpServer.Start(); 81 m_httpServer.Start();
@@ -107,11 +88,11 @@ namespace OpenSim.Grid.InventoryServer
107 m_httpServer.AddStreamHandler( 88 m_httpServer.AddStreamHandler(
108 new RestDeserialisehandler<Guid, InventoryCollection>( 89 new RestDeserialisehandler<Guid, InventoryCollection>(
109 "POST", "/GetInventory/", m_inventoryService.GetUserInventory)); 90 "POST", "/GetInventory/", m_inventoryService.GetUserInventory));
110 91
111 m_httpServer.AddStreamHandler( 92 m_httpServer.AddStreamHandler(
112 new RestDeserialisehandler<Guid, bool>( 93 new RestDeserialisehandler<Guid, bool>(
113 "POST", "/CreateInventory/", m_inventoryService.CreateUsersInventory)); 94 "POST", "/CreateInventory/", m_inventoryService.CreateUsersInventory));
114 95
115 m_httpServer.AddStreamHandler( 96 m_httpServer.AddStreamHandler(
116 new RestDeserialisehandler<InventoryFolderBase, bool>( 97 new RestDeserialisehandler<InventoryFolderBase, bool>(
117 "POST", "/NewFolder/", m_inventoryService.AddInventoryFolder)); 98 "POST", "/NewFolder/", m_inventoryService.AddInventoryFolder));
@@ -119,15 +100,15 @@ namespace OpenSim.Grid.InventoryServer
119 m_httpServer.AddStreamHandler( 100 m_httpServer.AddStreamHandler(
120 new RestDeserialisehandler<InventoryFolderBase, bool>( 101 new RestDeserialisehandler<InventoryFolderBase, bool>(
121 "POST", "/MoveFolder/", m_inventoryService.MoveInventoryFolder)); 102 "POST", "/MoveFolder/", m_inventoryService.MoveInventoryFolder));
122 103
123 m_httpServer.AddStreamHandler( 104 m_httpServer.AddStreamHandler(
124 new RestDeserialisehandler<InventoryFolderBase, bool>( 105 new RestDeserialisehandler<InventoryFolderBase, bool>(
125 "POST", "/PurgeFolder/", m_inventoryService.PurgeInventoryFolder)); 106 "POST", "/PurgeFolder/", m_inventoryService.PurgeInventoryFolder));
126 107
127 m_httpServer.AddStreamHandler( 108 m_httpServer.AddStreamHandler(
128 new RestDeserialisehandler<InventoryItemBase, bool>( 109 new RestDeserialisehandler<InventoryItemBase, bool>(
129 "POST", "/NewItem/", m_inventoryService.AddInventoryItem)); 110 "POST", "/NewItem/", m_inventoryService.AddInventoryItem));
130 111
131 m_httpServer.AddStreamHandler( 112 m_httpServer.AddStreamHandler(
132 new RestDeserialisehandler<InventoryItemBase, bool>( 113 new RestDeserialisehandler<InventoryItemBase, bool>(
133 "POST", "/DeleteItem/", m_inventoryService.DeleteInvItem)); 114 "POST", "/DeleteItem/", m_inventoryService.DeleteInvItem));
@@ -153,5 +134,21 @@ namespace OpenSim.Grid.InventoryServer
153 m_console.Prompt(); 134 m_console.Prompt();
154 } 135 }
155 } 136 }
137
138 public override void RunCmd(string cmd, string[] cmdparams)
139 {
140 base.RunCmd(cmd, cmdparams);
141
142 switch (cmd)
143 {
144 case "add-user":
145 m_inventoryService.CreateUsersInventory(LLUUID.Random().UUID);
146 break;
147 case "shutdown":
148 m_console.Close();
149 Environment.Exit(0);
150 break;
151 }
152 }
156 } 153 }
157} \ No newline at end of file 154}
diff --git a/OpenSim/Grid/MessagingServer/Main.cs b/OpenSim/Grid/MessagingServer/Main.cs
index e6e18d4..bf793bf 100644
--- a/OpenSim/Grid/MessagingServer/Main.cs
+++ b/OpenSim/Grid/MessagingServer/Main.cs
@@ -44,42 +44,9 @@ namespace OpenSim.Grid.MessagingServer
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 45
46 private MessageServerConfig Cfg; 46 private MessageServerConfig Cfg;
47
48 private LLUUID m_lastCreatedUser = LLUUID.Random();
49 private MessageService msgsvc; 47 private MessageService msgsvc;
50 48
51 private OpenMessage_Main() 49 private LLUUID m_lastCreatedUser = LLUUID.Random();
52 {
53 m_console = new ConsoleBase("OpenMessage", this);
54 MainConsole.Instance = m_console;
55 }
56
57 #region conscmd_callback Members
58
59 public override void RunCmd(string cmd, string[] cmdparams)
60 {
61 base.RunCmd(cmd, cmdparams);
62
63 switch (cmd)
64 {
65 case "help":
66 m_console.Notice("shutdown - shutdown the message server (USE CAUTION!)");
67 break;
68
69 case "shutdown":
70 msgsvc.deregisterWithUserServer();
71 m_console.Close();
72 Environment.Exit(0);
73 break;
74 }
75 }
76
77 public override void Show(string ShowWhat)
78 {
79 base.Show(ShowWhat);
80 }
81
82 #endregion
83 50
84 [STAThread] 51 [STAThread]
85 public static void Main(string[] args) 52 public static void Main(string[] args)
@@ -88,6 +55,7 @@ namespace OpenSim.Grid.MessagingServer
88 55
89 m_log.Info("Launching MessagingServer..."); 56 m_log.Info("Launching MessagingServer...");
90 57
58
91 59
92 OpenMessage_Main messageserver = new OpenMessage_Main(); 60 OpenMessage_Main messageserver = new OpenMessage_Main();
93 61
@@ -95,6 +63,12 @@ namespace OpenSim.Grid.MessagingServer
95 messageserver.Work(); 63 messageserver.Work();
96 } 64 }
97 65
66 private OpenMessage_Main()
67 {
68 m_console = new ConsoleBase("OpenMessage", this);
69 MainConsole.Instance = m_console;
70 }
71
98 private void Work() 72 private void Work()
99 { 73 {
100 m_console.Notice("Enter help for a list of commands\n"); 74 m_console.Notice("Enter help for a list of commands\n");
@@ -144,13 +118,12 @@ namespace OpenSim.Grid.MessagingServer
144 switch (what) 118 switch (what)
145 { 119 {
146 case "user": 120 case "user":
147 121
148 try 122 try
149 { 123 {
150 //userID = 124 //userID =
151 //m_userManager.AddUserProfile(tempfirstname, templastname, tempMD5Passwd, regX, regY); 125 //m_userManager.AddUserProfile(tempfirstname, templastname, tempMD5Passwd, regX, regY);
152 } 126 } catch (Exception ex)
153 catch (Exception ex)
154 { 127 {
155 m_console.Error("[SERVER]: Error creating user: {0}", ex.ToString()); 128 m_console.Error("[SERVER]: Error creating user: {0}", ex.ToString());
156 } 129 }
@@ -158,7 +131,7 @@ namespace OpenSim.Grid.MessagingServer
158 try 131 try
159 { 132 {
160 //RestObjectPoster.BeginPostObject<Guid>(m_userManager._config.InventoryUrl + "CreateInventory/", 133 //RestObjectPoster.BeginPostObject<Guid>(m_userManager._config.InventoryUrl + "CreateInventory/",
161 //userID.UUID); 134 //userID.UUID);
162 } 135 }
163 catch (Exception ex) 136 catch (Exception ex)
164 { 137 {
@@ -168,5 +141,28 @@ namespace OpenSim.Grid.MessagingServer
168 break; 141 break;
169 } 142 }
170 } 143 }
144
145 public override void RunCmd(string cmd, string[] cmdparams)
146 {
147 base.RunCmd(cmd, cmdparams);
148
149 switch (cmd)
150 {
151 case "help":
152 m_console.Notice("shutdown - shutdown the message server (USE CAUTION!)");
153 break;
154
155 case "shutdown":
156 msgsvc.deregisterWithUserServer();
157 m_console.Close();
158 Environment.Exit(0);
159 break;
160 }
161 }
162
163 public override void Show(string ShowWhat)
164 {
165 base.Show(ShowWhat);
166 }
171 } 167 }
172} \ No newline at end of file 168}
diff --git a/OpenSim/Grid/MessagingServer/MessageService.cs b/OpenSim/Grid/MessagingServer/MessageService.cs
index 33c133d..50e06af 100644
--- a/OpenSim/Grid/MessagingServer/MessageService.cs
+++ b/OpenSim/Grid/MessagingServer/MessageService.cs
@@ -45,16 +45,16 @@ namespace OpenSim.Grid.MessagingServer
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 47
48 private readonly MessageServerConfig m_cfg; 48 private MessageServerConfig m_cfg;
49 private readonly Hashtable m_presence_BackReferences = new Hashtable();
50 49
51 //A hashtable of all current presences this server knows about 50 //A hashtable of all current presences this server knows about
52 private readonly Hashtable m_presences = new Hashtable(); 51 private Hashtable m_presences = new Hashtable();
53 52
54 //a hashtable of all current regions this server knows about 53 //a hashtable of all current regions this server knows about
55 private readonly Hashtable m_regionInfoCache = new Hashtable(); 54 private Hashtable m_regionInfoCache = new Hashtable();
56 55
57 //A hashtable containing lists of UUIDs keyed by UUID for fast backreferencing 56 //A hashtable containing lists of UUIDs keyed by UUID for fast backreferencing
57 private Hashtable m_presence_BackReferences = new Hashtable();
58 58
59 // Hashtable containing work units that need to be processed 59 // Hashtable containing work units that need to be processed
60 private Hashtable m_unProcessedWorkUnits = new Hashtable(); 60 private Hashtable m_unProcessedWorkUnits = new Hashtable();
@@ -63,13 +63,13 @@ namespace OpenSim.Grid.MessagingServer
63 { 63 {
64 m_cfg = cfg; 64 m_cfg = cfg;
65 } 65 }
66 66
67 #region RegionComms Methods 67 #region RegionComms Methods
68 68
69 #endregion 69 #endregion
70 70
71 #region FriendList Methods 71 #region FriendList Methods
72 72
73 /// <summary> 73 /// <summary>
74 /// Process Friendlist subscriptions for a user 74 /// Process Friendlist subscriptions for a user
75 /// The login method calls this for a User 75 /// The login method calls this for a User
@@ -87,14 +87,14 @@ namespace OpenSim.Grid.MessagingServer
87 for (int i = 0; i < uFriendList.Count; i++) 87 for (int i = 0; i < uFriendList.Count; i++)
88 { 88 {
89 //m_presence_BackReferences.Add(userpresence.agentData.AgentID, uFriendList[i].Friend); 89 //m_presence_BackReferences.Add(userpresence.agentData.AgentID, uFriendList[i].Friend);
90 // m_presence_BackReferences.Add(uFriendList[i].Friend, userpresence.agentData.AgentID); 90 // m_presence_BackReferences.Add(uFriendList[i].Friend, userpresence.agentData.AgentID);
91 91
92 if (m_presences.Contains(uFriendList[i].Friend)) 92 if (m_presences.Contains(uFriendList[i].Friend))
93 { 93 {
94 UserPresenceData friendup = (UserPresenceData) m_presences[uFriendList[i].Friend]; 94 UserPresenceData friendup = (UserPresenceData)m_presences[uFriendList[i].Friend];
95 // Add backreference 95 // Add backreference
96 96
97 SubscribeToPresenceUpdates(userpresence, friendup, uFriendList[i], i); 97 SubscribeToPresenceUpdates(userpresence, friendup, uFriendList[i],i);
98 } 98 }
99 } 99 }
100 } 100 }
@@ -108,10 +108,10 @@ namespace OpenSim.Grid.MessagingServer
108 /// <param name="friendpresence">P2</param> 108 /// <param name="friendpresence">P2</param>
109 /// <param name="uFriendListItem"></param> 109 /// <param name="uFriendListItem"></param>
110 /// <param name="uFriendListIndex"></param> 110 /// <param name="uFriendListIndex"></param>
111 public void SubscribeToPresenceUpdates(UserPresenceData userpresence, UserPresenceData friendpresence, 111 public void SubscribeToPresenceUpdates(UserPresenceData userpresence, UserPresenceData friendpresence,
112 FriendListItem uFriendListItem, int uFriendListIndex) 112 FriendListItem uFriendListItem, int uFriendListIndex)
113 { 113 {
114 if ((uFriendListItem.FriendListOwnerPerms & (uint) FriendRights.CanSeeOnline) != 0) 114 if ((uFriendListItem.FriendListOwnerPerms & (uint)FriendRights.CanSeeOnline) != 0)
115 { 115 {
116 // Subscribe and Send Out updates 116 // Subscribe and Send Out updates
117 if (!friendpresence.subscriptionData.Contains(friendpresence.agentData.AgentID)) 117 if (!friendpresence.subscriptionData.Contains(friendpresence.agentData.AgentID))
@@ -126,13 +126,13 @@ namespace OpenSim.Grid.MessagingServer
126 PresenceInformer friendlistupdater = new PresenceInformer(); 126 PresenceInformer friendlistupdater = new PresenceInformer();
127 friendlistupdater.presence1 = friendpresence; 127 friendlistupdater.presence1 = friendpresence;
128 friendlistupdater.presence2 = userpresence; 128 friendlistupdater.presence2 = userpresence;
129 WaitCallback cb = friendlistupdater.go; 129 WaitCallback cb = new WaitCallback(friendlistupdater.go);
130 ThreadPool.QueueUserWorkItem(cb); 130 ThreadPool.QueueUserWorkItem(cb);
131 131
132 //SendRegionPresenceUpdate(friendpresence, userpresence); 132 //SendRegionPresenceUpdate(friendpresence, userpresence);
133 } 133 }
134 134
135 if ((uFriendListItem.FriendPerms & (uint) FriendRights.CanSeeOnline) != 0) 135 if ((uFriendListItem.FriendPerms & (uint)FriendRights.CanSeeOnline) != 0)
136 { 136 {
137 if (!friendpresence.subscriptionData.Contains(userpresence.agentData.AgentID)) 137 if (!friendpresence.subscriptionData.Contains(userpresence.agentData.AgentID))
138 { 138 {
@@ -147,9 +147,9 @@ namespace OpenSim.Grid.MessagingServer
147 friendlistupdater.presence1 = userpresence; 147 friendlistupdater.presence1 = userpresence;
148 friendlistupdater.presence2 = friendpresence; 148 friendlistupdater.presence2 = friendpresence;
149 149
150 WaitCallback cb2 = friendlistupdater.go; 150 WaitCallback cb2 = new WaitCallback(friendlistupdater.go);
151 ThreadPool.QueueUserWorkItem(cb2); 151 ThreadPool.QueueUserWorkItem(cb2);
152 152
153 //SendRegionPresenceUpdate(userpresence, friendpresence); 153 //SendRegionPresenceUpdate(userpresence, friendpresence);
154 } 154 }
155 } 155 }
@@ -164,7 +164,7 @@ namespace OpenSim.Grid.MessagingServer
164 { 164 {
165 if (m_presence_BackReferences.Contains(friendID)) 165 if (m_presence_BackReferences.Contains(friendID))
166 { 166 {
167 List<LLUUID> presenseBackReferences = (List<LLUUID>) m_presence_BackReferences[friendID]; 167 List<LLUUID> presenseBackReferences = (List<LLUUID>)m_presence_BackReferences[friendID];
168 if (!presenseBackReferences.Contains(agentID)) 168 if (!presenseBackReferences.Contains(agentID))
169 { 169 {
170 presenseBackReferences.Add(agentID); 170 presenseBackReferences.Add(agentID);
@@ -188,7 +188,7 @@ namespace OpenSim.Grid.MessagingServer
188 { 188 {
189 if (m_presence_BackReferences.Contains(friendID)) 189 if (m_presence_BackReferences.Contains(friendID))
190 { 190 {
191 List<LLUUID> presenseBackReferences = (List<LLUUID>) m_presence_BackReferences[friendID]; 191 List<LLUUID> presenseBackReferences = (List<LLUUID>)m_presence_BackReferences[friendID];
192 if (presenseBackReferences.Contains(agentID)) 192 if (presenseBackReferences.Contains(agentID))
193 { 193 {
194 presenseBackReferences.Remove(agentID); 194 presenseBackReferences.Remove(agentID);
@@ -216,29 +216,29 @@ namespace OpenSim.Grid.MessagingServer
216 { 216 {
217 if (m_presences.Contains(AgentID)) 217 if (m_presences.Contains(AgentID))
218 { 218 {
219 AgentData = (UserPresenceData) m_presences[AgentID]; 219 AgentData = (UserPresenceData)m_presences[AgentID];
220 } 220 }
221 } 221 }
222 222
223 if (AgentData != null) 223 if (AgentData != null)
224 { 224 {
225 AgentsNeedingNotification = AgentData.subscriptionData; 225 AgentsNeedingNotification = AgentData.subscriptionData;
226 //lock (m_presence_BackReferences) 226 //lock (m_presence_BackReferences)
227 //{ 227 //{
228 //if (m_presence_BackReferences.Contains(AgentID)) 228 //if (m_presence_BackReferences.Contains(AgentID))
229 //{ 229 //{
230 //AgentsNeedingNotification = (List<LLUUID>)m_presence_BackReferences[AgentID]; 230 //AgentsNeedingNotification = (List<LLUUID>)m_presence_BackReferences[AgentID];
231 //} 231 //}
232 //} 232 //}
233 233
234 for (int i = 0; i < AgentsNeedingNotification.Count; i++) 234 for (int i = 0; i < AgentsNeedingNotification.Count; i++)
235 { 235 {
236 // TODO: Do Region Notifications 236 // TODO: Do Region Notifications
237 lock (m_presences) 237 lock(m_presences)
238 { 238 {
239 if (m_presences.Contains(AgentsNeedingNotification[i])) 239 if (m_presences.Contains(AgentsNeedingNotification[i]))
240 { 240 {
241 friendd = (UserPresenceData) m_presences[AgentsNeedingNotification[i]]; 241 friendd = (UserPresenceData)m_presences[AgentsNeedingNotification[i]];
242 } 242 }
243 } 243 }
244 244
@@ -266,7 +266,7 @@ namespace OpenSim.Grid.MessagingServer
266 friendlistupdater.presence1 = AgentData; 266 friendlistupdater.presence1 = AgentData;
267 friendlistupdater.presence2 = friendd; 267 friendlistupdater.presence2 = friendd;
268 268
269 WaitCallback cb3 = friendlistupdater.go; 269 WaitCallback cb3 = new WaitCallback(friendlistupdater.go);
270 ThreadPool.QueueUserWorkItem(cb3); 270 ThreadPool.QueueUserWorkItem(cb3);
271 271
272 //SendRegionPresenceUpdate(AgentData, friendd); 272 //SendRegionPresenceUpdate(AgentData, friendd);
@@ -276,7 +276,7 @@ namespace OpenSim.Grid.MessagingServer
276 } 276 }
277 } 277 }
278 } 278 }
279 279
280 #endregion 280 #endregion
281 281
282 #region UserServer Comms 282 #region UserServer Comms
@@ -298,17 +298,18 @@ namespace OpenSim.Grid.MessagingServer
298 parameters.Add(param); 298 parameters.Add(param);
299 XmlRpcRequest req = new XmlRpcRequest("get_user_friend_list", parameters); 299 XmlRpcRequest req = new XmlRpcRequest("get_user_friend_list", parameters);
300 XmlRpcResponse resp = req.Send(m_cfg.UserServerURL, 3000); 300 XmlRpcResponse resp = req.Send(m_cfg.UserServerURL, 3000);
301 Hashtable respData = (Hashtable) resp.Value; 301 Hashtable respData = (Hashtable)resp.Value;
302 302
303 if (respData.Contains("avcount")) 303 if (respData.Contains("avcount"))
304 { 304 {
305 buddylist = ConvertXMLRPCDataToFriendListItemList(respData); 305 buddylist = ConvertXMLRPCDataToFriendListItemList(respData);
306 } 306 }
307
307 } 308 }
308 catch (WebException e) 309 catch (WebException e)
309 { 310 {
310 m_log.Warn("Error when trying to fetch Avatar's friends list: " + 311 m_log.Warn("Error when trying to fetch Avatar's friends list: " +
311 e.Message); 312 e.Message);
312 // Return Empty list (no friends) 313 // Return Empty list (no friends)
313 } 314 }
314 return buddylist; 315 return buddylist;
@@ -322,16 +323,16 @@ namespace OpenSim.Grid.MessagingServer
322 public List<FriendListItem> ConvertXMLRPCDataToFriendListItemList(Hashtable data) 323 public List<FriendListItem> ConvertXMLRPCDataToFriendListItemList(Hashtable data)
323 { 324 {
324 List<FriendListItem> buddylist = new List<FriendListItem>(); 325 List<FriendListItem> buddylist = new List<FriendListItem>();
325 int buddycount = Convert.ToInt32((string) data["avcount"]); 326 int buddycount = Convert.ToInt32((string)data["avcount"]);
326 327
327 for (int i = 0; i < buddycount; i++) 328 for (int i = 0; i < buddycount; i++)
328 { 329 {
329 FriendListItem buddylistitem = new FriendListItem(); 330 FriendListItem buddylistitem = new FriendListItem();
330 331
331 buddylistitem.FriendListOwner = new LLUUID((string) data["ownerID" + i]); 332 buddylistitem.FriendListOwner = new LLUUID((string)data["ownerID" + i.ToString()]);
332 buddylistitem.Friend = new LLUUID((string) data["friendID" + i]); 333 buddylistitem.Friend = new LLUUID((string)data["friendID" + i.ToString()]);
333 buddylistitem.FriendListOwnerPerms = (uint) Convert.ToInt32((string) data["ownerPerms" + i]); 334 buddylistitem.FriendListOwnerPerms = (uint)Convert.ToInt32((string)data["ownerPerms" + i.ToString()]);
334 buddylistitem.FriendPerms = (uint) Convert.ToInt32((string) data["friendPerms" + i]); 335 buddylistitem.FriendPerms = (uint)Convert.ToInt32((string)data["friendPerms" + i.ToString()]);
335 336
336 buddylist.Add(buddylistitem); 337 buddylist.Add(buddylistitem);
337 } 338 }
@@ -349,7 +350,7 @@ namespace OpenSim.Grid.MessagingServer
349 public XmlRpcResponse UserLoggedOn(XmlRpcRequest request) 350 public XmlRpcResponse UserLoggedOn(XmlRpcRequest request)
350 { 351 {
351 m_log.Info("[LOGON]: User logged on, building indexes for user"); 352 m_log.Info("[LOGON]: User logged on, building indexes for user");
352 Hashtable requestData = (Hashtable) request.Params[0]; 353 Hashtable requestData = (Hashtable)request.Params[0];
353 354
354 //requestData["sendkey"] = serv.sendkey; 355 //requestData["sendkey"] = serv.sendkey;
355 //requestData["agentid"] = agentID.ToString(); 356 //requestData["agentid"] = agentID.ToString();
@@ -363,13 +364,13 @@ namespace OpenSim.Grid.MessagingServer
363 //requestData["lastname"] = lastname; 364 //requestData["lastname"] = lastname;
364 365
365 AgentCircuitData agentData = new AgentCircuitData(); 366 AgentCircuitData agentData = new AgentCircuitData();
366 agentData.SessionID = new LLUUID((string) requestData["sessionid"]); 367 agentData.SessionID = new LLUUID((string)requestData["sessionid"]);
367 agentData.SecureSessionID = new LLUUID((string) requestData["secure_session_id"]); 368 agentData.SecureSessionID = new LLUUID((string)requestData["secure_session_id"]);
368 agentData.firstname = (string) requestData["firstname"]; 369 agentData.firstname = (string)requestData["firstname"];
369 agentData.lastname = (string) requestData["lastname"]; 370 agentData.lastname = (string)requestData["lastname"];
370 agentData.AgentID = new LLUUID((string) requestData["agentid"]); 371 agentData.AgentID = new LLUUID((string)requestData["agentid"]);
371 agentData.circuitcode = Convert.ToUInt32(requestData["circuit_code"]); 372 agentData.circuitcode = Convert.ToUInt32(requestData["circuit_code"]);
372 agentData.CapsPath = (string) requestData["caps_path"]; 373 agentData.CapsPath = (string)requestData["caps_path"];
373 374
374 if (requestData.ContainsKey("child_agent") && requestData["child_agent"].Equals("1")) 375 if (requestData.ContainsKey("child_agent") && requestData["child_agent"].Equals("1"))
375 { 376 {
@@ -378,13 +379,13 @@ namespace OpenSim.Grid.MessagingServer
378 else 379 else
379 { 380 {
380 agentData.startpos = 381 agentData.startpos =
381 new LLVector3(Convert.ToUInt32(requestData["positionx"]), 382 new LLVector3(Convert.ToUInt32(requestData["positionx"]),
382 Convert.ToUInt32(requestData["positiony"]), 383 Convert.ToUInt32(requestData["positiony"]),
383 Convert.ToUInt32(requestData["positionz"])); 384 Convert.ToUInt32(requestData["positionz"]));
384 agentData.child = false; 385 agentData.child = false;
385 } 386 }
386 387
387 ulong regionHandle = Convert.ToUInt64((string) requestData["regionhandle"]); 388 ulong regionHandle = Convert.ToUInt64((string)requestData["regionhandle"]);
388 389
389 UserPresenceData up = new UserPresenceData(); 390 UserPresenceData up = new UserPresenceData();
390 up.agentData = agentData; 391 up.agentData = agentData;
@@ -397,7 +398,7 @@ namespace OpenSim.Grid.MessagingServer
397 398
398 return new XmlRpcResponse(); 399 return new XmlRpcResponse();
399 } 400 }
400 401
401 /// <summary> 402 /// <summary>
402 /// The UserServer got a Logoff message 403 /// The UserServer got a Logoff message
403 /// Cleanup time for that user. Send out presence notifications 404 /// Cleanup time for that user. Send out presence notifications
@@ -406,9 +407,9 @@ namespace OpenSim.Grid.MessagingServer
406 /// <returns></returns> 407 /// <returns></returns>
407 public XmlRpcResponse UserLoggedOff(XmlRpcRequest request) 408 public XmlRpcResponse UserLoggedOff(XmlRpcRequest request)
408 { 409 {
409 Hashtable requestData = (Hashtable) request.Params[0]; 410 Hashtable requestData = (Hashtable)request.Params[0];
410 411
411 LLUUID AgentID = new LLUUID((string) requestData["agentid"]); 412 LLUUID AgentID = new LLUUID((string)requestData["agentid"]);
412 413
413 ProcessLogOff(AgentID); 414 ProcessLogOff(AgentID);
414 415
@@ -430,9 +431,9 @@ namespace OpenSim.Grid.MessagingServer
430 RegionProfileData regionInfo = null; 431 RegionProfileData regionInfo = null;
431 if (m_regionInfoCache.Contains(regionhandle)) 432 if (m_regionInfoCache.Contains(regionhandle))
432 { 433 {
433 regionInfo = (RegionProfileData) m_regionInfoCache[regionhandle]; 434 regionInfo = (RegionProfileData)m_regionInfoCache[regionhandle];
434 } 435 }
435 else 436 else
436 { 437 {
437 regionInfo = RequestRegionInfo(regionhandle); 438 regionInfo = RequestRegionInfo(regionhandle);
438 } 439 }
@@ -446,8 +447,7 @@ namespace OpenSim.Grid.MessagingServer
446 /// <param name="regionHandle"></param> 447 /// <param name="regionHandle"></param>
447 /// <returns></returns> 448 /// <returns></returns>
448 public RegionProfileData RequestRegionInfo(ulong regionHandle) 449 public RegionProfileData RequestRegionInfo(ulong regionHandle)
449 { 450 { RegionProfileData regionProfile = null;
450 RegionProfileData regionProfile = null;
451 try 451 try
452 { 452 {
453 Hashtable requestData = new Hashtable(); 453 Hashtable requestData = new Hashtable();
@@ -457,8 +457,8 @@ namespace OpenSim.Grid.MessagingServer
457 SendParams.Add(requestData); 457 SendParams.Add(requestData);
458 XmlRpcRequest GridReq = new XmlRpcRequest("simulator_data_request", SendParams); 458 XmlRpcRequest GridReq = new XmlRpcRequest("simulator_data_request", SendParams);
459 XmlRpcResponse GridResp = GridReq.Send(m_cfg.GridServerURL, 3000); 459 XmlRpcResponse GridResp = GridReq.Send(m_cfg.GridServerURL, 3000);
460 460
461 Hashtable responseData = (Hashtable) GridResp.Value; 461 Hashtable responseData = (Hashtable)GridResp.Value;
462 462
463 if (responseData.ContainsKey("error")) 463 if (responseData.ContainsKey("error"))
464 { 464 {
@@ -466,23 +466,23 @@ namespace OpenSim.Grid.MessagingServer
466 return null; 466 return null;
467 } 467 }
468 468
469 uint regX = Convert.ToUInt32((string) responseData["region_locx"]); 469 uint regX = Convert.ToUInt32((string)responseData["region_locx"]);
470 uint regY = Convert.ToUInt32((string) responseData["region_locy"]); 470 uint regY = Convert.ToUInt32((string)responseData["region_locy"]);
471 string internalIpStr = (string) responseData["sim_ip"]; 471 string internalIpStr = (string)responseData["sim_ip"];
472 uint port = Convert.ToUInt32(responseData["sim_port"]); 472 uint port = Convert.ToUInt32(responseData["sim_port"]);
473 string externalUri = (string) responseData["sim_uri"]; 473 string externalUri = (string)responseData["sim_uri"];
474 string neighbourExternalUri = externalUri; 474 string neighbourExternalUri = externalUri;
475 475
476 regionProfile = new RegionProfileData(); 476 regionProfile = new RegionProfileData();
477 regionProfile.httpPort = (uint) Convert.ToInt32((string) responseData["http_port"]); 477 regionProfile.httpPort = (uint)Convert.ToInt32((string)responseData["http_port"]);
478 regionProfile.httpServerURI = "http://" + internalIpStr + ":" + regionProfile.httpPort + "/"; 478 regionProfile.httpServerURI = "http://" + internalIpStr + ":" + regionProfile.httpPort + "/";
479 regionProfile.regionHandle = Helpers.UIntsToLong((regX * Constants.RegionSize), (regY * Constants.RegionSize)); 479 regionProfile.regionHandle = Helpers.UIntsToLong((regX * Constants.RegionSize), (regY * Constants.RegionSize));
480 regionProfile.regionLocX = regX; 480 regionProfile.regionLocX = regX;
481 regionProfile.regionLocY = regY; 481 regionProfile.regionLocY = regY;
482 482
483 regionProfile.remotingPort = Convert.ToUInt32((string) responseData["remoting_port"]); 483 regionProfile.remotingPort = Convert.ToUInt32((string)responseData["remoting_port"]);
484 regionProfile.UUID = new LLUUID((string) responseData["region_UUID"]); 484 regionProfile.UUID = new LLUUID((string)responseData["region_UUID"]);
485 regionProfile.regionName = (string) responseData["region_name"]; 485 regionProfile.regionName = (string)responseData["region_name"];
486 lock (m_regionInfoCache) 486 lock (m_regionInfoCache)
487 { 487 {
488 if (!m_regionInfoCache.Contains(regionHandle)) 488 if (!m_regionInfoCache.Contains(regionHandle))
@@ -494,31 +494,31 @@ namespace OpenSim.Grid.MessagingServer
494 catch (WebException) 494 catch (WebException)
495 { 495 {
496 m_log.Error("[GRID]: " + 496 m_log.Error("[GRID]: " +
497 "Region lookup failed for: " + regionHandle + 497 "Region lookup failed for: " + regionHandle.ToString() +
498 " - Is the GridServer down?"); 498 " - Is the GridServer down?");
499 return null; 499 return null;
500 } 500 }
501 501
502 return regionProfile; 502 return regionProfile;
503 } 503 }
504 504
505 public bool registerWithUserServer() 505 public bool registerWithUserServer ()
506 { 506 {
507 Hashtable UserParams = new Hashtable(); 507 Hashtable UserParams = new Hashtable();
508 // Login / Authentication 508 // Login / Authentication
509 509
510 if (m_cfg.HttpSSL) 510 if (m_cfg.HttpSSL)
511 { 511 {
512 UserParams["uri"] = "https://" + m_cfg.MessageServerIP + ":" + m_cfg.HttpPort; 512 UserParams["uri"] = "https://" + m_cfg.MessageServerIP + ":" + m_cfg.HttpPort;
513 } 513 }
514 else 514 else
515 { 515 {
516 UserParams["uri"] = "http://" + m_cfg.MessageServerIP + ":" + m_cfg.HttpPort; 516 UserParams["uri"] = "http://" + m_cfg.MessageServerIP + ":" + m_cfg.HttpPort;
517 } 517 }
518 518
519 UserParams["recvkey"] = m_cfg.UserRecvKey; 519 UserParams["recvkey"] = m_cfg.UserRecvKey;
520 UserParams["sendkey"] = m_cfg.UserRecvKey; 520 UserParams["sendkey"] = m_cfg.UserRecvKey;
521 521
522 // Package into an XMLRPC Request 522 // Package into an XMLRPC Request
523 ArrayList SendParams = new ArrayList(); 523 ArrayList SendParams = new ArrayList();
524 SendParams.Add(UserParams); 524 SendParams.Add(UserParams);
@@ -530,13 +530,12 @@ namespace OpenSim.Grid.MessagingServer
530 { 530 {
531 UserReq = new XmlRpcRequest("register_messageserver", SendParams); 531 UserReq = new XmlRpcRequest("register_messageserver", SendParams);
532 UserResp = UserReq.Send(m_cfg.UserServerURL, 16000); 532 UserResp = UserReq.Send(m_cfg.UserServerURL, 16000);
533 } 533 } catch (Exception ex)
534 catch (Exception ex)
535 { 534 {
536 m_log.Error("Unable to connect to grid. Grid server not running?"); 535 m_log.Error("Unable to connect to grid. Grid server not running?");
537 throw (ex); 536 throw(ex);
538 } 537 }
539 Hashtable GridRespData = (Hashtable) UserResp.Value; 538 Hashtable GridRespData = (Hashtable)UserResp.Value;
540 Hashtable griddatahash = GridRespData; 539 Hashtable griddatahash = GridRespData;
541 540
542 // Process Response 541 // Process Response
@@ -584,7 +583,7 @@ namespace OpenSim.Grid.MessagingServer
584 m_log.Error("Unable to connect to grid. Grid server not running?"); 583 m_log.Error("Unable to connect to grid. Grid server not running?");
585 throw (ex); 584 throw (ex);
586 } 585 }
587 Hashtable UserRespData = (Hashtable) UserResp.Value; 586 Hashtable UserRespData = (Hashtable)UserResp.Value;
588 Hashtable userdatahash = UserRespData; 587 Hashtable userdatahash = UserRespData;
589 588
590 // Process Response 589 // Process Response
@@ -600,4 +599,4 @@ namespace OpenSim.Grid.MessagingServer
600 599
601 #endregion 600 #endregion
602 } 601 }
603} \ No newline at end of file 602}
diff --git a/OpenSim/Grid/MessagingServer/PresenceInformer.cs b/OpenSim/Grid/MessagingServer/PresenceInformer.cs
index dd2fa5b..59d0e13 100644
--- a/OpenSim/Grid/MessagingServer/PresenceInformer.cs
+++ b/OpenSim/Grid/MessagingServer/PresenceInformer.cs
@@ -35,16 +35,21 @@ namespace OpenSim.Grid.MessagingServer
35{ 35{
36 public class PresenceInformer 36 public class PresenceInformer
37 { 37 {
38 public UserPresenceData presence1 = null;
39 public UserPresenceData presence2 = null;
38 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 40 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
39 public UserPresenceData presence1;
40 public UserPresenceData presence2;
41 41
42 public PresenceInformer()
43 {
44
45 }
42 public void go(object o) 46 public void go(object o)
43 { 47 {
44 if (presence1 != null && presence2 != null) 48 if (presence1 != null && presence2 != null)
45 { 49 {
46 SendRegionPresenceUpdate(presence1, presence2); 50 SendRegionPresenceUpdate(presence1, presence2);
47 } 51 }
52
48 } 53 }
49 54
50 /// <summary> 55 /// <summary>
@@ -69,4 +74,4 @@ namespace OpenSim.Grid.MessagingServer
69 XmlRpcResponse RegionResp = RegionReq.Send(whichRegion.httpServerURI, 6000); 74 XmlRpcResponse RegionResp = RegionReq.Send(whichRegion.httpServerURI, 6000);
70 } 75 }
71 } 76 }
72} \ No newline at end of file 77}
diff --git a/OpenSim/Grid/MessagingServer/UserPresenceData.cs b/OpenSim/Grid/MessagingServer/UserPresenceData.cs
index 790e999..7188201 100644
--- a/OpenSim/Grid/MessagingServer/UserPresenceData.cs
+++ b/OpenSim/Grid/MessagingServer/UserPresenceData.cs
@@ -36,9 +36,13 @@ namespace OpenSim.Grid.MessagingServer
36 public class UserPresenceData 36 public class UserPresenceData
37 { 37 {
38 public AgentCircuitData agentData = new AgentCircuitData(); 38 public AgentCircuitData agentData = new AgentCircuitData();
39 public List<FriendListItem> friendData = new List<FriendListItem>();
40 public string httpURI = String.Empty;
41 public RegionProfileData regionData = new RegionProfileData(); 39 public RegionProfileData regionData = new RegionProfileData();
40 public string httpURI = String.Empty;
41 public List<FriendListItem> friendData = new List<FriendListItem> ();
42 public List<LLUUID> subscriptionData = new List<LLUUID>(); 42 public List<LLUUID> subscriptionData = new List<LLUUID>();
43
44 public UserPresenceData()
45 {
46 }
43 } 47 }
44} \ No newline at end of file 48}
diff --git a/OpenSim/Grid/MessagingServer/WorkUnitBase.cs b/OpenSim/Grid/MessagingServer/WorkUnitBase.cs
index 1c1503b..d25f044 100644
--- a/OpenSim/Grid/MessagingServer/WorkUnitBase.cs
+++ b/OpenSim/Grid/MessagingServer/WorkUnitBase.cs
@@ -30,4 +30,4 @@ namespace OpenSim.Grid.MessagingServer
30 public class WorkUnitBase 30 public class WorkUnitBase
31 { 31 {
32 } 32 }
33} \ No newline at end of file 33}
diff --git a/OpenSim/Grid/MessagingServer/WorkUnitPresenceUpdate.cs b/OpenSim/Grid/MessagingServer/WorkUnitPresenceUpdate.cs
index 625a9f6..c31f0c7 100644
--- a/OpenSim/Grid/MessagingServer/WorkUnitPresenceUpdate.cs
+++ b/OpenSim/Grid/MessagingServer/WorkUnitPresenceUpdate.cs
@@ -30,4 +30,4 @@ namespace OpenSim.Grid.MessagingServer
30 public class WorkUnitPresenceUpdate : WorkUnitBase 30 public class WorkUnitPresenceUpdate : WorkUnitBase
31 { 31 {
32 } 32 }
33} \ No newline at end of file 33}
diff --git a/OpenSim/Grid/MessagingServer/XMPPHTTPService.cs b/OpenSim/Grid/MessagingServer/XMPPHTTPService.cs
index 257e802..df3bc22 100644
--- a/OpenSim/Grid/MessagingServer/XMPPHTTPService.cs
+++ b/OpenSim/Grid/MessagingServer/XMPPHTTPService.cs
@@ -48,26 +48,28 @@ namespace OpenSim.Grid.MessagingServer
48 : base("GET", "/presence") 48 : base("GET", "/presence")
49 { 49 {
50 m_log.Info("[REST]: In Get Request"); 50 m_log.Info("[REST]: In Get Request");
51
51 } 52 }
52 53
53 public override byte[] Handle(string path, Stream request) 54 public override byte[] Handle(string path, Stream request)
54 { 55 {
55 string param = GetParam(path); 56 string param = GetParam(path);
56 byte[] result = new byte[] {}; 57 byte[] result = new byte[] {};
57 try 58 try
58 { 59 {
59 string[] p = param.Split(new[] {'/', '?', '&'}, StringSplitOptions.RemoveEmptyEntries); 60 string[] p = param.Split(new char[] {'/', '?', '&'}, StringSplitOptions.RemoveEmptyEntries);
60 61
61 if (p.Length > 0) 62 if (p.Length > 0)
62 { 63 {
63 LLUUID assetID = null; 64 LLUUID assetID = null;
64 65
65 if (!LLUUID.TryParse(p[0], out assetID)) 66 if (!LLUUID.TryParse(p[0], out assetID))
66 { 67 {
67 m_log.InfoFormat( 68 m_log.InfoFormat(
68 "[REST]: GET:/presence ignoring request with malformed UUID {0}", p[0]); 69 "[REST]: GET:/presence ignoring request with malformed UUID {0}", p[0]);
69 return result; 70 return result;
70 } 71 }
72
71 } 73 }
72 } 74 }
73 catch (Exception e) 75 catch (Exception e)
@@ -82,11 +84,6 @@ namespace OpenSim.Grid.MessagingServer
82 { 84 {
83 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 85 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
84 86
85 public PostXMPPStreamHandler()
86 : base("POST", "/presence")
87 {
88 }
89
90 public override byte[] Handle(string path, Stream request) 87 public override byte[] Handle(string path, Stream request)
91 { 88 {
92 string param = GetParam(path); 89 string param = GetParam(path);
@@ -100,5 +97,12 @@ namespace OpenSim.Grid.MessagingServer
100 97
101 return new byte[] {}; 98 return new byte[] {};
102 } 99 }
100
101 public PostXMPPStreamHandler()
102 : base("POST", "/presence")
103 {
104
105 }
106
103 } 107 }
104} \ No newline at end of file 108}
diff --git a/OpenSim/Grid/ScriptServer/Application.cs b/OpenSim/Grid/ScriptServer/Application.cs
index dc0bf62..ef93f65 100644
--- a/OpenSim/Grid/ScriptServer/Application.cs
+++ b/OpenSim/Grid/ScriptServer/Application.cs
@@ -39,7 +39,7 @@ namespace OpenSim.Grid.ScriptServer
39 XmlConfigurator.Configure(); 39 XmlConfigurator.Configure();
40 40
41 AppDomain.CurrentDomain.UnhandledException += 41 AppDomain.CurrentDomain.UnhandledException +=
42 CurrentDomain_UnhandledException; 42 new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
43 43
44 // Application is starting 44 // Application is starting
45 SE = new ScriptServerMain(); 45 SE = new ScriptServerMain();
@@ -50,9 +50,9 @@ namespace OpenSim.Grid.ScriptServer
50 Console.WriteLine(String.Empty); 50 Console.WriteLine(String.Empty);
51 Console.WriteLine("APPLICATION EXCEPTION DETECTED"); 51 Console.WriteLine("APPLICATION EXCEPTION DETECTED");
52 Console.WriteLine(String.Empty); 52 Console.WriteLine(String.Empty);
53 Console.WriteLine("Application is terminating: " + e.IsTerminating); 53 Console.WriteLine("Application is terminating: " + e.IsTerminating.ToString());
54 //Console.WriteLine("Exception:"); 54 //Console.WriteLine("Exception:");
55 //Console.WriteLine(e.ExceptionObject.ToString()); 55 //Console.WriteLine(e.ExceptionObject.ToString());
56 } 56 }
57 } 57 }
58} \ No newline at end of file 58}
diff --git a/OpenSim/Grid/ScriptServer/FakeScene.cs b/OpenSim/Grid/ScriptServer/FakeScene.cs
index e037698..480050d 100644
--- a/OpenSim/Grid/ScriptServer/FakeScene.cs
+++ b/OpenSim/Grid/ScriptServer/FakeScene.cs
@@ -34,7 +34,7 @@ using OpenSim.Region.Environment.Scenes;
34 34
35namespace OpenSim.Grid.ScriptServer 35namespace OpenSim.Grid.ScriptServer
36{ 36{
37 public class FakeScene : Scene 37 public class FakeScene: Scene
38 { 38 {
39 public FakeScene(RegionInfo regInfo, AgentCircuitManager authen, PermissionManager permissionManager, 39 public FakeScene(RegionInfo regInfo, AgentCircuitManager authen, PermissionManager permissionManager,
40 CommunicationsManager commsMan, SceneCommunicationService sceneGridService, 40 CommunicationsManager commsMan, SceneCommunicationService sceneGridService,
@@ -48,4 +48,4 @@ namespace OpenSim.Grid.ScriptServer
48 48
49 // What does a scene have to do? :P 49 // What does a scene have to do? :P
50 } 50 }
51} \ No newline at end of file 51}
diff --git a/OpenSim/Grid/ScriptServer/Properties/AssemblyInfo.cs b/OpenSim/Grid/ScriptServer/Properties/AssemblyInfo.cs
index bb33e02..e4161d3 100644
--- a/OpenSim/Grid/ScriptServer/Properties/AssemblyInfo.cs
+++ b/OpenSim/Grid/ScriptServer/Properties/AssemblyInfo.cs
@@ -60,4 +60,4 @@ using System.Runtime.InteropServices;
60// 60//
61 61
62[assembly : AssemblyVersion("1.0.0.0")] 62[assembly : AssemblyVersion("1.0.0.0")]
63[assembly : AssemblyFileVersion("1.0.0.0")] \ No newline at end of file 63[assembly : AssemblyFileVersion("1.0.0.0")]
diff --git a/OpenSim/Grid/ScriptServer/RemotingObject.cs b/OpenSim/Grid/ScriptServer/RemotingObject.cs
index 6686b26..9d3065b 100644
--- a/OpenSim/Grid/ScriptServer/RemotingObject.cs
+++ b/OpenSim/Grid/ScriptServer/RemotingObject.cs
@@ -34,13 +34,9 @@ namespace OpenSim.Grid.ScriptServer
34 { 34 {
35 // This object will be exposed over remoting. It is a singleton, so it exists only in as one instance. 35 // This object will be exposed over remoting. It is a singleton, so it exists only in as one instance.
36 36
37 #region ServerRemotingObject Members
38
39 ScriptServerInterfaces.RemoteEvents ScriptServerInterfaces.ServerRemotingObject.Events() 37 ScriptServerInterfaces.RemoteEvents ScriptServerInterfaces.ServerRemotingObject.Events()
40 { 38 {
41 return ScriptServerMain.Engine.EventManager(); 39 return ScriptServerMain.Engine.EventManager();
42 } 40 }
43
44 #endregion
45 } 41 }
46} \ No newline at end of file 42}
diff --git a/OpenSim/Grid/ScriptServer/RemotingServer.cs b/OpenSim/Grid/ScriptServer/RemotingServer.cs
index 9d75a83..7d0e334 100644
--- a/OpenSim/Grid/ScriptServer/RemotingServer.cs
+++ b/OpenSim/Grid/ScriptServer/RemotingServer.cs
@@ -31,10 +31,9 @@ using System.Runtime.Remoting.Channels.Tcp;
31 31
32namespace OpenSim.Grid.ScriptServer 32namespace OpenSim.Grid.ScriptServer
33{ 33{
34 internal class RemotingServer 34 class RemotingServer
35 { 35 {
36 private readonly TcpChannel channel; 36 TcpChannel channel;
37
38 public RemotingServer(int port, string instanceName) 37 public RemotingServer(int port, string instanceName)
39 { 38 {
40 // Create an instance of a channel 39 // Create an instance of a channel
@@ -43,9 +42,9 @@ namespace OpenSim.Grid.ScriptServer
43 42
44 // Register as an available service with the name HelloWorld 43 // Register as an available service with the name HelloWorld
45 RemotingConfiguration.RegisterWellKnownServiceType( 44 RemotingConfiguration.RegisterWellKnownServiceType(
46 typeof (RemotingObject), 45 typeof(RemotingObject),
47 instanceName, 46 instanceName,
48 WellKnownObjectMode.Singleton); 47 WellKnownObjectMode.Singleton);
49 } 48 }
50 } 49 }
51} \ No newline at end of file 50}
diff --git a/OpenSim/Grid/ScriptServer/ScriptServer/Region/RegionBase.cs b/OpenSim/Grid/ScriptServer/ScriptServer/Region/RegionBase.cs
index 4f9f2e7..a02429c 100644
--- a/OpenSim/Grid/ScriptServer/ScriptServer/Region/RegionBase.cs
+++ b/OpenSim/Grid/ScriptServer/ScriptServer/Region/RegionBase.cs
@@ -32,13 +32,8 @@ namespace OpenSim.Grid.ScriptServer.ScriptServer.Region
32 // These are events that the region needs to have 32 // These are events that the region needs to have
33 33
34 // TEMP: Using System.Delegate -- needs replacing with a real delegate 34 // TEMP: Using System.Delegate -- needs replacing with a real delegate
35
36 #region Delegates
37
38 public delegate void DefaultDelegate(); 35 public delegate void DefaultDelegate();
39 36
40 #endregion
41
42 public event DefaultDelegate onScriptRez; 37 public event DefaultDelegate onScriptRez;
43 public event DefaultDelegate onstate_entry; 38 public event DefaultDelegate onstate_entry;
44 public event DefaultDelegate onstate_exit; 39 public event DefaultDelegate onstate_exit;
diff --git a/OpenSim/Grid/ScriptServer/ScriptServer/Region/RegionConnectionManager.cs b/OpenSim/Grid/ScriptServer/ScriptServer/Region/RegionConnectionManager.cs
index 3c20272..8c31b9b 100644
--- a/OpenSim/Grid/ScriptServer/ScriptServer/Region/RegionConnectionManager.cs
+++ b/OpenSim/Grid/ScriptServer/ScriptServer/Region/RegionConnectionManager.cs
@@ -29,8 +29,8 @@ namespace OpenSim.Grid.ScriptServer.ScriptServer.Region
29{ 29{
30 public class RegionConnectionManager : RegionBase 30 public class RegionConnectionManager : RegionBase
31 { 31 {
32 private object m_Connection;
33 private ScriptServerMain m_ScriptServerMain; 32 private ScriptServerMain m_ScriptServerMain;
33 private object m_Connection;
34 34
35 public RegionConnectionManager(ScriptServerMain scm, object Connection) 35 public RegionConnectionManager(ScriptServerMain scm, object Connection)
36 { 36 {
diff --git a/OpenSim/Grid/ScriptServer/ScriptServer/RegionCommManager.cs b/OpenSim/Grid/ScriptServer/ScriptServer/RegionCommManager.cs
index c1449bf..8422bea 100644
--- a/OpenSim/Grid/ScriptServer/ScriptServer/RegionCommManager.cs
+++ b/OpenSim/Grid/ScriptServer/ScriptServer/RegionCommManager.cs
@@ -34,10 +34,12 @@ namespace OpenSim.Grid.ScriptServer.ScriptServer
34{ 34{
35 internal class RegionCommManager 35 internal class RegionCommManager
36 { 36 {
37 private readonly ScriptServerMain m_ScriptServerMain;
38 private readonly List<RegionConnectionManager> Regions = new List<RegionConnectionManager>();
39 private Thread listenThread; 37 private Thread listenThread;
40 38
39 private List<RegionConnectionManager> Regions = new List<RegionConnectionManager>();
40
41 private ScriptServerMain m_ScriptServerMain;
42
41 public RegionCommManager(ScriptServerMain scm) 43 public RegionCommManager(ScriptServerMain scm)
42 { 44 {
43 m_ScriptServerMain = scm; 45 m_ScriptServerMain = scm;
diff --git a/OpenSim/Grid/ScriptServer/ScriptServer/ScriptEngineLoader.cs b/OpenSim/Grid/ScriptServer/ScriptServer/ScriptEngineLoader.cs
index dce92ce..4d8c559 100644
--- a/OpenSim/Grid/ScriptServer/ScriptServer/ScriptEngineLoader.cs
+++ b/OpenSim/Grid/ScriptServer/ScriptServer/ScriptEngineLoader.cs
@@ -51,7 +51,7 @@ namespace OpenSim.Grid.ScriptServer.ScriptServer
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 }
@@ -104,7 +104,7 @@ namespace OpenSim.Grid.ScriptServer.ScriptServer
104 ScriptServerInterfaces.ScriptEngine ret; 104 ScriptServerInterfaces.ScriptEngine ret;
105 //try 105 //try
106 //{ 106 //{
107 ret = (ScriptServerInterfaces.ScriptEngine) Activator.CreateInstance(t); 107 ret = (ScriptServerInterfaces.ScriptEngine)Activator.CreateInstance(t);
108 //} 108 //}
109 //catch (Exception e) 109 //catch (Exception e)
110 //{ 110 //{
@@ -114,4 +114,4 @@ namespace OpenSim.Grid.ScriptServer.ScriptServer
114 return ret; 114 return ret;
115 } 115 }
116 } 116 }
117} \ No newline at end of file 117}
diff --git a/OpenSim/Grid/ScriptServer/ScriptServer/ScriptEnginesManager.cs b/OpenSim/Grid/ScriptServer/ScriptServer/ScriptEnginesManager.cs
index 9ecd179..9d67602 100644
--- a/OpenSim/Grid/ScriptServer/ScriptServer/ScriptEnginesManager.cs
+++ b/OpenSim/Grid/ScriptServer/ScriptServer/ScriptEnginesManager.cs
@@ -32,8 +32,8 @@ namespace OpenSim.Grid.ScriptServer.ScriptServer
32{ 32{
33 internal class ScriptEngineManager 33 internal class ScriptEngineManager
34 { 34 {
35 private readonly ScriptEngineLoader ScriptEngineLoader; 35 private ScriptEngineLoader ScriptEngineLoader;
36 private readonly List<ScriptServerInterfaces.ScriptEngine> scriptEngines = new List<ScriptServerInterfaces.ScriptEngine>(); 36 private List<ScriptServerInterfaces.ScriptEngine> scriptEngines = new List<ScriptServerInterfaces.ScriptEngine>();
37 private ScriptServerMain m_ScriptServerMain; 37 private ScriptServerMain m_ScriptServerMain;
38 38
39 // Initialize 39 // Initialize
@@ -58,4 +58,4 @@ namespace OpenSim.Grid.ScriptServer.ScriptServer
58 return sei; 58 return sei;
59 } 59 }
60 } 60 }
61} \ No newline at end of file 61}
diff --git a/OpenSim/Grid/ScriptServer/ScriptServerMain.cs b/OpenSim/Grid/ScriptServer/ScriptServerMain.cs
index 131ff34..528b51c 100644
--- a/OpenSim/Grid/ScriptServer/ScriptServerMain.cs
+++ b/OpenSim/Grid/ScriptServer/ScriptServerMain.cs
@@ -44,20 +44,20 @@ namespace OpenSim.Grid.ScriptServer
44 // 44 //
45 // Root object. Creates objects used. 45 // Root object. Creates objects used.
46 // 46 //
47 private int listenPort = 8010;
47 48
48 // TEMP 49 // TEMP
49 public static ScriptServerInterfaces.ScriptEngine Engine; 50 public static ScriptServerInterfaces.ScriptEngine Engine;
50 private int listenPort = 8010;
51 //public static FakeScene m_Scene = new FakeScene(null,null,null,null,null,null,null,null,null,false, false, false); 51 //public static FakeScene m_Scene = new FakeScene(null,null,null,null,null,null,null,null,null,false, false, false);
52 52
53 // Objects we use 53 // Objects we use
54 internal RegionCommManager RegionScriptDaemon; // Listen for incoming from region
55 internal ScriptEngineManager ScriptEngines; // Loads scriptengines
54 //internal RemotingServer m_RemotingServer; 56 //internal RemotingServer m_RemotingServer;
55 internal TCPServer m_TCPServer; 57 internal TCPServer m_TCPServer;
56 internal RegionCommManager RegionScriptDaemon; // Listen for incoming from region
57 internal TRPC_Remote RPC; 58 internal TRPC_Remote RPC;
58 internal ScriptEngineManager ScriptEngines; // Loads scriptengines
59 59
60 public ScriptServerMain() 60 public ScriptServerMain()
61 { 61 {
62 m_console = CreateConsole(); 62 m_console = CreateConsole();
63 63
@@ -68,13 +68,13 @@ namespace OpenSim.Grid.ScriptServer
68 Engine = ScriptEngines.LoadEngine("DotNetEngine"); 68 Engine = ScriptEngines.LoadEngine("DotNetEngine");
69 69
70 Engine.InitializeEngine(null, null, false, Engine.GetScriptManager()); 70 Engine.InitializeEngine(null, null, false, Engine.GetScriptManager());
71 71
72 72
73 // Set up server 73 // Set up server
74 //m_RemotingServer = new RemotingServer(listenPort, "DotNetEngine"); 74 //m_RemotingServer = new RemotingServer(listenPort, "DotNetEngine");
75 m_TCPServer = new TCPServer(listenPort); 75 m_TCPServer = new TCPServer(listenPort);
76 RPC = new TRPC_Remote(m_TCPServer); 76 RPC = new TRPC_Remote(m_TCPServer);
77 RPC.ReceiveCommand += RPC_ReceiveCommand; 77 RPC.ReceiveCommand += new TRPC_Remote.ReceiveCommandDelegate(RPC_ReceiveCommand);
78 m_TCPServer.StartListen(); 78 m_TCPServer.StartListen();
79 79
80 Console.ReadLine(); 80 Console.ReadLine();
@@ -93,7 +93,7 @@ namespace OpenSim.Grid.ScriptServer
93 93
94 if (Command == "OnRezScript") 94 if (Command == "OnRezScript")
95 { 95 {
96 Engine.EventManager().OnRezScript((uint) p[0], new LLUUID((string) p[1]), (string) p[2]); 96 Engine.EventManager().OnRezScript((uint)p[0], new LLUUID((string)p[1]), (string)p[2]);
97 } 97 }
98 } 98 }
99 99
@@ -106,4 +106,4 @@ namespace OpenSim.Grid.ScriptServer
106 return new ConsoleBase("ScriptServer", this); 106 return new ConsoleBase("ScriptServer", this);
107 } 107 }
108 } 108 }
109} \ No newline at end of file 109}
diff --git a/OpenSim/Grid/UserServer/Main.cs b/OpenSim/Grid/UserServer/Main.cs
index 25e1585..0534e3b 100644
--- a/OpenSim/Grid/UserServer/Main.cs
+++ b/OpenSim/Grid/UserServer/Main.cs
@@ -48,61 +48,12 @@ namespace OpenSim.Grid.UserServer
48 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 48 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
49 49
50 private UserConfig Cfg; 50 private UserConfig Cfg;
51 private LLUUID m_lastCreatedUser = LLUUID.Random(); 51
52
53 public UserLoginService m_loginService;
54 public MessageServersConnector m_messagesService;
55 public UserManager m_userManager; 52 public UserManager m_userManager;
53 public UserLoginService m_loginService;
54 public MessageServersConnector m_messagesService;
56 55
57 private OpenUser_Main() 56 private LLUUID m_lastCreatedUser = LLUUID.Random();
58 {
59 m_console = new ConsoleBase("OpenUser", this);
60 MainConsole.Instance = m_console;
61 }
62
63 #region conscmd_callback Members
64
65 public override void RunCmd(string cmd, string[] cmdparams)
66 {
67 base.RunCmd(cmd, cmdparams);
68
69 switch (cmd)
70 {
71 case "help":
72 m_console.Notice("create user - create a new user");
73 m_console.Notice("stats - statistical information for this server");
74 m_console.Notice("shutdown - shutdown the grid (USE CAUTION!)");
75 break;
76
77 case "create":
78 do_create(cmdparams[0]);
79 break;
80
81 case "shutdown":
82 m_loginService.OnUserLoggedInAtLocation -= NotifyMessageServersUserLoggedInToLocation;
83 m_console.Close();
84 Environment.Exit(0);
85 break;
86
87 case "stats":
88 m_console.Notice(StatsManager.UserStats.Report());
89 break;
90
91 case "test-inventory":
92 // RestObjectPosterResponse<List<InventoryFolderBase>> requester = new RestObjectPosterResponse<List<InventoryFolderBase>>();
93 // requester.ReturnResponseVal = TestResponse;
94 // requester.BeginPostObject<LLUUID>(m_userManager._config.InventoryUrl + "RootFolders/", m_lastCreatedUser);
95 SynchronousRestObjectPoster.BeginPostObject<LLUUID, List<InventoryFolderBase>>("POST",
96 m_userManager.
97 _config.
98 InventoryUrl +
99 "RootFolders/",
100 m_lastCreatedUser);
101 break;
102 }
103 }
104
105 #endregion
106 57
107 [STAThread] 58 [STAThread]
108 public static void Main(string[] args) 59 public static void Main(string[] args)
@@ -117,6 +68,12 @@ namespace OpenSim.Grid.UserServer
117 userserver.Work(); 68 userserver.Work();
118 } 69 }
119 70
71 private OpenUser_Main()
72 {
73 m_console = new ConsoleBase("OpenUser", this);
74 MainConsole.Instance = m_console;
75 }
76
120 private void Work() 77 private void Work()
121 { 78 {
122 m_console.Notice("Enter help for a list of commands\n"); 79 m_console.Notice("Enter help for a list of commands\n");
@@ -130,16 +87,16 @@ namespace OpenSim.Grid.UserServer
130 public void Startup() 87 public void Startup()
131 { 88 {
132 Cfg = new UserConfig("USER SERVER", (Path.Combine(Util.configDir(), "UserServer_Config.xml"))); 89 Cfg = new UserConfig("USER SERVER", (Path.Combine(Util.configDir(), "UserServer_Config.xml")));
133 90
134 StatsManager.StartCollectingUserStats(); 91 StatsManager.StartCollectingUserStats();
135 92
136 m_log.Info("[REGION]: Establishing data connection"); 93 m_log.Info("[REGION]: Establishing data connection");
137 m_userManager = new UserManager(); 94 m_userManager = new UserManager();
138 m_userManager._config = Cfg; 95 m_userManager._config = Cfg;
139 m_userManager.AddPlugin(Cfg.DatabaseProvider); 96 m_userManager.AddPlugin(Cfg.DatabaseProvider);
140 97
141 m_loginService = new UserLoginService( 98 m_loginService = new UserLoginService(
142 m_userManager, new LibraryRootFolder(), Cfg, Cfg.DefaultStartupMsg); 99 m_userManager, new LibraryRootFolder(), Cfg, Cfg.DefaultStartupMsg);
143 100
144 m_messagesService = new MessageServersConnector(); 101 m_messagesService = new MessageServersConnector();
145 102
@@ -147,7 +104,7 @@ namespace OpenSim.Grid.UserServer
147 m_userManager.OnLogOffUser += NotifyMessageServersUserLoggOff; 104 m_userManager.OnLogOffUser += NotifyMessageServersUserLoggOff;
148 105
149 m_log.Info("[REGION]: Starting HTTP process"); 106 m_log.Info("[REGION]: Starting HTTP process");
150 107
151 m_httpServer = new BaseHttpServer(Cfg.HttpPort); 108 m_httpServer = new BaseHttpServer(Cfg.HttpPort);
152 AddHttpHandlers(); 109 AddHttpHandlers();
153 m_httpServer.Start(); 110 m_httpServer.Start();
@@ -160,7 +117,7 @@ namespace OpenSim.Grid.UserServer
160 m_httpServer.AddXmlRPCHandler("login_to_simulator", m_loginService.XmlRpcLoginMethod); 117 m_httpServer.AddXmlRPCHandler("login_to_simulator", m_loginService.XmlRpcLoginMethod);
161 118
162 m_httpServer.AddHTTPHandler("login", m_loginService.ProcessHTMLLogin); 119 m_httpServer.AddHTTPHandler("login", m_loginService.ProcessHTMLLogin);
163 120
164 m_httpServer.SetLLSDHandler(m_loginService.LLSDLoginMethod); 121 m_httpServer.SetLLSDHandler(m_loginService.LLSDLoginMethod);
165 122
166 m_httpServer.AddXmlRPCHandler("get_user_by_name", m_userManager.XmlRPCGetUserMethodName); 123 m_httpServer.AddXmlRPCHandler("get_user_by_name", m_userManager.XmlRPCGetUserMethodName);
@@ -171,7 +128,7 @@ namespace OpenSim.Grid.UserServer
171 m_httpServer.AddXmlRPCHandler("update_user_friend_perms", m_userManager.XmlRpcResponseXmlRPCUpdateUserFriendPerms); 128 m_httpServer.AddXmlRPCHandler("update_user_friend_perms", m_userManager.XmlRpcResponseXmlRPCUpdateUserFriendPerms);
172 m_httpServer.AddXmlRPCHandler("get_user_friend_list", m_userManager.XmlRpcResponseXmlRPCGetUserFriendList); 129 m_httpServer.AddXmlRPCHandler("get_user_friend_list", m_userManager.XmlRpcResponseXmlRPCGetUserFriendList);
173 m_httpServer.AddXmlRPCHandler("logout_of_simulator", m_userManager.XmlRPCLogOffUserMethodUUID); 130 m_httpServer.AddXmlRPCHandler("logout_of_simulator", m_userManager.XmlRPCLogOffUserMethodUUID);
174 131
175 // Message Server ---> User Server 132 // Message Server ---> User Server
176 m_httpServer.AddXmlRPCHandler("register_messageserver", m_messagesService.XmlRPCRegisterMessageServer); 133 m_httpServer.AddXmlRPCHandler("register_messageserver", m_messagesService.XmlRPCRegisterMessageServer);
177 m_httpServer.AddXmlRPCHandler("agent_change_region", m_messagesService.XmlRPCUserMovedtoRegion); 134 m_httpServer.AddXmlRPCHandler("agent_change_region", m_messagesService.XmlRPCUserMovedtoRegion);
@@ -206,17 +163,17 @@ namespace OpenSim.Grid.UserServer
206 { 163 {
207 m_log.ErrorFormat( 164 m_log.ErrorFormat(
208 "[USERS]: A user with the name {0} {1} already exists!", tempfirstname, templastname); 165 "[USERS]: A user with the name {0} {1} already exists!", tempfirstname, templastname);
209 166
210 break; 167 break;
211 } 168 }
212 169
213 tempMD5Passwd = Util.Md5Hash(Util.Md5Hash(tempMD5Passwd) + ":" + String.Empty); 170 tempMD5Passwd = Util.Md5Hash(Util.Md5Hash(tempMD5Passwd) + ":" + String.Empty);
214 171
215 LLUUID userID = new LLUUID(); 172 LLUUID userID = new LLUUID();
216 try 173 try
217 { 174 {
218 userID = m_userManager.AddUserProfile(tempfirstname, templastname, tempMD5Passwd, regX, regY); 175 userID = m_userManager.AddUserProfile(tempfirstname, templastname, tempMD5Passwd, regX, regY);
219 } 176 }
220 catch (Exception ex) 177 catch (Exception ex)
221 { 178 {
222 m_log.ErrorFormat("[USERS]: Error creating user: {0}", ex.ToString()); 179 m_log.ErrorFormat("[USERS]: Error creating user: {0}", ex.ToString());
@@ -224,35 +181,76 @@ namespace OpenSim.Grid.UserServer
224 181
225 try 182 try
226 { 183 {
227 bool created 184 bool created
228 = SynchronousRestObjectPoster.BeginPostObject<Guid, bool>( 185 = SynchronousRestObjectPoster.BeginPostObject<Guid, bool>(
229 "POST", m_userManager._config.InventoryUrl + "CreateInventory/", userID.UUID); 186 "POST", m_userManager._config.InventoryUrl + "CreateInventory/", userID.UUID);
230 187
231 if (!created) 188 if (!created)
232 { 189 {
233 throw new Exception( 190 throw new Exception(
234 String.Format( 191 String.Format(
235 "The inventory creation request for user {0} did not succeed." 192 "The inventory creation request for user {0} did not succeed."
236 + " Please contact your inventory service provider for more information.", 193 + " Please contact your inventory service provider for more information.",
237 userID)); 194 userID));
238 } 195 }
196
239 } 197 }
240 catch (WebException e) 198 catch (WebException e)
241 { 199 {
242 m_log.ErrorFormat( 200 m_log.ErrorFormat(
243 "[USERS]: Could not contact the inventory service at {0} to create an inventory for {1}", 201 "[USERS]: Could not contact the inventory service at {0} to create an inventory for {1}",
244 m_userManager._config.InventoryUrl + "CreateInventory/", userID.UUID); 202 m_userManager._config.InventoryUrl + "CreateInventory/", userID.UUID);
245 } 203 }
246 catch (Exception e) 204 catch (Exception e)
247 { 205 {
248 m_log.ErrorFormat("[USERS]: Error creating inventory for user: {0}", e); 206 m_log.ErrorFormat("[USERS]: Error creating inventory for user: {0}", e);
249 } 207 }
250 208
251 m_lastCreatedUser = userID; 209 m_lastCreatedUser = userID;
252 break; 210 break;
253 } 211 }
254 } 212 }
255 213
214 public override void RunCmd(string cmd, string[] cmdparams)
215 {
216 base.RunCmd(cmd, cmdparams);
217
218 switch (cmd)
219 {
220 case "help":
221 m_console.Notice("create user - create a new user");
222 m_console.Notice("stats - statistical information for this server");
223 m_console.Notice("shutdown - shutdown the grid (USE CAUTION!)");
224 break;
225
226 case "create":
227 do_create(cmdparams[0]);
228 break;
229
230 case "shutdown":
231 m_loginService.OnUserLoggedInAtLocation -= NotifyMessageServersUserLoggedInToLocation;
232 m_console.Close();
233 Environment.Exit(0);
234 break;
235
236 case "stats":
237 m_console.Notice(StatsManager.UserStats.Report());
238 break;
239
240 case "test-inventory":
241 // RestObjectPosterResponse<List<InventoryFolderBase>> requester = new RestObjectPosterResponse<List<InventoryFolderBase>>();
242 // requester.ReturnResponseVal = TestResponse;
243 // requester.BeginPostObject<LLUUID>(m_userManager._config.InventoryUrl + "RootFolders/", m_lastCreatedUser);
244 SynchronousRestObjectPoster.BeginPostObject<LLUUID, List<InventoryFolderBase>>("POST",
245 m_userManager.
246 _config.
247 InventoryUrl +
248 "RootFolders/",
249 m_lastCreatedUser);
250 break;
251 }
252 }
253
256 public void TestResponse(List<InventoryFolderBase> resp) 254 public void TestResponse(List<InventoryFolderBase> resp)
257 { 255 {
258 m_console.Notice("response got"); 256 m_console.Notice("response got");
@@ -264,11 +262,12 @@ namespace OpenSim.Grid.UserServer
264 } 262 }
265 263
266 public void NotifyMessageServersUserLoggedInToLocation(LLUUID agentID, LLUUID sessionID, LLUUID RegionID, 264 public void NotifyMessageServersUserLoggedInToLocation(LLUUID agentID, LLUUID sessionID, LLUUID RegionID,
267 ulong regionhandle, float positionX, float positionY, 265 ulong regionhandle, float positionX, float positionY,
268 float positionZ, string firstname, string lastname) 266 float positionZ, string firstname, string lastname)
269 { 267 {
270 m_messagesService.TellMessageServersAboutUser(agentID, sessionID, RegionID, regionhandle, positionX, 268
271 positionY, positionZ, firstname, lastname); 269 m_messagesService.TellMessageServersAboutUser( agentID, sessionID, RegionID, regionhandle, positionX,
270 positionY, positionZ, firstname, lastname);
272 } 271 }
273 } 272 }
274} \ No newline at end of file 273}
diff --git a/OpenSim/Grid/UserServer/MessageServersConnector.cs b/OpenSim/Grid/UserServer/MessageServersConnector.cs
index 70068e0..28f5c4c 100644
--- a/OpenSim/Grid/UserServer/MessageServersConnector.cs
+++ b/OpenSim/Grid/UserServer/MessageServersConnector.cs
@@ -41,12 +41,12 @@ namespace OpenSim.Grid.UserServer
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 public Dictionary<string, MessageServerInfo> MessageServers; 43 public Dictionary<string, MessageServerInfo> MessageServers;
44 44
45 public MessageServersConnector() 45 public MessageServersConnector()
46 { 46 {
47 MessageServers = new Dictionary<string, MessageServerInfo>(); 47 MessageServers = new Dictionary<string, MessageServerInfo>();
48 } 48 }
49 49
50 public void RegisterMessageServer(string URI, MessageServerInfo serverData) 50 public void RegisterMessageServer(string URI, MessageServerInfo serverData)
51 { 51 {
52 lock (MessageServers) 52 lock (MessageServers)
@@ -55,7 +55,7 @@ namespace OpenSim.Grid.UserServer
55 MessageServers.Add(URI, serverData); 55 MessageServers.Add(URI, serverData);
56 } 56 }
57 } 57 }
58 58
59 public void DeRegisterMessageServer(string URI) 59 public void DeRegisterMessageServer(string URI)
60 { 60 {
61 lock (MessageServers) 61 lock (MessageServers)
@@ -64,7 +64,7 @@ namespace OpenSim.Grid.UserServer
64 MessageServers.Remove(URI); 64 MessageServers.Remove(URI);
65 } 65 }
66 } 66 }
67 67
68 public void AddResponsibleRegion(string URI, ulong regionhandle) 68 public void AddResponsibleRegion(string URI, ulong regionhandle)
69 { 69 {
70 if (!MessageServers.ContainsKey(URI)) 70 if (!MessageServers.ContainsKey(URI))
@@ -76,9 +76,8 @@ namespace OpenSim.Grid.UserServer
76 MessageServerInfo msginfo = MessageServers["URI"]; 76 MessageServerInfo msginfo = MessageServers["URI"];
77 msginfo.responsibleForRegions.Add(regionhandle); 77 msginfo.responsibleForRegions.Add(regionhandle);
78 MessageServers["URI"] = msginfo; 78 MessageServers["URI"] = msginfo;
79 } 79 }
80 } 80 }
81
82 public void RemoveResponsibleRegion(string URI, ulong regionhandle) 81 public void RemoveResponsibleRegion(string URI, ulong regionhandle)
83 { 82 {
84 if (!MessageServers.ContainsKey(URI)) 83 if (!MessageServers.ContainsKey(URI))
@@ -93,20 +92,20 @@ namespace OpenSim.Grid.UserServer
93 msginfo.responsibleForRegions.Remove(regionhandle); 92 msginfo.responsibleForRegions.Remove(regionhandle);
94 MessageServers["URI"] = msginfo; 93 MessageServers["URI"] = msginfo;
95 } 94 }
96 } 95 }
97 }
98 96
97 }
99 public XmlRpcResponse XmlRPCRegisterMessageServer(XmlRpcRequest request) 98 public XmlRpcResponse XmlRPCRegisterMessageServer(XmlRpcRequest request)
100 { 99 {
101 XmlRpcResponse response = new XmlRpcResponse(); 100 XmlRpcResponse response = new XmlRpcResponse();
102 Hashtable requestData = (Hashtable) request.Params[0]; 101 Hashtable requestData = (Hashtable)request.Params[0];
103 Hashtable responseData = new Hashtable(); 102 Hashtable responseData = new Hashtable();
104 103
105 if (requestData.Contains("uri")) 104 if (requestData.Contains("uri"))
106 { 105 {
107 string URI = (string) requestData["uri"]; 106 string URI = (string)requestData["uri"];
108 string sendkey = (string) requestData["sendkey"]; 107 string sendkey=(string)requestData["sendkey"];
109 string recvkey = (string) requestData["recvkey"]; 108 string recvkey=(string)requestData["recvkey"];
110 MessageServerInfo m = new MessageServerInfo(); 109 MessageServerInfo m = new MessageServerInfo();
111 m.URI = URI; 110 m.URI = URI;
112 m.sendkey = sendkey; 111 m.sendkey = sendkey;
@@ -117,16 +116,15 @@ namespace OpenSim.Grid.UserServer
117 } 116 }
118 return response; 117 return response;
119 } 118 }
120
121 public XmlRpcResponse XmlRPCDeRegisterMessageServer(XmlRpcRequest request) 119 public XmlRpcResponse XmlRPCDeRegisterMessageServer(XmlRpcRequest request)
122 { 120 {
123 XmlRpcResponse response = new XmlRpcResponse(); 121 XmlRpcResponse response = new XmlRpcResponse();
124 Hashtable requestData = (Hashtable) request.Params[0]; 122 Hashtable requestData = (Hashtable)request.Params[0];
125 Hashtable responseData = new Hashtable(); 123 Hashtable responseData = new Hashtable();
126 124
127 if (requestData.Contains("uri")) 125 if (requestData.Contains("uri"))
128 { 126 {
129 string URI = (string) requestData["uri"]; 127 string URI = (string)requestData["uri"];
130 128
131 DeRegisterMessageServer(URI); 129 DeRegisterMessageServer(URI);
132 responseData["responsestring"] = "TRUE"; 130 responseData["responsestring"] = "TRUE";
@@ -134,24 +132,23 @@ namespace OpenSim.Grid.UserServer
134 } 132 }
135 return response; 133 return response;
136 } 134 }
137
138 public XmlRpcResponse XmlRPCUserMovedtoRegion(XmlRpcRequest request) 135 public XmlRpcResponse XmlRPCUserMovedtoRegion(XmlRpcRequest request)
139 { 136 {
140 XmlRpcResponse response = new XmlRpcResponse(); 137 XmlRpcResponse response = new XmlRpcResponse();
141 Hashtable requestData = (Hashtable) request.Params[0]; 138 Hashtable requestData = (Hashtable)request.Params[0];
142 Hashtable responseData = new Hashtable(); 139 Hashtable responseData = new Hashtable();
143 140
144 if (requestData.Contains("fromuri")) 141 if (requestData.Contains("fromuri"))
145 { 142 {
146 string sURI = (string) requestData["fromuri"]; 143 string sURI = (string)requestData["fromuri"];
147 string sagentID = (string) requestData["agentid"]; 144 string sagentID = (string)requestData["agentid"];
148 string ssessionID = (string) requestData["sessionid"]; 145 string ssessionID = (string)requestData["sessionid"];
149 string scurrentRegionID = (string) requestData["regionid"]; 146 string scurrentRegionID = (string)requestData["regionid"];
150 string sregionhandle = (string) requestData["regionhandle"]; 147 string sregionhandle = (string)requestData["regionhandle"];
151 string scurrentpos = (string) requestData["currentpos"]; 148 string scurrentpos = (string)requestData["currentpos"];
152 //LLVector3.TryParse((string)reader["currentPos"], out retval.currentPos); 149 //LLVector3.TryParse((string)reader["currentPos"], out retval.currentPos);
153 // TODO: Okay now raise event so the user server can pass this data to the Usermanager 150 // TODO: Okay now raise event so the user server can pass this data to the Usermanager
154 151
155 responseData["responsestring"] = "TRUE"; 152 responseData["responsestring"] = "TRUE";
156 response.Value = responseData; 153 response.Value = responseData;
157 } 154 }
@@ -159,7 +156,7 @@ namespace OpenSim.Grid.UserServer
159 } 156 }
160 157
161 public void TellMessageServersAboutUser(LLUUID agentID, LLUUID sessionID, LLUUID RegionID, 158 public void TellMessageServersAboutUser(LLUUID agentID, LLUUID sessionID, LLUUID RegionID,
162 ulong regionhandle, float positionX, float positionY, 159 ulong regionhandle, float positionX, float positionY,
163 float positionZ, string firstname, string lastname) 160 float positionZ, string firstname, string lastname)
164 { 161 {
165 // Loop over registered Message Servers ( AND THERE WILL BE MORE THEN ONE :D ) 162 // Loop over registered Message Servers ( AND THERE WILL BE MORE THEN ONE :D )
@@ -176,8 +173,8 @@ namespace OpenSim.Grid.UserServer
176 foreach (MessageServerInfo serv in MessageServers.Values) 173 foreach (MessageServerInfo serv in MessageServers.Values)
177 { 174 {
178 NotifyMessageServerAboutUser(serv, agentID, sessionID, RegionID, 175 NotifyMessageServerAboutUser(serv, agentID, sessionID, RegionID,
179 regionhandle, positionX, positionY, positionZ, 176 regionhandle, positionX, positionY, positionZ,
180 firstname, lastname); 177 firstname, lastname);
181 } 178 }
182 } 179 }
183 } 180 }
@@ -194,10 +191,10 @@ namespace OpenSim.Grid.UserServer
194// { 191// {
195// m_log.Debug("[MSGCONNECTOR]: No Message Servers registered, ignoring"); 192// m_log.Debug("[MSGCONNECTOR]: No Message Servers registered, ignoring");
196// } 193// }
197 foreach (MessageServerInfo serv in MessageServers.Values) 194 foreach (MessageServerInfo serv in MessageServers.Values)
198 { 195 {
199 NotifyMessageServerAboutUserLogoff(serv, agentID); 196 NotifyMessageServerAboutUserLogoff(serv,agentID);
200 } 197 }
201 } 198 }
202 } 199 }
203 200
@@ -221,10 +218,10 @@ namespace OpenSim.Grid.UserServer
221 m_log.Info("[LOGOUT]: Notified : " + serv.URI + " about user logout"); 218 m_log.Info("[LOGOUT]: Notified : " + serv.URI + " about user logout");
222 } 219 }
223 220
224 private void NotifyMessageServerAboutUser(MessageServerInfo serv, 221 private void NotifyMessageServerAboutUser(MessageServerInfo serv,
225 LLUUID agentID, LLUUID sessionID, LLUUID RegionID, 222 LLUUID agentID, LLUUID sessionID, LLUUID RegionID,
226 ulong regionhandle, float positionX, float positionY, float positionZ, 223 ulong regionhandle, float positionX, float positionY, float positionZ,
227 string firstname, string lastname) 224 string firstname, string lastname)
228 { 225 {
229 Hashtable reqparams = new Hashtable(); 226 Hashtable reqparams = new Hashtable();
230 reqparams["sendkey"] = serv.sendkey; 227 reqparams["sendkey"] = serv.sendkey;
@@ -253,6 +250,7 @@ namespace OpenSim.Grid.UserServer
253 { 250 {
254 m_log.Warn("[MSGCONNECTOR]: Unable to notify Message Server about login. Presence might be borked for this user"); 251 m_log.Warn("[MSGCONNECTOR]: Unable to notify Message Server about login. Presence might be borked for this user");
255 } 252 }
253
256 } 254 }
257 } 255 }
258} \ No newline at end of file 256}
diff --git a/OpenSim/Grid/UserServer/Properties/AssemblyInfo.cs b/OpenSim/Grid/UserServer/Properties/AssemblyInfo.cs
index eb60f11..680b357 100644
--- a/OpenSim/Grid/UserServer/Properties/AssemblyInfo.cs
+++ b/OpenSim/Grid/UserServer/Properties/AssemblyInfo.cs
@@ -60,4 +60,4 @@ using System.Runtime.InteropServices;
60// 60//
61 61
62[assembly : AssemblyVersion("1.0.0.0")] 62[assembly : AssemblyVersion("1.0.0.0")]
63[assembly : AssemblyFileVersion("1.0.0.0")] \ No newline at end of file 63[assembly : AssemblyFileVersion("1.0.0.0")]
diff --git a/OpenSim/Grid/UserServer/UserLoginService.cs b/OpenSim/Grid/UserServer/UserLoginService.cs
index b19b74d..b123b8c 100644
--- a/OpenSim/Grid/UserServer/UserLoginService.cs
+++ b/OpenSim/Grid/UserServer/UserLoginService.cs
@@ -41,26 +41,26 @@ using OpenSim.Framework.Servers;
41namespace OpenSim.Grid.UserServer 41namespace OpenSim.Grid.UserServer
42{ 42{
43 public delegate void UserLoggedInAtLocation(LLUUID agentID, LLUUID sessionID, LLUUID RegionID, 43 public delegate void UserLoggedInAtLocation(LLUUID agentID, LLUUID sessionID, LLUUID RegionID,
44 ulong regionhandle, float positionX, float positionY, float positionZ, string firstname, string lastname); 44 ulong regionhandle, float positionX, float positionY, float positionZ, string firstname, string lastname);
45 45
46 public class UserLoginService : LoginService 46 public class UserLoginService : LoginService
47 { 47 {
48 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 48 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
49 49
50 private UserLoggedInAtLocation handlerUserLoggedInAtLocation; 50 public event UserLoggedInAtLocation OnUserLoggedInAtLocation;
51 51
52 private UserLoggedInAtLocation handlerUserLoggedInAtLocation = null;
53
52 public UserConfig m_config; 54 public UserConfig m_config;
53 55
54 public UserLoginService( 56 public UserLoginService(
55 UserManagerBase userManager, LibraryRootFolder libraryRootFolder, 57 UserManagerBase userManager, LibraryRootFolder libraryRootFolder,
56 UserConfig config, string welcomeMess) 58 UserConfig config, string welcomeMess)
57 : base(userManager, libraryRootFolder, welcomeMess) 59 : base(userManager, libraryRootFolder, welcomeMess)
58 { 60 {
59 m_config = config; 61 m_config = config;
60 } 62 }
61 63
62 public event UserLoggedInAtLocation OnUserLoggedInAtLocation;
63
64 /// <summary> 64 /// <summary>
65 /// Customises the login response and fills in missing values. 65 /// Customises the login response and fills in missing values.
66 /// </summary> 66 /// </summary>
@@ -95,8 +95,7 @@ namespace OpenSim.Grid.UserServer
95 else 95 else
96 { 96 {
97 string[] startLocationRequestParsed = Util.ParseStartLocationRequest(startLocationRequest); 97 string[] startLocationRequestParsed = Util.ParseStartLocationRequest(startLocationRequest);
98 m_log.Info("[DEBUGLOGINPARSE]: 1:" + startLocationRequestParsed[0] + ", 2:" + startLocationRequestParsed[1] + ", 3:" + 98 m_log.Info("[DEBUGLOGINPARSE]: 1:" + startLocationRequestParsed[0] + ", 2:" + startLocationRequestParsed[1] + ", 3:" + startLocationRequestParsed[2] + ", 4:" + startLocationRequestParsed[3]);
99 startLocationRequestParsed[2] + ", 4:" + startLocationRequestParsed[3]);
100 if (startLocationRequestParsed[0] == "last") 99 if (startLocationRequestParsed[0] == "last")
101 { 100 {
102 // TODO: Parse out startlocationrequest string in the format; 'uri:RegionName&X&Y&Z' 101 // TODO: Parse out startlocationrequest string in the format; 'uri:RegionName&X&Y&Z'
@@ -109,9 +108,9 @@ namespace OpenSim.Grid.UserServer
109 { 108 {
110 m_log.Info("[LOGIN]: Looking up Sim: " + startLocationRequestParsed[0]); 109 m_log.Info("[LOGIN]: Looking up Sim: " + startLocationRequestParsed[0]);
111 SimInfo = 110 SimInfo =
112 RegionProfileData.RequestSimProfileData( 111 RegionProfileData.RequestSimProfileData(
113 startLocationRequestParsed[0], m_config.GridServerURL, 112 startLocationRequestParsed[0], m_config.GridServerURL,
114 m_config.GridSendKey, m_config.GridRecvKey); 113 m_config.GridSendKey, m_config.GridRecvKey);
115 114
116 if (SimInfo == null) 115 if (SimInfo == null)
117 { 116 {
@@ -120,9 +119,7 @@ namespace OpenSim.Grid.UserServer
120 RegionProfileData.RequestSimProfileData( 119 RegionProfileData.RequestSimProfileData(
121 theUser.HomeRegion, m_config.GridServerURL, 120 theUser.HomeRegion, m_config.GridServerURL,
122 m_config.GridSendKey, m_config.GridRecvKey); 121 m_config.GridSendKey, m_config.GridRecvKey);
123 } 122 } else {
124 else
125 {
126 start_x = Convert.ToInt32(startLocationRequestParsed[1]); 123 start_x = Convert.ToInt32(startLocationRequestParsed[1]);
127 start_y = Convert.ToInt32(startLocationRequestParsed[2]); 124 start_y = Convert.ToInt32(startLocationRequestParsed[2]);
128 start_z = Convert.ToInt32(startLocationRequestParsed[3]); 125 start_z = Convert.ToInt32(startLocationRequestParsed[3]);
@@ -133,30 +130,30 @@ namespace OpenSim.Grid.UserServer
133 // Customise the response 130 // Customise the response
134 //CFK: This is redundant and the next message should always appear. 131 //CFK: This is redundant and the next message should always appear.
135 //CFK: m_log.Info("[LOGIN]: Home Location"); 132 //CFK: m_log.Info("[LOGIN]: Home Location");
136 response.Home = "{'region_handle':[r" + (SimInfo.regionLocX * Constants.RegionSize) + ",r" + 133 response.Home = "{'region_handle':[r" + (SimInfo.regionLocX * Constants.RegionSize).ToString() + ",r" +
137 (SimInfo.regionLocY * Constants.RegionSize) + "], " + 134 (SimInfo.regionLocY * Constants.RegionSize).ToString() + "], " +
138 "'position':[r" + theUser.HomeLocation.X + ",r" + 135 "'position':[r" + theUser.HomeLocation.X.ToString() + ",r" +
139 theUser.HomeLocation.Y + ",r" + theUser.HomeLocation.Z + "], " + 136 theUser.HomeLocation.Y.ToString() + ",r" + theUser.HomeLocation.Z.ToString() + "], " +
140 "'look_at':[r" + theUser.HomeLocation.X + ",r" + 137 "'look_at':[r" + theUser.HomeLocation.X.ToString() + ",r" +
141 theUser.HomeLocation.Y + ",r" + theUser.HomeLocation.Z + "]}"; 138 theUser.HomeLocation.Y.ToString() + ",r" + theUser.HomeLocation.Z.ToString() + "]}";
142 139
143 // Destination 140 // Destination
144 //CFK: The "Notifying" message always seems to appear, so subsume the data from this message into 141 //CFK: The "Notifying" message always seems to appear, so subsume the data from this message into
145 //CFK: the next one for X & Y and comment this one. 142 //CFK: the next one for X & Y and comment this one.
146 //CFK: m_log.Info("[LOGIN]: CUSTOMISERESPONSE: Region X: " + SimInfo.regionLocX + 143 //CFK: m_log.Info("[LOGIN]: CUSTOMISERESPONSE: Region X: " + SimInfo.regionLocX +
147 //CFK: "; Region Y: " + SimInfo.regionLocY); 144 //CFK: "; Region Y: " + SimInfo.regionLocY);
148 response.SimAddress = Util.GetHostFromDNS(SimInfo.serverURI.Split(new[] {'/', ':'})[3]).ToString(); 145 response.SimAddress = Util.GetHostFromDNS(SimInfo.serverURI.Split(new char[] { '/', ':' })[3]).ToString();
149 response.SimPort = uint.Parse(SimInfo.serverURI.Split(new[] {'/', ':'})[4]); 146 response.SimPort = uint.Parse(SimInfo.serverURI.Split(new char[] { '/', ':' })[4]);
150 response.RegionX = SimInfo.regionLocX; 147 response.RegionX = SimInfo.regionLocX;
151 response.RegionY = SimInfo.regionLocY; 148 response.RegionY = SimInfo.regionLocY;
152 149
153 //Not sure if the + "/CAPS/" should in fact be +"CAPS/" depending if there is already a / as part of httpServerURI 150 //Not sure if the + "/CAPS/" should in fact be +"CAPS/" depending if there is already a / as part of httpServerURI
154 string capsPath = Util.GetRandomCapsPath(); 151 string capsPath = Util.GetRandomCapsPath();
155 response.SeedCapability = SimInfo.httpServerURI + "CAPS/" + capsPath + "0000/"; 152 response.SeedCapability = SimInfo.httpServerURI + "CAPS/" + capsPath + "0000/";
156 153
157 m_log.DebugFormat( 154 m_log.DebugFormat(
158 "[LOGIN]: Sending new CAPS seed url {0} to client {1}", 155 "[LOGIN]: Sending new CAPS seed url {0} to client {1}",
159 response.SeedCapability, response.AgentID); 156 response.SeedCapability, response.AgentID);
160 157
161 // Notify the target of an incoming user 158 // Notify the target of an incoming user
162 //CFK: The "Notifying" message always seems to appear, so subsume the data from this message into 159 //CFK: The "Notifying" message always seems to appear, so subsume the data from this message into
@@ -166,8 +163,7 @@ namespace OpenSim.Grid.UserServer
166 163
167 theUser.CurrentAgent.Region = SimInfo.UUID; 164 theUser.CurrentAgent.Region = SimInfo.UUID;
168 theUser.CurrentAgent.Handle = SimInfo.regionHandle; 165 theUser.CurrentAgent.Handle = SimInfo.regionHandle;
169 if (start_x >= 0 && start_y >= 0 && start_z >= 0) 166 if (start_x >= 0 && start_y >= 0 && start_z >= 0) {
170 {
171 LLVector3 tmp_v = new LLVector3(start_x, start_y, start_z); 167 LLVector3 tmp_v = new LLVector3(start_x, start_y, start_z);
172 theUser.CurrentAgent.Position = tmp_v; 168 theUser.CurrentAgent.Position = tmp_v;
173 } 169 }
@@ -190,43 +186,42 @@ namespace OpenSim.Grid.UserServer
190 // Update agent with target sim 186 // Update agent with target sim
191 187
192 m_log.InfoFormat( 188 m_log.InfoFormat(
193 "[LOGIN]: Telling region {0} @ {1},{2} ({3}) to expect user connection", 189 "[LOGIN]: Telling region {0} @ {1},{2} ({3}) to expect user connection",
194 SimInfo.regionName, response.RegionX, response.RegionY, SimInfo.httpServerURI); 190 SimInfo.regionName, response.RegionX, response.RegionY, SimInfo.httpServerURI);
195 191
196 XmlRpcRequest GridReq = new XmlRpcRequest("expect_user", SendParams); 192 XmlRpcRequest GridReq = new XmlRpcRequest("expect_user", SendParams);
197 XmlRpcResponse GridResp = GridReq.Send(SimInfo.httpServerURI, 6000); 193 XmlRpcResponse GridResp = GridReq.Send(SimInfo.httpServerURI, 6000);
198 194
199 if (GridResp.IsFault) 195 if (GridResp.IsFault)
200 { 196 {
201 m_log.ErrorFormat( 197 m_log.ErrorFormat(
202 "[LOGIN]: XMLRPC request for {0} failed, fault code: {1}, reason: {2}", 198 "[LOGIN]: XMLRPC request for {0} failed, fault code: {1}, reason: {2}",
203 SimInfo.httpServerURI, GridResp.FaultCode, GridResp.FaultString); 199 SimInfo.httpServerURI, GridResp.FaultCode, GridResp.FaultString);
204 } 200 }
205 handlerUserLoggedInAtLocation = OnUserLoggedInAtLocation; 201 handlerUserLoggedInAtLocation = OnUserLoggedInAtLocation;
206 if (handlerUserLoggedInAtLocation != null) 202 if (handlerUserLoggedInAtLocation != null)
207 { 203 {
208 //m_log.Info("[LOGIN]: Letting other objects know about login"); 204 //m_log.Info("[LOGIN]: Letting other objects know about login");
209 handlerUserLoggedInAtLocation(theUser.ID, theUser.CurrentAgent.SessionID, theUser.CurrentAgent.Region, 205 handlerUserLoggedInAtLocation(theUser.ID, theUser.CurrentAgent.SessionID, theUser.CurrentAgent.Region,
210 theUser.CurrentAgent.Handle, theUser.CurrentAgent.Position.X, theUser.CurrentAgent.Position.Y, 206 theUser.CurrentAgent.Handle, theUser.CurrentAgent.Position.X,theUser.CurrentAgent.Position.Y,theUser.CurrentAgent.Position.Z,
211 theUser.CurrentAgent.Position.Z, 207 theUser.FirstName,theUser.SurName);
212 theUser.FirstName, theUser.SurName);
213 } 208 }
214 } 209 }
215 catch (Exception) 210 catch (Exception)
216 //catch (System.AccessViolationException) 211 //catch (System.AccessViolationException)
217 { 212 {
218 tryDefault = true; 213 tryDefault = true;
219 } 214 }
220 215
221 if (tryDefault) 216 if (tryDefault)
222 { 217 {
223 // Send him to default region instead 218 // Send him to default region instead
224 // Load information from the gridserver 219 // Load information from the gridserver
225 220
226 ulong defaultHandle = (((ulong) m_config.DefaultX * Constants.RegionSize) << 32) | ((ulong) m_config.DefaultY * Constants.RegionSize); 221 ulong defaultHandle = (((ulong)m_config.DefaultX * Constants.RegionSize) << 32) | ((ulong)m_config.DefaultY * Constants.RegionSize);
227 222
228 m_log.Warn( 223 m_log.Warn(
229 "[LOGIN]: Home region not available: sending to default " + defaultHandle); 224 "[LOGIN]: Home region not available: sending to default " + defaultHandle.ToString());
230 225
231 try 226 try
232 { 227 {
@@ -236,19 +231,19 @@ namespace OpenSim.Grid.UserServer
236 231
237 // Customise the response 232 // Customise the response
238 m_log.Info("[LOGIN]: Home Location"); 233 m_log.Info("[LOGIN]: Home Location");
239 response.Home = "{'region_handle':[r" + (SimInfo.regionLocX * Constants.RegionSize) + ",r" + 234 response.Home = "{'region_handle':[r" + (SimInfo.regionLocX * Constants.RegionSize).ToString() + ",r" +
240 (SimInfo.regionLocY * Constants.RegionSize) + "], " + 235 (SimInfo.regionLocY * Constants.RegionSize).ToString() + "], " +
241 "'position':[r" + theUser.HomeLocation.X + ",r" + 236 "'position':[r" + theUser.HomeLocation.X.ToString() + ",r" +
242 theUser.HomeLocation.Y + ",r" + theUser.HomeLocation.Z + "], " + 237 theUser.HomeLocation.Y.ToString() + ",r" + theUser.HomeLocation.Z.ToString() + "], " +
243 "'look_at':[r" + theUser.HomeLocation.X + ",r" + 238 "'look_at':[r" + theUser.HomeLocation.X.ToString() + ",r" +
244 theUser.HomeLocation.Y + ",r" + theUser.HomeLocation.Z + "]}"; 239 theUser.HomeLocation.Y.ToString() + ",r" + theUser.HomeLocation.Z.ToString() + "]}";
245 240
246 // Destination 241 // Destination
247 m_log.Info("[LOGIN]: " + 242 m_log.Info("[LOGIN]: " +
248 "CUSTOMISERESPONSE: Region X: " + SimInfo.regionLocX + "; Region Y: " + 243 "CUSTOMISERESPONSE: Region X: " + SimInfo.regionLocX + "; Region Y: " +
249 SimInfo.regionLocY); 244 SimInfo.regionLocY);
250 response.SimAddress = Util.GetHostFromDNS(SimInfo.serverURI.Split(new[] {'/', ':'})[3]).ToString(); 245 response.SimAddress = Util.GetHostFromDNS(SimInfo.serverURI.Split(new char[] { '/', ':' })[3]).ToString();
251 response.SimPort = uint.Parse(SimInfo.serverURI.Split(new[] {'/', ':'})[4]); 246 response.SimPort = uint.Parse(SimInfo.serverURI.Split(new char[] { '/', ':' })[4]);
252 response.RegionX = SimInfo.regionLocX; 247 response.RegionX = SimInfo.regionLocX;
253 response.RegionY = SimInfo.regionLocY; 248 response.RegionY = SimInfo.regionLocY;
254 249
@@ -288,16 +283,15 @@ namespace OpenSim.Grid.UserServer
288 { 283 {
289 m_log.Info("[LOGIN]: Letting other objects know about login"); 284 m_log.Info("[LOGIN]: Letting other objects know about login");
290 handlerUserLoggedInAtLocation(theUser.ID, theUser.CurrentAgent.SessionID, theUser.CurrentAgent.Region, 285 handlerUserLoggedInAtLocation(theUser.ID, theUser.CurrentAgent.SessionID, theUser.CurrentAgent.Region,
291 theUser.CurrentAgent.Handle, theUser.CurrentAgent.Position.X, theUser.CurrentAgent.Position.Y, 286 theUser.CurrentAgent.Handle, theUser.CurrentAgent.Position.X, theUser.CurrentAgent.Position.Y, theUser.CurrentAgent.Position.Z,
292 theUser.CurrentAgent.Position.Z, 287 theUser.FirstName, theUser.SurName);
293 theUser.FirstName, theUser.SurName);
294 } 288 }
295 } 289 }
296 290
297 catch (Exception e) 291 catch (Exception e)
298 { 292 {
299 m_log.Warn("[LOGIN]: Default region also not available"); 293 m_log.Warn("[LOGIN]: Default region also not available");
300 m_log.Warn("[LOGIN]: " + e); 294 m_log.Warn("[LOGIN]: " + e.ToString());
301 } 295 }
302 } 296 }
303 } 297 }
@@ -306,8 +300,8 @@ namespace OpenSim.Grid.UserServer
306 protected override InventoryData GetInventorySkeleton(LLUUID userID) 300 protected override InventoryData GetInventorySkeleton(LLUUID userID)
307 { 301 {
308 m_log.DebugFormat( 302 m_log.DebugFormat(
309 "[LOGIN]: Contacting inventory service at {0} for inventory skeleton of user {1}", 303 "[LOGIN]: Contacting inventory service at {0} for inventory skeleton of user {1}",
310 m_config.InventoryUrl, userID); 304 m_config.InventoryUrl, userID);
311 305
312 List<InventoryFolderBase> folders 306 List<InventoryFolderBase> folders
313 = SynchronousRestObjectPoster.BeginPostObject<Guid, List<InventoryFolderBase>>( 307 = SynchronousRestObjectPoster.BeginPostObject<Guid, List<InventoryFolderBase>>(
@@ -322,23 +316,23 @@ namespace OpenSim.Grid.UserServer
322 // tools are creating the user profile directly in the database without creating the inventory. At 316 // tools are creating the user profile directly in the database without creating the inventory. At
323 // this time we'll accomodate them by lazily creating the user inventory now if it doesn't already 317 // this time we'll accomodate them by lazily creating the user inventory now if it doesn't already
324 // exist. 318 // exist.
325 bool created = 319 bool created =
326 SynchronousRestObjectPoster.BeginPostObject<Guid, bool>( 320 SynchronousRestObjectPoster.BeginPostObject<Guid, bool>(
327 "POST", m_config.InventoryUrl + "CreateInventory/", userID.UUID); 321 "POST", m_config.InventoryUrl + "CreateInventory/", userID.UUID);
328 322
329 if (!created) 323 if (!created)
330 { 324 {
331 throw new Exception( 325 throw new Exception(
332 String.Format( 326 String.Format(
333 "The inventory creation request for user {0} did not succeed." 327 "The inventory creation request for user {0} did not succeed."
334 + " Please contact your inventory service provider for more information.", 328 + " Please contact your inventory service provider for more information.",
335 userID)); 329 userID));
336 } 330 }
337 else 331 else
338 { 332 {
339 m_log.InfoFormat("[LOGIN]: A new inventory skeleton was successfully created for user {0}", userID); 333 m_log.InfoFormat("[LOGIN]: A new inventory skeleton was successfully created for user {0}", userID);
340 } 334 }
341 335
342 folders = SynchronousRestObjectPoster.BeginPostObject<Guid, List<InventoryFolderBase>>( 336 folders = SynchronousRestObjectPoster.BeginPostObject<Guid, List<InventoryFolderBase>>(
343 "POST", m_config.InventoryUrl + "RootFolders/", userID.UUID); 337 "POST", m_config.InventoryUrl + "RootFolders/", userID.UUID);
344 } 338 }
@@ -348,11 +342,11 @@ namespace OpenSim.Grid.UserServer
348 LLUUID rootID = LLUUID.Zero; 342 LLUUID rootID = LLUUID.Zero;
349 ArrayList AgentInventoryArray = new ArrayList(); 343 ArrayList AgentInventoryArray = new ArrayList();
350 Hashtable TempHash; 344 Hashtable TempHash;
351 345
352 foreach (InventoryFolderBase InvFolder in folders) 346 foreach (InventoryFolderBase InvFolder in folders)
353 { 347 {
354// m_log.DebugFormat("[LOGIN]: Received agent inventory folder {0}", InvFolder.name); 348// m_log.DebugFormat("[LOGIN]: Received agent inventory folder {0}", InvFolder.name);
355 349
356 if (InvFolder.ParentID == LLUUID.Zero) 350 if (InvFolder.ParentID == LLUUID.Zero)
357 { 351 {
358 rootID = InvFolder.ID; 352 rootID = InvFolder.ID;
@@ -365,16 +359,16 @@ namespace OpenSim.Grid.UserServer
365 TempHash["folder_id"] = InvFolder.ID.ToString(); 359 TempHash["folder_id"] = InvFolder.ID.ToString();
366 AgentInventoryArray.Add(TempHash); 360 AgentInventoryArray.Add(TempHash);
367 } 361 }
368 362
369 return new InventoryData(AgentInventoryArray, rootID); 363 return new InventoryData(AgentInventoryArray, rootID);
370 } 364 }
371 else 365 else
372 { 366 {
373 throw new Exception( 367 throw new Exception(
374 String.Format( 368 String.Format(
375 "A root inventory folder for user {0} could not be retrieved from the inventory service", 369 "A root inventory folder for user {0} could not be retrieved from the inventory service",
376 userID)); 370 userID));
377 } 371 }
378 } 372 }
379 } 373 }
380} \ No newline at end of file 374}
diff --git a/OpenSim/Grid/UserServer/UserManager.cs b/OpenSim/Grid/UserServer/UserManager.cs
index 0122ad0..5d0e1d6 100644
--- a/OpenSim/Grid/UserServer/UserManager.cs
+++ b/OpenSim/Grid/UserServer/UserManager.cs
@@ -41,11 +41,11 @@ namespace OpenSim.Grid.UserServer
41 public delegate void logOffUser(LLUUID AgentID); 41 public delegate void logOffUser(LLUUID AgentID);
42 42
43 public class UserManager : UserManagerBase 43 public class UserManager : UserManagerBase
44 { 44 {
45 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 45 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
46 46
47 private logOffUser handlerLogOffUser;
48 public event logOffUser OnLogOffUser; 47 public event logOffUser OnLogOffUser;
48 private logOffUser handlerLogOffUser = null;
49 49
50 /// <summary> 50 /// <summary>
51 /// Deletes an active agent session 51 /// Deletes an active agent session
@@ -81,17 +81,17 @@ namespace OpenSim.Grid.UserServer
81 XmlRpcResponse response = new XmlRpcResponse(); 81 XmlRpcResponse response = new XmlRpcResponse();
82 Hashtable responseData = new Hashtable(); 82 Hashtable responseData = new Hashtable();
83 // Query Result Information 83 // Query Result Information
84 responseData["queryid"] = queryID.ToString(); 84 responseData["queryid"] = (string) queryID.ToString();
85 responseData["avcount"] = returnUsers.Count.ToString(); 85 responseData["avcount"] = (string) returnUsers.Count.ToString();
86 86
87 for (int i = 0; i < returnUsers.Count; i++) 87 for (int i = 0; i < returnUsers.Count; i++)
88 { 88 {
89 responseData["avatarid" + i] = returnUsers[i].AvatarID.ToString(); 89 responseData["avatarid" + i.ToString()] = returnUsers[i].AvatarID.ToString();
90 responseData["firstname" + i] = returnUsers[i].firstName; 90 responseData["firstname" + i.ToString()] = returnUsers[i].firstName;
91 responseData["lastname" + i] = returnUsers[i].lastName; 91 responseData["lastname" + i.ToString()] = returnUsers[i].lastName;
92 } 92 }
93 response.Value = responseData; 93 response.Value = responseData;
94 94
95 return response; 95 return response;
96 } 96 }
97 97
@@ -101,14 +101,14 @@ namespace OpenSim.Grid.UserServer
101 Hashtable responseData = new Hashtable(); 101 Hashtable responseData = new Hashtable();
102 // Query Result Information 102 // Query Result Information
103 103
104 responseData["avcount"] = returnUsers.Count.ToString(); 104 responseData["avcount"] = (string)returnUsers.Count.ToString();
105 105
106 for (int i = 0; i < returnUsers.Count; i++) 106 for (int i = 0; i < returnUsers.Count; i++)
107 { 107 {
108 responseData["ownerID" + i] = returnUsers[i].FriendListOwner.UUID.ToString(); 108 responseData["ownerID" + i.ToString()] = returnUsers[i].FriendListOwner.UUID.ToString();
109 responseData["friendID" + i] = returnUsers[i].Friend.UUID.ToString(); 109 responseData["friendID" + i.ToString()] = returnUsers[i].Friend.UUID.ToString();
110 responseData["ownerPerms" + i] = returnUsers[i].FriendListOwnerPerms.ToString(); 110 responseData["ownerPerms" + i.ToString()] = returnUsers[i].FriendListOwnerPerms.ToString();
111 responseData["friendPerms" + i] = returnUsers[i].FriendPerms.ToString(); 111 responseData["friendPerms" + i.ToString()] = returnUsers[i].FriendPerms.ToString();
112 } 112 }
113 response.Value = responseData; 113 response.Value = responseData;
114 114
@@ -156,21 +156,6 @@ namespace OpenSim.Grid.UserServer
156 return response; 156 return response;
157 } 157 }
158 158
159 public override UserProfileData SetupMasterUser(string firstName, string lastName)
160 {
161 throw new Exception("The method or operation is not implemented.");
162 }
163
164 public override UserProfileData SetupMasterUser(string firstName, string lastName, string password)
165 {
166 throw new Exception("The method or operation is not implemented.");
167 }
168
169 public override UserProfileData SetupMasterUser(LLUUID uuid)
170 {
171 throw new Exception("The method or operation is not implemented.");
172 }
173
174 #region XMLRPC User Methods 159 #region XMLRPC User Methods
175 160
176 public XmlRpcResponse XmlRPCGetAvatarPickerAvatar(XmlRpcRequest request) 161 public XmlRpcResponse XmlRPCGetAvatarPickerAvatar(XmlRpcRequest request)
@@ -193,16 +178,15 @@ namespace OpenSim.Grid.UserServer
193 public XmlRpcResponse XmlRpcResponseXmlRPCAddUserFriend(XmlRpcRequest request) 178 public XmlRpcResponse XmlRpcResponseXmlRPCAddUserFriend(XmlRpcRequest request)
194 { 179 {
195 XmlRpcResponse response = new XmlRpcResponse(); 180 XmlRpcResponse response = new XmlRpcResponse();
196 Hashtable requestData = (Hashtable) request.Params[0]; 181 Hashtable requestData = (Hashtable)request.Params[0];
197 Hashtable responseData = new Hashtable(); 182 Hashtable responseData = new Hashtable();
198 string returnString = "FALSE"; 183 string returnString = "FALSE";
199 // Query Result Information 184 // Query Result Information
200 185
201 if (requestData.Contains("ownerID") && requestData.Contains("friendID") && requestData.Contains("friendPerms")) 186 if (requestData.Contains("ownerID") && requestData.Contains("friendID") && requestData.Contains("friendPerms"))
202 { 187 {
203 // UserManagerBase.AddNewuserFriend 188 // UserManagerBase.AddNewuserFriend
204 AddNewUserFriend(new LLUUID((string) requestData["ownerID"]), new LLUUID((string) requestData["friendID"]), 189 AddNewUserFriend(new LLUUID((string)requestData["ownerID"]), new LLUUID((string)requestData["friendID"]), (uint)Convert.ToInt32((string)requestData["friendPerms"]));
205 (uint) Convert.ToInt32((string) requestData["friendPerms"]));
206 returnString = "TRUE"; 190 returnString = "TRUE";
207 } 191 }
208 responseData["returnString"] = returnString; 192 responseData["returnString"] = returnString;
@@ -213,15 +197,15 @@ namespace OpenSim.Grid.UserServer
213 public XmlRpcResponse XmlRpcResponseXmlRPCRemoveUserFriend(XmlRpcRequest request) 197 public XmlRpcResponse XmlRpcResponseXmlRPCRemoveUserFriend(XmlRpcRequest request)
214 { 198 {
215 XmlRpcResponse response = new XmlRpcResponse(); 199 XmlRpcResponse response = new XmlRpcResponse();
216 Hashtable requestData = (Hashtable) request.Params[0]; 200 Hashtable requestData = (Hashtable)request.Params[0];
217 Hashtable responseData = new Hashtable(); 201 Hashtable responseData = new Hashtable();
218 string returnString = "FALSE"; 202 string returnString = "FALSE";
219 // Query Result Information 203 // Query Result Information
220 204
221 if (requestData.Contains("ownerID") && requestData.Contains("friendID")) 205 if (requestData.Contains("ownerID") && requestData.Contains("friendID"))
222 { 206 {
223 // UserManagerBase.AddNewuserFriend 207 // UserManagerBase.AddNewuserFriend
224 RemoveUserFriend(new LLUUID((string) requestData["ownerID"]), new LLUUID((string) requestData["friendID"])); 208 RemoveUserFriend(new LLUUID((string)requestData["ownerID"]), new LLUUID((string)requestData["friendID"]));
225 returnString = "TRUE"; 209 returnString = "TRUE";
226 } 210 }
227 responseData["returnString"] = returnString; 211 responseData["returnString"] = returnString;
@@ -232,14 +216,13 @@ namespace OpenSim.Grid.UserServer
232 public XmlRpcResponse XmlRpcResponseXmlRPCUpdateUserFriendPerms(XmlRpcRequest request) 216 public XmlRpcResponse XmlRpcResponseXmlRPCUpdateUserFriendPerms(XmlRpcRequest request)
233 { 217 {
234 XmlRpcResponse response = new XmlRpcResponse(); 218 XmlRpcResponse response = new XmlRpcResponse();
235 Hashtable requestData = (Hashtable) request.Params[0]; 219 Hashtable requestData = (Hashtable)request.Params[0];
236 Hashtable responseData = new Hashtable(); 220 Hashtable responseData = new Hashtable();
237 string returnString = "FALSE"; 221 string returnString = "FALSE";
238 222
239 if (requestData.Contains("ownerID") && requestData.Contains("friendID") && requestData.Contains("friendPerms")) 223 if (requestData.Contains("ownerID") && requestData.Contains("friendID") && requestData.Contains("friendPerms"))
240 { 224 {
241 UpdateUserFriendPerms(new LLUUID((string) requestData["ownerID"]), new LLUUID((string) requestData["friendID"]), 225 UpdateUserFriendPerms(new LLUUID((string)requestData["ownerID"]), new LLUUID((string)requestData["friendID"]), (uint)Convert.ToInt32((string)requestData["friendPerms"]));
242 (uint) Convert.ToInt32((string) requestData["friendPerms"]));
243 // UserManagerBase. 226 // UserManagerBase.
244 returnString = "TRUE"; 227 returnString = "TRUE";
245 } 228 }
@@ -251,16 +234,16 @@ namespace OpenSim.Grid.UserServer
251 public XmlRpcResponse XmlRpcResponseXmlRPCGetUserFriendList(XmlRpcRequest request) 234 public XmlRpcResponse XmlRpcResponseXmlRPCGetUserFriendList(XmlRpcRequest request)
252 { 235 {
253 XmlRpcResponse response = new XmlRpcResponse(); 236 XmlRpcResponse response = new XmlRpcResponse();
254 Hashtable requestData = (Hashtable) request.Params[0]; 237 Hashtable requestData = (Hashtable)request.Params[0];
255 Hashtable responseData = new Hashtable(); 238 Hashtable responseData = new Hashtable();
256 239
257 List<FriendListItem> returndata = new List<FriendListItem>(); 240 List<FriendListItem> returndata = new List<FriendListItem>();
258 241
259 if (requestData.Contains("ownerID")) 242 if (requestData.Contains("ownerID"))
260 { 243 {
261 returndata = GetUserFriendList(new LLUUID((string) requestData["ownerID"])); 244 returndata = this.GetUserFriendList(new LLUUID((string)requestData["ownerID"]));
262 } 245 }
263 246
264 return FriendListItemListtoXmlRPCResponse(returndata); 247 return FriendListItemListtoXmlRPCResponse(returndata);
265 } 248 }
266 249
@@ -338,7 +321,7 @@ namespace OpenSim.Grid.UserServer
338 { 321 {
339 m_log.Debug("[UserManager]: Got request to update user profile"); 322 m_log.Debug("[UserManager]: Got request to update user profile");
340 XmlRpcResponse response = new XmlRpcResponse(); 323 XmlRpcResponse response = new XmlRpcResponse();
341 Hashtable requestData = (Hashtable) request.Params[0]; 324 Hashtable requestData = (Hashtable)request.Params[0];
342 Hashtable responseData = new Hashtable(); 325 Hashtable responseData = new Hashtable();
343 326
344 UserProfileData userProfile; 327 UserProfileData userProfile;
@@ -347,7 +330,7 @@ namespace OpenSim.Grid.UserServer
347 return CreateUnknownUserErrorResponse(); 330 return CreateUnknownUserErrorResponse();
348 } 331 }
349 332
350 LLUUID UserUUID = new LLUUID((string) requestData["avatar_uuid"]); 333 LLUUID UserUUID = new LLUUID((string)requestData["avatar_uuid"]);
351 userProfile = GetUserProfile(UserUUID); 334 userProfile = GetUserProfile(UserUUID);
352 if (null == userProfile) 335 if (null == userProfile)
353 { 336 {
@@ -359,33 +342,33 @@ namespace OpenSim.Grid.UserServer
359 } 342 }
360 if (requestData.Contains("FLImageID")) 343 if (requestData.Contains("FLImageID"))
361 { 344 {
362 userProfile.FirstLifeImage = new LLUUID((string) requestData["FLImageID"]); 345 userProfile.FirstLifeImage = new LLUUID((string)requestData["FLImageID"]);
363 } 346 }
364 if (requestData.Contains("ImageID")) 347 if (requestData.Contains("ImageID"))
365 { 348 {
366 userProfile.Image = new LLUUID((string) requestData["ImageID"]); 349 userProfile.Image = new LLUUID((string)requestData["ImageID"]);
367 } 350 }
368 // dont' know how yet 351 // dont' know how yet
369 if (requestData.Contains("MaturePublish")) 352 if (requestData.Contains("MaturePublish"))
370 { 353 {
371 } 354 }
372 if (requestData.Contains("AboutText")) 355 if (requestData.Contains("AboutText"))
373 { 356 {
374 userProfile.AboutText = (string) requestData["AboutText"]; 357 userProfile.AboutText = (string)requestData["AboutText"];
375 } 358 }
376 if (requestData.Contains("FLAboutText")) 359 if (requestData.Contains("FLAboutText"))
377 { 360 {
378 userProfile.FirstLifeAboutText = (string) requestData["FLAboutText"]; 361 userProfile.FirstLifeAboutText = (string)requestData["FLAboutText"];
379 } 362 }
380 // not in DB yet. 363 // not in DB yet.
381 if (requestData.Contains("ProfileURL")) 364 if (requestData.Contains("ProfileURL"))
382 { 365 {
383 } 366 }
384 if (requestData.Contains("home_region")) 367 if (requestData.Contains("home_region"))
385 { 368 {
386 try 369 try
387 { 370 {
388 userProfile.HomeRegion = Convert.ToUInt64((string) requestData["home_region"]); 371 userProfile.HomeRegion = Convert.ToUInt64((string)requestData["home_region"]);
389 } 372 }
390 catch (ArgumentException) 373 catch (ArgumentException)
391 { 374 {
@@ -399,23 +382,25 @@ namespace OpenSim.Grid.UserServer
399 { 382 {
400 m_log.Error("[PROFILE]:Failed to set home region, Value was too large"); 383 m_log.Error("[PROFILE]:Failed to set home region, Value was too large");
401 } 384 }
385
402 } 386 }
403 if (requestData.Contains("home_pos_x")) 387 if (requestData.Contains("home_pos_x"))
404 { 388 {
405 try 389 try
406 { 390 {
407 userProfile.HomeLocationX = (float) Convert.ToDecimal((string) requestData["home_pos_x"]); 391 userProfile.HomeLocationX = (float)Convert.ToDecimal((string)requestData["home_pos_x"]);
408 } 392 }
409 catch (InvalidCastException) 393 catch (InvalidCastException)
410 { 394 {
411 m_log.Error("[PROFILE]:Failed to set home postion x"); 395 m_log.Error("[PROFILE]:Failed to set home postion x");
412 } 396 }
397
413 } 398 }
414 if (requestData.Contains("home_pos_y")) 399 if (requestData.Contains("home_pos_y"))
415 { 400 {
416 try 401 try
417 { 402 {
418 userProfile.HomeLocationY = (float) Convert.ToDecimal((string) requestData["home_pos_y"]); 403 userProfile.HomeLocationY = (float)Convert.ToDecimal((string)requestData["home_pos_y"]);
419 } 404 }
420 catch (InvalidCastException) 405 catch (InvalidCastException)
421 { 406 {
@@ -426,7 +411,7 @@ namespace OpenSim.Grid.UserServer
426 { 411 {
427 try 412 try
428 { 413 {
429 userProfile.HomeLocationZ = (float) Convert.ToDecimal((string) requestData["home_pos_z"]); 414 userProfile.HomeLocationZ = (float)Convert.ToDecimal((string)requestData["home_pos_z"]);
430 } 415 }
431 catch (InvalidCastException) 416 catch (InvalidCastException)
432 { 417 {
@@ -437,7 +422,7 @@ namespace OpenSim.Grid.UserServer
437 { 422 {
438 try 423 try
439 { 424 {
440 userProfile.HomeLookAtX = (float) Convert.ToDecimal((string) requestData["home_look_x"]); 425 userProfile.HomeLookAtX = (float)Convert.ToDecimal((string)requestData["home_look_x"]);
441 } 426 }
442 catch (InvalidCastException) 427 catch (InvalidCastException)
443 { 428 {
@@ -448,7 +433,7 @@ namespace OpenSim.Grid.UserServer
448 { 433 {
449 try 434 try
450 { 435 {
451 userProfile.HomeLookAtY = (float) Convert.ToDecimal((string) requestData["home_look_y"]); 436 userProfile.HomeLookAtY = (float)Convert.ToDecimal((string)requestData["home_look_y"]);
452 } 437 }
453 catch (InvalidCastException) 438 catch (InvalidCastException)
454 { 439 {
@@ -457,9 +442,9 @@ namespace OpenSim.Grid.UserServer
457 } 442 }
458 if (requestData.Contains("home_look_z")) 443 if (requestData.Contains("home_look_z"))
459 { 444 {
460 try 445 try
461 { 446 {
462 userProfile.HomeLookAtZ = (float) Convert.ToDecimal((string) requestData["home_look_z"]); 447 userProfile.HomeLookAtZ = (float)Convert.ToDecimal((string)requestData["home_look_z"]);
463 } 448 }
464 catch (InvalidCastException) 449 catch (InvalidCastException)
465 { 450 {
@@ -476,18 +461,18 @@ namespace OpenSim.Grid.UserServer
476 public XmlRpcResponse XmlRPCLogOffUserMethodUUID(XmlRpcRequest request) 461 public XmlRpcResponse XmlRPCLogOffUserMethodUUID(XmlRpcRequest request)
477 { 462 {
478 XmlRpcResponse response = new XmlRpcResponse(); 463 XmlRpcResponse response = new XmlRpcResponse();
479 Hashtable requestData = (Hashtable) request.Params[0]; 464 Hashtable requestData = (Hashtable)request.Params[0];
480 465
481 if (requestData.Contains("avatar_uuid")) 466 if (requestData.Contains("avatar_uuid"))
482 { 467 {
483 try 468 try
484 { 469 {
485 LLUUID userUUID = new LLUUID((string) requestData["avatar_uuid"]); 470 LLUUID userUUID = new LLUUID((string)requestData["avatar_uuid"]);
486 LLUUID RegionID = new LLUUID((string) requestData["region_uuid"]); 471 LLUUID RegionID = new LLUUID((string)requestData["region_uuid"]);
487 ulong regionhandle = (ulong) Convert.ToInt64((string) requestData["region_handle"]); 472 ulong regionhandle = (ulong)Convert.ToInt64((string)requestData["region_handle"]);
488 float posx = (float) Convert.ToDecimal((string) requestData["region_pos_x"]); 473 float posx = (float)Convert.ToDecimal((string)requestData["region_pos_x"]);
489 float posy = (float) Convert.ToDecimal((string) requestData["region_pos_y"]); 474 float posy = (float)Convert.ToDecimal((string)requestData["region_pos_y"]);
490 float posz = (float) Convert.ToDecimal((string) requestData["region_pos_z"]); 475 float posz = (float)Convert.ToDecimal((string)requestData["region_pos_z"]);
491 476
492 handlerLogOffUser = OnLogOffUser; 477 handlerLogOffUser = OnLogOffUser;
493 if (handlerLogOffUser != null) 478 if (handlerLogOffUser != null)
@@ -510,5 +495,20 @@ namespace OpenSim.Grid.UserServer
510 } 495 }
511 496
512 #endregion 497 #endregion
498
499 public override UserProfileData SetupMasterUser(string firstName, string lastName)
500 {
501 throw new Exception("The method or operation is not implemented.");
502 }
503
504 public override UserProfileData SetupMasterUser(string firstName, string lastName, string password)
505 {
506 throw new Exception("The method or operation is not implemented.");
507 }
508
509 public override UserProfileData SetupMasterUser(LLUUID uuid)
510 {
511 throw new Exception("The method or operation is not implemented.");
512 }
513 } 513 }
514} \ No newline at end of file 514}
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}
diff --git a/ThirdParty/3Di/LoadBalancer/LoadBalancerPlugin.cs b/ThirdParty/3Di/LoadBalancer/LoadBalancerPlugin.cs
index af979a6..dda8be6 100644
--- a/ThirdParty/3Di/LoadBalancer/LoadBalancerPlugin.cs
+++ b/ThirdParty/3Di/LoadBalancer/LoadBalancerPlugin.cs
@@ -52,12 +52,12 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer
52 public class LoadBalancerPlugin : IApplicationPlugin 52 public class LoadBalancerPlugin : IApplicationPlugin
53 { 53 {
54 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 54 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
55 private readonly object padlock = new object();
56 55
57 private BaseHttpServer commandServer; 56 private BaseHttpServer commandServer;
58 private bool[] isLocalNeighbour; 57 private bool[] isLocalNeighbour;
59 private bool isSplit; 58 private bool isSplit = false;
60 private TcpServer mTcpServer; 59 private TcpServer mTcpServer;
60 private object padlock = new object();
61 61
62 private int proxyOffset; 62 private int proxyOffset;
63 private string proxyURL; 63 private string proxyURL;
@@ -80,8 +80,8 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer
80 if (proxyURL.Length == 0) return; 80 if (proxyURL.Length == 0) return;
81 81
82 StartTcpServer(); 82 StartTcpServer();
83 ClientView.SynchronizeClient = SynchronizePackets; 83 ClientView.SynchronizeClient = new ClientView.SynchronizeClientHandler(SynchronizePackets);
84 AsynchronousSocketListener.PacketHandler = SynchronizePacketRecieve; 84 AsynchronousSocketListener.PacketHandler = new AsynchronousSocketListener.PacketRecieveHandler(SynchronizePacketRecieve);
85 85
86 sceneManager = openSim.SceneManager; 86 sceneManager = openSim.SceneManager;
87 udpServers = openSim.UdpServers; 87 udpServers = openSim.UdpServers;
@@ -146,7 +146,7 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer
146 { 146 {
147 ClientView client = (ClientView) pre.ControllingClient; 147 ClientView client = (ClientView) pre.ControllingClient;
148 //if(pre.MovementFlag!=0 && client.PacketProcessingEnabled==true) { 148 //if(pre.MovementFlag!=0 && client.PacketProcessingEnabled==true) {
149 if (client.PacketProcessingEnabled) 149 if (client.PacketProcessingEnabled == true)
150 { 150 {
151 get_scene_presence_filter++; 151 get_scene_presence_filter++;
152 } 152 }
@@ -159,7 +159,7 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer
159 { 159 {
160 ClientView client = (ClientView) pre.ControllingClient; 160 ClientView client = (ClientView) pre.ControllingClient;
161 //if(pre.MovementFlag!=0 && client.PacketProcessingEnabled==true) { 161 //if(pre.MovementFlag!=0 && client.PacketProcessingEnabled==true) {
162 if (client.PacketProcessingEnabled) 162 if (client.PacketProcessingEnabled == true)
163 { 163 {
164 get_avatar_filter++; 164 get_avatar_filter++;
165 avatar_names += pre.Firstname + " " + pre.Lastname + "; "; 165 avatar_names += pre.Firstname + " " + pre.Lastname + "; ";
@@ -178,7 +178,7 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer
178 } 178 }
179 catch (Exception e) 179 catch (Exception e)
180 { 180 {
181 m_log.Error("[BALANCER] " + e); 181 m_log.Error("[BALANCER] " + e.ToString());
182 m_log.Error("[BALANCER] " + e.StackTrace); 182 m_log.Error("[BALANCER] " + e.StackTrace);
183 } 183 }
184 return response; 184 return response;
@@ -199,7 +199,7 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer
199 } 199 }
200 catch (Exception e) 200 catch (Exception e)
201 { 201 {
202 m_log.Error("[BALANCER] " + e); 202 m_log.Error("[BALANCER] " + e.ToString());
203 m_log.Error("[BALANCER] " + e.StackTrace); 203 m_log.Error("[BALANCER] " + e.StackTrace);
204 } 204 }
205 205
@@ -223,7 +223,7 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer
223 } 223 }
224 catch (Exception e) 224 catch (Exception e)
225 { 225 {
226 m_log.Error("[BALANCER] " + e); 226 m_log.Error("[BALANCER] " + e.ToString());
227 m_log.Error("[BALANCER] " + e.StackTrace); 227 m_log.Error("[BALANCER] " + e.StackTrace);
228 } 228 }
229 229
@@ -247,7 +247,7 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer
247 } 247 }
248 catch (Exception e) 248 catch (Exception e)
249 { 249 {
250 m_log.Error("[BALANCER] " + e); 250 m_log.Error("[BALANCER] " + e.ToString());
251 m_log.Error("[BALANCER] " + e.StackTrace); 251 m_log.Error("[BALANCER] " + e.StackTrace);
252 throw e; 252 throw e;
253 } 253 }
@@ -264,14 +264,14 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer
264 int src_port = (int) request.Params[0]; 264 int src_port = (int) request.Params[0];
265 265
266 // backgroud 266 // backgroud
267 WaitCallback callback = TerminateRegion; 267 WaitCallback callback = new WaitCallback(TerminateRegion);
268 ThreadPool.QueueUserWorkItem(callback, src_port); 268 ThreadPool.QueueUserWorkItem(callback, src_port);
269 269
270 m_log.Info("[BALANCER] " + "Exiting TerminateRegion()"); 270 m_log.Info("[BALANCER] " + "Exiting TerminateRegion()");
271 } 271 }
272 catch (Exception e) 272 catch (Exception e)
273 { 273 {
274 m_log.Error("[BALANCER] " + e); 274 m_log.Error("[BALANCER] " + e.ToString());
275 m_log.Error("[BALANCER] " + e.StackTrace); 275 m_log.Error("[BALANCER] " + e.StackTrace);
276 } 276 }
277 277
@@ -330,8 +330,8 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer
330 dst_region = DeserializeRegion(dst_port, false, serializeDir); 330 dst_region = DeserializeRegion(dst_port, false, serializeDir);
331 331
332 // Decide who is in charge for each section 332 // Decide who is in charge for each section
333 int[] port = new[] {src_port, dst_port}; 333 int[] port = new int[] {src_port, dst_port};
334 string[] url = new[] {"http://" + src_url + ":" + commandServer.Port, "http://" + dst_url + ":" + commandServer.Port}; 334 string[] url = new string[] {"http://" + src_url + ":" + commandServer.Port, "http://" + dst_url + ":" + commandServer.Port};
335 for (int i = 0; i < 2; i++) Util.XmlRpcCommand(url[i], "SplitRegion", i, 2, port[0], port[1], url[0], url[1]); 335 for (int i = 0; i < 2; i++) Util.XmlRpcCommand(url[i], "SplitRegion", i, 2, port[0], port[1], url[0], url[1]);
336 336
337 // Enable the proxy 337 // Enable the proxy
@@ -424,7 +424,7 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer
424 // serialization of region data 424 // serialization of region data
425 SearializableRegionInfo dst_region = new SearializableRegionInfo(src_region); 425 SearializableRegionInfo dst_region = new SearializableRegionInfo(src_region);
426 426
427 filename = export_dir + "RegionInfo_" + src_region.RegionID + ".bin"; 427 filename = export_dir + "RegionInfo_" + src_region.RegionID.ToString() + ".bin";
428 Util.SerializeToFile(filename, dst_region); 428 Util.SerializeToFile(filename, dst_region);
429 429
430 // backup current scene's entities 430 // backup current scene's entities
@@ -451,7 +451,7 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer
451 { 451 {
452 ClientInfo info = controller.GetClientInfo(); 452 ClientInfo info = controller.GetClientInfo();
453 453
454 filename = export_dir + "ClientInfo-" + String.Format("{0:0000}", idx) + "_" + controller.CircuitCode + ".bin"; 454 filename = export_dir + "ClientInfo-" + String.Format("{0:0000}", idx) + "_" + controller.CircuitCode.ToString() + ".bin";
455 455
456 Util.SerializeToFile(filename, info); 456 Util.SerializeToFile(filename, info);
457 457
@@ -469,12 +469,13 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer
469 469
470 private RegionInfo DeserializeRegion(int dst_port, bool move_flag, string import_dir) 470 private RegionInfo DeserializeRegion(int dst_port, bool move_flag, string import_dir)
471 { 471 {
472 string[] files = null;
472 RegionInfo dst_region = null; 473 RegionInfo dst_region = null;
473 474
474 try 475 try
475 { 476 {
476 // deserialization of region data 477 // deserialization of region data
477 string[] files = Directory.GetFiles(import_dir, "RegionInfo_*.bin"); 478 files = Directory.GetFiles(import_dir, "RegionInfo_*.bin");
478 479
479 foreach (string filename in files) 480 foreach (string filename in files)
480 { 481 {
@@ -502,7 +503,7 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer
502 } 503 }
503 catch (Exception e) 504 catch (Exception e)
504 { 505 {
505 m_log.Error("[BALANCER] " + e); 506 m_log.Error("[BALANCER] " + e.ToString());
506 m_log.Error("[BALANCER] " + e.StackTrace); 507 m_log.Error("[BALANCER] " + e.StackTrace);
507 throw e; 508 throw e;
508 } 509 }
@@ -592,7 +593,7 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer
592 593
593 // change RegionInfo (memory only) 594 // change RegionInfo (memory only)
594 dst_region.InternalEndPoint.Port = dst_port; 595 dst_region.InternalEndPoint.Port = dst_port;
595 dst_region.ExternalHostName = proxyURL.Split(new[] {'/', ':'})[3]; 596 dst_region.ExternalHostName = proxyURL.Split(new char[] {'/', ':'})[3];
596 597
597 // Create new region 598 // Create new region
598 simMain.CreateRegion(dst_region, false); 599 simMain.CreateRegion(dst_region, false);
@@ -694,7 +695,7 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer
694 695
695 for (int i = 0; i < numRegions; i++) 696 for (int i = 0; i < numRegions; i++)
696 { 697 {
697 hostname = sceneURL[i].Split(new[] {'/', ':'})[3]; 698 hostname = sceneURL[i].Split(new char[] {'/', ':'})[3];
698 m_log.InfoFormat("[SPLITSCENE] " + "creating tcp client host:{0}", hostname); 699 m_log.InfoFormat("[SPLITSCENE] " + "creating tcp client host:{0}", hostname);
699 tcpClientList[i] = new TcpClient(hostname, 10001); 700 tcpClientList[i] = new TcpClient(hostname, 10001);
700 } 701 }
@@ -730,11 +731,12 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer
730 List<uint> circuits = scene.ClientManager.GetAllCircuitCodes(); 731 List<uint> circuits = scene.ClientManager.GetAllCircuitCodes();
731 circuits.Sort(); 732 circuits.Sort();
732 733
734 IClientAPI controller = null;
735
733 foreach (uint code in circuits) 736 foreach (uint code in circuits)
734 { 737 {
735 m_log.InfoFormat("[BALANCER] " + "circuit code : {0}", code); 738 m_log.InfoFormat("[BALANCER] " + "circuit code : {0}", code);
736 739
737 IClientAPI controller;
738 if (scene.ClientManager.TryGetClient(code, out controller)) 740 if (scene.ClientManager.TryGetClient(code, out controller))
739 { 741 {
740 // Divide the presences evenly over the set of subscenes 742 // Divide the presences evenly over the set of subscenes
@@ -754,7 +756,7 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer
754 } 756 }
755 757
756 scene.splitID = myID; 758 scene.splitID = myID;
757 scene.SynchronizeScene = SynchronizeScenes; 759 scene.SynchronizeScene = new Scene.SynchronizeSceneHandler(SynchronizeScenes);
758 isSplit = true; 760 isSplit = true;
759 } 761 }
760 else 762 else
@@ -764,7 +766,7 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer
764 } 766 }
765 catch (Exception e) 767 catch (Exception e)
766 { 768 {
767 m_log.Error("[SPLITSCENE] " + e); 769 m_log.Error("[SPLITSCENE] " + e.ToString());
768 m_log.Error("[SPLITSCENE] " + e.StackTrace); 770 m_log.Error("[SPLITSCENE] " + e.StackTrace);
769 } 771 }
770 772
@@ -818,7 +820,7 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer
818 } 820 }
819 catch (Exception e) 821 catch (Exception e)
820 { 822 {
821 m_log.Error("[BALANCER] " + e); 823 m_log.Error("[BALANCER] " + e.ToString());
822 m_log.Error("[BALANCER] " + e.StackTrace); 824 m_log.Error("[BALANCER] " + e.StackTrace);
823 throw e; 825 throw e;
824 } 826 }
@@ -891,7 +893,7 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer
891 // Because data changes by the physics simulation when the client doesn't move, 893 // Because data changes by the physics simulation when the client doesn't move,
892 // if MovementFlag is false, It is necessary to synchronize. 894 // if MovementFlag is false, It is necessary to synchronize.
893 //if(pre.MovementFlag!=0 && client.PacketProcessingEnabled==true) 895 //if(pre.MovementFlag!=0 && client.PacketProcessingEnabled==true)
894 if (client.PacketProcessingEnabled) 896 if (client.PacketProcessingEnabled == true)
895 { 897 {
896 //m_log.Info("[SPLITSCENE] "+String.Format("Client moving in {0} {1}", scene.RegionInfo.RegionID, pre.AbsolutePosition)); 898 //m_log.Info("[SPLITSCENE] "+String.Format("Client moving in {0} {1}", scene.RegionInfo.RegionID, pre.AbsolutePosition));
897 899
@@ -1014,7 +1016,7 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer
1014 return; 1016 return;
1015 } 1017 }
1016 1018
1017 if (((ClientView) pre.ControllingClient).PacketProcessingEnabled) 1019 if (((ClientView) pre.ControllingClient).PacketProcessingEnabled == true)
1018 { 1020 {
1019 pre.ControllingClient.OutPacket(packet, throttlePacketType); 1021 pre.ControllingClient.OutPacket(packet, throttlePacketType);
1020 } 1022 }
@@ -1058,7 +1060,7 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer
1058 } 1060 }
1059 catch (Exception e) 1061 catch (Exception e)
1060 { 1062 {
1061 m_log.Error("[SPLITSCENE] " + e); 1063 m_log.Error("[SPLITSCENE] " + e.ToString());
1062 m_log.Error("[SPLITSCENE] " + e.StackTrace); 1064 m_log.Error("[SPLITSCENE] " + e.StackTrace);
1063 } 1065 }
1064 1066
@@ -1070,7 +1072,7 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer
1070 LLUUID scenePresenceID = new LLUUID(header.agent_id); 1072 LLUUID scenePresenceID = new LLUUID(header.agent_id);
1071 LLVector3 position = new LLVector3(buff, 0); 1073 LLVector3 position = new LLVector3(buff, 0);
1072 LLVector3 velocity = new LLVector3(buff, 12); 1074 LLVector3 velocity = new LLVector3(buff, 12);
1073 bool flying = ((buff[24] == 1) ? true : false); 1075 bool flying = ((buff[24] == (byte) 1) ? true : false);
1074 1076
1075 LocalUpdatePhysics(regionPort, scenePresenceID, position, velocity, flying); 1077 LocalUpdatePhysics(regionPort, scenePresenceID, position, velocity, flying);
1076 1078
@@ -1084,4 +1086,4 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer
1084// m_log.Info("[SPLITSCENE] "+"exiting SynchronizePacketRecieve"); 1086// m_log.Info("[SPLITSCENE] "+"exiting SynchronizePacketRecieve");
1085 } 1087 }
1086 } 1088 }
1087} \ No newline at end of file 1089}
diff --git a/ThirdParty/3Di/LoadBalancer/TcpClient.cs b/ThirdParty/3Di/LoadBalancer/TcpClient.cs
index e9e019c..af678a0 100644
--- a/ThirdParty/3Di/LoadBalancer/TcpClient.cs
+++ b/ThirdParty/3Di/LoadBalancer/TcpClient.cs
@@ -34,8 +34,8 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer
34{ 34{
35 public class AsynchronousClient 35 public class AsynchronousClient
36 { 36 {
37 private static readonly ManualResetEvent connectDone = new ManualResetEvent(false); 37 private static ManualResetEvent connectDone = new ManualResetEvent(false);
38 private static readonly ManualResetEvent sendDone = new ManualResetEvent(false); 38 private static ManualResetEvent sendDone = new ManualResetEvent(false);
39 39
40 public static Socket StartClient(string hostname, int port) 40 public static Socket StartClient(string hostname, int port)
41 { 41 {
@@ -46,7 +46,7 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer
46 IPEndPoint remoteEP = new IPEndPoint(ipAddress, port); 46 IPEndPoint remoteEP = new IPEndPoint(ipAddress, port);
47 47
48 Socket client = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); 48 Socket client = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
49 client.BeginConnect(remoteEP, ConnectCallback, client); 49 client.BeginConnect(remoteEP, new AsyncCallback(ConnectCallback), client);
50 connectDone.WaitOne(); 50 connectDone.WaitOne();
51 /* 51 /*
52 Send(client,"This is a test<EOF>"); 52 Send(client,"This is a test<EOF>");
@@ -71,7 +71,7 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer
71 { 71 {
72 Socket client = (Socket) ar.AsyncState; 72 Socket client = (Socket) ar.AsyncState;
73 client.EndConnect(ar); 73 client.EndConnect(ar);
74 Console.WriteLine("Socket connected to {0}", client.RemoteEndPoint); 74 Console.WriteLine("Socket connected to {0}", client.RemoteEndPoint.ToString());
75 connectDone.Set(); 75 connectDone.Set();
76 } 76 }
77 catch (Exception e) 77 catch (Exception e)
@@ -138,8 +138,8 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer
138 138
139 public class InternalPacketHeader 139 public class InternalPacketHeader
140 { 140 {
141 private readonly byte[] buffer = new byte[32];
142 public Guid agent_id; 141 public Guid agent_id;
142 private byte[] buffer = new byte[32];
143 public int numbytes; 143 public int numbytes;
144 public int region_port; 144 public int region_port;
145 public int throttlePacketType; 145 public int throttlePacketType;
@@ -150,16 +150,16 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer
150 int i = 0; // offset 150 int i = 0; // offset
151 try 151 try
152 { 152 {
153 type = (bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); 153 type = (int) (bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24));
154 throttlePacketType = (bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); 154 throttlePacketType = (int) (bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24));
155 numbytes = (bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); 155 numbytes = (int) (bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24));
156 agent_id = new Guid( 156 agent_id = new Guid(
157 bytes[i++] | (bytes[i++] << 8) | (bytes[i++] << 16) | bytes[i++] << 24, 157 bytes[i++] | (bytes[i++] << 8) | (bytes[i++] << 16) | bytes[i++] << 24,
158 (short) (bytes[i++] | (bytes[i++] << 8)), 158 (short) (bytes[i++] | (bytes[i++] << 8)),
159 (short) (bytes[i++] | (bytes[i++] << 8)), 159 (short) (bytes[i++] | (bytes[i++] << 8)),
160 bytes[i++], bytes[i++], bytes[i++], bytes[i++], 160 bytes[i++], bytes[i++], bytes[i++], bytes[i++],
161 bytes[i++], bytes[i++], bytes[i++], bytes[i++]); 161 bytes[i++], bytes[i++], bytes[i++], bytes[i++]);
162 region_port = (bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); 162 region_port = (int) (bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24));
163 } 163 }
164 catch (Exception) 164 catch (Exception)
165 { 165 {
@@ -201,11 +201,11 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer
201 public class TcpClient 201 public class TcpClient
202 { 202 {
203 public static int internalPacketHeaderSize = 4 * 4 + 16 * 1; 203 public static int internalPacketHeaderSize = 4 * 4 + 16 * 1;
204
205 private readonly string mHostname;
206 private readonly int mPort;
207 private Socket mConnection; 204 private Socket mConnection;
208 205
206 private string mHostname;
207 private int mPort;
208
209 public TcpClient(string hostname, int port) 209 public TcpClient(string hostname, int port)
210 { 210 {
211 mHostname = hostname; 211 mHostname = hostname;
diff --git a/ThirdParty/3Di/LoadBalancer/TcpServer.cs b/ThirdParty/3Di/LoadBalancer/TcpServer.cs
index cd94b95..9722a1b 100644
--- a/ThirdParty/3Di/LoadBalancer/TcpServer.cs
+++ b/ThirdParty/3Di/LoadBalancer/TcpServer.cs
@@ -37,15 +37,15 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer
37 { 37 {
38 public const int BufferSize = 2048; 38 public const int BufferSize = 2048;
39 public byte[] buffer = new byte[BufferSize]; 39 public byte[] buffer = new byte[BufferSize];
40 public InternalPacketHeader header; 40 public InternalPacketHeader header = null;
41 public MemoryStream ms_ptr = new MemoryStream(); 41 public MemoryStream ms_ptr = new MemoryStream();
42 public Socket workSocket; 42 public Socket workSocket = null;
43 } 43 }
44 44
45 public class AsynchronousSocketListener 45 public class AsynchronousSocketListener
46 { 46 {
47 public static ManualResetEvent allDone = new ManualResetEvent(false); 47 public static ManualResetEvent allDone = new ManualResetEvent(false);
48 public static string data; 48 public static string data = null;
49 49
50 #region KIRYU 50 #region KIRYU
51 51
@@ -55,10 +55,14 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer
55 55
56 #endregion 56 #endregion
57 57
58 public static PacketRecieveHandler PacketHandler; 58 public static PacketRecieveHandler PacketHandler = null;
59 59
60 #endregion 60 #endregion
61 61
62 public AsynchronousSocketListener()
63 {
64 }
65
62 public static void StartListening(int port) 66 public static void StartListening(int port)
63 { 67 {
64 IPHostEntry ipHostInfo = Dns.GetHostEntry(Dns.GetHostName()); 68 IPHostEntry ipHostInfo = Dns.GetHostEntry(Dns.GetHostName());
@@ -195,7 +199,7 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer
195 199
196 public class TcpServer 200 public class TcpServer
197 { 201 {
198 private readonly int mPort = 11000; 202 private int mPort = 11000;
199 203
200 public TcpServer() 204 public TcpServer()
201 { 205 {
diff --git a/ThirdParty/3Di/RegionProxy/RegionProxyPlugin.cs b/ThirdParty/3Di/RegionProxy/RegionProxyPlugin.cs
index 2c86fd4..eaafe6c 100644
--- a/ThirdParty/3Di/RegionProxy/RegionProxyPlugin.cs
+++ b/ThirdParty/3Di/RegionProxy/RegionProxyPlugin.cs
@@ -75,7 +75,7 @@ namespace OpenSim.ApplicationPlugins.RegionProxy
75 string proxyURL = openSim.ConfigSource.Configs["Network"].GetString("proxy_url", ""); 75 string proxyURL = openSim.ConfigSource.Configs["Network"].GetString("proxy_url", "");
76 if (proxyURL.Length == 0) return; 76 if (proxyURL.Length == 0) return;
77 77
78 uint port = (uint) Int32.Parse(proxyURL.Split(new[] {':'})[2]); 78 uint port = (uint) Int32.Parse(proxyURL.Split(new char[] {':'})[2]);
79 command_server = new BaseHttpServer(port); 79 command_server = new BaseHttpServer(port);
80 command_server.Start(); 80 command_server.Start();
81 command_server.AddXmlRPCHandler("AddPort", AddPort); 81 command_server.AddXmlRPCHandler("AddPort", AddPort);
@@ -223,7 +223,7 @@ namespace OpenSim.ApplicationPlugins.RegionProxy
223 { 223 {
224 m_log = log; 224 m_log = log;
225 running = false; 225 running = false;
226 receivedData = OnReceivedData; 226 receivedData = new AsyncCallback(OnReceivedData);
227 } 227 }
228 228
229 public void BlockClientMessages(string regionUrl, int regionPort) 229 public void BlockClientMessages(string regionUrl, int regionPort)
@@ -452,7 +452,7 @@ namespace OpenSim.ApplicationPlugins.RegionProxy
452 452
453 protected class ProxyMap 453 protected class ProxyMap
454 { 454 {
455 private readonly Dictionary<EndPoint, RegionData> map; 455 private Dictionary<EndPoint, RegionData> map;
456 456
457 public ProxyMap() 457 public ProxyMap()
458 { 458 {
@@ -494,7 +494,7 @@ namespace OpenSim.ApplicationPlugins.RegionProxy
494 494
495 public class RegionData 495 public class RegionData
496 { 496 {
497 public bool isBlocked; 497 public bool isBlocked = false;
498 public List<EndPoint> regions = new List<EndPoint>(); 498 public List<EndPoint> regions = new List<EndPoint>();
499 public Queue storedMessages = new Queue(); 499 public Queue storedMessages = new Queue();
500 } 500 }