diff options
Diffstat (limited to 'OpenSim')
167 files changed, 5417 insertions, 4152 deletions
diff --git a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs index f4e1db4..3bc557d 100644 --- a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs +++ b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs | |||
@@ -123,6 +123,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
123 | availableMethods["admin_region_query"] = XmlRpcRegionQueryMethod; | 123 | availableMethods["admin_region_query"] = XmlRpcRegionQueryMethod; |
124 | availableMethods["admin_shutdown"] = XmlRpcShutdownMethod; | 124 | availableMethods["admin_shutdown"] = XmlRpcShutdownMethod; |
125 | availableMethods["admin_broadcast"] = XmlRpcAlertMethod; | 125 | availableMethods["admin_broadcast"] = XmlRpcAlertMethod; |
126 | availableMethods["admin_dialog"] = XmlRpcDialogMethod; | ||
126 | availableMethods["admin_restart"] = XmlRpcRestartMethod; | 127 | availableMethods["admin_restart"] = XmlRpcRestartMethod; |
127 | availableMethods["admin_load_heightmap"] = XmlRpcLoadHeightmapMethod; | 128 | availableMethods["admin_load_heightmap"] = XmlRpcLoadHeightmapMethod; |
128 | // User management | 129 | // User management |
@@ -277,6 +278,53 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
277 | m_log.Info("[RADMIN]: Alert request complete"); | 278 | m_log.Info("[RADMIN]: Alert request complete"); |
278 | return response; | 279 | return response; |
279 | } | 280 | } |
281 | public XmlRpcResponse XmlRpcDialogMethod(XmlRpcRequest request, IPEndPoint remoteClient) | ||
282 | { | ||
283 | XmlRpcResponse response = new XmlRpcResponse(); | ||
284 | Hashtable responseData = new Hashtable(); | ||
285 | |||
286 | m_log.Info("[RADMIN]: Dialog request started"); | ||
287 | |||
288 | try | ||
289 | { | ||
290 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
291 | |||
292 | checkStringParameters(request, new string[] { "password", "from", "message" }); | ||
293 | |||
294 | if (m_requiredPassword != String.Empty && | ||
295 | (!requestData.Contains("password") || (string)requestData["password"] != m_requiredPassword)) | ||
296 | throw new Exception("wrong password"); | ||
297 | |||
298 | string message = (string)requestData["message"]; | ||
299 | string fromuuid = (string)requestData["from"]; | ||
300 | m_log.InfoFormat("[RADMIN]: Broadcasting: {0}", message); | ||
301 | |||
302 | responseData["accepted"] = true; | ||
303 | responseData["success"] = true; | ||
304 | response.Value = responseData; | ||
305 | |||
306 | m_app.SceneManager.ForEachScene( | ||
307 | delegate(Scene scene) | ||
308 | { | ||
309 | IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>(); | ||
310 | if (dialogModule != null) | ||
311 | dialogModule.SendNotificationToUsersInRegion(UUID.Zero, fromuuid, message); | ||
312 | }); | ||
313 | } | ||
314 | catch (Exception e) | ||
315 | { | ||
316 | m_log.ErrorFormat("[RADMIN]: Broadcasting: failed: {0}", e.Message); | ||
317 | m_log.DebugFormat("[RADMIN]: Broadcasting: failed: {0}", e.ToString()); | ||
318 | |||
319 | responseData["accepted"] = false; | ||
320 | responseData["success"] = false; | ||
321 | responseData["error"] = e.Message; | ||
322 | response.Value = responseData; | ||
323 | } | ||
324 | |||
325 | m_log.Info("[RADMIN]: Alert request complete"); | ||
326 | return response; | ||
327 | } | ||
280 | 328 | ||
281 | public XmlRpcResponse XmlRpcLoadHeightmapMethod(XmlRpcRequest request, IPEndPoint remoteClient) | 329 | public XmlRpcResponse XmlRpcLoadHeightmapMethod(XmlRpcRequest request, IPEndPoint remoteClient) |
282 | { | 330 | { |
@@ -360,7 +408,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
360 | && ((string) requestData["shutdown"] == "delayed") | 408 | && ((string) requestData["shutdown"] == "delayed") |
361 | && requestData.ContainsKey("milliseconds")) | 409 | && requestData.ContainsKey("milliseconds")) |
362 | { | 410 | { |
363 | timeout = (Int32) requestData["milliseconds"]; | 411 | timeout = Int32.Parse(requestData["milliseconds"].ToString()); |
364 | 412 | ||
365 | message | 413 | message |
366 | = "Region is going down in " + ((int) (timeout/1000)).ToString() | 414 | = "Region is going down in " + ((int) (timeout/1000)).ToString() |
@@ -1562,11 +1610,8 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
1562 | assets = doc.GetElementsByTagName("RequiredAsset"); | 1610 | assets = doc.GetElementsByTagName("RequiredAsset"); |
1563 | foreach (XmlNode asset in assets) | 1611 | foreach (XmlNode asset in assets) |
1564 | { | 1612 | { |
1565 | AssetBase rass = new AssetBase(); | 1613 | AssetBase rass = new AssetBase(UUID.Random(), GetStringAttribute(asset,"name",""), SByte.Parse(GetStringAttribute(asset,"type",""))); |
1566 | rass.FullID = UUID.Random(); | ||
1567 | rass.Name = GetStringAttribute(asset,"name",""); | ||
1568 | rass.Description = GetStringAttribute(asset,"desc",""); | 1614 | rass.Description = GetStringAttribute(asset,"desc",""); |
1569 | rass.Type = SByte.Parse(GetStringAttribute(asset,"type","")); | ||
1570 | rass.Local = Boolean.Parse(GetStringAttribute(asset,"local","")); | 1615 | rass.Local = Boolean.Parse(GetStringAttribute(asset,"local","")); |
1571 | rass.Temporary = Boolean.Parse(GetStringAttribute(asset,"temporary","")); | 1616 | rass.Temporary = Boolean.Parse(GetStringAttribute(asset,"temporary","")); |
1572 | rass.Data = Convert.FromBase64String(asset.InnerText); | 1617 | rass.Data = Convert.FromBase64String(asset.InnerText); |
diff --git a/OpenSim/ApplicationPlugins/Rest/Inventory/RestAssetServices.cs b/OpenSim/ApplicationPlugins/Rest/Inventory/RestAssetServices.cs index f862af1..66572d5 100644 --- a/OpenSim/ApplicationPlugins/Rest/Inventory/RestAssetServices.cs +++ b/OpenSim/ApplicationPlugins/Rest/Inventory/RestAssetServices.cs | |||
@@ -261,11 +261,8 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
261 | modified = (asset != null); | 261 | modified = (asset != null); |
262 | created = !modified; | 262 | created = !modified; |
263 | 263 | ||
264 | asset = new AssetBase(); | 264 | asset = new AssetBase(uuid, xml.GetAttribute("name"), SByte.Parse(xml.GetAttribute("type"))); |
265 | asset.FullID = uuid; | ||
266 | asset.Name = xml.GetAttribute("name"); | ||
267 | asset.Description = xml.GetAttribute("desc"); | 265 | asset.Description = xml.GetAttribute("desc"); |
268 | asset.Type = SByte.Parse(xml.GetAttribute("type")); | ||
269 | asset.Local = Int32.Parse(xml.GetAttribute("local")) != 0; | 266 | asset.Local = Int32.Parse(xml.GetAttribute("local")) != 0; |
270 | asset.Temporary = Int32.Parse(xml.GetAttribute("temporary")) != 0; | 267 | asset.Temporary = Int32.Parse(xml.GetAttribute("temporary")) != 0; |
271 | asset.Data = Convert.FromBase64String(xml.ReadElementContentAsString("Asset", "")); | 268 | asset.Data = Convert.FromBase64String(xml.ReadElementContentAsString("Asset", "")); |
@@ -341,11 +338,8 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
341 | modified = (asset != null); | 338 | modified = (asset != null); |
342 | created = !modified; | 339 | created = !modified; |
343 | 340 | ||
344 | asset = new AssetBase(); | 341 | asset = new AssetBase(uuid, xml.GetAttribute("name"), SByte.Parse(xml.GetAttribute("type"))); |
345 | asset.FullID = uuid; | ||
346 | asset.Name = xml.GetAttribute("name"); | ||
347 | asset.Description = xml.GetAttribute("desc"); | 342 | asset.Description = xml.GetAttribute("desc"); |
348 | asset.Type = SByte.Parse(xml.GetAttribute("type")); | ||
349 | asset.Local = Int32.Parse(xml.GetAttribute("local")) != 0; | 343 | asset.Local = Int32.Parse(xml.GetAttribute("local")) != 0; |
350 | asset.Temporary = Int32.Parse(xml.GetAttribute("temporary")) != 0; | 344 | asset.Temporary = Int32.Parse(xml.GetAttribute("temporary")) != 0; |
351 | asset.Data = Convert.FromBase64String(xml.ReadElementContentAsString("Asset", "")); | 345 | asset.Data = Convert.FromBase64String(xml.ReadElementContentAsString("Asset", "")); |
diff --git a/OpenSim/ApplicationPlugins/Rest/Inventory/RestInventoryServices.cs b/OpenSim/ApplicationPlugins/Rest/Inventory/RestInventoryServices.cs index 4e03e67..01bfe00 100644 --- a/OpenSim/ApplicationPlugins/Rest/Inventory/RestInventoryServices.cs +++ b/OpenSim/ApplicationPlugins/Rest/Inventory/RestInventoryServices.cs | |||
@@ -1869,10 +1869,9 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
1869 | 1869 | ||
1870 | // Create AssetBase entity to hold the inlined asset | 1870 | // Create AssetBase entity to hold the inlined asset |
1871 | 1871 | ||
1872 | asset = new AssetBase(uuid, name); | 1872 | asset = new AssetBase(uuid, name, type); |
1873 | 1873 | ||
1874 | asset.Description = desc; | 1874 | asset.Description = desc; |
1875 | asset.Type = type; // type == 0 == texture | ||
1876 | asset.Local = local; | 1875 | asset.Local = local; |
1877 | asset.Temporary = temp; | 1876 | asset.Temporary = temp; |
1878 | 1877 | ||
diff --git a/OpenSim/Client/Linden/LLStandaloneLoginModule.cs b/OpenSim/Client/Linden/LLStandaloneLoginModule.cs index bb9b623..8739ce5 100644 --- a/OpenSim/Client/Linden/LLStandaloneLoginModule.cs +++ b/OpenSim/Client/Linden/LLStandaloneLoginModule.cs | |||
@@ -231,6 +231,10 @@ namespace OpenSim.Client.Linden | |||
231 | { | 231 | { |
232 | return scene.RegionInfo; | 232 | return scene.RegionInfo; |
233 | } | 233 | } |
234 | else if (m_scenes.Count > 0) | ||
235 | { | ||
236 | return m_scenes[0].RegionInfo; | ||
237 | } | ||
234 | return null; | 238 | return null; |
235 | } | 239 | } |
236 | 240 | ||
diff --git a/OpenSim/Client/MXP/ClientStack/MXPClientView.cs b/OpenSim/Client/MXP/ClientStack/MXPClientView.cs index 204603d..0cae3dd 100644 --- a/OpenSim/Client/MXP/ClientStack/MXPClientView.cs +++ b/OpenSim/Client/MXP/ClientStack/MXPClientView.cs | |||
@@ -676,6 +676,7 @@ namespace OpenSim.Client.MXP.ClientStack | |||
676 | public event FriendActionDelegate OnApproveFriendRequest; | 676 | public event FriendActionDelegate OnApproveFriendRequest; |
677 | public event FriendActionDelegate OnDenyFriendRequest; | 677 | public event FriendActionDelegate OnDenyFriendRequest; |
678 | public event FriendshipTermination OnTerminateFriendship; | 678 | public event FriendshipTermination OnTerminateFriendship; |
679 | public event GrantUserFriendRights OnGrantUserRights; | ||
679 | public event MoneyTransferRequest OnMoneyTransferRequest; | 680 | public event MoneyTransferRequest OnMoneyTransferRequest; |
680 | public event EconomyDataRequest OnEconomyDataRequest; | 681 | public event EconomyDataRequest OnEconomyDataRequest; |
681 | public event MoneyBalanceRequest OnMoneyBalanceRequest; | 682 | public event MoneyBalanceRequest OnMoneyBalanceRequest; |
@@ -1052,7 +1053,7 @@ namespace OpenSim.Client.MXP.ClientStack | |||
1052 | { | 1053 | { |
1053 | } | 1054 | } |
1054 | 1055 | ||
1055 | public void SendInventoryFolderDetails(UUID ownerID, UUID folderID, List<InventoryItemBase> items, List<InventoryFolderBase> folders, bool fetchFolders, bool fetchItems) | 1056 | public void SendInventoryFolderDetails(UUID ownerID, UUID folderID, List<InventoryItemBase> items, List<InventoryFolderBase> folders, int version, bool fetchFolders, bool fetchItems) |
1056 | { | 1057 | { |
1057 | // Need to translate to MXP somehow | 1058 | // Need to translate to MXP somehow |
1058 | } | 1059 | } |
diff --git a/OpenSim/Client/MXP/MXPModule.cs b/OpenSim/Client/MXP/MXPModule.cs index a6b0396..0b442cc 100644 --- a/OpenSim/Client/MXP/MXPModule.cs +++ b/OpenSim/Client/MXP/MXPModule.cs | |||
@@ -110,8 +110,11 @@ namespace OpenSim.Client.MXP | |||
110 | public void Close() | 110 | public void Close() |
111 | { | 111 | { |
112 | m_shutdown = true; | 112 | m_shutdown = true; |
113 | lock (m_ticker) | 113 | if (m_ticker != null) |
114 | m_ticker.Stop(); | 114 | { |
115 | lock (m_ticker) | ||
116 | m_ticker.Stop(); | ||
117 | } | ||
115 | } | 118 | } |
116 | 119 | ||
117 | public string Name | 120 | public string Name |
diff --git a/OpenSim/Client/VWoHTTP/ClientStack/VWHClientView.cs b/OpenSim/Client/VWoHTTP/ClientStack/VWHClientView.cs index 4a54c67..fb87c15 100644 --- a/OpenSim/Client/VWoHTTP/ClientStack/VWHClientView.cs +++ b/OpenSim/Client/VWoHTTP/ClientStack/VWHClientView.cs | |||
@@ -327,6 +327,7 @@ namespace OpenSim.Client.VWoHTTP.ClientStack | |||
327 | public event FriendActionDelegate OnApproveFriendRequest = delegate { }; | 327 | public event FriendActionDelegate OnApproveFriendRequest = delegate { }; |
328 | public event FriendActionDelegate OnDenyFriendRequest = delegate { }; | 328 | public event FriendActionDelegate OnDenyFriendRequest = delegate { }; |
329 | public event FriendshipTermination OnTerminateFriendship = delegate { }; | 329 | public event FriendshipTermination OnTerminateFriendship = delegate { }; |
330 | public event GrantUserFriendRights OnGrantUserRights = delegate { }; | ||
330 | public event MoneyTransferRequest OnMoneyTransferRequest = delegate { }; | 331 | public event MoneyTransferRequest OnMoneyTransferRequest = delegate { }; |
331 | public event EconomyDataRequest OnEconomyDataRequest = delegate { }; | 332 | public event EconomyDataRequest OnEconomyDataRequest = delegate { }; |
332 | public event MoneyBalanceRequest OnMoneyBalanceRequest = delegate { }; | 333 | public event MoneyBalanceRequest OnMoneyBalanceRequest = delegate { }; |
@@ -406,6 +407,7 @@ namespace OpenSim.Client.VWoHTTP.ClientStack | |||
406 | public event PlacesQuery OnPlacesQuery = delegate { }; | 407 | public event PlacesQuery OnPlacesQuery = delegate { }; |
407 | 408 | ||
408 | 409 | ||
410 | |||
409 | public void SetDebugPacketLevel(int newDebug) | 411 | public void SetDebugPacketLevel(int newDebug) |
410 | { | 412 | { |
411 | throw new System.NotImplementedException(); | 413 | throw new System.NotImplementedException(); |
@@ -606,7 +608,7 @@ namespace OpenSim.Client.VWoHTTP.ClientStack | |||
606 | throw new System.NotImplementedException(); | 608 | throw new System.NotImplementedException(); |
607 | } | 609 | } |
608 | 610 | ||
609 | public void SendInventoryFolderDetails(UUID ownerID, UUID folderID, List<InventoryItemBase> items, List<InventoryFolderBase> folders, bool fetchFolders, bool fetchItems) | 611 | public void SendInventoryFolderDetails(UUID ownerID, UUID folderID, List<InventoryItemBase> items, List<InventoryFolderBase> folders, int version, bool fetchFolders, bool fetchItems) |
610 | { | 612 | { |
611 | throw new System.NotImplementedException(); | 613 | throw new System.NotImplementedException(); |
612 | } | 614 | } |
diff --git a/OpenSim/Data/MSSQL/AutoClosingSqlCommand.cs b/OpenSim/Data/MSSQL/AutoClosingSqlCommand.cs index 0e21880..93e48cd 100644 --- a/OpenSim/Data/MSSQL/AutoClosingSqlCommand.cs +++ b/OpenSim/Data/MSSQL/AutoClosingSqlCommand.cs | |||
@@ -197,11 +197,20 @@ namespace OpenSim.Data.MSSQL | |||
197 | public void Dispose() | 197 | public void Dispose() |
198 | { | 198 | { |
199 | SqlConnection conn = realCommand.Connection; | 199 | SqlConnection conn = realCommand.Connection; |
200 | try { realCommand.Dispose(); } | 200 | try |
201 | { | ||
202 | realCommand.Dispose(); | ||
203 | } | ||
201 | finally | 204 | finally |
202 | { | 205 | { |
203 | try { conn.Dispose(); } | 206 | try |
204 | finally { } | 207 | { |
208 | conn.Close(); | ||
209 | } | ||
210 | finally | ||
211 | { | ||
212 | conn.Dispose(); | ||
213 | } | ||
205 | } | 214 | } |
206 | } | 215 | } |
207 | 216 | ||
diff --git a/OpenSim/Data/MSSQL/MSSQLAssetData.cs b/OpenSim/Data/MSSQL/MSSQLAssetData.cs index 25f7cf0..1ce4abf 100644 --- a/OpenSim/Data/MSSQL/MSSQLAssetData.cs +++ b/OpenSim/Data/MSSQL/MSSQLAssetData.cs | |||
@@ -132,12 +132,13 @@ namespace OpenSim.Data.MSSQL | |||
132 | { | 132 | { |
133 | if (reader.Read()) | 133 | if (reader.Read()) |
134 | { | 134 | { |
135 | AssetBase asset = new AssetBase(); | 135 | AssetBase asset = new AssetBase( |
136 | new UUID((Guid)reader["id"]), | ||
137 | (string)reader["name"], | ||
138 | Convert.ToSByte(reader["assetType"]) | ||
139 | ); | ||
136 | // Region Main | 140 | // Region Main |
137 | asset.FullID = new UUID((Guid)reader["id"]); | ||
138 | asset.Name = (string)reader["name"]; | ||
139 | asset.Description = (string)reader["description"]; | 141 | asset.Description = (string)reader["description"]; |
140 | asset.Type = Convert.ToSByte(reader["assetType"]); | ||
141 | asset.Local = Convert.ToBoolean(reader["local"]); | 142 | asset.Local = Convert.ToBoolean(reader["local"]); |
142 | asset.Temporary = Convert.ToBoolean(reader["temporary"]); | 143 | asset.Temporary = Convert.ToBoolean(reader["temporary"]); |
143 | asset.Data = (byte[])reader["data"]; | 144 | asset.Data = (byte[])reader["data"]; |
diff --git a/OpenSim/Data/MSSQL/MSSQLInventoryData.cs b/OpenSim/Data/MSSQL/MSSQLInventoryData.cs index d49c2b3..1482184 100644 --- a/OpenSim/Data/MSSQL/MSSQLInventoryData.cs +++ b/OpenSim/Data/MSSQL/MSSQLInventoryData.cs | |||
@@ -348,6 +348,8 @@ namespace OpenSim.Data.MSSQL | |||
348 | //Delete the actual row | 348 | //Delete the actual row |
349 | DeleteOneFolder(folderID, connection); | 349 | DeleteOneFolder(folderID, connection); |
350 | DeleteItemsInFolder(folderID, connection); | 350 | DeleteItemsInFolder(folderID, connection); |
351 | |||
352 | connection.Close(); | ||
351 | } | 353 | } |
352 | } | 354 | } |
353 | 355 | ||
diff --git a/OpenSim/Data/MSSQL/MSSQLLegacyRegionData.cs b/OpenSim/Data/MSSQL/MSSQLLegacyRegionData.cs index cff6b00..6371307 100644 --- a/OpenSim/Data/MSSQL/MSSQLLegacyRegionData.cs +++ b/OpenSim/Data/MSSQL/MSSQLLegacyRegionData.cs | |||
@@ -1049,7 +1049,7 @@ VALUES | |||
1049 | if (!(primRow["ParticleSystem"] is DBNull)) | 1049 | if (!(primRow["ParticleSystem"] is DBNull)) |
1050 | prim.ParticleSystem = (Byte[])primRow["ParticleSystem"]; | 1050 | prim.ParticleSystem = (Byte[])primRow["ParticleSystem"]; |
1051 | 1051 | ||
1052 | prim.RotationalVelocity = new Vector3( | 1052 | prim.AngularVelocity = new Vector3( |
1053 | Convert.ToSingle(primRow["OmegaX"]), | 1053 | Convert.ToSingle(primRow["OmegaX"]), |
1054 | Convert.ToSingle(primRow["OmegaY"]), | 1054 | Convert.ToSingle(primRow["OmegaY"]), |
1055 | Convert.ToSingle(primRow["OmegaZ"])); | 1055 | Convert.ToSingle(primRow["OmegaZ"])); |
@@ -1429,9 +1429,9 @@ VALUES | |||
1429 | parameters.Add(_Database.CreateParameter("TextureAnimation", prim.TextureAnimation)); | 1429 | parameters.Add(_Database.CreateParameter("TextureAnimation", prim.TextureAnimation)); |
1430 | parameters.Add(_Database.CreateParameter("ParticleSystem", prim.ParticleSystem)); | 1430 | parameters.Add(_Database.CreateParameter("ParticleSystem", prim.ParticleSystem)); |
1431 | 1431 | ||
1432 | parameters.Add(_Database.CreateParameter("OmegaX", prim.RotationalVelocity.X)); | 1432 | parameters.Add(_Database.CreateParameter("OmegaX", prim.AngularVelocity.X)); |
1433 | parameters.Add(_Database.CreateParameter("OmegaY", prim.RotationalVelocity.Y)); | 1433 | parameters.Add(_Database.CreateParameter("OmegaY", prim.AngularVelocity.Y)); |
1434 | parameters.Add(_Database.CreateParameter("OmegaZ", prim.RotationalVelocity.Z)); | 1434 | parameters.Add(_Database.CreateParameter("OmegaZ", prim.AngularVelocity.Z)); |
1435 | 1435 | ||
1436 | parameters.Add(_Database.CreateParameter("CameraEyeOffsetX", prim.GetCameraEyeOffset().X)); | 1436 | parameters.Add(_Database.CreateParameter("CameraEyeOffsetX", prim.GetCameraEyeOffset().X)); |
1437 | parameters.Add(_Database.CreateParameter("CameraEyeOffsetY", prim.GetCameraEyeOffset().Y)); | 1437 | parameters.Add(_Database.CreateParameter("CameraEyeOffsetY", prim.GetCameraEyeOffset().Y)); |
diff --git a/OpenSim/Data/MSSQL/MSSQLManager.cs b/OpenSim/Data/MSSQL/MSSQLManager.cs index 992ce02..3d7a768 100644 --- a/OpenSim/Data/MSSQL/MSSQLManager.cs +++ b/OpenSim/Data/MSSQL/MSSQLManager.cs | |||
@@ -340,6 +340,8 @@ namespace OpenSim.Data.MSSQL | |||
340 | MSSQLMigration migration = new MSSQLMigration(connection, assem, migrationStore); | 340 | MSSQLMigration migration = new MSSQLMigration(connection, assem, migrationStore); |
341 | 341 | ||
342 | migration.Update(); | 342 | migration.Update(); |
343 | |||
344 | connection.Close(); | ||
343 | } | 345 | } |
344 | } | 346 | } |
345 | 347 | ||
@@ -383,7 +385,9 @@ namespace OpenSim.Data.MSSQL | |||
383 | m_log.Error(e.ToString()); | 385 | m_log.Error(e.ToString()); |
384 | } | 386 | } |
385 | } | 387 | } |
388 | tables.Close(); | ||
386 | } | 389 | } |
390 | |||
387 | } | 391 | } |
388 | 392 | ||
389 | /// <summary> | 393 | /// <summary> |
diff --git a/OpenSim/Data/MSSQL/MSSQLMigration.cs b/OpenSim/Data/MSSQL/MSSQLMigration.cs index 549bcb3..aea31c9 100644 --- a/OpenSim/Data/MSSQL/MSSQLMigration.cs +++ b/OpenSim/Data/MSSQL/MSSQLMigration.cs | |||
@@ -56,6 +56,7 @@ namespace OpenSim.Data.MSSQL | |||
56 | { | 56 | { |
57 | version = Convert.ToInt32(reader["version"]); | 57 | version = Convert.ToInt32(reader["version"]); |
58 | } | 58 | } |
59 | reader.Close(); | ||
59 | } | 60 | } |
60 | } | 61 | } |
61 | catch | 62 | catch |
diff --git a/OpenSim/Data/Migration.cs b/OpenSim/Data/Migration.cs index 7a99d4a..e51dc22 100644 --- a/OpenSim/Data/Migration.cs +++ b/OpenSim/Data/Migration.cs | |||
@@ -131,26 +131,25 @@ namespace OpenSim.Data | |||
131 | m_log.InfoFormat("[MIGRATIONS] Upgrading {0} to latest revision.", _type); | 131 | m_log.InfoFormat("[MIGRATIONS] Upgrading {0} to latest revision.", _type); |
132 | m_log.Info("[MIGRATIONS] NOTE: this may take a while, don't interupt this process!"); | 132 | m_log.Info("[MIGRATIONS] NOTE: this may take a while, don't interupt this process!"); |
133 | 133 | ||
134 | using (DbCommand cmd = _conn.CreateCommand()) | 134 | DbCommand cmd = _conn.CreateCommand(); |
135 | foreach (KeyValuePair<int, string> kvp in migrations) | ||
135 | { | 136 | { |
136 | foreach (KeyValuePair<int, string> kvp in migrations) | 137 | int newversion = kvp.Key; |
137 | { | 138 | cmd.CommandText = kvp.Value; |
138 | int newversion = kvp.Key; | 139 | // we need to up the command timeout to infinite as we might be doing long migrations. |
139 | cmd.CommandText = kvp.Value; | 140 | cmd.CommandTimeout = 0; |
140 | // we need to up the command timeout to infinite as we might be doing long migrations. | 141 | cmd.ExecuteNonQuery(); |
141 | cmd.CommandTimeout = 0; | ||
142 | cmd.ExecuteNonQuery(); | ||
143 | 142 | ||
144 | if (version == 0) | 143 | if (version == 0) |
145 | { | 144 | { |
146 | InsertVersion(_type, newversion); | 145 | InsertVersion(_type, newversion); |
147 | } | ||
148 | else | ||
149 | { | ||
150 | UpdateVersion(_type, newversion); | ||
151 | } | ||
152 | version = newversion; | ||
153 | } | 146 | } |
147 | else | ||
148 | { | ||
149 | UpdateVersion(_type, newversion); | ||
150 | } | ||
151 | version = newversion; | ||
152 | cmd.Dispose(); | ||
154 | } | 153 | } |
155 | } | 154 | } |
156 | 155 | ||
@@ -190,45 +189,43 @@ namespace OpenSim.Data | |||
190 | protected virtual int FindVersion(DbConnection conn, string type) | 189 | protected virtual int FindVersion(DbConnection conn, string type) |
191 | { | 190 | { |
192 | int version = 0; | 191 | int version = 0; |
193 | 192 | DbCommand cmd = conn.CreateCommand(); | |
194 | using (DbCommand cmd = conn.CreateCommand()) | 193 | try |
195 | { | 194 | { |
196 | try | 195 | cmd.CommandText = "select version from migrations where name='" + type +"' order by version desc"; |
196 | using (IDataReader reader = cmd.ExecuteReader()) | ||
197 | { | 197 | { |
198 | cmd.CommandText = "select version from migrations where name='" + type + "' order by version desc"; | 198 | if (reader.Read()) |
199 | using (IDataReader reader = cmd.ExecuteReader()) | ||
200 | { | 199 | { |
201 | if (reader.Read()) | 200 | version = Convert.ToInt32(reader["version"]); |
202 | version = Convert.ToInt32(reader["version"]); | ||
203 | } | 201 | } |
204 | } | 202 | reader.Close(); |
205 | catch | ||
206 | { | ||
207 | // Something went wrong, so we're version 0 | ||
208 | } | 203 | } |
209 | } | 204 | } |
210 | 205 | catch | |
206 | { | ||
207 | // Something went wrong, so we're version 0 | ||
208 | } | ||
209 | cmd.Dispose(); | ||
211 | return version; | 210 | return version; |
212 | } | 211 | } |
213 | 212 | ||
214 | private void InsertVersion(string type, int version) | 213 | private void InsertVersion(string type, int version) |
215 | { | 214 | { |
216 | using (DbCommand cmd = _conn.CreateCommand()) | 215 | DbCommand cmd = _conn.CreateCommand(); |
217 | { | 216 | cmd.CommandText = "insert into migrations(name, version) values('" + type + "', " + version + ")"; |
218 | cmd.CommandText = "insert into migrations(name, version) values('" + type + "', " + version + ")"; | 217 | m_log.InfoFormat("[MIGRATIONS]: Creating {0} at version {1}", type, version); |
219 | m_log.InfoFormat("[MIGRATIONS]: Creating {0} at version {1}", type, version); | 218 | cmd.ExecuteNonQuery(); |
220 | cmd.ExecuteNonQuery(); | 219 | cmd.Dispose(); |
221 | } | ||
222 | } | 220 | } |
223 | 221 | ||
224 | private void UpdateVersion(string type, int version) | 222 | private void UpdateVersion(string type, int version) |
225 | { | 223 | { |
226 | using (DbCommand cmd = _conn.CreateCommand()) | 224 | DbCommand cmd = _conn.CreateCommand(); |
227 | { | 225 | cmd.CommandText = "update migrations set version=" + version + " where name='" + type + "'"; |
228 | cmd.CommandText = "update migrations set version=" + version + " where name='" + type + "'"; | 226 | m_log.InfoFormat("[MIGRATIONS]: Updating {0} to version {1}", type, version); |
229 | m_log.InfoFormat("[MIGRATIONS]: Updating {0} to version {1}", type, version); | 227 | cmd.ExecuteNonQuery(); |
230 | cmd.ExecuteNonQuery(); | 228 | cmd.Dispose(); |
231 | } | ||
232 | } | 229 | } |
233 | 230 | ||
234 | // private SortedList<int, string> GetAllMigrations() | 231 | // private SortedList<int, string> GetAllMigrations() |
diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index 4d49733..6a4ccd7 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs | |||
@@ -139,42 +139,42 @@ namespace OpenSim.Data.MySQL | |||
139 | { | 139 | { |
140 | _dbConnection.CheckConnection(); | 140 | _dbConnection.CheckConnection(); |
141 | 141 | ||
142 | using (MySqlCommand cmd = new MySqlCommand( | 142 | MySqlCommand cmd = |
143 | "SELECT name, description, assetType, local, temporary, data FROM assets WHERE id=?id", | 143 | new MySqlCommand( |
144 | _dbConnection.Connection)) | 144 | "SELECT name, description, assetType, local, temporary, data FROM assets WHERE id=?id", |
145 | { | 145 | _dbConnection.Connection); |
146 | cmd.Parameters.AddWithValue("?id", assetID.ToString()); | 146 | cmd.Parameters.AddWithValue("?id", assetID.ToString()); |
147 | 147 | ||
148 | try | 148 | try |
149 | { | ||
150 | using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) | ||
149 | { | 151 | { |
150 | using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) | 152 | if (dbReader.Read()) |
151 | { | 153 | { |
152 | if (dbReader.Read()) | 154 | asset = new AssetBase(assetID, (string)dbReader["name"], (sbyte)dbReader["assetType"]); |
153 | { | 155 | asset.Data = (byte[]) dbReader["data"]; |
154 | asset = new AssetBase(); | 156 | asset.Description = (string) dbReader["description"]; |
155 | asset.Data = (byte[])dbReader["data"]; | 157 | |
156 | asset.Description = (string)dbReader["description"]; | 158 | string local = dbReader["local"].ToString(); |
157 | asset.FullID = assetID; | 159 | if (local.Equals("1") || local.Equals("true", StringComparison.InvariantCultureIgnoreCase)) |
158 | 160 | asset.Local = true; | |
159 | string local = dbReader["local"].ToString(); | 161 | else |
160 | if (local.Equals("1") || local.Equals("true", StringComparison.InvariantCultureIgnoreCase)) | 162 | asset.Local = false; |
161 | asset.Local = true; | 163 | |
162 | else | 164 | asset.Temporary = Convert.ToBoolean(dbReader["temporary"]); |
163 | asset.Local = false; | ||
164 | |||
165 | asset.Name = (string)dbReader["name"]; | ||
166 | asset.Type = (sbyte)dbReader["assetType"]; | ||
167 | asset.Temporary = Convert.ToBoolean(dbReader["temporary"]); | ||
168 | } | ||
169 | } | 165 | } |
166 | dbReader.Close(); | ||
167 | cmd.Dispose(); | ||
170 | } | 168 | } |
171 | catch (Exception e) | 169 | if (asset != null) |
172 | { | 170 | UpdateAccessTime(asset); |
173 | m_log.ErrorFormat( | 171 | } |
174 | "[ASSETS DB]: MySql failure fetching asset {0}" + Environment.NewLine + e.ToString() | 172 | catch (Exception e) |
175 | + Environment.NewLine + "Reconnecting", assetID); | 173 | { |
176 | _dbConnection.Reconnect(); | 174 | m_log.ErrorFormat( |
177 | } | 175 | "[ASSETS DB]: MySql failure fetching asset {0}" + Environment.NewLine + e.ToString() |
176 | + Environment.NewLine + "Reconnecting", assetID); | ||
177 | _dbConnection.Reconnect(); | ||
178 | } | 178 | } |
179 | } | 179 | } |
180 | return asset; | 180 | return asset; |
@@ -291,27 +291,32 @@ namespace OpenSim.Data.MySQL | |||
291 | { | 291 | { |
292 | _dbConnection.CheckConnection(); | 292 | _dbConnection.CheckConnection(); |
293 | 293 | ||
294 | using (MySqlCommand cmd = new MySqlCommand( | 294 | MySqlCommand cmd = |
295 | "SELECT id FROM assets WHERE id=?id", | 295 | new MySqlCommand( |
296 | _dbConnection.Connection)) | 296 | "SELECT id FROM assets WHERE id=?id", |
297 | { | 297 | _dbConnection.Connection); |
298 | cmd.Parameters.AddWithValue("?id", uuid.ToString()); | ||
299 | 298 | ||
300 | try | 299 | cmd.Parameters.AddWithValue("?id", uuid.ToString()); |
300 | |||
301 | try | ||
302 | { | ||
303 | using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) | ||
301 | { | 304 | { |
302 | using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) | 305 | if (dbReader.Read()) |
303 | { | 306 | { |
304 | if (dbReader.Read()) | 307 | assetExists = true; |
305 | assetExists = true; | ||
306 | } | 308 | } |
309 | |||
310 | dbReader.Close(); | ||
311 | cmd.Dispose(); | ||
307 | } | 312 | } |
308 | catch (Exception e) | 313 | } |
309 | { | 314 | catch (Exception e) |
310 | m_log.ErrorFormat( | 315 | { |
311 | "[ASSETS DB]: MySql failure fetching asset {0}" + Environment.NewLine + e.ToString() | 316 | m_log.ErrorFormat( |
312 | + Environment.NewLine + "Attempting reconnection", uuid); | 317 | "[ASSETS DB]: MySql failure fetching asset {0}" + Environment.NewLine + e.ToString() |
313 | _dbConnection.Reconnect(); | 318 | + Environment.NewLine + "Attempting reconnection", uuid); |
314 | } | 319 | _dbConnection.Reconnect(); |
315 | } | 320 | } |
316 | } | 321 | } |
317 | 322 | ||
diff --git a/OpenSim/Data/MySQL/MySQLAuthenticationData.cs b/OpenSim/Data/MySQL/MySQLAuthenticationData.cs index 0780936..e508b52 100644 --- a/OpenSim/Data/MySQL/MySQLAuthenticationData.cs +++ b/OpenSim/Data/MySQL/MySQLAuthenticationData.cs | |||
@@ -55,7 +55,9 @@ namespace OpenSim.Data.MySQL | |||
55 | AuthenticationData ret = new AuthenticationData(); | 55 | AuthenticationData ret = new AuthenticationData(); |
56 | ret.Data = new Dictionary<string, object>(); | 56 | ret.Data = new Dictionary<string, object>(); |
57 | 57 | ||
58 | MySqlCommand cmd = new MySqlCommand("select * from `" + m_Realm + "` where UUID = ?principalID"); | 58 | MySqlCommand cmd = new MySqlCommand( |
59 | "select * from `"+m_Realm+"` where UUID = ?principalID" | ||
60 | ); | ||
59 | 61 | ||
60 | cmd.Parameters.AddWithValue("?principalID", principalID.ToString()); | 62 | cmd.Parameters.AddWithValue("?principalID", principalID.ToString()); |
61 | 63 | ||
@@ -82,14 +84,16 @@ namespace OpenSim.Data.MySQL | |||
82 | ret.Data[s] = result[s].ToString(); | 84 | ret.Data[s] = result[s].ToString(); |
83 | } | 85 | } |
84 | 86 | ||
85 | CloseDBConnection(result, cmd); | 87 | result.Close(); |
88 | CloseReaderCommand(cmd); | ||
89 | |||
86 | return ret; | 90 | return ret; |
87 | } | 91 | } |
88 | else | 92 | |
89 | { | 93 | result.Close(); |
90 | CloseDBConnection(result, cmd); | 94 | CloseReaderCommand(cmd); |
91 | return null; | 95 | |
92 | } | 96 | return null; |
93 | } | 97 | } |
94 | 98 | ||
95 | public bool Store(AuthenticationData data) | 99 | public bool Store(AuthenticationData data) |
diff --git a/OpenSim/Data/MySQL/MySQLEstateData.cs b/OpenSim/Data/MySQL/MySQLEstateData.cs index 7166b29..e8694fc 100644 --- a/OpenSim/Data/MySQL/MySQLEstateData.cs +++ b/OpenSim/Data/MySQL/MySQLEstateData.cs | |||
@@ -95,17 +95,21 @@ namespace OpenSim.Data.MySQL | |||
95 | 95 | ||
96 | protected void GetWaitTimeout() | 96 | protected void GetWaitTimeout() |
97 | { | 97 | { |
98 | using (MySqlCommand cmd = new MySqlCommand(m_waitTimeoutSelect, m_connection)) | 98 | MySqlCommand cmd = new MySqlCommand(m_waitTimeoutSelect, |
99 | m_connection); | ||
100 | |||
101 | using (MySqlDataReader dbReader = | ||
102 | cmd.ExecuteReader(CommandBehavior.SingleRow)) | ||
99 | { | 103 | { |
100 | using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) | 104 | if (dbReader.Read()) |
101 | { | 105 | { |
102 | if (dbReader.Read()) | 106 | m_waitTimeout |
103 | { | 107 | = Convert.ToInt32(dbReader["@@wait_timeout"]) * |
104 | m_waitTimeout | 108 | TimeSpan.TicksPerSecond + m_waitTimeoutLeeway; |
105 | = Convert.ToInt32(dbReader["@@wait_timeout"]) * | ||
106 | TimeSpan.TicksPerSecond + m_waitTimeoutLeeway; | ||
107 | } | ||
108 | } | 109 | } |
110 | |||
111 | dbReader.Close(); | ||
112 | cmd.Dispose(); | ||
109 | } | 113 | } |
110 | 114 | ||
111 | m_lastConnectionUse = DateTime.Now.Ticks; | 115 | m_lastConnectionUse = DateTime.Now.Ticks; |
@@ -143,103 +147,110 @@ namespace OpenSim.Data.MySQL | |||
143 | 147 | ||
144 | CheckConnection(); | 148 | CheckConnection(); |
145 | 149 | ||
146 | bool migration = true; | 150 | MySqlCommand cmd = m_connection.CreateCommand(); |
147 | 151 | ||
148 | using (MySqlCommand cmd = m_connection.CreateCommand()) | 152 | cmd.CommandText = sql; |
149 | { | 153 | cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); |
150 | cmd.CommandText = sql; | 154 | |
151 | cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); | 155 | IDataReader r = cmd.ExecuteReader(); |
152 | 156 | ||
153 | using (IDataReader r = cmd.ExecuteReader()) | 157 | if (r.Read()) |
158 | { | ||
159 | foreach (string name in FieldList) | ||
154 | { | 160 | { |
155 | if (r.Read()) | 161 | if (m_FieldMap[name].GetValue(es) is bool) |
156 | { | 162 | { |
157 | migration = false; | 163 | int v = Convert.ToInt32(r[name]); |
158 | 164 | if (v != 0) | |
159 | foreach (string name in FieldList) | 165 | m_FieldMap[name].SetValue(es, true); |
160 | { | 166 | else |
161 | if (m_FieldMap[name].GetValue(es) is bool) | 167 | m_FieldMap[name].SetValue(es, false); |
162 | { | 168 | } |
163 | int v = Convert.ToInt32(r[name]); | 169 | else if (m_FieldMap[name].GetValue(es) is UUID) |
164 | if (v != 0) | 170 | { |
165 | m_FieldMap[name].SetValue(es, true); | 171 | UUID uuid = UUID.Zero; |
166 | else | 172 | |
167 | m_FieldMap[name].SetValue(es, false); | 173 | UUID.TryParse(r[name].ToString(), out uuid); |
168 | } | 174 | m_FieldMap[name].SetValue(es, uuid); |
169 | else if (m_FieldMap[name].GetValue(es) is UUID) | 175 | } |
170 | { | 176 | else |
171 | UUID uuid = UUID.Zero; | 177 | { |
172 | 178 | m_FieldMap[name].SetValue(es, r[name]); | |
173 | UUID.TryParse(r[name].ToString(), out uuid); | ||
174 | m_FieldMap[name].SetValue(es, uuid); | ||
175 | } | ||
176 | else | ||
177 | { | ||
178 | m_FieldMap[name].SetValue(es, r[name]); | ||
179 | } | ||
180 | } | ||
181 | } | 179 | } |
182 | } | 180 | } |
181 | r.Close(); | ||
183 | } | 182 | } |
184 | 183 | else | |
185 | if (migration) | ||
186 | { | 184 | { |
187 | // Migration case | 185 | // Migration case |
186 | // | ||
187 | r.Close(); | ||
188 | |||
188 | List<string> names = new List<string>(FieldList); | 189 | List<string> names = new List<string>(FieldList); |
189 | 190 | ||
190 | names.Remove("EstateID"); | 191 | names.Remove("EstateID"); |
191 | 192 | ||
192 | sql = "insert into estate_settings (" + String.Join(",", names.ToArray()) + ") values ( ?" + String.Join(", ?", names.ToArray()) + ")"; | 193 | sql = "insert into estate_settings (" + String.Join(",", names.ToArray()) + ") values ( ?" + String.Join(", ?", names.ToArray()) + ")"; |
193 | 194 | ||
194 | using (MySqlCommand cmd = m_connection.CreateCommand()) | 195 | cmd.CommandText = sql; |
195 | { | 196 | cmd.Parameters.Clear(); |
196 | cmd.CommandText = sql; | ||
197 | cmd.Parameters.Clear(); | ||
198 | 197 | ||
199 | foreach (string name in FieldList) | 198 | foreach (string name in FieldList) |
199 | { | ||
200 | if (m_FieldMap[name].GetValue(es) is bool) | ||
200 | { | 201 | { |
201 | if (m_FieldMap[name].GetValue(es) is bool) | 202 | if ((bool)m_FieldMap[name].GetValue(es)) |
202 | { | 203 | cmd.Parameters.AddWithValue("?" + name, "1"); |
203 | if ((bool)m_FieldMap[name].GetValue(es)) | ||
204 | cmd.Parameters.AddWithValue("?" + name, "1"); | ||
205 | else | ||
206 | cmd.Parameters.AddWithValue("?" + name, "0"); | ||
207 | } | ||
208 | else | 204 | else |
209 | { | 205 | cmd.Parameters.AddWithValue("?" + name, "0"); |
210 | cmd.Parameters.AddWithValue("?" + name, m_FieldMap[name].GetValue(es).ToString()); | ||
211 | } | ||
212 | } | 206 | } |
207 | else | ||
208 | { | ||
209 | cmd.Parameters.AddWithValue("?" + name, m_FieldMap[name].GetValue(es).ToString()); | ||
210 | } | ||
211 | } | ||
213 | 212 | ||
214 | cmd.ExecuteNonQuery(); | 213 | cmd.ExecuteNonQuery(); |
215 | 214 | ||
216 | cmd.CommandText = "select LAST_INSERT_ID() as id"; | 215 | cmd.CommandText = "select LAST_INSERT_ID() as id"; |
217 | cmd.Parameters.Clear(); | 216 | cmd.Parameters.Clear(); |
218 | 217 | ||
219 | using (IDataReader r = cmd.ExecuteReader()) | 218 | r = cmd.ExecuteReader(); |
220 | { | 219 | |
221 | r.Read(); | 220 | r.Read(); |
222 | es.EstateID = Convert.ToUInt32(r["id"]); | ||
223 | } | ||
224 | 221 | ||
225 | cmd.CommandText = "insert into estate_map values (?RegionID, ?EstateID)"; | 222 | es.EstateID = Convert.ToUInt32(r["id"]); |
226 | cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); | ||
227 | cmd.Parameters.AddWithValue("?EstateID", es.EstateID.ToString()); | ||
228 | 223 | ||
229 | // This will throw on dupe key | 224 | r.Close(); |
230 | try { cmd.ExecuteNonQuery(); } | 225 | |
231 | catch (Exception) { } | 226 | cmd.CommandText = "insert into estate_map values (?RegionID, ?EstateID)"; |
227 | cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); | ||
228 | cmd.Parameters.AddWithValue("?EstateID", es.EstateID.ToString()); | ||
232 | 229 | ||
233 | // Munge and transfer the ban list | 230 | // This will throw on dupe key |
234 | cmd.Parameters.Clear(); | 231 | try |
235 | cmd.CommandText = "insert into estateban select " + es.EstateID.ToString() + ", bannedUUID, bannedIp, bannedIpHostMask, '' from regionban where regionban.regionUUID = ?UUID"; | 232 | { |
236 | cmd.Parameters.AddWithValue("?UUID", regionID.ToString()); | 233 | cmd.ExecuteNonQuery(); |
234 | } | ||
235 | catch (Exception) | ||
236 | { | ||
237 | } | ||
237 | 238 | ||
238 | try { cmd.ExecuteNonQuery(); } | 239 | // Munge and transfer the ban list |
239 | catch (Exception) { } | 240 | // |
241 | cmd.Parameters.Clear(); | ||
242 | cmd.CommandText = "insert into estateban select " + es.EstateID.ToString() + ", bannedUUID, bannedIp, bannedIpHostMask, '' from regionban where regionban.regionUUID = ?UUID"; | ||
243 | cmd.Parameters.AddWithValue("?UUID", regionID.ToString()); | ||
240 | 244 | ||
241 | es.Save(); | 245 | try |
246 | { | ||
247 | cmd.ExecuteNonQuery(); | ||
248 | } | ||
249 | catch (Exception) | ||
250 | { | ||
242 | } | 251 | } |
252 | |||
253 | es.Save(); | ||
243 | } | 254 | } |
244 | 255 | ||
245 | LoadBanList(es); | 256 | LoadBanList(es); |
@@ -256,28 +267,27 @@ namespace OpenSim.Data.MySQL | |||
256 | 267 | ||
257 | CheckConnection(); | 268 | CheckConnection(); |
258 | 269 | ||
259 | using (MySqlCommand cmd = m_connection.CreateCommand()) | 270 | MySqlCommand cmd = m_connection.CreateCommand(); |
260 | { | ||
261 | cmd.CommandText = sql; | ||
262 | 271 | ||
263 | foreach (string name in FieldList) | 272 | cmd.CommandText = sql; |
273 | |||
274 | foreach (string name in FieldList) | ||
275 | { | ||
276 | if (m_FieldMap[name].GetValue(es) is bool) | ||
264 | { | 277 | { |
265 | if (m_FieldMap[name].GetValue(es) is bool) | 278 | if ((bool)m_FieldMap[name].GetValue(es)) |
266 | { | 279 | cmd.Parameters.AddWithValue("?" + name, "1"); |
267 | if ((bool)m_FieldMap[name].GetValue(es)) | ||
268 | cmd.Parameters.AddWithValue("?" + name, "1"); | ||
269 | else | ||
270 | cmd.Parameters.AddWithValue("?" + name, "0"); | ||
271 | } | ||
272 | else | 280 | else |
273 | { | 281 | cmd.Parameters.AddWithValue("?" + name, "0"); |
274 | cmd.Parameters.AddWithValue("?" + name, m_FieldMap[name].GetValue(es).ToString()); | 282 | } |
275 | } | 283 | else |
284 | { | ||
285 | cmd.Parameters.AddWithValue("?" + name, m_FieldMap[name].GetValue(es).ToString()); | ||
276 | } | 286 | } |
277 | |||
278 | cmd.ExecuteNonQuery(); | ||
279 | } | 287 | } |
280 | 288 | ||
289 | cmd.ExecuteNonQuery(); | ||
290 | |||
281 | SaveBanList(es); | 291 | SaveBanList(es); |
282 | SaveUUIDList(es.EstateID, "estate_managers", es.EstateManagers); | 292 | SaveUUIDList(es.EstateID, "estate_managers", es.EstateManagers); |
283 | SaveUUIDList(es.EstateID, "estate_users", es.EstateAccess); | 293 | SaveUUIDList(es.EstateID, "estate_users", es.EstateAccess); |
@@ -290,52 +300,50 @@ namespace OpenSim.Data.MySQL | |||
290 | 300 | ||
291 | CheckConnection(); | 301 | CheckConnection(); |
292 | 302 | ||
293 | using (MySqlCommand cmd = m_connection.CreateCommand()) | 303 | MySqlCommand cmd = m_connection.CreateCommand(); |
294 | { | ||
295 | cmd.CommandText = "select bannedUUID from estateban where EstateID = ?EstateID"; | ||
296 | cmd.Parameters.AddWithValue("?EstateID", es.EstateID); | ||
297 | 304 | ||
298 | using (IDataReader r = cmd.ExecuteReader()) | 305 | cmd.CommandText = "select bannedUUID from estateban where EstateID = ?EstateID"; |
299 | { | 306 | cmd.Parameters.AddWithValue("?EstateID", es.EstateID); |
300 | while (r.Read()) | ||
301 | { | ||
302 | EstateBan eb = new EstateBan(); | ||
303 | 307 | ||
304 | UUID uuid = new UUID(); | 308 | IDataReader r = cmd.ExecuteReader(); |
305 | UUID.TryParse(r["bannedUUID"].ToString(), out uuid); | ||
306 | 309 | ||
307 | eb.BannedUserID = uuid; | 310 | while (r.Read()) |
308 | eb.BannedHostAddress = "0.0.0.0"; | 311 | { |
309 | eb.BannedHostIPMask = "0.0.0.0"; | 312 | EstateBan eb = new EstateBan(); |
310 | es.AddBan(eb); | 313 | |
311 | } | 314 | UUID uuid = new UUID(); |
312 | } | 315 | UUID.TryParse(r["bannedUUID"].ToString(), out uuid); |
316 | |||
317 | eb.BannedUserID = uuid; | ||
318 | eb.BannedHostAddress = "0.0.0.0"; | ||
319 | eb.BannedHostIPMask = "0.0.0.0"; | ||
320 | es.AddBan(eb); | ||
313 | } | 321 | } |
322 | r.Close(); | ||
314 | } | 323 | } |
315 | 324 | ||
316 | private void SaveBanList(EstateSettings es) | 325 | private void SaveBanList(EstateSettings es) |
317 | { | 326 | { |
318 | CheckConnection(); | 327 | CheckConnection(); |
319 | 328 | ||
320 | using (MySqlCommand cmd = m_connection.CreateCommand()) | 329 | MySqlCommand cmd = m_connection.CreateCommand(); |
321 | { | ||
322 | cmd.CommandText = "delete from estateban where EstateID = ?EstateID"; | ||
323 | cmd.Parameters.AddWithValue("?EstateID", es.EstateID.ToString()); | ||
324 | 330 | ||
325 | cmd.ExecuteNonQuery(); | 331 | cmd.CommandText = "delete from estateban where EstateID = ?EstateID"; |
332 | cmd.Parameters.AddWithValue("?EstateID", es.EstateID.ToString()); | ||
326 | 333 | ||
327 | cmd.Parameters.Clear(); | 334 | cmd.ExecuteNonQuery(); |
328 | 335 | ||
329 | cmd.CommandText = "insert into estateban (EstateID, bannedUUID, bannedIp, bannedIpHostMask, bannedNameMask) values ( ?EstateID, ?bannedUUID, '', '', '' )"; | 336 | cmd.Parameters.Clear(); |
330 | 337 | ||
331 | foreach (EstateBan b in es.EstateBans) | 338 | cmd.CommandText = "insert into estateban (EstateID, bannedUUID, bannedIp, bannedIpHostMask, bannedNameMask) values ( ?EstateID, ?bannedUUID, '', '', '' )"; |
332 | { | ||
333 | cmd.Parameters.AddWithValue("?EstateID", es.EstateID.ToString()); | ||
334 | cmd.Parameters.AddWithValue("?bannedUUID", b.BannedUserID.ToString()); | ||
335 | 339 | ||
336 | cmd.ExecuteNonQuery(); | 340 | foreach (EstateBan b in es.EstateBans) |
337 | cmd.Parameters.Clear(); | 341 | { |
338 | } | 342 | cmd.Parameters.AddWithValue("?EstateID", es.EstateID.ToString()); |
343 | cmd.Parameters.AddWithValue("?bannedUUID", b.BannedUserID.ToString()); | ||
344 | |||
345 | cmd.ExecuteNonQuery(); | ||
346 | cmd.Parameters.Clear(); | ||
339 | } | 347 | } |
340 | } | 348 | } |
341 | 349 | ||
@@ -343,25 +351,24 @@ namespace OpenSim.Data.MySQL | |||
343 | { | 351 | { |
344 | CheckConnection(); | 352 | CheckConnection(); |
345 | 353 | ||
346 | using (MySqlCommand cmd = m_connection.CreateCommand()) | 354 | MySqlCommand cmd = m_connection.CreateCommand(); |
347 | { | ||
348 | cmd.CommandText = "delete from " + table + " where EstateID = ?EstateID"; | ||
349 | cmd.Parameters.AddWithValue("?EstateID", EstateID.ToString()); | ||
350 | 355 | ||
351 | cmd.ExecuteNonQuery(); | 356 | cmd.CommandText = "delete from " + table + " where EstateID = ?EstateID"; |
357 | cmd.Parameters.AddWithValue("?EstateID", EstateID.ToString()); | ||
352 | 358 | ||
353 | cmd.Parameters.Clear(); | 359 | cmd.ExecuteNonQuery(); |
354 | 360 | ||
355 | cmd.CommandText = "insert into " + table + " (EstateID, uuid) values ( ?EstateID, ?uuid )"; | 361 | cmd.Parameters.Clear(); |
356 | 362 | ||
357 | foreach (UUID uuid in data) | 363 | cmd.CommandText = "insert into " + table + " (EstateID, uuid) values ( ?EstateID, ?uuid )"; |
358 | { | ||
359 | cmd.Parameters.AddWithValue("?EstateID", EstateID.ToString()); | ||
360 | cmd.Parameters.AddWithValue("?uuid", uuid.ToString()); | ||
361 | 364 | ||
362 | cmd.ExecuteNonQuery(); | 365 | foreach (UUID uuid in data) |
363 | cmd.Parameters.Clear(); | 366 | { |
364 | } | 367 | cmd.Parameters.AddWithValue("?EstateID", EstateID.ToString()); |
368 | cmd.Parameters.AddWithValue("?uuid", uuid.ToString()); | ||
369 | |||
370 | cmd.ExecuteNonQuery(); | ||
371 | cmd.Parameters.Clear(); | ||
365 | } | 372 | } |
366 | } | 373 | } |
367 | 374 | ||
@@ -371,24 +378,23 @@ namespace OpenSim.Data.MySQL | |||
371 | 378 | ||
372 | CheckConnection(); | 379 | CheckConnection(); |
373 | 380 | ||
374 | using (MySqlCommand cmd = m_connection.CreateCommand()) | 381 | MySqlCommand cmd = m_connection.CreateCommand(); |
375 | { | ||
376 | cmd.CommandText = "select uuid from " + table + " where EstateID = ?EstateID"; | ||
377 | cmd.Parameters.AddWithValue("?EstateID", EstateID); | ||
378 | 382 | ||
379 | using (IDataReader r = cmd.ExecuteReader()) | 383 | cmd.CommandText = "select uuid from " + table + " where EstateID = ?EstateID"; |
380 | { | 384 | cmd.Parameters.AddWithValue("?EstateID", EstateID); |
381 | while (r.Read()) | ||
382 | { | ||
383 | // EstateBan eb = new EstateBan(); | ||
384 | 385 | ||
385 | UUID uuid = new UUID(); | 386 | IDataReader r = cmd.ExecuteReader(); |
386 | UUID.TryParse(r["uuid"].ToString(), out uuid); | ||
387 | 387 | ||
388 | uuids.Add(uuid); | 388 | while (r.Read()) |
389 | } | 389 | { |
390 | } | 390 | // EstateBan eb = new EstateBan(); |
391 | |||
392 | UUID uuid = new UUID(); | ||
393 | UUID.TryParse(r["uuid"].ToString(), out uuid); | ||
394 | |||
395 | uuids.Add(uuid); | ||
391 | } | 396 | } |
397 | r.Close(); | ||
392 | 398 | ||
393 | return uuids.ToArray(); | 399 | return uuids.ToArray(); |
394 | } | 400 | } |
diff --git a/OpenSim/Data/MySQL/MySQLFramework.cs b/OpenSim/Data/MySQL/MySQLFramework.cs index ccd1ab0..fca0ca5 100644 --- a/OpenSim/Data/MySQL/MySQLFramework.cs +++ b/OpenSim/Data/MySQL/MySQLFramework.cs | |||
@@ -40,10 +40,6 @@ namespace OpenSim.Data.MySQL | |||
40 | /// </summary> | 40 | /// </summary> |
41 | public class MySqlFramework | 41 | public class MySqlFramework |
42 | { | 42 | { |
43 | private static readonly log4net.ILog m_log = | ||
44 | log4net.LogManager.GetLogger( | ||
45 | System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | ||
46 | |||
47 | protected MySqlConnection m_Connection; | 43 | protected MySqlConnection m_Connection; |
48 | 44 | ||
49 | protected MySqlFramework(string connectionString) | 45 | protected MySqlFramework(string connectionString) |
@@ -73,11 +69,11 @@ namespace OpenSim.Data.MySQL | |||
73 | } | 69 | } |
74 | catch (MySqlException e) | 70 | catch (MySqlException e) |
75 | { | 71 | { |
76 | m_log.Error(e.Message, e); | ||
77 | if (errorSeen) | 72 | if (errorSeen) |
78 | throw; | 73 | throw; |
79 | 74 | ||
80 | // This is "Server has gone away" and "Server lost" | 75 | // This is "Server has gone away" and "Server lost" |
76 | // | ||
81 | if (e.Number == 2006 || e.Number == 2013) | 77 | if (e.Number == 2006 || e.Number == 2013) |
82 | { | 78 | { |
83 | errorSeen = true; | 79 | errorSeen = true; |
@@ -96,7 +92,6 @@ namespace OpenSim.Data.MySQL | |||
96 | } | 92 | } |
97 | catch (Exception e) | 93 | catch (Exception e) |
98 | { | 94 | { |
99 | m_log.Error(e.Message, e); | ||
100 | return 0; | 95 | return 0; |
101 | } | 96 | } |
102 | } | 97 | } |
@@ -113,11 +108,11 @@ namespace OpenSim.Data.MySQL | |||
113 | return cmd.ExecuteReader(); | 108 | return cmd.ExecuteReader(); |
114 | } | 109 | } |
115 | 110 | ||
116 | protected void CloseDBConnection(IDataReader reader, MySqlCommand cmd) | 111 | protected void CloseReaderCommand(MySqlCommand cmd) |
117 | { | 112 | { |
118 | reader.Close(); | ||
119 | cmd.Connection.Close(); | 113 | cmd.Connection.Close(); |
120 | cmd.Connection.Dispose(); | 114 | cmd.Connection.Dispose(); |
115 | cmd.Dispose(); | ||
121 | } | 116 | } |
122 | } | 117 | } |
123 | } | 118 | } |
diff --git a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs new file mode 100644 index 0000000..4eb4a24 --- /dev/null +++ b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs | |||
@@ -0,0 +1,200 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Data; | ||
31 | using System.Reflection; | ||
32 | using log4net; | ||
33 | using MySql.Data.MySqlClient; | ||
34 | using OpenMetaverse; | ||
35 | using OpenSim.Framework; | ||
36 | using OpenSim.Region.Framework.Interfaces; | ||
37 | |||
38 | namespace OpenSim.Data.MySQL | ||
39 | { | ||
40 | public class MySQLGenericTableHandler<T> : MySqlFramework where T: struct | ||
41 | { | ||
42 | private static readonly ILog m_log = | ||
43 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
44 | |||
45 | |||
46 | protected Dictionary<string, FieldInfo> m_Fields = | ||
47 | new Dictionary<string, FieldInfo>(); | ||
48 | |||
49 | protected List<string> m_ColumnNames = null; | ||
50 | protected string m_Realm; | ||
51 | protected FieldInfo m_DataField = null; | ||
52 | |||
53 | public MySQLGenericTableHandler(string connectionString, | ||
54 | string realm, string storeName) : base(connectionString) | ||
55 | { | ||
56 | m_Realm = realm; | ||
57 | if (storeName != String.Empty) | ||
58 | { | ||
59 | Assembly assem = GetType().Assembly; | ||
60 | |||
61 | Migration m = new Migration(m_Connection, assem, storeName); | ||
62 | m.Update(); | ||
63 | } | ||
64 | |||
65 | Type t = typeof(T); | ||
66 | FieldInfo[] fields = t.GetFields(BindingFlags.NonPublic | | ||
67 | BindingFlags.Instance | | ||
68 | BindingFlags.DeclaredOnly); | ||
69 | |||
70 | if (fields.Length == 0) | ||
71 | return; | ||
72 | |||
73 | foreach (FieldInfo f in fields) | ||
74 | { | ||
75 | if (f.Name != "Data") | ||
76 | m_Fields[f.Name] = f; | ||
77 | else | ||
78 | m_DataField = f; | ||
79 | } | ||
80 | } | ||
81 | |||
82 | private void CheckColumnNames(IDataReader reader) | ||
83 | { | ||
84 | if (m_ColumnNames != null) | ||
85 | return; | ||
86 | |||
87 | m_ColumnNames = new List<string>(); | ||
88 | |||
89 | DataTable schemaTable = reader.GetSchemaTable(); | ||
90 | foreach (DataRow row in schemaTable.Rows) | ||
91 | { | ||
92 | if (row["ColumnName"] != null && | ||
93 | (!m_Fields.ContainsKey(row["ColumnName"].ToString()))) | ||
94 | m_ColumnNames.Add(row["ColumnName"].ToString()); | ||
95 | } | ||
96 | } | ||
97 | |||
98 | public T[] Get(string field, string key) | ||
99 | { | ||
100 | return Get(new string[] { field }, new string[] { key }); | ||
101 | } | ||
102 | |||
103 | public T[] Get(string[] fields, string[] keys) | ||
104 | { | ||
105 | if (fields.Length != keys.Length) | ||
106 | return new T[0]; | ||
107 | |||
108 | List<string> terms = new List<string>(); | ||
109 | |||
110 | MySqlCommand cmd = new MySqlCommand(); | ||
111 | |||
112 | for (int i = 0 ; i < fields.Length ; i++) | ||
113 | { | ||
114 | cmd.Parameters.AddWithValue(fields[i], keys[i]); | ||
115 | terms.Add(fields[i] + " = ?" + fields[i]); | ||
116 | } | ||
117 | |||
118 | string where = String.Join(" and ", terms.ToArray()); | ||
119 | |||
120 | string query = String.Format("select * from {0} where {1}", | ||
121 | m_Realm, where); | ||
122 | |||
123 | cmd.CommandText = query; | ||
124 | |||
125 | return DoQuery(cmd); | ||
126 | } | ||
127 | |||
128 | protected T[] DoQuery(MySqlCommand cmd) | ||
129 | { | ||
130 | IDataReader reader = ExecuteReader(cmd); | ||
131 | if (reader == null) | ||
132 | return new T[0]; | ||
133 | |||
134 | CheckColumnNames(reader); | ||
135 | |||
136 | List<T> result = new List<T>(); | ||
137 | |||
138 | while(reader.Read()) | ||
139 | { | ||
140 | T row = new T(); | ||
141 | |||
142 | foreach (string name in m_Fields.Keys) | ||
143 | { | ||
144 | if (m_Fields[name].GetValue(row) is bool) | ||
145 | { | ||
146 | int v = Convert.ToInt32(reader[name]); | ||
147 | m_Fields[name].SetValue(row, v != 0 ? true : false); | ||
148 | } | ||
149 | else if(m_Fields[name].GetValue(row) is UUID) | ||
150 | { | ||
151 | UUID uuid = UUID.Zero; | ||
152 | |||
153 | UUID.TryParse(reader[name].ToString(), out uuid); | ||
154 | m_Fields[name].SetValue(row, uuid); | ||
155 | } | ||
156 | else | ||
157 | { | ||
158 | m_Fields[name].SetValue(row, reader[name]); | ||
159 | } | ||
160 | } | ||
161 | |||
162 | if (m_DataField != null) | ||
163 | { | ||
164 | Dictionary<string, string> data = | ||
165 | new Dictionary<string, string>(); | ||
166 | |||
167 | foreach (string col in m_ColumnNames) | ||
168 | data[col] = reader[col].ToString(); | ||
169 | |||
170 | m_DataField.SetValue(row, data); | ||
171 | } | ||
172 | |||
173 | result.Add(row); | ||
174 | } | ||
175 | |||
176 | CloseReaderCommand(cmd); | ||
177 | |||
178 | return result.ToArray(); | ||
179 | } | ||
180 | |||
181 | public T[] Get(string where) | ||
182 | { | ||
183 | MySqlCommand cmd = new MySqlCommand(); | ||
184 | |||
185 | string query = String.Format("select * from {0} where {1}", | ||
186 | m_Realm, where); | ||
187 | |||
188 | cmd.CommandText = query; | ||
189 | |||
190 | return DoQuery(cmd); | ||
191 | } | ||
192 | |||
193 | public void Store(T row) | ||
194 | { | ||
195 | MySqlCommand cmd = new MySqlCommand(); | ||
196 | |||
197 | string query = ""; | ||
198 | } | ||
199 | } | ||
200 | } | ||
diff --git a/OpenSim/Data/MySQL/MySQLGridData.cs b/OpenSim/Data/MySQL/MySQLGridData.cs index 38cb3b7..1ec2609 100644 --- a/OpenSim/Data/MySQL/MySQLGridData.cs +++ b/OpenSim/Data/MySQL/MySQLGridData.cs | |||
@@ -197,27 +197,29 @@ namespace OpenSim.Data.MySQL | |||
197 | param["?xmax"] = xmax.ToString(); | 197 | param["?xmax"] = xmax.ToString(); |
198 | param["?ymax"] = ymax.ToString(); | 198 | param["?ymax"] = ymax.ToString(); |
199 | 199 | ||
200 | using (IDbCommand result = dbm.Manager.Query( | 200 | IDbCommand result = |
201 | dbm.Manager.Query( | ||
201 | "SELECT * FROM regions WHERE locX >= ?xmin AND locX <= ?xmax AND locY >= ?ymin AND locY <= ?ymax", | 202 | "SELECT * FROM regions WHERE locX >= ?xmin AND locX <= ?xmax AND locY >= ?ymin AND locY <= ?ymax", |
202 | param)) | 203 | param); |
203 | { | 204 | IDataReader reader = result.ExecuteReader(); |
204 | using (IDataReader reader = result.ExecuteReader()) | ||
205 | { | ||
206 | RegionProfileData row; | ||
207 | 205 | ||
208 | List<RegionProfileData> rows = new List<RegionProfileData>(); | 206 | RegionProfileData row; |
209 | 207 | ||
210 | while ((row = dbm.Manager.readSimRow(reader)) != null) | 208 | List<RegionProfileData> rows = new List<RegionProfileData>(); |
211 | rows.Add(row); | ||
212 | 209 | ||
213 | return rows.ToArray(); | 210 | while ((row = dbm.Manager.readSimRow(reader)) != null) |
214 | } | 211 | { |
212 | rows.Add(row); | ||
215 | } | 213 | } |
214 | reader.Close(); | ||
215 | result.Dispose(); | ||
216 | |||
217 | return rows.ToArray(); | ||
216 | } | 218 | } |
217 | catch (Exception e) | 219 | catch (Exception e) |
218 | { | 220 | { |
219 | dbm.Manager.Reconnect(); | 221 | dbm.Manager.Reconnect(); |
220 | m_log.Error(e.Message, e); | 222 | m_log.Error(e.ToString()); |
221 | return null; | 223 | return null; |
222 | } | 224 | } |
223 | finally | 225 | finally |
@@ -241,27 +243,29 @@ namespace OpenSim.Data.MySQL | |||
241 | Dictionary<string, object> param = new Dictionary<string, object>(); | 243 | Dictionary<string, object> param = new Dictionary<string, object>(); |
242 | param["?name"] = namePrefix + "%"; | 244 | param["?name"] = namePrefix + "%"; |
243 | 245 | ||
244 | using (IDbCommand result = dbm.Manager.Query( | 246 | IDbCommand result = |
245 | "SELECT * FROM regions WHERE regionName LIKE ?name", | 247 | dbm.Manager.Query( |
246 | param)) | 248 | "SELECT * FROM regions WHERE regionName LIKE ?name", |
247 | { | 249 | param); |
248 | using (IDataReader reader = result.ExecuteReader()) | 250 | IDataReader reader = result.ExecuteReader(); |
249 | { | ||
250 | RegionProfileData row; | ||
251 | 251 | ||
252 | List<RegionProfileData> rows = new List<RegionProfileData>(); | 252 | RegionProfileData row; |
253 | 253 | ||
254 | while (rows.Count < maxNum && (row = dbm.Manager.readSimRow(reader)) != null) | 254 | List<RegionProfileData> rows = new List<RegionProfileData>(); |
255 | rows.Add(row); | ||
256 | 255 | ||
257 | return rows; | 256 | while (rows.Count < maxNum && (row = dbm.Manager.readSimRow(reader)) != null) |
258 | } | 257 | { |
258 | rows.Add(row); | ||
259 | } | 259 | } |
260 | reader.Close(); | ||
261 | result.Dispose(); | ||
262 | |||
263 | return rows; | ||
260 | } | 264 | } |
261 | catch (Exception e) | 265 | catch (Exception e) |
262 | { | 266 | { |
263 | dbm.Manager.Reconnect(); | 267 | dbm.Manager.Reconnect(); |
264 | m_log.Error(e.Message, e); | 268 | m_log.Error(e.ToString()); |
265 | return null; | 269 | return null; |
266 | } | 270 | } |
267 | finally | 271 | finally |
@@ -282,21 +286,21 @@ namespace OpenSim.Data.MySQL | |||
282 | try | 286 | try |
283 | { | 287 | { |
284 | Dictionary<string, object> param = new Dictionary<string, object>(); | 288 | Dictionary<string, object> param = new Dictionary<string, object>(); |
285 | param["?handle"] = handle.ToString(); | 289 | param["?handle"] = handle.ToString(); |
286 | 290 | ||
287 | using (IDbCommand result = dbm.Manager.Query("SELECT * FROM regions WHERE regionHandle = ?handle", param)) | 291 | IDbCommand result = dbm.Manager.Query("SELECT * FROM regions WHERE regionHandle = ?handle", param); |
288 | { | 292 | IDataReader reader = result.ExecuteReader(); |
289 | using (IDataReader reader = result.ExecuteReader()) | 293 | |
290 | { | 294 | RegionProfileData row = dbm.Manager.readSimRow(reader); |
291 | RegionProfileData row = dbm.Manager.readSimRow(reader); | 295 | reader.Close(); |
292 | return row; | 296 | result.Dispose(); |
293 | } | 297 | |
298 | return row; | ||
294 | } | 299 | } |
295 | } | ||
296 | catch (Exception e) | 300 | catch (Exception e) |
297 | { | 301 | { |
298 | dbm.Manager.Reconnect(); | 302 | dbm.Manager.Reconnect(); |
299 | m_log.Error(e.Message, e); | 303 | m_log.Error(e.ToString()); |
300 | return null; | 304 | return null; |
301 | } | 305 | } |
302 | finally | 306 | finally |
@@ -317,24 +321,23 @@ namespace OpenSim.Data.MySQL | |||
317 | try | 321 | try |
318 | { | 322 | { |
319 | Dictionary<string, object> param = new Dictionary<string, object>(); | 323 | Dictionary<string, object> param = new Dictionary<string, object>(); |
320 | param["?uuid"] = uuid.ToString(); | 324 | param["?uuid"] = uuid.ToString(); |
321 | 325 | ||
322 | using (IDbCommand result = dbm.Manager.Query("SELECT * FROM regions WHERE uuid = ?uuid", param)) | 326 | IDbCommand result = dbm.Manager.Query("SELECT * FROM regions WHERE uuid = ?uuid", param); |
323 | { | 327 | IDataReader reader = result.ExecuteReader(); |
324 | using (IDataReader reader = result.ExecuteReader()) | 328 | |
325 | { | 329 | RegionProfileData row = dbm.Manager.readSimRow(reader); |
326 | RegionProfileData row = dbm.Manager.readSimRow(reader); | 330 | reader.Close(); |
327 | return row; | 331 | result.Dispose(); |
328 | } | 332 | |
333 | return row; | ||
329 | } | 334 | } |
330 | } | ||
331 | catch (Exception e) | 335 | catch (Exception e) |
332 | { | 336 | { |
333 | dbm.Manager.Reconnect(); | 337 | dbm.Manager.Reconnect(); |
334 | m_log.Error(e.Message, e); | 338 | m_log.Error(e.ToString()); |
335 | return null; | 339 | return null; |
336 | } | 340 | } finally |
337 | finally | ||
338 | { | 341 | { |
339 | dbm.Release(); | 342 | dbm.Release(); |
340 | } | 343 | } |
@@ -356,21 +359,22 @@ namespace OpenSim.Data.MySQL | |||
356 | // Add % because this is a like query. | 359 | // Add % because this is a like query. |
357 | param["?regionName"] = regionName + "%"; | 360 | param["?regionName"] = regionName + "%"; |
358 | // Order by statement will return shorter matches first. Only returns one record or no record. | 361 | // Order by statement will return shorter matches first. Only returns one record or no record. |
359 | using (IDbCommand result = dbm.Manager.Query( | 362 | IDbCommand result = |
360 | "SELECT * FROM regions WHERE regionName like ?regionName order by LENGTH(regionName) asc LIMIT 1", | 363 | dbm.Manager.Query( |
361 | param)) | 364 | "SELECT * FROM regions WHERE regionName like ?regionName order by LENGTH(regionName) asc LIMIT 1", |
362 | { | 365 | param); |
363 | using (IDataReader reader = result.ExecuteReader()) | 366 | IDataReader reader = result.ExecuteReader(); |
364 | { | 367 | |
365 | RegionProfileData row = dbm.Manager.readSimRow(reader); | 368 | RegionProfileData row = dbm.Manager.readSimRow(reader); |
366 | return row; | 369 | reader.Close(); |
367 | } | 370 | result.Dispose(); |
368 | } | 371 | |
372 | return row; | ||
369 | } | 373 | } |
370 | catch (Exception e) | 374 | catch (Exception e) |
371 | { | 375 | { |
372 | dbm.Manager.Reconnect(); | 376 | dbm.Manager.Reconnect(); |
373 | m_log.Error(e.Message, e); | 377 | m_log.Error(e.ToString()); |
374 | return null; | 378 | return null; |
375 | } | 379 | } |
376 | finally | 380 | finally |
@@ -378,7 +382,6 @@ namespace OpenSim.Data.MySQL | |||
378 | dbm.Release(); | 382 | dbm.Release(); |
379 | } | 383 | } |
380 | } | 384 | } |
381 | |||
382 | m_log.Error("[GRID DB]: Searched for a Region Name shorter then 3 characters"); | 385 | m_log.Error("[GRID DB]: Searched for a Region Name shorter then 3 characters"); |
383 | return null; | 386 | return null; |
384 | } | 387 | } |
@@ -391,12 +394,12 @@ namespace OpenSim.Data.MySQL | |||
391 | override public DataResponse StoreProfile(RegionProfileData profile) | 394 | override public DataResponse StoreProfile(RegionProfileData profile) |
392 | { | 395 | { |
393 | MySQLSuperManager dbm = GetLockedConnection(); | 396 | MySQLSuperManager dbm = GetLockedConnection(); |
394 | try | 397 | try { |
395 | { | ||
396 | if (dbm.Manager.insertRegion(profile)) | 398 | if (dbm.Manager.insertRegion(profile)) |
399 | { | ||
397 | return DataResponse.RESPONSE_OK; | 400 | return DataResponse.RESPONSE_OK; |
398 | else | 401 | } |
399 | return DataResponse.RESPONSE_ERROR; | 402 | return DataResponse.RESPONSE_ERROR; |
400 | } | 403 | } |
401 | finally | 404 | finally |
402 | { | 405 | { |
@@ -414,14 +417,14 @@ namespace OpenSim.Data.MySQL | |||
414 | { | 417 | { |
415 | MySQLSuperManager dbm = GetLockedConnection(); | 418 | MySQLSuperManager dbm = GetLockedConnection(); |
416 | 419 | ||
417 | try | 420 | |
418 | { | 421 | try { |
419 | if (dbm.Manager.deleteRegion(uuid)) | 422 | if (dbm.Manager.deleteRegion(uuid)) |
423 | { | ||
420 | return DataResponse.RESPONSE_OK; | 424 | return DataResponse.RESPONSE_OK; |
421 | else | 425 | } |
422 | return DataResponse.RESPONSE_ERROR; | 426 | return DataResponse.RESPONSE_ERROR; |
423 | } | 427 | } finally |
424 | finally | ||
425 | { | 428 | { |
426 | dbm.Release(); | 429 | dbm.Release(); |
427 | } | 430 | } |
@@ -479,26 +482,26 @@ namespace OpenSim.Data.MySQL | |||
479 | try | 482 | try |
480 | { | 483 | { |
481 | Dictionary<string, object> param = new Dictionary<string, object>(); | 484 | Dictionary<string, object> param = new Dictionary<string, object>(); |
482 | param["?x"] = x.ToString(); | 485 | param["?x"] = x.ToString(); |
483 | param["?y"] = y.ToString(); | 486 | param["?y"] = y.ToString(); |
484 | using (IDbCommand result = dbm.Manager.Query( | 487 | IDbCommand result = |
485 | "SELECT * FROM reservations WHERE resXMin <= ?x AND resXMax >= ?x AND resYMin <= ?y AND resYMax >= ?y", | 488 | dbm.Manager.Query( |
486 | param)) | 489 | "SELECT * FROM reservations WHERE resXMin <= ?x AND resXMax >= ?x AND resYMin <= ?y AND resYMax >= ?y", |
487 | { | 490 | param); |
488 | using (IDataReader reader = result.ExecuteReader()) | 491 | IDataReader reader = result.ExecuteReader(); |
489 | { | 492 | |
490 | ReservationData row = dbm.Manager.readReservationRow(reader); | 493 | ReservationData row = dbm.Manager.readReservationRow(reader); |
491 | return row; | 494 | reader.Close(); |
492 | } | 495 | result.Dispose(); |
493 | } | 496 | |
497 | return row; | ||
494 | } | 498 | } |
495 | catch (Exception e) | 499 | catch (Exception e) |
496 | { | 500 | { |
497 | dbm.Manager.Reconnect(); | 501 | dbm.Manager.Reconnect(); |
498 | m_log.Error(e.Message, e); | 502 | m_log.Error(e.ToString()); |
499 | return null; | 503 | return null; |
500 | } | 504 | } finally |
501 | finally | ||
502 | { | 505 | { |
503 | dbm.Release(); | 506 | dbm.Release(); |
504 | } | 507 | } |
diff --git a/OpenSim/Data/MySQL/MySQLInventoryData.cs b/OpenSim/Data/MySQL/MySQLInventoryData.cs index 598971d..0eecf06 100644 --- a/OpenSim/Data/MySQL/MySQLInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLInventoryData.cs | |||
@@ -135,30 +135,30 @@ namespace OpenSim.Data.MySQL | |||
135 | 135 | ||
136 | database.CheckConnection(); | 136 | database.CheckConnection(); |
137 | 137 | ||
138 | using (MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryitems WHERE parentFolderID = ?uuid", | 138 | MySqlCommand result = |
139 | database.Connection)) | 139 | new MySqlCommand("SELECT * FROM inventoryitems WHERE parentFolderID = ?uuid", |
140 | database.Connection); | ||
141 | result.Parameters.AddWithValue("?uuid", folderID.ToString()); | ||
142 | MySqlDataReader reader = result.ExecuteReader(); | ||
143 | |||
144 | while (reader.Read()) | ||
140 | { | 145 | { |
141 | result.Parameters.AddWithValue("?uuid", folderID.ToString()); | 146 | // A null item (because something went wrong) breaks everything in the folder |
147 | InventoryItemBase item = readInventoryItem(reader); | ||
148 | if (item != null) | ||
149 | items.Add(item); | ||
150 | } | ||
142 | 151 | ||
143 | using (MySqlDataReader reader = result.ExecuteReader()) | 152 | reader.Close(); |
144 | { | 153 | result.Dispose(); |
145 | while (reader.Read()) | ||
146 | { | ||
147 | // A null item (because something went wrong) breaks everything in the folder | ||
148 | InventoryItemBase item = readInventoryItem(reader); | ||
149 | if (item != null) | ||
150 | items.Add(item); | ||
151 | } | ||
152 | 154 | ||
153 | return items; | 155 | return items; |
154 | } | ||
155 | } | ||
156 | } | 156 | } |
157 | } | 157 | } |
158 | catch (Exception e) | 158 | catch (Exception e) |
159 | { | 159 | { |
160 | database.Reconnect(); | 160 | database.Reconnect(); |
161 | m_log.Error(e.Message, e); | 161 | m_log.Error(e.ToString()); |
162 | return null; | 162 | return null; |
163 | } | 163 | } |
164 | } | 164 | } |
@@ -176,28 +176,29 @@ namespace OpenSim.Data.MySQL | |||
176 | { | 176 | { |
177 | database.CheckConnection(); | 177 | database.CheckConnection(); |
178 | 178 | ||
179 | using (MySqlCommand result = new MySqlCommand( | 179 | MySqlCommand result = |
180 | "SELECT * FROM inventoryfolders WHERE parentFolderID = ?zero AND agentID = ?uuid", | 180 | new MySqlCommand( |
181 | database.Connection)) | 181 | "SELECT * FROM inventoryfolders WHERE parentFolderID = ?zero AND agentID = ?uuid", |
182 | { | 182 | database.Connection); |
183 | result.Parameters.AddWithValue("?uuid", user.ToString()); | 183 | result.Parameters.AddWithValue("?uuid", user.ToString()); |
184 | result.Parameters.AddWithValue("?zero", UUID.Zero.ToString()); | 184 | result.Parameters.AddWithValue("?zero", UUID.Zero.ToString()); |
185 | MySqlDataReader reader = result.ExecuteReader(); | ||
185 | 186 | ||
186 | using (MySqlDataReader reader = result.ExecuteReader()) | 187 | List<InventoryFolderBase> items = new List<InventoryFolderBase>(); |
187 | { | 188 | while (reader.Read()) |
188 | List<InventoryFolderBase> items = new List<InventoryFolderBase>(); | 189 | items.Add(readInventoryFolder(reader)); |
189 | while (reader.Read()) | ||
190 | items.Add(readInventoryFolder(reader)); | ||
191 | 190 | ||
192 | return items; | 191 | |
193 | } | 192 | reader.Close(); |
194 | } | 193 | result.Dispose(); |
194 | |||
195 | return items; | ||
195 | } | 196 | } |
196 | } | 197 | } |
197 | catch (Exception e) | 198 | catch (Exception e) |
198 | { | 199 | { |
199 | database.Reconnect(); | 200 | database.Reconnect(); |
200 | m_log.Error(e.Message, e); | 201 | m_log.Error(e.ToString()); |
201 | return null; | 202 | return null; |
202 | } | 203 | } |
203 | } | 204 | } |
@@ -216,38 +217,41 @@ namespace OpenSim.Data.MySQL | |||
216 | { | 217 | { |
217 | database.CheckConnection(); | 218 | database.CheckConnection(); |
218 | 219 | ||
219 | using (MySqlCommand result = new MySqlCommand( | 220 | MySqlCommand result = |
220 | "SELECT * FROM inventoryfolders WHERE parentFolderID = ?zero AND agentID = ?uuid", | 221 | new MySqlCommand( |
221 | database.Connection)) | 222 | "SELECT * FROM inventoryfolders WHERE parentFolderID = ?zero AND agentID = ?uuid", |
222 | { | 223 | database.Connection); |
223 | result.Parameters.AddWithValue("?uuid", user.ToString()); | 224 | result.Parameters.AddWithValue("?uuid", user.ToString()); |
224 | result.Parameters.AddWithValue("?zero", UUID.Zero.ToString()); | 225 | result.Parameters.AddWithValue("?zero", UUID.Zero.ToString()); |
225 | 226 | ||
226 | using (MySqlDataReader reader = result.ExecuteReader()) | 227 | MySqlDataReader reader = result.ExecuteReader(); |
227 | { | ||
228 | List<InventoryFolderBase> items = new List<InventoryFolderBase>(); | ||
229 | while (reader.Read()) | ||
230 | items.Add(readInventoryFolder(reader)); | ||
231 | 228 | ||
232 | InventoryFolderBase rootFolder = null; | 229 | List<InventoryFolderBase> items = new List<InventoryFolderBase>(); |
230 | while (reader.Read()) | ||
231 | items.Add(readInventoryFolder(reader)); | ||
233 | 232 | ||
234 | // There should only ever be one root folder for a user. However, if there's more | 233 | InventoryFolderBase rootFolder = null; |
235 | // than one we'll simply use the first one rather than failing. It would be even | ||
236 | // nicer to print some message to this effect, but this feels like it's too low a | ||
237 | // to put such a message out, and it's too minor right now to spare the time to | ||
238 | // suitably refactor. | ||
239 | if (items.Count > 0) | ||
240 | rootFolder = items[0]; | ||
241 | 234 | ||
242 | return rootFolder; | 235 | // There should only ever be one root folder for a user. However, if there's more |
243 | } | 236 | // than one we'll simply use the first one rather than failing. It would be even |
237 | // nicer to print some message to this effect, but this feels like it's too low a | ||
238 | // to put such a message out, and it's too minor right now to spare the time to | ||
239 | // suitably refactor. | ||
240 | if (items.Count > 0) | ||
241 | { | ||
242 | rootFolder = items[0]; | ||
244 | } | 243 | } |
244 | |||
245 | reader.Close(); | ||
246 | result.Dispose(); | ||
247 | |||
248 | return rootFolder; | ||
245 | } | 249 | } |
246 | } | 250 | } |
247 | catch (Exception e) | 251 | catch (Exception e) |
248 | { | 252 | { |
249 | database.Reconnect(); | 253 | database.Reconnect(); |
250 | m_log.Error(e.Message, e); | 254 | m_log.Error(e.ToString()); |
251 | return null; | 255 | return null; |
252 | } | 256 | } |
253 | } | 257 | } |
@@ -267,26 +271,27 @@ namespace OpenSim.Data.MySQL | |||
267 | { | 271 | { |
268 | database.CheckConnection(); | 272 | database.CheckConnection(); |
269 | 273 | ||
270 | using (MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE parentFolderID = ?uuid", | 274 | MySqlCommand result = |
271 | database.Connection)) | 275 | new MySqlCommand("SELECT * FROM inventoryfolders WHERE parentFolderID = ?uuid", |
272 | { | 276 | database.Connection); |
273 | result.Parameters.AddWithValue("?uuid", parentID.ToString()); | 277 | result.Parameters.AddWithValue("?uuid", parentID.ToString()); |
274 | using (MySqlDataReader reader = result.ExecuteReader()) | 278 | MySqlDataReader reader = result.ExecuteReader(); |
275 | { | ||
276 | List<InventoryFolderBase> items = new List<InventoryFolderBase>(); | ||
277 | 279 | ||
278 | while (reader.Read()) | 280 | List<InventoryFolderBase> items = new List<InventoryFolderBase>(); |
279 | items.Add(readInventoryFolder(reader)); | ||
280 | 281 | ||
281 | return items; | 282 | while (reader.Read()) |
282 | } | 283 | items.Add(readInventoryFolder(reader)); |
283 | } | 284 | |
285 | reader.Close(); | ||
286 | result.Dispose(); | ||
287 | |||
288 | return items; | ||
284 | } | 289 | } |
285 | } | 290 | } |
286 | catch (Exception e) | 291 | catch (Exception e) |
287 | { | 292 | { |
288 | database.Reconnect(); | 293 | database.Reconnect(); |
289 | m_log.Error(e.Message, e); | 294 | m_log.Error(e.ToString()); |
290 | return null; | 295 | return null; |
291 | } | 296 | } |
292 | } | 297 | } |
@@ -365,25 +370,25 @@ namespace OpenSim.Data.MySQL | |||
365 | { | 370 | { |
366 | database.CheckConnection(); | 371 | database.CheckConnection(); |
367 | 372 | ||
368 | using (MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryitems WHERE inventoryID = ?uuid", database.Connection)) | 373 | MySqlCommand result = |
369 | { | 374 | new MySqlCommand("SELECT * FROM inventoryitems WHERE inventoryID = ?uuid", database.Connection); |
370 | result.Parameters.AddWithValue("?uuid", itemID.ToString()); | 375 | result.Parameters.AddWithValue("?uuid", itemID.ToString()); |
376 | MySqlDataReader reader = result.ExecuteReader(); | ||
371 | 377 | ||
372 | using (MySqlDataReader reader = result.ExecuteReader()) | 378 | InventoryItemBase item = null; |
373 | { | 379 | if (reader.Read()) |
374 | InventoryItemBase item = null; | 380 | item = readInventoryItem(reader); |
375 | if (reader.Read()) | ||
376 | item = readInventoryItem(reader); | ||
377 | 381 | ||
378 | return item; | 382 | reader.Close(); |
379 | } | 383 | result.Dispose(); |
380 | } | 384 | |
385 | return item; | ||
381 | } | 386 | } |
382 | } | 387 | } |
383 | catch (Exception e) | 388 | catch (Exception e) |
384 | { | 389 | { |
385 | database.Reconnect(); | 390 | database.Reconnect(); |
386 | m_log.Error(e.Message, e); | 391 | m_log.Error(e.ToString()); |
387 | } | 392 | } |
388 | return null; | 393 | return null; |
389 | } | 394 | } |
@@ -408,7 +413,7 @@ namespace OpenSim.Data.MySQL | |||
408 | } | 413 | } |
409 | catch (Exception e) | 414 | catch (Exception e) |
410 | { | 415 | { |
411 | m_log.Error(e.Message, e); | 416 | m_log.Error(e.ToString()); |
412 | } | 417 | } |
413 | 418 | ||
414 | return null; | 419 | return null; |
@@ -428,25 +433,24 @@ namespace OpenSim.Data.MySQL | |||
428 | { | 433 | { |
429 | database.CheckConnection(); | 434 | database.CheckConnection(); |
430 | 435 | ||
431 | using (MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE folderID = ?uuid", database.Connection)) | 436 | MySqlCommand result = |
432 | { | 437 | new MySqlCommand("SELECT * FROM inventoryfolders WHERE folderID = ?uuid", database.Connection); |
433 | result.Parameters.AddWithValue("?uuid", folderID.ToString()); | 438 | result.Parameters.AddWithValue("?uuid", folderID.ToString()); |
439 | MySqlDataReader reader = result.ExecuteReader(); | ||
434 | 440 | ||
435 | using (MySqlDataReader reader = result.ExecuteReader()) | 441 | InventoryFolderBase folder = null; |
436 | { | 442 | if (reader.Read()) |
437 | InventoryFolderBase folder = null; | 443 | folder = readInventoryFolder(reader); |
438 | if (reader.Read()) | 444 | reader.Close(); |
439 | folder = readInventoryFolder(reader); | 445 | result.Dispose(); |
440 | 446 | ||
441 | return folder; | 447 | return folder; |
442 | } | ||
443 | } | ||
444 | } | 448 | } |
445 | } | 449 | } |
446 | catch (Exception e) | 450 | catch (Exception e) |
447 | { | 451 | { |
448 | database.Reconnect(); | 452 | database.Reconnect(); |
449 | m_log.Error(e.Message, e); | 453 | m_log.Error(e.ToString()); |
450 | return null; | 454 | return null; |
451 | } | 455 | } |
452 | } | 456 | } |
@@ -694,73 +698,69 @@ namespace OpenSim.Data.MySQL | |||
694 | try | 698 | try |
695 | { | 699 | { |
696 | List<InventoryFolderBase> folders = new List<InventoryFolderBase>(); | 700 | List<InventoryFolderBase> folders = new List<InventoryFolderBase>(); |
697 | Dictionary<UUID, List<InventoryFolderBase>> hashtable = new Dictionary<UUID, List<InventoryFolderBase>>(); ; | 701 | Dictionary<UUID, List<InventoryFolderBase>> hashtable |
702 | = new Dictionary<UUID, List<InventoryFolderBase>>(); ; | ||
698 | List<InventoryFolderBase> parentFolder = new List<InventoryFolderBase>(); | 703 | List<InventoryFolderBase> parentFolder = new List<InventoryFolderBase>(); |
699 | bool buildResultsFromHashTable = false; | ||
700 | |||
701 | lock (database) | 704 | lock (database) |
702 | { | 705 | { |
706 | MySqlCommand result; | ||
707 | MySqlDataReader reader; | ||
708 | bool buildResultsFromHashTable = false; | ||
709 | |||
703 | database.CheckConnection(); | 710 | database.CheckConnection(); |
704 | 711 | ||
705 | /* Fetch the parent folder from the database to determine the agent ID, and if | 712 | /* Fetch the parent folder from the database to determine the agent ID, and if |
706 | * we're querying the root of the inventory folder tree */ | 713 | * we're querying the root of the inventory folder tree */ |
707 | using (MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE folderID = ?uuid", database.Connection)) | 714 | result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE folderID = ?uuid", |
708 | { | 715 | database.Connection); |
709 | result.Parameters.AddWithValue("?uuid", parentID.ToString()); | 716 | result.Parameters.AddWithValue("?uuid", parentID.ToString()); |
710 | 717 | reader = result.ExecuteReader(); | |
711 | using (MySqlDataReader reader = result.ExecuteReader()) | 718 | while (reader.Read()) // Should be at most 1 result |
712 | { | 719 | parentFolder.Add(readInventoryFolder(reader)); |
713 | // Should be at most 1 result | 720 | reader.Close(); |
714 | while (reader.Read()) | 721 | result.Dispose(); |
715 | parentFolder.Add(readInventoryFolder(reader)); | ||
716 | } | ||
717 | } | ||
718 | 722 | ||
719 | if (parentFolder.Count >= 1) // No result means parent folder does not exist | 723 | if (parentFolder.Count >= 1) // No result means parent folder does not exist |
720 | { | 724 | { |
721 | if (parentFolder[0].ParentID == UUID.Zero) // We are querying the root folder | 725 | if (parentFolder[0].ParentID == UUID.Zero) // We are querying the root folder |
722 | { | 726 | { |
723 | /* Get all of the agent's folders from the database, put them in a list and return it */ | 727 | /* Get all of the agent's folders from the database, put them in a list and return it */ |
724 | using (MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE agentID = ?uuid", database.Connection)) | 728 | result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE agentID = ?uuid", |
729 | database.Connection); | ||
730 | result.Parameters.AddWithValue("?uuid", parentFolder[0].Owner.ToString()); | ||
731 | reader = result.ExecuteReader(); | ||
732 | while (reader.Read()) | ||
725 | { | 733 | { |
726 | result.Parameters.AddWithValue("?uuid", parentFolder[0].Owner.ToString()); | 734 | InventoryFolderBase curFolder = readInventoryFolder(reader); |
727 | 735 | if (curFolder.ID != parentID) // Do not need to add the root node of the tree to the list | |
728 | using (MySqlDataReader reader = result.ExecuteReader()) | 736 | folders.Add(curFolder); |
729 | { | ||
730 | while (reader.Read()) | ||
731 | { | ||
732 | InventoryFolderBase curFolder = readInventoryFolder(reader); | ||
733 | if (curFolder.ID != parentID) // Do not need to add the root node of the tree to the list | ||
734 | folders.Add(curFolder); | ||
735 | } | ||
736 | } | ||
737 | } | 737 | } |
738 | reader.Close(); | ||
739 | result.Dispose(); | ||
738 | } // if we are querying the root folder | 740 | } // if we are querying the root folder |
739 | else // else we are querying a subtree of the inventory folder tree | 741 | else // else we are querying a subtree of the inventory folder tree |
740 | { | 742 | { |
741 | /* Get all of the agent's folders from the database, put them all in a hash table | 743 | /* Get all of the agent's folders from the database, put them all in a hash table |
742 | * indexed by their parent ID */ | 744 | * indexed by their parent ID */ |
743 | using (MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE agentID = ?uuid", database.Connection)) | 745 | result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE agentID = ?uuid", |
746 | database.Connection); | ||
747 | result.Parameters.AddWithValue("?uuid", parentFolder[0].Owner.ToString()); | ||
748 | reader = result.ExecuteReader(); | ||
749 | while (reader.Read()) | ||
744 | { | 750 | { |
745 | result.Parameters.AddWithValue("?uuid", parentFolder[0].Owner.ToString()); | 751 | InventoryFolderBase curFolder = readInventoryFolder(reader); |
746 | 752 | if (hashtable.ContainsKey(curFolder.ParentID)) // Current folder already has a sibling | |
747 | using (MySqlDataReader reader = result.ExecuteReader()) | 753 | hashtable[curFolder.ParentID].Add(curFolder); // append to sibling list |
754 | else // else current folder has no known (yet) siblings | ||
748 | { | 755 | { |
749 | while (reader.Read()) | 756 | List<InventoryFolderBase> siblingList = new List<InventoryFolderBase>(); |
750 | { | 757 | siblingList.Add(curFolder); |
751 | InventoryFolderBase curFolder = readInventoryFolder(reader); | 758 | // Current folder has no known (yet) siblings |
752 | if (hashtable.ContainsKey(curFolder.ParentID)) // Current folder already has a sibling | 759 | hashtable.Add(curFolder.ParentID, siblingList); |
753 | hashtable[curFolder.ParentID].Add(curFolder); // append to sibling list | ||
754 | else // else current folder has no known (yet) siblings | ||
755 | { | ||
756 | List<InventoryFolderBase> siblingList = new List<InventoryFolderBase>(); | ||
757 | siblingList.Add(curFolder); | ||
758 | // Current folder has no known (yet) siblings | ||
759 | hashtable.Add(curFolder.ParentID, siblingList); | ||
760 | } | ||
761 | } // while more items to read from the database | ||
762 | } | 760 | } |
763 | } | 761 | } // while more items to read from the database |
762 | reader.Close(); | ||
763 | result.Dispose(); | ||
764 | 764 | ||
765 | // Set flag so we know we need to build the results from the hash table after | 765 | // Set flag so we know we need to build the results from the hash table after |
766 | // we unlock the database | 766 | // we unlock the database |
@@ -781,13 +781,12 @@ namespace OpenSim.Data.MySQL | |||
781 | folders.AddRange(hashtable[folders[i].ID]); | 781 | folders.AddRange(hashtable[folders[i].ID]); |
782 | } | 782 | } |
783 | } // lock (database) | 783 | } // lock (database) |
784 | |||
785 | return folders; | 784 | return folders; |
786 | } | 785 | } |
787 | catch (Exception e) | 786 | catch (Exception e) |
788 | { | 787 | { |
789 | database.Reconnect(); | 788 | database.Reconnect(); |
790 | m_log.Error(e.Message, e); | 789 | m_log.Error(e.ToString()); |
791 | return null; | 790 | return null; |
792 | } | 791 | } |
793 | } | 792 | } |
@@ -802,18 +801,19 @@ namespace OpenSim.Data.MySQL | |||
802 | { | 801 | { |
803 | database.CheckConnection(); | 802 | database.CheckConnection(); |
804 | 803 | ||
805 | using (MySqlCommand cmd = new MySqlCommand("DELETE FROM inventoryfolders WHERE folderID=?uuid", database.Connection)) | 804 | MySqlCommand cmd = |
806 | { | 805 | new MySqlCommand("DELETE FROM inventoryfolders WHERE folderID=?uuid", database.Connection); |
807 | cmd.Parameters.AddWithValue("?uuid", folderID.ToString()); | 806 | cmd.Parameters.AddWithValue("?uuid", folderID.ToString()); |
808 | 807 | ||
809 | lock (database) | 808 | lock (database) |
810 | cmd.ExecuteNonQuery(); | 809 | { |
810 | cmd.ExecuteNonQuery(); | ||
811 | } | 811 | } |
812 | } | 812 | } |
813 | catch (MySqlException e) | 813 | catch (MySqlException e) |
814 | { | 814 | { |
815 | database.Reconnect(); | 815 | database.Reconnect(); |
816 | m_log.Error(e.Message, e); | 816 | m_log.Error(e.ToString()); |
817 | } | 817 | } |
818 | } | 818 | } |
819 | 819 | ||
@@ -827,12 +827,13 @@ namespace OpenSim.Data.MySQL | |||
827 | { | 827 | { |
828 | database.CheckConnection(); | 828 | database.CheckConnection(); |
829 | 829 | ||
830 | using (MySqlCommand cmd = new MySqlCommand("DELETE FROM inventoryitems WHERE parentFolderID=?uuid", database.Connection)) | 830 | MySqlCommand cmd = |
831 | { | 831 | new MySqlCommand("DELETE FROM inventoryitems WHERE parentFolderID=?uuid", database.Connection); |
832 | cmd.Parameters.AddWithValue("?uuid", folderID.ToString()); | 832 | cmd.Parameters.AddWithValue("?uuid", folderID.ToString()); |
833 | 833 | ||
834 | lock (database) | 834 | lock (database) |
835 | cmd.ExecuteNonQuery(); | 835 | { |
836 | cmd.ExecuteNonQuery(); | ||
836 | } | 837 | } |
837 | } | 838 | } |
838 | catch (MySqlException e) | 839 | catch (MySqlException e) |
@@ -864,38 +865,40 @@ namespace OpenSim.Data.MySQL | |||
864 | 865 | ||
865 | public List<InventoryItemBase> fetchActiveGestures(UUID avatarID) | 866 | public List<InventoryItemBase> fetchActiveGestures(UUID avatarID) |
866 | { | 867 | { |
868 | MySqlDataReader result = null; | ||
869 | MySqlCommand sqlCmd = null; | ||
867 | lock (database) | 870 | lock (database) |
868 | { | 871 | { |
869 | try | 872 | try |
870 | { | 873 | { |
871 | database.CheckConnection(); | 874 | database.CheckConnection(); |
872 | 875 | sqlCmd = new MySqlCommand( | |
873 | using (MySqlCommand sqlCmd = new MySqlCommand( | ||
874 | "SELECT * FROM inventoryitems WHERE avatarId = ?uuid AND assetType = ?type and flags = 1", | 876 | "SELECT * FROM inventoryitems WHERE avatarId = ?uuid AND assetType = ?type and flags = 1", |
875 | database.Connection)) | 877 | database.Connection); |
876 | { | 878 | sqlCmd.Parameters.AddWithValue("?uuid", avatarID.ToString()); |
877 | sqlCmd.Parameters.AddWithValue("?uuid", avatarID.ToString()); | 879 | sqlCmd.Parameters.AddWithValue("?type", (int)AssetType.Gesture); |
878 | sqlCmd.Parameters.AddWithValue("?type", (int)AssetType.Gesture); | 880 | result = sqlCmd.ExecuteReader(); |
879 | 881 | ||
880 | using (MySqlDataReader result = sqlCmd.ExecuteReader()) | 882 | List<InventoryItemBase> list = new List<InventoryItemBase>(); |
881 | { | 883 | while (result.Read()) |
882 | List<InventoryItemBase> list = new List<InventoryItemBase>(); | 884 | { |
883 | while (result.Read()) | 885 | InventoryItemBase item = readInventoryItem(result); |
884 | { | 886 | if (item != null) |
885 | InventoryItemBase item = readInventoryItem(result); | 887 | list.Add(item); |
886 | if (item != null) | ||
887 | list.Add(item); | ||
888 | } | ||
889 | return list; | ||
890 | } | ||
891 | } | 888 | } |
889 | return list; | ||
892 | } | 890 | } |
893 | catch (Exception e) | 891 | catch (Exception e) |
894 | { | 892 | { |
895 | database.Reconnect(); | 893 | database.Reconnect(); |
896 | m_log.Error(e.Message, e); | 894 | m_log.Error(e.ToString()); |
897 | return null; | 895 | return null; |
898 | } | 896 | } |
897 | finally | ||
898 | { | ||
899 | if (result != null) result.Close(); | ||
900 | if (sqlCmd != null) sqlCmd.Dispose(); | ||
901 | } | ||
899 | } | 902 | } |
900 | } | 903 | } |
901 | } | 904 | } |
diff --git a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs index a807948..c49153f 100644 --- a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs | |||
@@ -908,7 +908,7 @@ namespace OpenSim.Data.MySQL | |||
908 | if (!(row["ParticleSystem"] is DBNull)) | 908 | if (!(row["ParticleSystem"] is DBNull)) |
909 | prim.ParticleSystem = (byte[])row["ParticleSystem"]; | 909 | prim.ParticleSystem = (byte[])row["ParticleSystem"]; |
910 | 910 | ||
911 | prim.RotationalVelocity = new Vector3( | 911 | prim.AngularVelocity = new Vector3( |
912 | (float)(double)row["OmegaX"], | 912 | (float)(double)row["OmegaX"], |
913 | (float)(double)row["OmegaY"], | 913 | (float)(double)row["OmegaY"], |
914 | (float)(double)row["OmegaZ"] | 914 | (float)(double)row["OmegaZ"] |
@@ -1240,9 +1240,9 @@ namespace OpenSim.Data.MySQL | |||
1240 | cmd.Parameters.AddWithValue("TextureAnimation", prim.TextureAnimation); | 1240 | cmd.Parameters.AddWithValue("TextureAnimation", prim.TextureAnimation); |
1241 | cmd.Parameters.AddWithValue("ParticleSystem", prim.ParticleSystem); | 1241 | cmd.Parameters.AddWithValue("ParticleSystem", prim.ParticleSystem); |
1242 | 1242 | ||
1243 | cmd.Parameters.AddWithValue("OmegaX", (double)prim.RotationalVelocity.X); | 1243 | cmd.Parameters.AddWithValue("OmegaX", (double)prim.AngularVelocity.X); |
1244 | cmd.Parameters.AddWithValue("OmegaY", (double)prim.RotationalVelocity.Y); | 1244 | cmd.Parameters.AddWithValue("OmegaY", (double)prim.AngularVelocity.Y); |
1245 | cmd.Parameters.AddWithValue("OmegaZ", (double)prim.RotationalVelocity.Z); | 1245 | cmd.Parameters.AddWithValue("OmegaZ", (double)prim.AngularVelocity.Z); |
1246 | 1246 | ||
1247 | cmd.Parameters.AddWithValue("CameraEyeOffsetX", (double)prim.GetCameraEyeOffset().X); | 1247 | cmd.Parameters.AddWithValue("CameraEyeOffsetX", (double)prim.GetCameraEyeOffset().X); |
1248 | cmd.Parameters.AddWithValue("CameraEyeOffsetY", (double)prim.GetCameraEyeOffset().Y); | 1248 | cmd.Parameters.AddWithValue("CameraEyeOffsetY", (double)prim.GetCameraEyeOffset().Y); |
diff --git a/OpenSim/Data/MySQL/MySQLManager.cs b/OpenSim/Data/MySQL/MySQLManager.cs index a724a50..a6cce57 100644 --- a/OpenSim/Data/MySQL/MySQLManager.cs +++ b/OpenSim/Data/MySQL/MySQLManager.cs | |||
@@ -134,16 +134,18 @@ namespace OpenSim.Data.MySQL | |||
134 | /// </summary> | 134 | /// </summary> |
135 | protected void GetWaitTimeout() | 135 | protected void GetWaitTimeout() |
136 | { | 136 | { |
137 | using (MySqlCommand cmd = new MySqlCommand(m_waitTimeoutSelect, dbcon)) | 137 | MySqlCommand cmd = new MySqlCommand(m_waitTimeoutSelect, dbcon); |
138 | |||
139 | using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) | ||
138 | { | 140 | { |
139 | using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) | 141 | if (dbReader.Read()) |
140 | { | 142 | { |
141 | if (dbReader.Read()) | 143 | m_waitTimeout |
142 | { | 144 | = Convert.ToInt32(dbReader["@@wait_timeout"]) * TimeSpan.TicksPerSecond + m_waitTimeoutLeeway; |
143 | m_waitTimeout | ||
144 | = Convert.ToInt32(dbReader["@@wait_timeout"]) * TimeSpan.TicksPerSecond + m_waitTimeoutLeeway; | ||
145 | } | ||
146 | } | 145 | } |
146 | |||
147 | dbReader.Close(); | ||
148 | cmd.Dispose(); | ||
147 | } | 149 | } |
148 | 150 | ||
149 | m_lastConnectionUse = DateTime.Now.Ticks; | 151 | m_lastConnectionUse = DateTime.Now.Ticks; |
@@ -301,31 +303,31 @@ namespace OpenSim.Data.MySQL | |||
301 | { | 303 | { |
302 | CheckConnection(); | 304 | CheckConnection(); |
303 | 305 | ||
304 | using (MySqlCommand tablesCmd = new MySqlCommand( | 306 | MySqlCommand tablesCmd = |
305 | "SELECT TABLE_NAME, TABLE_COMMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA=?dbname", | 307 | new MySqlCommand( |
306 | dbcon)) | 308 | "SELECT TABLE_NAME, TABLE_COMMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA=?dbname", |
307 | { | 309 | dbcon); |
308 | tablesCmd.Parameters.AddWithValue("?dbname", dbcon.Database); | 310 | tablesCmd.Parameters.AddWithValue("?dbname", dbcon.Database); |
309 | 311 | ||
310 | using (MySqlDataReader tables = tablesCmd.ExecuteReader()) | 312 | using (MySqlDataReader tables = tablesCmd.ExecuteReader()) |
313 | { | ||
314 | while (tables.Read()) | ||
311 | { | 315 | { |
312 | while (tables.Read()) | 316 | try |
313 | { | 317 | { |
314 | try | 318 | string tableName = (string) tables["TABLE_NAME"]; |
315 | { | 319 | string comment = (string) tables["TABLE_COMMENT"]; |
316 | string tableName = (string)tables["TABLE_NAME"]; | 320 | if (tableList.ContainsKey(tableName)) |
317 | string comment = (string)tables["TABLE_COMMENT"]; | ||
318 | if (tableList.ContainsKey(tableName)) | ||
319 | { | ||
320 | tableList[tableName] = comment; | ||
321 | } | ||
322 | } | ||
323 | catch (Exception e) | ||
324 | { | 321 | { |
325 | m_log.Error(e.Message, e); | 322 | tableList[tableName] = comment; |
326 | } | 323 | } |
327 | } | 324 | } |
325 | catch (Exception e) | ||
326 | { | ||
327 | m_log.Error(e.ToString()); | ||
328 | } | ||
328 | } | 329 | } |
330 | tables.Close(); | ||
329 | } | 331 | } |
330 | } | 332 | } |
331 | } | 333 | } |
@@ -344,19 +346,19 @@ namespace OpenSim.Data.MySQL | |||
344 | { | 346 | { |
345 | CheckConnection(); // Not sure if this one is necessary | 347 | CheckConnection(); // Not sure if this one is necessary |
346 | 348 | ||
347 | MySqlCommand dbcommand = (MySqlCommand)dbcon.CreateCommand(); | 349 | MySqlCommand dbcommand = (MySqlCommand) dbcon.CreateCommand(); |
348 | dbcommand.CommandText = sql; | 350 | dbcommand.CommandText = sql; |
349 | foreach (KeyValuePair<string, object> param in parameters) | 351 | foreach (KeyValuePair<string, object> param in parameters) |
350 | { | 352 | { |
351 | dbcommand.Parameters.AddWithValue(param.Key, param.Value); | 353 | dbcommand.Parameters.AddWithValue(param.Key, param.Value); |
352 | } | 354 | } |
353 | 355 | ||
354 | return (IDbCommand)dbcommand; | 356 | return (IDbCommand) dbcommand; |
355 | } | 357 | } |
356 | catch (Exception e) | 358 | catch (Exception e) |
357 | { | 359 | { |
358 | // Return null if it fails. | 360 | // Return null if it fails. |
359 | m_log.Error("Failed during Query generation: " + e.Message, e); | 361 | m_log.Error("Failed during Query generation: " + e.ToString()); |
360 | return null; | 362 | return null; |
361 | } | 363 | } |
362 | } | 364 | } |
@@ -692,6 +694,8 @@ namespace OpenSim.Data.MySQL | |||
692 | ret.Add(attachpoint, item); | 694 | ret.Add(attachpoint, item); |
693 | } | 695 | } |
694 | 696 | ||
697 | r.Close(); | ||
698 | |||
695 | return ret; | 699 | return ret; |
696 | } | 700 | } |
697 | 701 | ||
diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index f514076..b0075e8 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs | |||
@@ -56,13 +56,12 @@ namespace OpenSim.Data.MySQL | |||
56 | if (scopeID != UUID.Zero) | 56 | if (scopeID != UUID.Zero) |
57 | command += " and ScopeID = ?scopeID"; | 57 | command += " and ScopeID = ?scopeID"; |
58 | 58 | ||
59 | using (MySqlCommand cmd = new MySqlCommand(command)) | 59 | MySqlCommand cmd = new MySqlCommand(command); |
60 | { | ||
61 | cmd.Parameters.AddWithValue("?regionName", regionName); | ||
62 | cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); | ||
63 | 60 | ||
64 | return RunCommand(cmd); | 61 | cmd.Parameters.AddWithValue("?regionName", regionName); |
65 | } | 62 | cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); |
63 | |||
64 | return RunCommand(cmd); | ||
66 | } | 65 | } |
67 | 66 | ||
68 | public RegionData Get(int posX, int posY, UUID scopeID) | 67 | public RegionData Get(int posX, int posY, UUID scopeID) |
@@ -71,18 +70,17 @@ namespace OpenSim.Data.MySQL | |||
71 | if (scopeID != UUID.Zero) | 70 | if (scopeID != UUID.Zero) |
72 | command += " and ScopeID = ?scopeID"; | 71 | command += " and ScopeID = ?scopeID"; |
73 | 72 | ||
74 | using (MySqlCommand cmd = new MySqlCommand(command)) | 73 | MySqlCommand cmd = new MySqlCommand(command); |
75 | { | ||
76 | cmd.Parameters.AddWithValue("?posX", posX.ToString()); | ||
77 | cmd.Parameters.AddWithValue("?posY", posY.ToString()); | ||
78 | cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); | ||
79 | 74 | ||
80 | List<RegionData> ret = RunCommand(cmd); | 75 | cmd.Parameters.AddWithValue("?posX", posX.ToString()); |
81 | if (ret.Count == 0) | 76 | cmd.Parameters.AddWithValue("?posY", posY.ToString()); |
82 | return null; | 77 | cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); |
83 | 78 | ||
84 | return ret[0]; | 79 | List<RegionData> ret = RunCommand(cmd); |
85 | } | 80 | if (ret.Count == 0) |
81 | return null; | ||
82 | |||
83 | return ret[0]; | ||
86 | } | 84 | } |
87 | 85 | ||
88 | public RegionData Get(UUID regionID, UUID scopeID) | 86 | public RegionData Get(UUID regionID, UUID scopeID) |
@@ -91,17 +89,16 @@ namespace OpenSim.Data.MySQL | |||
91 | if (scopeID != UUID.Zero) | 89 | if (scopeID != UUID.Zero) |
92 | command += " and ScopeID = ?scopeID"; | 90 | command += " and ScopeID = ?scopeID"; |
93 | 91 | ||
94 | using (MySqlCommand cmd = new MySqlCommand(command)) | 92 | MySqlCommand cmd = new MySqlCommand(command); |
95 | { | ||
96 | cmd.Parameters.AddWithValue("?regionID", regionID.ToString()); | ||
97 | cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); | ||
98 | 93 | ||
99 | List<RegionData> ret = RunCommand(cmd); | 94 | cmd.Parameters.AddWithValue("?regionID", regionID.ToString()); |
100 | if (ret.Count == 0) | 95 | cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); |
101 | return null; | ||
102 | 96 | ||
103 | return ret[0]; | 97 | List<RegionData> ret = RunCommand(cmd); |
104 | } | 98 | if (ret.Count == 0) |
99 | return null; | ||
100 | |||
101 | return ret[0]; | ||
105 | } | 102 | } |
106 | 103 | ||
107 | public List<RegionData> Get(int startX, int startY, int endX, int endY, UUID scopeID) | 104 | public List<RegionData> Get(int startX, int startY, int endX, int endY, UUID scopeID) |
@@ -110,44 +107,43 @@ namespace OpenSim.Data.MySQL | |||
110 | if (scopeID != UUID.Zero) | 107 | if (scopeID != UUID.Zero) |
111 | command += " and ScopeID = ?scopeID"; | 108 | command += " and ScopeID = ?scopeID"; |
112 | 109 | ||
113 | using (MySqlCommand cmd = new MySqlCommand(command)) | 110 | MySqlCommand cmd = new MySqlCommand(command); |
114 | { | ||
115 | cmd.Parameters.AddWithValue("?startX", startX.ToString()); | ||
116 | cmd.Parameters.AddWithValue("?startY", startY.ToString()); | ||
117 | cmd.Parameters.AddWithValue("?endX", endX.ToString()); | ||
118 | cmd.Parameters.AddWithValue("?endY", endY.ToString()); | ||
119 | cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); | ||
120 | 111 | ||
121 | return RunCommand(cmd); | 112 | cmd.Parameters.AddWithValue("?startX", startX.ToString()); |
122 | } | 113 | cmd.Parameters.AddWithValue("?startY", startY.ToString()); |
114 | cmd.Parameters.AddWithValue("?endX", endX.ToString()); | ||
115 | cmd.Parameters.AddWithValue("?endY", endY.ToString()); | ||
116 | cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); | ||
117 | |||
118 | return RunCommand(cmd); | ||
123 | } | 119 | } |
124 | 120 | ||
125 | public List<RegionData> RunCommand(MySqlCommand cmd) | 121 | public List<RegionData> RunCommand(MySqlCommand cmd) |
126 | { | 122 | { |
127 | List<RegionData> retList = new List<RegionData>(); | 123 | List<RegionData> retList = new List<RegionData>(); |
128 | 124 | ||
129 | using (IDataReader result = ExecuteReader(cmd)) | 125 | IDataReader result = ExecuteReader(cmd); |
126 | |||
127 | while (result.Read()) | ||
130 | { | 128 | { |
131 | while (result.Read()) | 129 | RegionData ret = new RegionData(); |
130 | ret.Data = new Dictionary<string, object>(); | ||
131 | |||
132 | UUID regionID; | ||
133 | UUID.TryParse(result["uuid"].ToString(), out regionID); | ||
134 | ret.RegionID = regionID; | ||
135 | UUID scope; | ||
136 | UUID.TryParse(result["ScopeID"].ToString(), out scope); | ||
137 | ret.ScopeID = scope; | ||
138 | ret.RegionName = result["regionName"].ToString(); | ||
139 | ret.posX = Convert.ToInt32(result["locX"]); | ||
140 | ret.posY = Convert.ToInt32(result["locY"]); | ||
141 | ret.sizeX = Convert.ToInt32(result["sizeX"]); | ||
142 | ret.sizeY = Convert.ToInt32(result["sizeY"]); | ||
143 | |||
144 | if (m_ColumnNames == null) | ||
132 | { | 145 | { |
133 | RegionData ret = new RegionData(); | 146 | m_ColumnNames = new List<string>(); |
134 | ret.Data = new Dictionary<string, object>(); | ||
135 | |||
136 | UUID regionID; | ||
137 | UUID.TryParse(result["uuid"].ToString(), out regionID); | ||
138 | ret.RegionID = regionID; | ||
139 | UUID scope; | ||
140 | UUID.TryParse(result["ScopeID"].ToString(), out scope); | ||
141 | ret.ScopeID = scope; | ||
142 | ret.RegionName = result["regionName"].ToString(); | ||
143 | ret.posX = Convert.ToInt32(result["locX"]); | ||
144 | ret.posY = Convert.ToInt32(result["locY"]); | ||
145 | ret.sizeX = Convert.ToInt32(result["sizeX"]); | ||
146 | ret.sizeY = Convert.ToInt32(result["sizeY"]); | ||
147 | |||
148 | if (m_ColumnNames == null) | ||
149 | { | ||
150 | m_ColumnNames = new List<string>(); | ||
151 | 147 | ||
152 | DataTable schemaTable = result.GetSchemaTable(); | 148 | DataTable schemaTable = result.GetSchemaTable(); |
153 | foreach (DataRow row in schemaTable.Rows) | 149 | foreach (DataRow row in schemaTable.Rows) |
@@ -157,28 +153,28 @@ namespace OpenSim.Data.MySQL | |||
157 | } | 153 | } |
158 | } | 154 | } |
159 | 155 | ||
160 | foreach (string s in m_ColumnNames) | 156 | foreach (string s in m_ColumnNames) |
161 | { | 157 | { |
162 | if (s == "uuid") | 158 | if (s == "uuid") |
163 | continue; | 159 | continue; |
164 | if (s == "ScopeID") | 160 | if (s == "ScopeID") |
165 | continue; | 161 | continue; |
166 | if (s == "regionName") | 162 | if (s == "regionName") |
167 | continue; | 163 | continue; |
168 | if (s == "locX") | 164 | if (s == "locX") |
169 | continue; | 165 | continue; |
170 | if (s == "locY") | 166 | if (s == "locY") |
171 | continue; | 167 | continue; |
172 | 168 | ||
173 | ret.Data[s] = result[s].ToString(); | 169 | ret.Data[s] = result[s].ToString(); |
174 | } | ||
175 | |||
176 | retList.Add(ret); | ||
177 | } | 170 | } |
178 | 171 | ||
179 | CloseDBConnection(result, cmd); | 172 | retList.Add(ret); |
180 | } | 173 | } |
181 | 174 | ||
175 | result.Close(); | ||
176 | CloseReaderCommand(cmd); | ||
177 | |||
182 | return retList; | 178 | return retList; |
183 | } | 179 | } |
184 | 180 | ||
@@ -205,72 +201,76 @@ namespace OpenSim.Data.MySQL | |||
205 | 201 | ||
206 | string[] fields = new List<string>(data.Data.Keys).ToArray(); | 202 | string[] fields = new List<string>(data.Data.Keys).ToArray(); |
207 | 203 | ||
208 | using (MySqlCommand cmd = new MySqlCommand()) | 204 | MySqlCommand cmd = new MySqlCommand(); |
205 | |||
206 | string update = "update `"+m_Realm+"` set locX=?posX, locY=?posY, sizeX=?sizeX, sizeY=?sizeY"; | ||
207 | foreach (string field in fields) | ||
209 | { | 208 | { |
210 | string update = "update `" + m_Realm + "` set locX=?posX, locY=?posY, sizeX=?sizeX, sizeY=?sizeY"; | 209 | update += ", "; |
211 | foreach (string field in fields) | 210 | update += "`" + field + "` = ?"+field; |
212 | { | ||
213 | update += ", "; | ||
214 | update += "`" + field + "` = ?" + field; | ||
215 | 211 | ||
216 | cmd.Parameters.AddWithValue("?" + field, data.Data[field]); | 212 | cmd.Parameters.AddWithValue("?"+field, data.Data[field]); |
217 | } | 213 | } |
218 | 214 | ||
219 | update += " where uuid = ?regionID"; | 215 | update += " where uuid = ?regionID"; |
220 | 216 | ||
221 | if (data.ScopeID != UUID.Zero) | 217 | if (data.ScopeID != UUID.Zero) |
222 | update += " and ScopeID = ?scopeID"; | 218 | update += " and ScopeID = ?scopeID"; |
223 | 219 | ||
224 | cmd.CommandText = update; | 220 | cmd.CommandText = update; |
225 | cmd.Parameters.AddWithValue("?regionID", data.RegionID.ToString()); | 221 | cmd.Parameters.AddWithValue("?regionID", data.RegionID.ToString()); |
226 | cmd.Parameters.AddWithValue("?regionName", data.RegionName); | 222 | cmd.Parameters.AddWithValue("?regionName", data.RegionName); |
227 | cmd.Parameters.AddWithValue("?scopeID", data.ScopeID.ToString()); | 223 | cmd.Parameters.AddWithValue("?scopeID", data.ScopeID.ToString()); |
228 | cmd.Parameters.AddWithValue("?posX", data.posX.ToString()); | 224 | cmd.Parameters.AddWithValue("?posX", data.posX.ToString()); |
229 | cmd.Parameters.AddWithValue("?posY", data.posY.ToString()); | 225 | cmd.Parameters.AddWithValue("?posY", data.posY.ToString()); |
230 | cmd.Parameters.AddWithValue("?sizeX", data.sizeX.ToString()); | 226 | cmd.Parameters.AddWithValue("?sizeX", data.sizeX.ToString()); |
231 | cmd.Parameters.AddWithValue("?sizeY", data.sizeY.ToString()); | 227 | cmd.Parameters.AddWithValue("?sizeY", data.sizeY.ToString()); |
232 | 228 | ||
233 | if (ExecuteNonQuery(cmd) < 1) | 229 | if (ExecuteNonQuery(cmd) < 1) |
234 | { | 230 | { |
235 | string insert = "insert into `" + m_Realm + "` (`uuid`, `ScopeID`, `locX`, `locY`, `sizeX`, `sizeY`, `regionName`, `" + | 231 | string insert = "insert into `" + m_Realm + "` (`uuid`, `ScopeID`, `locX`, `locY`, `sizeX`, `sizeY`, `regionName`, `" + |
236 | String.Join("`, `", fields) + | 232 | String.Join("`, `", fields) + |
237 | "`) values ( ?regionID, ?scopeID, ?posX, ?posY, ?sizeX, ?sizeY, ?regionName, ?" + String.Join(", ?", fields) + ")"; | 233 | "`) values ( ?regionID, ?scopeID, ?posX, ?posY, ?sizeX, ?sizeY, ?regionName, ?" + String.Join(", ?", fields) + ")"; |
238 | 234 | ||
239 | cmd.CommandText = insert; | 235 | cmd.CommandText = insert; |
240 | 236 | ||
241 | if (ExecuteNonQuery(cmd) < 1) | 237 | if (ExecuteNonQuery(cmd) < 1) |
242 | { | 238 | { |
243 | return false; | 239 | cmd.Dispose(); |
244 | } | 240 | return false; |
245 | } | 241 | } |
246 | } | 242 | } |
247 | 243 | ||
244 | cmd.Dispose(); | ||
245 | |||
248 | return true; | 246 | return true; |
249 | } | 247 | } |
250 | 248 | ||
251 | public bool SetDataItem(UUID regionID, string item, string value) | 249 | public bool SetDataItem(UUID regionID, string item, string value) |
252 | { | 250 | { |
253 | using (MySqlCommand cmd = new MySqlCommand("update `" + m_Realm + "` set `" + item + "` = ?" + item + " where uuid = ?UUID")) | 251 | MySqlCommand cmd = new MySqlCommand("update `" + m_Realm + |
254 | { | 252 | "` set `" + item + "` = ?" + item + " where uuid = ?UUID"); |
255 | cmd.Parameters.AddWithValue("?" + item, value); | ||
256 | cmd.Parameters.AddWithValue("?UUID", regionID.ToString()); | ||
257 | 253 | ||
258 | if (ExecuteNonQuery(cmd) > 0) | 254 | |
259 | return true; | 255 | cmd.Parameters.AddWithValue("?"+item, value); |
260 | } | 256 | cmd.Parameters.AddWithValue("?UUID", regionID.ToString()); |
257 | |||
258 | if (ExecuteNonQuery(cmd) > 0) | ||
259 | return true; | ||
261 | 260 | ||
262 | return false; | 261 | return false; |
263 | } | 262 | } |
264 | 263 | ||
265 | public bool Delete(UUID regionID) | 264 | public bool Delete(UUID regionID) |
266 | { | 265 | { |
267 | using (MySqlCommand cmd = new MySqlCommand("delete from `" + m_Realm + "` where uuid = ?UUID")) | 266 | MySqlCommand cmd = new MySqlCommand("delete from `" + m_Realm + |
268 | { | 267 | "` where uuid = ?UUID"); |
269 | cmd.Parameters.AddWithValue("?UUID", regionID.ToString()); | ||
270 | 268 | ||
271 | if (ExecuteNonQuery(cmd) > 0) | 269 | |
272 | return true; | 270 | cmd.Parameters.AddWithValue("?UUID", regionID.ToString()); |
273 | } | 271 | |
272 | if (ExecuteNonQuery(cmd) > 0) | ||
273 | return true; | ||
274 | 274 | ||
275 | return false; | 275 | return false; |
276 | } | 276 | } |
diff --git a/OpenSim/Data/MySQL/MySQLUserAccountData.cs b/OpenSim/Data/MySQL/MySQLUserAccountData.cs index 0bbc3f5..d48144d 100644 --- a/OpenSim/Data/MySQL/MySQLUserAccountData.cs +++ b/OpenSim/Data/MySQL/MySQLUserAccountData.cs | |||
@@ -97,14 +97,16 @@ namespace OpenSim.Data.MySQL | |||
97 | ret.Data[s] = result[s].ToString(); | 97 | ret.Data[s] = result[s].ToString(); |
98 | } | 98 | } |
99 | 99 | ||
100 | CloseDBConnection(result, cmd); | 100 | result.Close(); |
101 | CloseReaderCommand(cmd); | ||
102 | |||
101 | return ret; | 103 | return ret; |
102 | } | 104 | } |
103 | else | 105 | |
104 | { | 106 | result.Close(); |
105 | CloseDBConnection(result, cmd); | 107 | CloseReaderCommand(cmd); |
106 | return null; | 108 | |
107 | } | 109 | return null; |
108 | } | 110 | } |
109 | 111 | ||
110 | public bool Store(UserAccountData data) | 112 | public bool Store(UserAccountData data) |
@@ -116,60 +118,61 @@ namespace OpenSim.Data.MySQL | |||
116 | 118 | ||
117 | string[] fields = new List<string>(data.Data.Keys).ToArray(); | 119 | string[] fields = new List<string>(data.Data.Keys).ToArray(); |
118 | 120 | ||
119 | using (MySqlCommand cmd = new MySqlCommand()) | 121 | MySqlCommand cmd = new MySqlCommand(); |
122 | |||
123 | string update = "update `"+m_Realm+"` set "; | ||
124 | bool first = true; | ||
125 | foreach (string field in fields) | ||
120 | { | 126 | { |
121 | string update = "update `" + m_Realm + "` set "; | 127 | if (!first) |
122 | bool first = true; | 128 | update += ", "; |
123 | foreach (string field in fields) | 129 | update += "`" + field + "` = ?"+field; |
124 | { | ||
125 | if (!first) | ||
126 | update += ", "; | ||
127 | update += "`" + field + "` = ?" + field; | ||
128 | 130 | ||
129 | first = false; | 131 | first = false; |
130 | 132 | ||
131 | cmd.Parameters.AddWithValue("?" + field, data.Data[field]); | 133 | cmd.Parameters.AddWithValue("?"+field, data.Data[field]); |
132 | } | 134 | } |
133 | 135 | ||
134 | update += " where UUID = ?principalID"; | 136 | update += " where UUID = ?principalID"; |
135 | 137 | ||
136 | if (data.ScopeID != UUID.Zero) | 138 | if (data.ScopeID != UUID.Zero) |
137 | update += " and ScopeID = ?scopeID"; | 139 | update += " and ScopeID = ?scopeID"; |
138 | 140 | ||
139 | cmd.CommandText = update; | 141 | cmd.CommandText = update; |
140 | cmd.Parameters.AddWithValue("?principalID", data.PrincipalID.ToString()); | 142 | cmd.Parameters.AddWithValue("?principalID", data.PrincipalID.ToString()); |
141 | cmd.Parameters.AddWithValue("?scopeID", data.ScopeID.ToString()); | 143 | cmd.Parameters.AddWithValue("?scopeID", data.ScopeID.ToString()); |
142 | 144 | ||
143 | if (ExecuteNonQuery(cmd) < 1) | 145 | if (ExecuteNonQuery(cmd) < 1) |
144 | { | 146 | { |
145 | string insert = "insert into `" + m_Realm + "` (`UUID`, `ScopeID`, `" + | 147 | string insert = "insert into `" + m_Realm + "` (`UUID`, `ScopeID`, `" + |
146 | String.Join("`, `", fields) + | 148 | String.Join("`, `", fields) + |
147 | "`) values (?principalID, ?scopeID, ?" + String.Join(", ?", fields) + ")"; | 149 | "`) values (?principalID, ?scopeID, ?" + String.Join(", ?", fields) + ")"; |
148 | 150 | ||
149 | cmd.CommandText = insert; | 151 | cmd.CommandText = insert; |
150 | 152 | ||
151 | if (ExecuteNonQuery(cmd) < 1) | 153 | if (ExecuteNonQuery(cmd) < 1) |
152 | { | 154 | { |
153 | cmd.Dispose(); | 155 | cmd.Dispose(); |
154 | return false; | 156 | return false; |
155 | } | ||
156 | } | 157 | } |
157 | } | 158 | } |
158 | 159 | ||
160 | cmd.Dispose(); | ||
161 | |||
159 | return true; | 162 | return true; |
160 | } | 163 | } |
161 | 164 | ||
162 | public bool SetDataItem(UUID principalID, string item, string value) | 165 | public bool SetDataItem(UUID principalID, string item, string value) |
163 | { | 166 | { |
164 | using (MySqlCommand cmd = new MySqlCommand("update `" + m_Realm + "` set `" + | 167 | MySqlCommand cmd = new MySqlCommand("update `" + m_Realm + |
165 | item + "` = ?" + item + " where UUID = ?UUID")) | 168 | "` set `" + item + "` = ?" + item + " where UUID = ?UUID"); |
166 | { | ||
167 | cmd.Parameters.AddWithValue("?" + item, value); | ||
168 | cmd.Parameters.AddWithValue("?UUID", principalID.ToString()); | ||
169 | 169 | ||
170 | if (ExecuteNonQuery(cmd) > 0) | 170 | |
171 | return true; | 171 | cmd.Parameters.AddWithValue("?"+item, value); |
172 | } | 172 | cmd.Parameters.AddWithValue("?UUID", principalID.ToString()); |
173 | |||
174 | if (ExecuteNonQuery(cmd) > 0) | ||
175 | return true; | ||
173 | 176 | ||
174 | return false; | 177 | return false; |
175 | } | 178 | } |
diff --git a/OpenSim/Data/MySQL/MySQLUserData.cs b/OpenSim/Data/MySQL/MySQLUserData.cs index bd46dfc..04f872f 100644 --- a/OpenSim/Data/MySQL/MySQLUserData.cs +++ b/OpenSim/Data/MySQL/MySQLUserData.cs | |||
@@ -181,20 +181,21 @@ namespace OpenSim.Data.MySQL | |||
181 | param["?first"] = user; | 181 | param["?first"] = user; |
182 | param["?second"] = last; | 182 | param["?second"] = last; |
183 | 183 | ||
184 | using (IDbCommand result = dbm.Manager.Query( | 184 | IDbCommand result = |
185 | "SELECT * FROM " + m_usersTableName + " WHERE username = ?first AND lastname = ?second", param)) | 185 | dbm.Manager.Query( |
186 | { | 186 | "SELECT * FROM " + m_usersTableName + " WHERE username = ?first AND lastname = ?second", param); |
187 | using (IDataReader reader = result.ExecuteReader()) | 187 | IDataReader reader = result.ExecuteReader(); |
188 | { | 188 | |
189 | UserProfileData row = dbm.Manager.readUserRow(reader); | 189 | UserProfileData row = dbm.Manager.readUserRow(reader); |
190 | return row; | 190 | |
191 | } | 191 | reader.Dispose(); |
192 | } | 192 | result.Dispose(); |
193 | return row; | ||
193 | } | 194 | } |
194 | catch (Exception e) | 195 | catch (Exception e) |
195 | { | 196 | { |
196 | dbm.Manager.Reconnect(); | 197 | dbm.Manager.Reconnect(); |
197 | m_log.Error(e.Message, e); | 198 | m_log.Error(e.ToString()); |
198 | return null; | 199 | return null; |
199 | } | 200 | } |
200 | finally | 201 | finally |
@@ -219,30 +220,28 @@ namespace OpenSim.Data.MySQL | |||
219 | 220 | ||
220 | try | 221 | try |
221 | { | 222 | { |
222 | using (IDbCommand adder = dbm.Manager.Query( | 223 | IDbCommand adder = |
223 | "INSERT INTO `" + m_userFriendsTableName + "` " + | 224 | dbm.Manager.Query( |
224 | "(`ownerID`,`friendID`,`friendPerms`,`datetimestamp`) " + | 225 | "INSERT INTO `" + m_userFriendsTableName + "` " + |
225 | "VALUES " + | 226 | "(`ownerID`,`friendID`,`friendPerms`,`datetimestamp`) " + |
226 | "(?ownerID,?friendID,?friendPerms,?datetimestamp)", | 227 | "VALUES " + |
227 | param)) | 228 | "(?ownerID,?friendID,?friendPerms,?datetimestamp)", |
228 | { | 229 | param); |
229 | adder.ExecuteNonQuery(); | 230 | adder.ExecuteNonQuery(); |
230 | } | 231 | |
231 | 232 | adder = | |
232 | using (IDbCommand adder = dbm.Manager.Query( | 233 | dbm.Manager.Query( |
233 | "INSERT INTO `" + m_userFriendsTableName + "` " + | 234 | "INSERT INTO `" + m_userFriendsTableName + "` " + |
234 | "(`ownerID`,`friendID`,`friendPerms`,`datetimestamp`) " + | 235 | "(`ownerID`,`friendID`,`friendPerms`,`datetimestamp`) " + |
235 | "VALUES " + | 236 | "VALUES " + |
236 | "(?friendID,?ownerID,?friendPerms,?datetimestamp)", | 237 | "(?friendID,?ownerID,?friendPerms,?datetimestamp)", |
237 | param)) | 238 | param); |
238 | { | 239 | adder.ExecuteNonQuery(); |
239 | adder.ExecuteNonQuery(); | ||
240 | } | ||
241 | } | 240 | } |
242 | catch (Exception e) | 241 | catch (Exception e) |
243 | { | 242 | { |
244 | dbm.Manager.Reconnect(); | 243 | dbm.Manager.Reconnect(); |
245 | m_log.Error(e.Message, e); | 244 | m_log.Error(e.ToString()); |
246 | return; | 245 | return; |
247 | } | 246 | } |
248 | finally | 247 | finally |
@@ -261,24 +260,22 @@ namespace OpenSim.Data.MySQL | |||
261 | 260 | ||
262 | try | 261 | try |
263 | { | 262 | { |
264 | using (IDbCommand updater = dbm.Manager.Query( | 263 | IDbCommand updater = |
264 | dbm.Manager.Query( | ||
265 | "delete from " + m_userFriendsTableName + " where ownerID = ?ownerID and friendID = ?friendID", | 265 | "delete from " + m_userFriendsTableName + " where ownerID = ?ownerID and friendID = ?friendID", |
266 | param)) | 266 | param); |
267 | { | 267 | updater.ExecuteNonQuery(); |
268 | updater.ExecuteNonQuery(); | ||
269 | } | ||
270 | 268 | ||
271 | using (IDbCommand updater = dbm.Manager.Query( | 269 | updater = |
270 | dbm.Manager.Query( | ||
272 | "delete from " + m_userFriendsTableName + " where ownerID = ?friendID and friendID = ?ownerID", | 271 | "delete from " + m_userFriendsTableName + " where ownerID = ?friendID and friendID = ?ownerID", |
273 | param)) | 272 | param); |
274 | { | 273 | updater.ExecuteNonQuery(); |
275 | updater.ExecuteNonQuery(); | ||
276 | } | ||
277 | } | 274 | } |
278 | catch (Exception e) | 275 | catch (Exception e) |
279 | { | 276 | { |
280 | dbm.Manager.Reconnect(); | 277 | dbm.Manager.Reconnect(); |
281 | m_log.Error(e.Message, e); | 278 | m_log.Error(e.ToString()); |
282 | return; | 279 | return; |
283 | } | 280 | } |
284 | finally | 281 | finally |
@@ -298,19 +295,18 @@ namespace OpenSim.Data.MySQL | |||
298 | 295 | ||
299 | try | 296 | try |
300 | { | 297 | { |
301 | using (IDbCommand updater = dbm.Manager.Query( | 298 | IDbCommand updater = |
299 | dbm.Manager.Query( | ||
302 | "update " + m_userFriendsTableName + | 300 | "update " + m_userFriendsTableName + |
303 | " SET friendPerms = ?friendPerms " + | 301 | " SET friendPerms = ?friendPerms " + |
304 | "where ownerID = ?ownerID and friendID = ?friendID", | 302 | "where ownerID = ?ownerID and friendID = ?friendID", |
305 | param)) | 303 | param); |
306 | { | 304 | updater.ExecuteNonQuery(); |
307 | updater.ExecuteNonQuery(); | ||
308 | } | ||
309 | } | 305 | } |
310 | catch (Exception e) | 306 | catch (Exception e) |
311 | { | 307 | { |
312 | dbm.Manager.Reconnect(); | 308 | dbm.Manager.Reconnect(); |
313 | m_log.Error(e.Message, e); | 309 | m_log.Error(e.ToString()); |
314 | return; | 310 | return; |
315 | } | 311 | } |
316 | finally | 312 | finally |
@@ -331,33 +327,34 @@ namespace OpenSim.Data.MySQL | |||
331 | try | 327 | try |
332 | { | 328 | { |
333 | //Left Join userfriends to itself | 329 | //Left Join userfriends to itself |
334 | using (IDbCommand result = dbm.Manager.Query( | 330 | IDbCommand result = |
335 | "select a.ownerID,a.friendID,a.friendPerms,b.friendPerms as ownerperms from " + | 331 | dbm.Manager.Query( |
336 | m_userFriendsTableName + " as a, " + m_userFriendsTableName + " as b" + | 332 | "select a.ownerID,a.friendID,a.friendPerms,b.friendPerms as ownerperms from " + |
337 | " where a.ownerID = ?ownerID and b.ownerID = a.friendID and b.friendID = a.ownerID", | 333 | m_userFriendsTableName + " as a, " + m_userFriendsTableName + " as b" + |
338 | param)) | 334 | " where a.ownerID = ?ownerID and b.ownerID = a.friendID and b.friendID = a.ownerID", |
335 | param); | ||
336 | IDataReader reader = result.ExecuteReader(); | ||
337 | |||
338 | while (reader.Read()) | ||
339 | { | 339 | { |
340 | using (IDataReader reader = result.ExecuteReader()) | 340 | FriendListItem fli = new FriendListItem(); |
341 | { | 341 | fli.FriendListOwner = new UUID((string) reader["ownerID"]); |
342 | while (reader.Read()) | 342 | fli.Friend = new UUID((string) reader["friendID"]); |
343 | { | 343 | fli.FriendPerms = (uint) Convert.ToInt32(reader["friendPerms"]); |
344 | FriendListItem fli = new FriendListItem(); | 344 | |
345 | fli.FriendListOwner = new UUID((string)reader["ownerID"]); | 345 | // This is not a real column in the database table, it's a joined column from the opposite record |
346 | fli.Friend = new UUID((string)reader["friendID"]); | 346 | fli.FriendListOwnerPerms = (uint) Convert.ToInt32(reader["ownerperms"]); |
347 | fli.FriendPerms = (uint)Convert.ToInt32(reader["friendPerms"]); | 347 | |
348 | 348 | Lfli.Add(fli); | |
349 | // This is not a real column in the database table, it's a joined column from the opposite record | ||
350 | fli.FriendListOwnerPerms = (uint)Convert.ToInt32(reader["ownerperms"]); | ||
351 | |||
352 | Lfli.Add(fli); | ||
353 | } | ||
354 | } | ||
355 | } | 349 | } |
350 | |||
351 | reader.Dispose(); | ||
352 | result.Dispose(); | ||
356 | } | 353 | } |
357 | catch (Exception e) | 354 | catch (Exception e) |
358 | { | 355 | { |
359 | dbm.Manager.Reconnect(); | 356 | dbm.Manager.Reconnect(); |
360 | m_log.Error(e.Message, e); | 357 | m_log.Error(e.ToString()); |
361 | return Lfli; | 358 | return Lfli; |
362 | } | 359 | } |
363 | finally | 360 | finally |
@@ -379,29 +376,29 @@ namespace OpenSim.Data.MySQL | |||
379 | { | 376 | { |
380 | Dictionary<string, object> param = new Dictionary<string, object>(); | 377 | Dictionary<string, object> param = new Dictionary<string, object>(); |
381 | param["?uuid"] = uuid.ToString(); | 378 | param["?uuid"] = uuid.ToString(); |
379 | IDbCommand result = | ||
380 | dbm.Manager.Query("select agentOnline,currentHandle from " + m_agentsTableName + | ||
381 | " where UUID = ?uuid", param); | ||
382 | 382 | ||
383 | using (IDbCommand result = dbm.Manager.Query("select agentOnline,currentHandle from " + m_agentsTableName + | 383 | IDataReader reader = result.ExecuteReader(); |
384 | " where UUID = ?uuid", param)) | 384 | while (reader.Read()) |
385 | { | 385 | { |
386 | using (IDataReader reader = result.ExecuteReader()) | 386 | FriendRegionInfo fri = new FriendRegionInfo(); |
387 | { | 387 | fri.isOnline = (sbyte)reader["agentOnline"] != 0; |
388 | while (reader.Read()) | 388 | fri.regionHandle = (ulong)reader["currentHandle"]; |
389 | { | 389 | |
390 | FriendRegionInfo fri = new FriendRegionInfo(); | 390 | infos[uuid] = fri; |
391 | fri.isOnline = (sbyte)reader["agentOnline"] != 0; | ||
392 | fri.regionHandle = (ulong)reader["currentHandle"]; | ||
393 | |||
394 | infos[uuid] = fri; | ||
395 | } | ||
396 | } | ||
397 | } | 391 | } |
392 | |||
393 | reader.Dispose(); | ||
394 | result.Dispose(); | ||
398 | } | 395 | } |
399 | } | 396 | } |
400 | catch (Exception e) | 397 | catch (Exception e) |
401 | { | 398 | { |
402 | m_log.Warn("[MYSQL]: Got exception on trying to find friends regions:", e); | 399 | m_log.Warn("[MYSQL]: Got exception on trying to find friends regions:", e); |
403 | dbm.Manager.Reconnect(); | 400 | dbm.Manager.Reconnect(); |
404 | m_log.Error(e.Message, e); | 401 | m_log.Error(e.ToString()); |
405 | } | 402 | } |
406 | finally | 403 | finally |
407 | { | 404 | { |
@@ -430,28 +427,28 @@ namespace OpenSim.Data.MySQL | |||
430 | 427 | ||
431 | try | 428 | try |
432 | { | 429 | { |
433 | using (IDbCommand result = dbm.Manager.Query( | 430 | IDbCommand result = |
434 | "SELECT UUID,username,lastname FROM " + m_usersTableName + | 431 | dbm.Manager.Query( |
435 | " WHERE username like ?first AND lastname like ?second LIMIT 100", | 432 | "SELECT UUID,username,lastname FROM " + m_usersTableName + |
436 | param)) | 433 | " WHERE username like ?first AND lastname like ?second LIMIT 100", |
434 | param); | ||
435 | IDataReader reader = result.ExecuteReader(); | ||
436 | |||
437 | while (reader.Read()) | ||
437 | { | 438 | { |
438 | using (IDataReader reader = result.ExecuteReader()) | 439 | AvatarPickerAvatar user = new AvatarPickerAvatar(); |
439 | { | 440 | user.AvatarID = new UUID((string) reader["UUID"]); |
440 | while (reader.Read()) | 441 | user.firstName = (string) reader["username"]; |
441 | { | 442 | user.lastName = (string) reader["lastname"]; |
442 | AvatarPickerAvatar user = new AvatarPickerAvatar(); | 443 | returnlist.Add(user); |
443 | user.AvatarID = new UUID((string)reader["UUID"]); | ||
444 | user.firstName = (string)reader["username"]; | ||
445 | user.lastName = (string)reader["lastname"]; | ||
446 | returnlist.Add(user); | ||
447 | } | ||
448 | } | ||
449 | } | 444 | } |
445 | reader.Dispose(); | ||
446 | result.Dispose(); | ||
450 | } | 447 | } |
451 | catch (Exception e) | 448 | catch (Exception e) |
452 | { | 449 | { |
453 | dbm.Manager.Reconnect(); | 450 | dbm.Manager.Reconnect(); |
454 | m_log.Error(e.Message, e); | 451 | m_log.Error(e.ToString()); |
455 | return returnlist; | 452 | return returnlist; |
456 | } | 453 | } |
457 | finally | 454 | finally |
@@ -468,28 +465,28 @@ namespace OpenSim.Data.MySQL | |||
468 | Dictionary<string, object> param = new Dictionary<string, object>(); | 465 | Dictionary<string, object> param = new Dictionary<string, object>(); |
469 | param["?first"] = objAlphaNumericPattern.Replace(querysplit[0], String.Empty) + "%"; | 466 | param["?first"] = objAlphaNumericPattern.Replace(querysplit[0], String.Empty) + "%"; |
470 | 467 | ||
471 | using (IDbCommand result = dbm.Manager.Query( | 468 | IDbCommand result = |
472 | "SELECT UUID,username,lastname FROM " + m_usersTableName + | 469 | dbm.Manager.Query( |
473 | " WHERE username like ?first OR lastname like ?first LIMIT 100", | 470 | "SELECT UUID,username,lastname FROM " + m_usersTableName + |
474 | param)) | 471 | " WHERE username like ?first OR lastname like ?first LIMIT 100", |
472 | param); | ||
473 | IDataReader reader = result.ExecuteReader(); | ||
474 | |||
475 | while (reader.Read()) | ||
475 | { | 476 | { |
476 | using (IDataReader reader = result.ExecuteReader()) | 477 | AvatarPickerAvatar user = new AvatarPickerAvatar(); |
477 | { | 478 | user.AvatarID = new UUID((string) reader["UUID"]); |
478 | while (reader.Read()) | 479 | user.firstName = (string) reader["username"]; |
479 | { | 480 | user.lastName = (string) reader["lastname"]; |
480 | AvatarPickerAvatar user = new AvatarPickerAvatar(); | 481 | returnlist.Add(user); |
481 | user.AvatarID = new UUID((string)reader["UUID"]); | ||
482 | user.firstName = (string)reader["username"]; | ||
483 | user.lastName = (string)reader["lastname"]; | ||
484 | returnlist.Add(user); | ||
485 | } | ||
486 | } | ||
487 | } | 482 | } |
483 | reader.Dispose(); | ||
484 | result.Dispose(); | ||
488 | } | 485 | } |
489 | catch (Exception e) | 486 | catch (Exception e) |
490 | { | 487 | { |
491 | dbm.Manager.Reconnect(); | 488 | dbm.Manager.Reconnect(); |
492 | m_log.Error(e.Message, e); | 489 | m_log.Error(e.ToString()); |
493 | return returnlist; | 490 | return returnlist; |
494 | } | 491 | } |
495 | finally | 492 | finally |
@@ -513,19 +510,20 @@ namespace OpenSim.Data.MySQL | |||
513 | Dictionary<string, object> param = new Dictionary<string, object>(); | 510 | Dictionary<string, object> param = new Dictionary<string, object>(); |
514 | param["?uuid"] = uuid.ToString(); | 511 | param["?uuid"] = uuid.ToString(); |
515 | 512 | ||
516 | using (IDbCommand result = dbm.Manager.Query("SELECT * FROM " + m_usersTableName + " WHERE UUID = ?uuid", param)) | 513 | IDbCommand result = dbm.Manager.Query("SELECT * FROM " + m_usersTableName + " WHERE UUID = ?uuid", param); |
517 | { | 514 | IDataReader reader = result.ExecuteReader(); |
518 | using (IDataReader reader = result.ExecuteReader()) | 515 | |
519 | { | 516 | UserProfileData row = dbm.Manager.readUserRow(reader); |
520 | UserProfileData row = dbm.Manager.readUserRow(reader); | 517 | |
521 | return row; | 518 | reader.Dispose(); |
522 | } | 519 | result.Dispose(); |
523 | } | 520 | |
521 | return row; | ||
524 | } | 522 | } |
525 | catch (Exception e) | 523 | catch (Exception e) |
526 | { | 524 | { |
527 | dbm.Manager.Reconnect(); | 525 | dbm.Manager.Reconnect(); |
528 | m_log.Error(e.Message, e); | 526 | m_log.Error(e.ToString()); |
529 | return null; | 527 | return null; |
530 | } | 528 | } |
531 | finally | 529 | finally |
@@ -571,15 +569,15 @@ namespace OpenSim.Data.MySQL | |||
571 | 569 | ||
572 | try | 570 | try |
573 | { | 571 | { |
574 | dbm.Manager.ExecuteParameterizedSql( | 572 | dbm.Manager.ExecuteParameterizedSql( |
575 | "update " + m_usersTableName + " SET webLoginKey = ?webLoginKey " + | 573 | "update " + m_usersTableName + " SET webLoginKey = ?webLoginKey " + |
576 | "where UUID = ?UUID", | 574 | "where UUID = ?UUID", |
577 | param); | 575 | param); |
578 | } | 576 | } |
579 | catch (Exception e) | 577 | catch (Exception e) |
580 | { | 578 | { |
581 | dbm.Manager.Reconnect(); | 579 | dbm.Manager.Reconnect(); |
582 | m_log.Error(e.Message, e); | 580 | m_log.Error(e.ToString()); |
583 | return; | 581 | return; |
584 | } | 582 | } |
585 | finally | 583 | finally |
@@ -602,19 +600,21 @@ namespace OpenSim.Data.MySQL | |||
602 | Dictionary<string, object> param = new Dictionary<string, object>(); | 600 | Dictionary<string, object> param = new Dictionary<string, object>(); |
603 | param["?uuid"] = uuid.ToString(); | 601 | param["?uuid"] = uuid.ToString(); |
604 | 602 | ||
605 | using (IDbCommand result = dbm.Manager.Query("SELECT * FROM " + m_agentsTableName + " WHERE UUID = ?uuid", param)) | 603 | IDbCommand result = dbm.Manager.Query("SELECT * FROM " + m_agentsTableName + " WHERE UUID = ?uuid", |
606 | { | 604 | param); |
607 | using (IDataReader reader = result.ExecuteReader()) | 605 | IDataReader reader = result.ExecuteReader(); |
608 | { | 606 | |
609 | UserAgentData row = dbm.Manager.readAgentRow(reader); | 607 | UserAgentData row = dbm.Manager.readAgentRow(reader); |
610 | return row; | 608 | |
611 | } | 609 | reader.Dispose(); |
612 | } | 610 | result.Dispose(); |
611 | |||
612 | return row; | ||
613 | } | 613 | } |
614 | catch (Exception e) | 614 | catch (Exception e) |
615 | { | 615 | { |
616 | dbm.Manager.Reconnect(); | 616 | dbm.Manager.Reconnect(); |
617 | m_log.Error(e.Message, e); | 617 | m_log.Error(e.ToString()); |
618 | return null; | 618 | return null; |
619 | } | 619 | } |
620 | finally | 620 | finally |
@@ -638,20 +638,19 @@ namespace OpenSim.Data.MySQL | |||
638 | 638 | ||
639 | try | 639 | try |
640 | { | 640 | { |
641 | dbm.Manager.insertUserRow( | 641 | dbm.Manager.insertUserRow(user.ID, user.FirstName, user.SurName, user.Email, user.PasswordHash, user.PasswordSalt, |
642 | user.ID, user.FirstName, user.SurName, user.Email, user.PasswordHash, user.PasswordSalt, | 642 | user.HomeRegion, user.HomeRegionID, user.HomeLocation.X, user.HomeLocation.Y, |
643 | user.HomeRegion, user.HomeRegionID, user.HomeLocation.X, user.HomeLocation.Y, | 643 | user.HomeLocation.Z, |
644 | user.HomeLocation.Z, | 644 | user.HomeLookAt.X, user.HomeLookAt.Y, user.HomeLookAt.Z, user.Created, |
645 | user.HomeLookAt.X, user.HomeLookAt.Y, user.HomeLookAt.Z, user.Created, | 645 | user.LastLogin, user.UserInventoryURI, user.UserAssetURI, |
646 | user.LastLogin, user.UserInventoryURI, user.UserAssetURI, | 646 | user.CanDoMask, user.WantDoMask, |
647 | user.CanDoMask, user.WantDoMask, | 647 | user.AboutText, user.FirstLifeAboutText, user.Image, |
648 | user.AboutText, user.FirstLifeAboutText, user.Image, | 648 | user.FirstLifeImage, user.WebLoginKey, user.UserFlags, user.GodLevel, user.CustomType, user.Partner); |
649 | user.FirstLifeImage, user.WebLoginKey, user.UserFlags, user.GodLevel, user.CustomType, user.Partner); | ||
650 | } | 649 | } |
651 | catch (Exception e) | 650 | catch (Exception e) |
652 | { | 651 | { |
653 | dbm.Manager.Reconnect(); | 652 | dbm.Manager.Reconnect(); |
654 | m_log.Error(e.Message, e); | 653 | m_log.Error(e.ToString()); |
655 | } | 654 | } |
656 | finally | 655 | finally |
657 | { | 656 | { |
@@ -677,7 +676,7 @@ namespace OpenSim.Data.MySQL | |||
677 | catch (Exception e) | 676 | catch (Exception e) |
678 | { | 677 | { |
679 | dbm.Manager.Reconnect(); | 678 | dbm.Manager.Reconnect(); |
680 | m_log.Error(e.Message, e); | 679 | m_log.Error(e.ToString()); |
681 | } | 680 | } |
682 | finally | 681 | finally |
683 | { | 682 | { |
@@ -694,15 +693,14 @@ namespace OpenSim.Data.MySQL | |||
694 | MySQLSuperManager dbm = GetLockedConnection("UpdateUserProfile"); | 693 | MySQLSuperManager dbm = GetLockedConnection("UpdateUserProfile"); |
695 | try | 694 | try |
696 | { | 695 | { |
697 | dbm.Manager.updateUserRow( | 696 | dbm.Manager.updateUserRow(user.ID, user.FirstName, user.SurName, user.Email, user.PasswordHash, user.PasswordSalt, |
698 | user.ID, user.FirstName, user.SurName, user.Email, user.PasswordHash, user.PasswordSalt, | 697 | user.HomeRegion, user.HomeRegionID, user.HomeLocation.X, user.HomeLocation.Y, |
699 | user.HomeRegion, user.HomeRegionID, user.HomeLocation.X, user.HomeLocation.Y, | 698 | user.HomeLocation.Z, user.HomeLookAt.X, |
700 | user.HomeLocation.Z, user.HomeLookAt.X, | 699 | user.HomeLookAt.Y, user.HomeLookAt.Z, user.Created, user.LastLogin, |
701 | user.HomeLookAt.Y, user.HomeLookAt.Z, user.Created, user.LastLogin, | 700 | user.UserInventoryURI, |
702 | user.UserInventoryURI, | 701 | user.UserAssetURI, user.CanDoMask, user.WantDoMask, user.AboutText, |
703 | user.UserAssetURI, user.CanDoMask, user.WantDoMask, user.AboutText, | 702 | user.FirstLifeAboutText, user.Image, user.FirstLifeImage, user.WebLoginKey, |
704 | user.FirstLifeAboutText, user.Image, user.FirstLifeImage, user.WebLoginKey, | 703 | user.UserFlags, user.GodLevel, user.CustomType, user.Partner); |
705 | user.UserFlags, user.GodLevel, user.CustomType, user.Partner); | ||
706 | } | 704 | } |
707 | finally | 705 | finally |
708 | { | 706 | { |
@@ -750,29 +748,29 @@ namespace OpenSim.Data.MySQL | |||
750 | Dictionary<string, object> param = new Dictionary<string, object>(); | 748 | Dictionary<string, object> param = new Dictionary<string, object>(); |
751 | param["?owner"] = user.ToString(); | 749 | param["?owner"] = user.ToString(); |
752 | 750 | ||
753 | using (IDbCommand result = dbm.Manager.Query("SELECT * FROM " + m_appearanceTableName + " WHERE owner = ?owner", param)) | 751 | IDbCommand result = dbm.Manager.Query( |
752 | "SELECT * FROM " + m_appearanceTableName + " WHERE owner = ?owner", param); | ||
753 | IDataReader reader = result.ExecuteReader(); | ||
754 | |||
755 | AvatarAppearance appearance = dbm.Manager.readAppearanceRow(reader); | ||
756 | |||
757 | reader.Dispose(); | ||
758 | result.Dispose(); | ||
759 | |||
760 | if (null == appearance) | ||
754 | { | 761 | { |
755 | using (IDataReader reader = result.ExecuteReader()) | 762 | m_log.WarnFormat("[USER DB] No appearance found for user {0}", user.ToString()); |
756 | { | 763 | return null; |
757 | AvatarAppearance appearance = dbm.Manager.readAppearanceRow(reader); | ||
758 | |||
759 | if (appearance == null) | ||
760 | { | ||
761 | m_log.WarnFormat("[USER DB] No appearance found for user {0}", user.ToString()); | ||
762 | return null; | ||
763 | } | ||
764 | else | ||
765 | { | ||
766 | appearance.SetAttachments(GetUserAttachments(user)); | ||
767 | return appearance; | ||
768 | } | ||
769 | } | ||
770 | } | 764 | } |
765 | |||
766 | appearance.SetAttachments(GetUserAttachments(user)); | ||
767 | |||
768 | return appearance; | ||
771 | } | 769 | } |
772 | catch (Exception e) | 770 | catch (Exception e) |
773 | { | 771 | { |
774 | dbm.Manager.Reconnect(); | 772 | dbm.Manager.Reconnect(); |
775 | m_log.Error(e.Message, e); | 773 | m_log.Error(e.ToString()); |
776 | return null; | 774 | return null; |
777 | } | 775 | } |
778 | finally | 776 | finally |
@@ -800,7 +798,7 @@ namespace OpenSim.Data.MySQL | |||
800 | catch (Exception e) | 798 | catch (Exception e) |
801 | { | 799 | { |
802 | dbm.Manager.Reconnect(); | 800 | dbm.Manager.Reconnect(); |
803 | m_log.Error(e.Message, e); | 801 | m_log.Error(e.ToString()); |
804 | } | 802 | } |
805 | finally | 803 | finally |
806 | { | 804 | { |
@@ -835,20 +833,20 @@ namespace OpenSim.Data.MySQL | |||
835 | 833 | ||
836 | try | 834 | try |
837 | { | 835 | { |
838 | using (IDbCommand result = dbm.Manager.Query( | 836 | IDbCommand result = dbm.Manager.Query( |
839 | "SELECT attachpoint, item, asset from " + m_attachmentsTableName + " WHERE UUID = ?uuid", param)) | 837 | "SELECT attachpoint, item, asset from " + m_attachmentsTableName + " WHERE UUID = ?uuid", param); |
840 | { | 838 | IDataReader reader = result.ExecuteReader(); |
841 | using (IDataReader reader = result.ExecuteReader()) | 839 | |
842 | { | 840 | Hashtable ret = dbm.Manager.readAttachments(reader); |
843 | Hashtable ret = dbm.Manager.readAttachments(reader); | 841 | |
844 | return ret; | 842 | reader.Dispose(); |
845 | } | 843 | result.Dispose(); |
846 | } | 844 | return ret; |
847 | } | 845 | } |
848 | catch (Exception e) | 846 | catch (Exception e) |
849 | { | 847 | { |
850 | dbm.Manager.Reconnect(); | 848 | dbm.Manager.Reconnect(); |
851 | m_log.Error(e.Message, e); | 849 | m_log.Error(e.ToString()); |
852 | return null; | 850 | return null; |
853 | } | 851 | } |
854 | finally | 852 | finally |
@@ -907,7 +905,7 @@ namespace OpenSim.Data.MySQL | |||
907 | catch (Exception e) | 905 | catch (Exception e) |
908 | { | 906 | { |
909 | dbm.Manager.Reconnect(); | 907 | dbm.Manager.Reconnect(); |
910 | m_log.Error(e.Message, e); | 908 | m_log.Error(e.ToString()); |
911 | return; | 909 | return; |
912 | } | 910 | } |
913 | finally | 911 | finally |
diff --git a/OpenSim/Data/SQLite/SQLiteAssetData.cs b/OpenSim/Data/SQLite/SQLiteAssetData.cs index 49275cb..23642b3 100644 --- a/OpenSim/Data/SQLite/SQLiteAssetData.cs +++ b/OpenSim/Data/SQLite/SQLiteAssetData.cs | |||
@@ -162,22 +162,22 @@ namespace OpenSim.Data.SQLite | |||
162 | } | 162 | } |
163 | } | 163 | } |
164 | 164 | ||
165 | /// <summary> | 165 | // /// <summary> |
166 | /// Some... logging functionnality | 166 | // /// Some... logging functionnality |
167 | /// </summary> | 167 | // /// </summary> |
168 | /// <param name="asset"></param> | 168 | // /// <param name="asset"></param> |
169 | private static void LogAssetLoad(AssetBase asset) | 169 | // private static void LogAssetLoad(AssetBase asset) |
170 | { | 170 | // { |
171 | string temporary = asset.Temporary ? "Temporary" : "Stored"; | 171 | // string temporary = asset.Temporary ? "Temporary" : "Stored"; |
172 | string local = asset.Local ? "Local" : "Remote"; | 172 | // string local = asset.Local ? "Local" : "Remote"; |
173 | 173 | // | |
174 | int assetLength = (asset.Data != null) ? asset.Data.Length : 0; | 174 | // int assetLength = (asset.Data != null) ? asset.Data.Length : 0; |
175 | 175 | // | |
176 | m_log.Debug("[ASSET DB]: " + | 176 | // m_log.Debug("[ASSET DB]: " + |
177 | string.Format("Loaded {5} {4} Asset: [{0}][{3}] \"{1}\":{2} ({6} bytes)", | 177 | // string.Format("Loaded {5} {4} Asset: [{0}][{3}] \"{1}\":{2} ({6} bytes)", |
178 | asset.FullID, asset.Name, asset.Description, asset.Type, | 178 | // asset.FullID, asset.Name, asset.Description, asset.Type, |
179 | temporary, local, assetLength)); | 179 | // temporary, local, assetLength)); |
180 | } | 180 | // } |
181 | 181 | ||
182 | /// <summary> | 182 | /// <summary> |
183 | /// Check if an asset exist in database | 183 | /// Check if an asset exist in database |
@@ -231,12 +231,13 @@ namespace OpenSim.Data.SQLite | |||
231 | // TODO: this doesn't work yet because something more | 231 | // TODO: this doesn't work yet because something more |
232 | // interesting has to be done to actually get these values | 232 | // interesting has to be done to actually get these values |
233 | // back out. Not enough time to figure it out yet. | 233 | // back out. Not enough time to figure it out yet. |
234 | AssetBase asset = new AssetBase(); | 234 | AssetBase asset = new AssetBase( |
235 | new UUID((String)row["UUID"]), | ||
236 | (String)row["Name"], | ||
237 | Convert.ToSByte(row["Type"]) | ||
238 | ); | ||
235 | 239 | ||
236 | asset.FullID = new UUID((String) row["UUID"]); | ||
237 | asset.Name = (String) row["Name"]; | ||
238 | asset.Description = (String) row["Description"]; | 240 | asset.Description = (String) row["Description"]; |
239 | asset.Type = Convert.ToSByte(row["Type"]); | ||
240 | asset.Local = Convert.ToBoolean(row["Local"]); | 241 | asset.Local = Convert.ToBoolean(row["Local"]); |
241 | asset.Temporary = Convert.ToBoolean(row["Temporary"]); | 242 | asset.Temporary = Convert.ToBoolean(row["Temporary"]); |
242 | asset.Data = (byte[]) row["Data"]; | 243 | asset.Data = (byte[]) row["Data"]; |
diff --git a/OpenSim/Data/SQLite/SQLiteRegionData.cs b/OpenSim/Data/SQLite/SQLiteRegionData.cs index 08af7c3..b68de1a 100644 --- a/OpenSim/Data/SQLite/SQLiteRegionData.cs +++ b/OpenSim/Data/SQLite/SQLiteRegionData.cs | |||
@@ -1213,7 +1213,7 @@ namespace OpenSim.Data.SQLite | |||
1213 | if (!row.IsNull("ParticleSystem")) | 1213 | if (!row.IsNull("ParticleSystem")) |
1214 | prim.ParticleSystem = Convert.FromBase64String(row["ParticleSystem"].ToString()); | 1214 | prim.ParticleSystem = Convert.FromBase64String(row["ParticleSystem"].ToString()); |
1215 | 1215 | ||
1216 | prim.RotationalVelocity = new Vector3( | 1216 | prim.AngularVelocity = new Vector3( |
1217 | Convert.ToSingle(row["OmegaX"]), | 1217 | Convert.ToSingle(row["OmegaX"]), |
1218 | Convert.ToSingle(row["OmegaY"]), | 1218 | Convert.ToSingle(row["OmegaY"]), |
1219 | Convert.ToSingle(row["OmegaZ"]) | 1219 | Convert.ToSingle(row["OmegaZ"]) |
@@ -1530,9 +1530,9 @@ namespace OpenSim.Data.SQLite | |||
1530 | row["TextureAnimation"] = Convert.ToBase64String(prim.TextureAnimation); | 1530 | row["TextureAnimation"] = Convert.ToBase64String(prim.TextureAnimation); |
1531 | row["ParticleSystem"] = Convert.ToBase64String(prim.ParticleSystem); | 1531 | row["ParticleSystem"] = Convert.ToBase64String(prim.ParticleSystem); |
1532 | 1532 | ||
1533 | row["OmegaX"] = prim.RotationalVelocity.X; | 1533 | row["OmegaX"] = prim.AngularVelocity.X; |
1534 | row["OmegaY"] = prim.RotationalVelocity.Y; | 1534 | row["OmegaY"] = prim.AngularVelocity.Y; |
1535 | row["OmegaZ"] = prim.RotationalVelocity.Z; | 1535 | row["OmegaZ"] = prim.AngularVelocity.Z; |
1536 | 1536 | ||
1537 | row["CameraEyeOffsetX"] = prim.GetCameraEyeOffset().X; | 1537 | row["CameraEyeOffsetX"] = prim.GetCameraEyeOffset().X; |
1538 | row["CameraEyeOffsetY"] = prim.GetCameraEyeOffset().Y; | 1538 | row["CameraEyeOffsetY"] = prim.GetCameraEyeOffset().Y; |
diff --git a/OpenSim/Data/Tests/BasicAssetTest.cs b/OpenSim/Data/Tests/BasicAssetTest.cs index 1969d76..25aed61 100644 --- a/OpenSim/Data/Tests/BasicAssetTest.cs +++ b/OpenSim/Data/Tests/BasicAssetTest.cs | |||
@@ -66,9 +66,9 @@ namespace OpenSim.Data.Tests | |||
66 | [Test] | 66 | [Test] |
67 | public void T010_StoreSimpleAsset() | 67 | public void T010_StoreSimpleAsset() |
68 | { | 68 | { |
69 | AssetBase a1 = new AssetBase(uuid1, "asset one"); | 69 | AssetBase a1 = new AssetBase(uuid1, "asset one", (sbyte)AssetType.Texture); |
70 | AssetBase a2 = new AssetBase(uuid2, "asset two"); | 70 | AssetBase a2 = new AssetBase(uuid2, "asset two", (sbyte)AssetType.Texture); |
71 | AssetBase a3 = new AssetBase(uuid3, "asset three"); | 71 | AssetBase a3 = new AssetBase(uuid3, "asset three", (sbyte)AssetType.Texture); |
72 | a1.Data = asset1; | 72 | a1.Data = asset1; |
73 | a2.Data = asset1; | 73 | a2.Data = asset1; |
74 | a3.Data = asset1; | 74 | a3.Data = asset1; |
diff --git a/OpenSim/Data/Tests/BasicRegionTest.cs b/OpenSim/Data/Tests/BasicRegionTest.cs index 60a8874..f76962c 100644 --- a/OpenSim/Data/Tests/BasicRegionTest.cs +++ b/OpenSim/Data/Tests/BasicRegionTest.cs | |||
@@ -252,7 +252,7 @@ namespace OpenSim.Data.Tests | |||
252 | regionInfo.RegionLocX = 0; | 252 | regionInfo.RegionLocX = 0; |
253 | regionInfo.RegionLocY = 0; | 253 | regionInfo.RegionLocY = 0; |
254 | 254 | ||
255 | Scene scene = new Scene(regionInfo); | 255 | // Scene scene = new Scene(regionInfo); |
256 | 256 | ||
257 | SceneObjectPart sop = new SceneObjectPart(); | 257 | SceneObjectPart sop = new SceneObjectPart(); |
258 | sop.RegionHandle = regionh; | 258 | sop.RegionHandle = regionh; |
diff --git a/OpenSim/Data/Tests/PropertyCompareConstraint.cs b/OpenSim/Data/Tests/PropertyCompareConstraint.cs index 06ca53e..5b1f935 100644 --- a/OpenSim/Data/Tests/PropertyCompareConstraint.cs +++ b/OpenSim/Data/Tests/PropertyCompareConstraint.cs | |||
@@ -297,8 +297,8 @@ namespace OpenSim.Data.Tests | |||
297 | public void AssetShouldMatch() | 297 | public void AssetShouldMatch() |
298 | { | 298 | { |
299 | UUID uuid1 = UUID.Random(); | 299 | UUID uuid1 = UUID.Random(); |
300 | AssetBase actual = new AssetBase(uuid1, "asset one"); | 300 | AssetBase actual = new AssetBase(uuid1, "asset one", (sbyte)AssetType.Texture); |
301 | AssetBase expected = new AssetBase(uuid1, "asset one"); | 301 | AssetBase expected = new AssetBase(uuid1, "asset one", (sbyte)AssetType.Texture); |
302 | 302 | ||
303 | var constraint = Constraints.PropertyCompareConstraint(expected); | 303 | var constraint = Constraints.PropertyCompareConstraint(expected); |
304 | 304 | ||
@@ -309,8 +309,8 @@ namespace OpenSim.Data.Tests | |||
309 | public void AssetShouldNotMatch() | 309 | public void AssetShouldNotMatch() |
310 | { | 310 | { |
311 | UUID uuid1 = UUID.Random(); | 311 | UUID uuid1 = UUID.Random(); |
312 | AssetBase actual = new AssetBase(uuid1, "asset one"); | 312 | AssetBase actual = new AssetBase(uuid1, "asset one", (sbyte)AssetType.Texture); |
313 | AssetBase expected = new AssetBase(UUID.Random(), "asset one"); | 313 | AssetBase expected = new AssetBase(UUID.Random(), "asset one", (sbyte)AssetType.Texture); |
314 | 314 | ||
315 | var constraint = Constraints.PropertyCompareConstraint(expected); | 315 | var constraint = Constraints.PropertyCompareConstraint(expected); |
316 | 316 | ||
@@ -321,8 +321,8 @@ namespace OpenSim.Data.Tests | |||
321 | public void AssetShouldNotMatch2() | 321 | public void AssetShouldNotMatch2() |
322 | { | 322 | { |
323 | UUID uuid1 = UUID.Random(); | 323 | UUID uuid1 = UUID.Random(); |
324 | AssetBase actual = new AssetBase(uuid1, "asset one"); | 324 | AssetBase actual = new AssetBase(uuid1, "asset one", (sbyte)AssetType.Texture); |
325 | AssetBase expected = new AssetBase(uuid1, "asset two"); | 325 | AssetBase expected = new AssetBase(uuid1, "asset two", (sbyte)AssetType.Texture); |
326 | 326 | ||
327 | var constraint = Constraints.PropertyCompareConstraint(expected); | 327 | var constraint = Constraints.PropertyCompareConstraint(expected); |
328 | 328 | ||
diff --git a/OpenSim/Data/Tests/PropertyScrambler.cs b/OpenSim/Data/Tests/PropertyScrambler.cs index 72aaff1..c968364 100644 --- a/OpenSim/Data/Tests/PropertyScrambler.cs +++ b/OpenSim/Data/Tests/PropertyScrambler.cs | |||
@@ -165,7 +165,7 @@ namespace OpenSim.Data.Tests | |||
165 | [Test] | 165 | [Test] |
166 | public void TestScramble() | 166 | public void TestScramble() |
167 | { | 167 | { |
168 | AssetBase actual = new AssetBase(UUID.Random(), "asset one"); | 168 | AssetBase actual = new AssetBase(UUID.Random(), "asset one", (sbyte)AssetType.Texture); |
169 | new PropertyScrambler<AssetBase>().Scramble(actual); | 169 | new PropertyScrambler<AssetBase>().Scramble(actual); |
170 | } | 170 | } |
171 | 171 | ||
@@ -173,8 +173,7 @@ namespace OpenSim.Data.Tests | |||
173 | public void DontScramble() | 173 | public void DontScramble() |
174 | { | 174 | { |
175 | UUID uuid = UUID.Random(); | 175 | UUID uuid = UUID.Random(); |
176 | AssetBase asset = new AssetBase(); | 176 | AssetBase asset = new AssetBase(uuid, "asset", (sbyte)AssetType.Texture); |
177 | asset.FullID = uuid; | ||
178 | new PropertyScrambler<AssetBase>() | 177 | new PropertyScrambler<AssetBase>() |
179 | .DontScramble(x => x.Metadata) | 178 | .DontScramble(x => x.Metadata) |
180 | .DontScramble(x => x.FullID) | 179 | .DontScramble(x => x.FullID) |
diff --git a/OpenSim/Framework/ACL.cs b/OpenSim/Framework/ACL.cs index 3b1c0f0..f76e8b7 100644 --- a/OpenSim/Framework/ACL.cs +++ b/OpenSim/Framework/ACL.cs | |||
@@ -248,35 +248,5 @@ namespace OpenSim.Framework | |||
248 | 248 | ||
249 | #endregion | 249 | #endregion |
250 | 250 | ||
251 | #region Tests | 251 | |
252 | |||
253 | /// <summary> | ||
254 | /// ACL Test class | ||
255 | /// </summary> | ||
256 | internal class ACLTester | ||
257 | { | ||
258 | public ACLTester() | ||
259 | { | ||
260 | ACL acl = new ACL(); | ||
261 | |||
262 | Role Guests = new Role("Guests"); | ||
263 | acl.AddRole(Guests); | ||
264 | |||
265 | Role[] parents = new Role[0]; | ||
266 | parents[0] = Guests; | ||
267 | |||
268 | Role JoeGuest = new Role("JoeGuest", parents); | ||
269 | acl.AddRole(JoeGuest); | ||
270 | |||
271 | Resource CanBuild = new Resource("CanBuild"); | ||
272 | acl.AddResource(CanBuild); | ||
273 | |||
274 | |||
275 | acl.GrantPermission("Guests", "CanBuild"); | ||
276 | |||
277 | acl.HasPermission("JoeGuest", "CanBuild"); | ||
278 | } | ||
279 | } | ||
280 | |||
281 | #endregion | ||
282 | } \ No newline at end of file | 252 | } \ No newline at end of file |
diff --git a/OpenSim/Framework/AssetBase.cs b/OpenSim/Framework/AssetBase.cs index 9679ff2..212f41d 100644 --- a/OpenSim/Framework/AssetBase.cs +++ b/OpenSim/Framework/AssetBase.cs | |||
@@ -27,6 +27,8 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Xml.Serialization; | 29 | using System.Xml.Serialization; |
30 | using System.Reflection; | ||
31 | using log4net; | ||
30 | using OpenMetaverse; | 32 | using OpenMetaverse; |
31 | 33 | ||
32 | namespace OpenSim.Framework | 34 | namespace OpenSim.Framework |
@@ -37,6 +39,8 @@ namespace OpenSim.Framework | |||
37 | [Serializable] | 39 | [Serializable] |
38 | public class AssetBase | 40 | public class AssetBase |
39 | { | 41 | { |
42 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
43 | |||
40 | /// <summary> | 44 | /// <summary> |
41 | /// Data of the Asset | 45 | /// Data of the Asset |
42 | /// </summary> | 46 | /// </summary> |
@@ -47,16 +51,44 @@ namespace OpenSim.Framework | |||
47 | /// </summary> | 51 | /// </summary> |
48 | private AssetMetadata m_metadata; | 52 | private AssetMetadata m_metadata; |
49 | 53 | ||
54 | // This is needed for .NET serialization!!! | ||
55 | // Do NOT "Optimize" away! | ||
50 | public AssetBase() | 56 | public AssetBase() |
51 | { | 57 | { |
52 | m_metadata = new AssetMetadata(); | 58 | m_metadata = new AssetMetadata(); |
59 | m_metadata.FullID = UUID.Zero; | ||
60 | m_metadata.ID = UUID.Zero.ToString(); | ||
61 | m_metadata.Type = (sbyte)AssetType.Unknown; | ||
53 | } | 62 | } |
54 | 63 | ||
55 | public AssetBase(UUID assetId, string name) | 64 | public AssetBase(UUID assetID, string name, sbyte assetType) |
56 | { | 65 | { |
66 | if (assetType == (sbyte)AssetType.Unknown) | ||
67 | { | ||
68 | System.Diagnostics.StackTrace trace = new System.Diagnostics.StackTrace(true); | ||
69 | m_log.ErrorFormat("[ASSETBASE]: Creating asset '{0}' ({1}) with an unknown asset type\n{2}", | ||
70 | name, assetID, trace.ToString()); | ||
71 | } | ||
72 | |||
57 | m_metadata = new AssetMetadata(); | 73 | m_metadata = new AssetMetadata(); |
58 | m_metadata.FullID = assetId; | 74 | m_metadata.FullID = assetID; |
59 | m_metadata.Name = name; | 75 | m_metadata.Name = name; |
76 | m_metadata.Type = assetType; | ||
77 | } | ||
78 | |||
79 | public AssetBase(string assetID, string name, sbyte assetType) | ||
80 | { | ||
81 | if (assetType == (sbyte)AssetType.Unknown) | ||
82 | { | ||
83 | System.Diagnostics.StackTrace trace = new System.Diagnostics.StackTrace(true); | ||
84 | m_log.ErrorFormat("[ASSETBASE]: Creating asset '{0}' ({1}) with an unknown asset type\n{2}", | ||
85 | name, assetID, trace.ToString()); | ||
86 | } | ||
87 | |||
88 | m_metadata = new AssetMetadata(); | ||
89 | m_metadata.ID = assetID; | ||
90 | m_metadata.Name = name; | ||
91 | m_metadata.Type = assetType; | ||
60 | } | 92 | } |
61 | 93 | ||
62 | public bool ContainsReferences | 94 | public bool ContainsReferences |
@@ -193,11 +225,11 @@ namespace OpenSim.Framework | |||
193 | private string m_name = String.Empty; | 225 | private string m_name = String.Empty; |
194 | private string m_description = String.Empty; | 226 | private string m_description = String.Empty; |
195 | private DateTime m_creation_date; | 227 | private DateTime m_creation_date; |
196 | private sbyte m_type; | 228 | private sbyte m_type = (sbyte)AssetType.Unknown; |
197 | private string m_content_type; | 229 | private string m_content_type; |
198 | private byte[] m_sha1; | 230 | private byte[] m_sha1; |
199 | private bool m_local = false; | 231 | private bool m_local; |
200 | private bool m_temporary = false; | 232 | private bool m_temporary; |
201 | //private Dictionary<string, Uri> m_methods = new Dictionary<string, Uri>(); | 233 | //private Dictionary<string, Uri> m_methods = new Dictionary<string, Uri>(); |
202 | //private OSDMap m_extra_data; | 234 | //private OSDMap m_extra_data; |
203 | 235 | ||
@@ -211,7 +243,13 @@ namespace OpenSim.Framework | |||
211 | { | 243 | { |
212 | //get { return m_fullid.ToString(); } | 244 | //get { return m_fullid.ToString(); } |
213 | //set { m_fullid = new UUID(value); } | 245 | //set { m_fullid = new UUID(value); } |
214 | get { return m_id; } | 246 | get |
247 | { | ||
248 | if (String.IsNullOrEmpty(m_id)) | ||
249 | m_id = m_fullid.ToString(); | ||
250 | |||
251 | return m_id; | ||
252 | } | ||
215 | set | 253 | set |
216 | { | 254 | { |
217 | UUID uuid = UUID.Zero; | 255 | UUID uuid = UUID.Zero; |
diff --git a/OpenSim/Framework/AssetLandmark.cs b/OpenSim/Framework/AssetLandmark.cs index fd7a2cd..058b442 100644 --- a/OpenSim/Framework/AssetLandmark.cs +++ b/OpenSim/Framework/AssetLandmark.cs | |||
@@ -38,11 +38,9 @@ namespace OpenSim.Framework | |||
38 | public int Version; | 38 | public int Version; |
39 | 39 | ||
40 | public AssetLandmark(AssetBase a) | 40 | public AssetLandmark(AssetBase a) |
41 | : base(a.FullID, a.Name, a.Type) | ||
41 | { | 42 | { |
42 | Data = a.Data; | 43 | Data = a.Data; |
43 | FullID = a.FullID; | ||
44 | Type = a.Type; | ||
45 | Name = a.Name; | ||
46 | Description = a.Description; | 44 | Description = a.Description; |
47 | InternData(); | 45 | InternData(); |
48 | } | 46 | } |
diff --git a/OpenSim/Framework/AssetLoader/Filesystem/AssetLoaderFileSystem.cs b/OpenSim/Framework/AssetLoader/Filesystem/AssetLoaderFileSystem.cs index a394b1a..6ab1b58 100644 --- a/OpenSim/Framework/AssetLoader/Filesystem/AssetLoaderFileSystem.cs +++ b/OpenSim/Framework/AssetLoader/Filesystem/AssetLoaderFileSystem.cs | |||
@@ -43,18 +43,15 @@ namespace OpenSim.Framework.AssetLoader.Filesystem | |||
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 | protected static AssetBase CreateAsset(string assetIdStr, string name, string path, bool isImage) | 46 | protected static AssetBase CreateAsset(string assetIdStr, string name, string path, sbyte type) |
47 | { | 47 | { |
48 | AssetBase asset = new AssetBase( | 48 | AssetBase asset = new AssetBase(new UUID(assetIdStr), name, type); |
49 | new UUID(assetIdStr), | ||
50 | name | ||
51 | ); | ||
52 | 49 | ||
53 | if (!String.IsNullOrEmpty(path)) | 50 | if (!String.IsNullOrEmpty(path)) |
54 | { | 51 | { |
55 | //m_log.InfoFormat("[ASSETS]: Loading: [{0}][{1}]", name, path); | 52 | //m_log.InfoFormat("[ASSETS]: Loading: [{0}][{1}]", name, path); |
56 | 53 | ||
57 | LoadAsset(asset, isImage, path); | 54 | LoadAsset(asset, path); |
58 | } | 55 | } |
59 | else | 56 | else |
60 | { | 57 | { |
@@ -64,8 +61,14 @@ namespace OpenSim.Framework.AssetLoader.Filesystem | |||
64 | return asset; | 61 | return asset; |
65 | } | 62 | } |
66 | 63 | ||
67 | protected static void LoadAsset(AssetBase info, bool image, string path) | 64 | protected static void LoadAsset(AssetBase info, string path) |
68 | { | 65 | { |
66 | // bool image = | ||
67 | // (info.Type == (sbyte)AssetType.Texture || | ||
68 | // info.Type == (sbyte)AssetType.TextureTGA || | ||
69 | // info.Type == (sbyte)AssetType.ImageJPEG || | ||
70 | // info.Type == (sbyte)AssetType.ImageTGA); | ||
71 | |||
69 | FileInfo fInfo = new FileInfo(path); | 72 | FileInfo fInfo = new FileInfo(path); |
70 | long numBytes = fInfo.Length; | 73 | long numBytes = fInfo.Length; |
71 | if (fInfo.Exists) | 74 | if (fInfo.Exists) |
@@ -138,10 +141,10 @@ namespace OpenSim.Framework.AssetLoader.Filesystem | |||
138 | { | 141 | { |
139 | string assetIdStr = source.Configs[i].GetString("assetID", UUID.Random().ToString()); | 142 | string assetIdStr = source.Configs[i].GetString("assetID", UUID.Random().ToString()); |
140 | string name = source.Configs[i].GetString("name", String.Empty); | 143 | string name = source.Configs[i].GetString("name", String.Empty); |
141 | sbyte type = (sbyte) source.Configs[i].GetInt("assetType", 0); | 144 | sbyte type = (sbyte)source.Configs[i].GetInt("assetType", 0); |
142 | string assetPath = Path.Combine(dir, source.Configs[i].GetString("fileName", String.Empty)); | 145 | string assetPath = Path.Combine(dir, source.Configs[i].GetString("fileName", String.Empty)); |
143 | 146 | ||
144 | AssetBase newAsset = CreateAsset(assetIdStr, name, assetPath, false); | 147 | AssetBase newAsset = CreateAsset(assetIdStr, name, assetPath, type); |
145 | 148 | ||
146 | newAsset.Type = type; | 149 | newAsset.Type = type; |
147 | assets.Add(newAsset); | 150 | assets.Add(newAsset); |
diff --git a/OpenSim/Framework/Capabilities/Caps.cs b/OpenSim/Framework/Capabilities/Caps.cs index 1dfb2d4..1f1ac78 100644 --- a/OpenSim/Framework/Capabilities/Caps.cs +++ b/OpenSim/Framework/Capabilities/Caps.cs | |||
@@ -89,7 +89,7 @@ namespace OpenSim.Framework.Capabilities | |||
89 | //private static readonly string m_requestTexture = "0003/"; | 89 | //private static readonly string m_requestTexture = "0003/"; |
90 | private static readonly string m_notecardUpdatePath = "0004/"; | 90 | private static readonly string m_notecardUpdatePath = "0004/"; |
91 | private static readonly string m_notecardTaskUpdatePath = "0005/"; | 91 | private static readonly string m_notecardTaskUpdatePath = "0005/"; |
92 | private static readonly string m_fetchInventoryPath = "0006/"; | 92 | // private static readonly string m_fetchInventoryPath = "0006/"; |
93 | 93 | ||
94 | // The following entries are in a module, however, they are also here so that we don't re-assign | 94 | // The following entries are in a module, however, they are also here so that we don't re-assign |
95 | // the path to another cap by mistake. | 95 | // the path to another cap by mistake. |
@@ -208,7 +208,7 @@ namespace OpenSim.Framework.Capabilities | |||
208 | // As of RC 1.22.9 of the Linden client this is | 208 | // As of RC 1.22.9 of the Linden client this is |
209 | // supported | 209 | // supported |
210 | 210 | ||
211 | m_capsHandlers["WebFetchInventoryDescendents"] =new RestStreamHandler("POST", capsBase + m_fetchInventoryPath, FetchInventoryDescendentsRequest); | 211 | //m_capsHandlers["WebFetchInventoryDescendents"] =new RestStreamHandler("POST", capsBase + m_fetchInventoryPath, FetchInventoryDescendentsRequest); |
212 | 212 | ||
213 | // justincc: I've disabled the CAPS service for now to fix problems with selecting textures, and | 213 | // justincc: I've disabled the CAPS service for now to fix problems with selecting textures, and |
214 | // subsequent inventory breakage, in the edit object pane (such as mantis 1085). This requires | 214 | // subsequent inventory breakage, in the edit object pane (such as mantis 1085). This requires |
@@ -888,10 +888,7 @@ namespace OpenSim.Framework.Capabilities | |||
888 | } | 888 | } |
889 | 889 | ||
890 | AssetBase asset; | 890 | AssetBase asset; |
891 | asset = new AssetBase(); | 891 | asset = new AssetBase(assetID, assetName, assType); |
892 | asset.FullID = assetID; | ||
893 | asset.Type = assType; | ||
894 | asset.Name = assetName; | ||
895 | asset.Data = data; | 892 | asset.Data = data; |
896 | if (AddNewAsset != null) | 893 | if (AddNewAsset != null) |
897 | AddNewAsset(asset); | 894 | AddNewAsset(asset); |
diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index aa71536..6648c36 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs | |||
@@ -679,7 +679,7 @@ namespace OpenSim.Framework.Communications.Cache | |||
679 | /// <param name="fetchFolders"></param> | 679 | /// <param name="fetchFolders"></param> |
680 | /// <param name="fetchItems"></param> | 680 | /// <param name="fetchItems"></param> |
681 | /// <returns>true if the request was queued or successfully processed, false otherwise</returns> | 681 | /// <returns>true if the request was queued or successfully processed, false otherwise</returns> |
682 | public bool SendInventoryDecendents(IClientAPI client, UUID folderID, bool fetchFolders, bool fetchItems) | 682 | public bool SendInventoryDecendents(IClientAPI client, UUID folderID, int version, bool fetchFolders, bool fetchItems) |
683 | { | 683 | { |
684 | if (m_hasReceivedInventory) | 684 | if (m_hasReceivedInventory) |
685 | { | 685 | { |
@@ -693,7 +693,7 @@ namespace OpenSim.Framework.Communications.Cache | |||
693 | 693 | ||
694 | client.SendInventoryFolderDetails( | 694 | client.SendInventoryFolderDetails( |
695 | client.AgentId, folderID, folder.RequestListOfItems(), | 695 | client.AgentId, folderID, folder.RequestListOfItems(), |
696 | folder.RequestListOfFolders(), fetchFolders, fetchItems); | 696 | folder.RequestListOfFolders(), version, fetchFolders, fetchItems); |
697 | 697 | ||
698 | return true; | 698 | return true; |
699 | } | 699 | } |
diff --git a/OpenSim/Framework/Communications/Osp/OspResolver.cs b/OpenSim/Framework/Communications/Osp/OspResolver.cs index 32f0efc..4013896 100644 --- a/OpenSim/Framework/Communications/Osp/OspResolver.cs +++ b/OpenSim/Framework/Communications/Osp/OspResolver.cs | |||
@@ -93,7 +93,7 @@ namespace OpenSim.Framework.Communications.Osp | |||
93 | if (!ospa.StartsWith(OSPA_PREFIX)) | 93 | if (!ospa.StartsWith(OSPA_PREFIX)) |
94 | return UUID.Zero; | 94 | return UUID.Zero; |
95 | 95 | ||
96 | m_log.DebugFormat("[OSP RESOLVER]: Resolving {0}", ospa); | 96 | // m_log.DebugFormat("[OSP RESOLVER]: Resolving {0}", ospa); |
97 | 97 | ||
98 | string ospaMeat = ospa.Substring(OSPA_PREFIX.Length); | 98 | string ospaMeat = ospa.Substring(OSPA_PREFIX.Length); |
99 | string[] ospaTuples = ospaMeat.Split(OSPA_TUPLE_SEPARATOR_ARRAY); | 99 | string[] ospaTuples = ospaMeat.Split(OSPA_TUPLE_SEPARATOR_ARRAY); |
diff --git a/OpenSim/Framework/Communications/Services/LoginService.cs b/OpenSim/Framework/Communications/Services/LoginService.cs index 922cd49..b652299 100644 --- a/OpenSim/Framework/Communications/Services/LoginService.cs +++ b/OpenSim/Framework/Communications/Services/LoginService.cs | |||
@@ -1031,30 +1031,26 @@ namespace OpenSim.Framework.Communications.Services | |||
1031 | return true; | 1031 | return true; |
1032 | } | 1032 | } |
1033 | 1033 | ||
1034 | // StartLocation not available, send him to a nearby region instead | 1034 | // Get the default region handle |
1035 | // regionInfo = m_gridService.RequestClosestRegion(""); | 1035 | ulong defaultHandle = Utils.UIntsToLong(m_defaultHomeX * Constants.RegionSize, m_defaultHomeY * Constants.RegionSize); |
1036 | //m_log.InfoFormat("[LOGIN]: StartLocation not available sending to region {0}", regionInfo.regionName); | ||
1037 | 1036 | ||
1038 | // Send him to default region instead | 1037 | // If we haven't already tried the default region, reset regionInfo |
1039 | ulong defaultHandle = (((ulong)m_defaultHomeX * Constants.RegionSize) << 32) | | 1038 | if (regionInfo != null && defaultHandle != regionInfo.RegionHandle) |
1040 | ((ulong)m_defaultHomeY * Constants.RegionSize); | 1039 | regionInfo = null; |
1041 | 1040 | ||
1042 | if ((regionInfo != null) && (defaultHandle == regionInfo.RegionHandle)) | 1041 | if (regionInfo == null) |
1043 | { | 1042 | { |
1044 | m_log.ErrorFormat("[LOGIN]: Not trying the default region since this is the same as the selected region"); | 1043 | m_log.Error("[LOGIN]: Sending user to default region " + defaultHandle + " instead"); |
1045 | return false; | 1044 | regionInfo = GetRegionInfo(defaultHandle); |
1046 | } | 1045 | } |
1047 | 1046 | ||
1048 | m_log.Error("[LOGIN]: Sending user to default region " + defaultHandle + " instead"); | ||
1049 | regionInfo = GetRegionInfo(defaultHandle); | ||
1050 | |||
1051 | if (regionInfo == null) | 1047 | if (regionInfo == null) |
1052 | { | 1048 | { |
1053 | m_log.ErrorFormat("[LOGIN]: No default region available. Aborting."); | 1049 | m_log.ErrorFormat("[LOGIN]: Sending user to any region"); |
1054 | return false; | 1050 | regionInfo = RequestClosestRegion(String.Empty); |
1055 | } | 1051 | } |
1056 | 1052 | ||
1057 | theUser.CurrentAgent.Position = new Vector3(128, 128, 0); | 1053 | theUser.CurrentAgent.Position = new Vector3(128f, 128f, 0f); |
1058 | response.StartLocation = "safe"; | 1054 | response.StartLocation = "safe"; |
1059 | 1055 | ||
1060 | return PrepareLoginToRegion(regionInfo, theUser, response, client); | 1056 | return PrepareLoginToRegion(regionInfo, theUser, response, client); |
diff --git a/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs b/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs deleted file mode 100644 index caaebd7..0000000 --- a/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs +++ /dev/null | |||
@@ -1,159 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Threading; | ||
31 | using NUnit.Framework; | ||
32 | using NUnit.Framework.SyntaxHelpers; | ||
33 | using OpenMetaverse; | ||
34 | using OpenSim.Framework; | ||
35 | using OpenSim.Framework.Communications.Cache; | ||
36 | using OpenSim.Services.Interfaces; | ||
37 | using OpenSim.Tests.Common.Mock; | ||
38 | |||
39 | namespace OpenSim.Framework.Communications.Tests | ||
40 | { | ||
41 | /// <summary> | ||
42 | /// Asset cache tests | ||
43 | /// </summary> | ||
44 | [TestFixture] | ||
45 | public class AssetCacheTests | ||
46 | { | ||
47 | private class FakeUserService : IUserService | ||
48 | { | ||
49 | public void AddTemporaryUserProfile(UserProfileData userProfile) | ||
50 | { | ||
51 | throw new NotImplementedException(); | ||
52 | } | ||
53 | |||
54 | public UserProfileData GetUserProfile(string firstName, string lastName) | ||
55 | { | ||
56 | throw new NotImplementedException(); | ||
57 | } | ||
58 | |||
59 | public UserProfileData GetUserProfile(UUID userId) | ||
60 | { | ||
61 | throw new NotImplementedException(); | ||
62 | } | ||
63 | |||
64 | public UserProfileData GetUserProfile(Uri uri) | ||
65 | { | ||
66 | UserProfileData userProfile = new UserProfileData(); | ||
67 | |||
68 | // userProfile.ID = new UUID(Util.GetHashGuid(uri.ToString(), AssetCache.AssetInfo.Secret)); | ||
69 | |||
70 | return userProfile; | ||
71 | } | ||
72 | |||
73 | public Uri GetUserUri(UserProfileData userProfile) | ||
74 | { | ||
75 | throw new NotImplementedException(); | ||
76 | } | ||
77 | |||
78 | public UserAgentData GetAgentByUUID(UUID userId) | ||
79 | { | ||
80 | throw new NotImplementedException(); | ||
81 | } | ||
82 | |||
83 | public void ClearUserAgent(UUID avatarID) | ||
84 | { | ||
85 | throw new NotImplementedException(); | ||
86 | } | ||
87 | |||
88 | public List<AvatarPickerAvatar> GenerateAgentPickerRequestResponse(UUID QueryID, string Query) | ||
89 | { | ||
90 | throw new NotImplementedException(); | ||
91 | } | ||
92 | |||
93 | public UserProfileData SetupMasterUser(string firstName, string lastName) | ||
94 | { | ||
95 | throw new NotImplementedException(); | ||
96 | } | ||
97 | |||
98 | public UserProfileData SetupMasterUser(string firstName, string lastName, string password) | ||
99 | { | ||
100 | throw new NotImplementedException(); | ||
101 | } | ||
102 | |||
103 | public UserProfileData SetupMasterUser(UUID userId) | ||
104 | { | ||
105 | throw new NotImplementedException(); | ||
106 | } | ||
107 | |||
108 | public bool UpdateUserProfile(UserProfileData data) | ||
109 | { | ||
110 | throw new NotImplementedException(); | ||
111 | } | ||
112 | |||
113 | public void AddNewUserFriend(UUID friendlistowner, UUID friend, uint perms) | ||
114 | { | ||
115 | throw new NotImplementedException(); | ||
116 | } | ||
117 | |||
118 | public void RemoveUserFriend(UUID friendlistowner, UUID friend) | ||
119 | { | ||
120 | throw new NotImplementedException(); | ||
121 | } | ||
122 | |||
123 | public void UpdateUserFriendPerms(UUID friendlistowner, UUID friend, uint perms) | ||
124 | { | ||
125 | throw new NotImplementedException(); | ||
126 | } | ||
127 | |||
128 | public void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, Vector3 position, Vector3 lookat) | ||
129 | { | ||
130 | throw new NotImplementedException(); | ||
131 | } | ||
132 | |||
133 | public void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, float posx, float posy, float posz) | ||
134 | { | ||
135 | throw new NotImplementedException(); | ||
136 | } | ||
137 | |||
138 | public List<FriendListItem> GetUserFriendList(UUID friendlistowner) | ||
139 | { | ||
140 | throw new NotImplementedException(); | ||
141 | } | ||
142 | |||
143 | public bool VerifySession(UUID userID, UUID sessionID) | ||
144 | { | ||
145 | return true; | ||
146 | } | ||
147 | |||
148 | public void SetInventoryService(IInventoryService inv) | ||
149 | { | ||
150 | throw new NotImplementedException(); | ||
151 | } | ||
152 | |||
153 | public virtual bool AuthenticateUserByPassword(UUID userID, string password) | ||
154 | { | ||
155 | throw new NotImplementedException(); | ||
156 | } | ||
157 | } | ||
158 | } | ||
159 | } | ||
diff --git a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs index e891d9c..60f0ba8 100644 --- a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs +++ b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs | |||
@@ -75,7 +75,7 @@ namespace OpenSim.Framework.Communications.Tests | |||
75 | 75 | ||
76 | m_regionConnector.AddRegion(new RegionInfo(42, 43, m_capsEndPoint, m_regionExternalName)); | 76 | m_regionConnector.AddRegion(new RegionInfo(42, 43, m_capsEndPoint, m_regionExternalName)); |
77 | 77 | ||
78 | //IInventoryService m_inventoryService = new TestInventoryService(); | 78 | //IInventoryService m_inventoryService = new MockInventoryService(); |
79 | 79 | ||
80 | m_localUserServices = (LocalUserServices) m_commsManager.UserService; | 80 | m_localUserServices = (LocalUserServices) m_commsManager.UserService; |
81 | m_localUserServices.AddUser(m_firstName,m_lastName,"boingboing","abc@ftw.com",42,43); | 81 | m_localUserServices.AddUser(m_firstName,m_lastName,"boingboing","abc@ftw.com",42,43); |
@@ -95,7 +95,8 @@ namespace OpenSim.Framework.Communications.Tests | |||
95 | TestHelper.InMethod(); | 95 | TestHelper.InMethod(); |
96 | // We want to use our own LoginService for this test, one that | 96 | // We want to use our own LoginService for this test, one that |
97 | // doesn't require authentication. | 97 | // doesn't require authentication. |
98 | new LLStandaloneLoginService((UserManagerBase)m_commsManager.UserService, "Hello folks", new TestInventoryService(), | 98 | new LLStandaloneLoginService( |
99 | (UserManagerBase)m_commsManager.UserService, "Hello folks", new MockInventoryService(), | ||
99 | m_commsManager.NetworkServersInfo, false, new LibraryRootFolder(String.Empty), m_regionConnector); | 100 | m_commsManager.NetworkServersInfo, false, new LibraryRootFolder(String.Empty), m_regionConnector); |
100 | 101 | ||
101 | Hashtable loginParams = new Hashtable(); | 102 | Hashtable loginParams = new Hashtable(); |
@@ -457,148 +458,4 @@ namespace OpenSim.Framework.Communications.Tests | |||
457 | #endregion | 458 | #endregion |
458 | } | 459 | } |
459 | } | 460 | } |
460 | 461 | } \ No newline at end of file | |
461 | class TestInventoryService : IInventoryService | ||
462 | { | ||
463 | public TestInventoryService() | ||
464 | { | ||
465 | } | ||
466 | |||
467 | /// <summary> | ||
468 | /// <see cref="OpenSim.Framework.Communications.IInterServiceInventoryServices"/> | ||
469 | /// </summary> | ||
470 | /// <param name="userId"></param> | ||
471 | /// <returns></returns> | ||
472 | public bool CreateUserInventory(UUID userId) | ||
473 | { | ||
474 | return false; | ||
475 | } | ||
476 | |||
477 | /// <summary> | ||
478 | /// <see cref="OpenSim.Framework.Communications.IInterServiceInventoryServices"/> | ||
479 | /// </summary> | ||
480 | /// <param name="userId"></param> | ||
481 | /// <returns></returns> | ||
482 | public List<InventoryFolderBase> GetInventorySkeleton(UUID userId) | ||
483 | { | ||
484 | List<InventoryFolderBase> folders = new List<InventoryFolderBase>(); | ||
485 | InventoryFolderBase folder = new InventoryFolderBase(); | ||
486 | folder.ID = UUID.Random(); | ||
487 | folder.Owner = userId; | ||
488 | folders.Add(folder); | ||
489 | return folders; | ||
490 | } | ||
491 | |||
492 | /// <summary> | ||
493 | /// Returns a list of all the active gestures in a user's inventory. | ||
494 | /// </summary> | ||
495 | /// <param name="userId"> | ||
496 | /// The <see cref="UUID"/> of the user | ||
497 | /// </param> | ||
498 | /// <returns> | ||
499 | /// A flat list of the gesture items. | ||
500 | /// </returns> | ||
501 | public List<InventoryItemBase> GetActiveGestures(UUID userId) | ||
502 | { | ||
503 | return null; | ||
504 | } | ||
505 | |||
506 | public InventoryCollection GetUserInventory(UUID userID) | ||
507 | { | ||
508 | return null; | ||
509 | } | ||
510 | |||
511 | public void GetUserInventory(UUID userID, OpenSim.Services.Interfaces.InventoryReceiptCallback callback) | ||
512 | { | ||
513 | } | ||
514 | |||
515 | public InventoryFolderBase GetFolderForType(UUID userID, AssetType type) | ||
516 | { | ||
517 | return null; | ||
518 | } | ||
519 | |||
520 | public InventoryCollection GetFolderContent(UUID userID, UUID folderID) | ||
521 | { | ||
522 | return null; | ||
523 | } | ||
524 | |||
525 | public List<InventoryItemBase> GetFolderItems(UUID userID, UUID folderID) | ||
526 | { | ||
527 | return null; | ||
528 | } | ||
529 | |||
530 | public bool AddFolder(InventoryFolderBase folder) | ||
531 | { | ||
532 | return false; | ||
533 | } | ||
534 | |||
535 | public bool UpdateFolder(InventoryFolderBase folder) | ||
536 | { | ||
537 | return false; | ||
538 | } | ||
539 | |||
540 | public bool MoveFolder(InventoryFolderBase folder) | ||
541 | { | ||
542 | return false; | ||
543 | } | ||
544 | |||
545 | public bool DeleteFolders(UUID ownerID, List<UUID> ids) | ||
546 | { | ||
547 | return false; | ||
548 | } | ||
549 | |||
550 | public bool PurgeFolder(InventoryFolderBase folder) | ||
551 | { | ||
552 | return false; | ||
553 | } | ||
554 | |||
555 | public bool AddItem(InventoryItemBase item) | ||
556 | { | ||
557 | return false; | ||
558 | } | ||
559 | |||
560 | public bool UpdateItem(InventoryItemBase item) | ||
561 | { | ||
562 | return false; | ||
563 | } | ||
564 | |||
565 | public bool MoveItems(UUID owner, List<InventoryItemBase> items) | ||
566 | { | ||
567 | return false; | ||
568 | } | ||
569 | |||
570 | public bool DeleteItems(UUID owner, List<UUID> items) | ||
571 | { | ||
572 | return false; | ||
573 | } | ||
574 | |||
575 | public InventoryItemBase GetItem(InventoryItemBase item) | ||
576 | { | ||
577 | return null; | ||
578 | } | ||
579 | |||
580 | public InventoryFolderBase GetFolder(InventoryFolderBase folder) | ||
581 | { | ||
582 | return null; | ||
583 | } | ||
584 | |||
585 | public bool HasInventoryForUser(UUID userID) | ||
586 | { | ||
587 | return false; | ||
588 | } | ||
589 | |||
590 | public InventoryFolderBase GetRootFolder(UUID userID) | ||
591 | { | ||
592 | InventoryFolderBase root = new InventoryFolderBase(); | ||
593 | root.ID = UUID.Random(); | ||
594 | root.Owner = userID; | ||
595 | root.ParentID = UUID.Zero; | ||
596 | return root; | ||
597 | } | ||
598 | |||
599 | public int GetAssetPermissions(UUID userID, UUID assetID) | ||
600 | { | ||
601 | return 1; | ||
602 | } | ||
603 | } | ||
604 | } | ||
diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs index d304345..04ba9c6 100644 --- a/OpenSim/Framework/IClientAPI.cs +++ b/OpenSim/Framework/IClientAPI.cs | |||
@@ -446,6 +446,7 @@ namespace OpenSim.Framework | |||
446 | public delegate void AvatarNotesUpdate(IClientAPI client, UUID targetID, string notes); | 446 | public delegate void AvatarNotesUpdate(IClientAPI client, UUID targetID, string notes); |
447 | public delegate void MuteListRequest(IClientAPI client, uint muteCRC); | 447 | public delegate void MuteListRequest(IClientAPI client, uint muteCRC); |
448 | public delegate void AvatarInterestUpdate(IClientAPI client, uint wantmask, string wanttext, uint skillsmask, string skillstext, string languages); | 448 | public delegate void AvatarInterestUpdate(IClientAPI client, uint wantmask, string wanttext, uint skillsmask, string skillstext, string languages); |
449 | public delegate void GrantUserFriendRights(IClientAPI client, UUID requester, UUID target, int rights); | ||
449 | public delegate void PlacesQuery(UUID QueryID, UUID TransactionID, string QueryText, uint QueryFlags, byte Category, string SimName, IClientAPI client); | 450 | public delegate void PlacesQuery(UUID QueryID, UUID TransactionID, string QueryText, uint QueryFlags, byte Category, string SimName, IClientAPI client); |
450 | 451 | ||
451 | public delegate void AgentFOV(IClientAPI client, float verticalAngle); | 452 | public delegate void AgentFOV(IClientAPI client, float verticalAngle); |
@@ -591,7 +592,6 @@ namespace OpenSim.Framework | |||
591 | public readonly Vector3 Velocity; | 592 | public readonly Vector3 Velocity; |
592 | public readonly Vector3 Acceleration; | 593 | public readonly Vector3 Acceleration; |
593 | public readonly Vector3 AngularVelocity; | 594 | public readonly Vector3 AngularVelocity; |
594 | public readonly byte State; | ||
595 | public readonly UUID AssetID; | 595 | public readonly UUID AssetID; |
596 | public readonly UUID OwnerID; | 596 | public readonly UUID OwnerID; |
597 | public readonly int AttachPoint; | 597 | public readonly int AttachPoint; |
@@ -599,7 +599,7 @@ namespace OpenSim.Framework | |||
599 | public readonly double Priority; | 599 | public readonly double Priority; |
600 | 600 | ||
601 | public SendPrimitiveTerseData(ulong regionHandle, ushort timeDilation, uint localID, Vector3 position, | 601 | public SendPrimitiveTerseData(ulong regionHandle, ushort timeDilation, uint localID, Vector3 position, |
602 | Quaternion rotation, Vector3 velocity, Vector3 acceleration, Vector3 rotationalvelocity, byte state, | 602 | Quaternion rotation, Vector3 velocity, Vector3 acceleration, Vector3 rotationalvelocity, |
603 | UUID assetID, UUID ownerID, int attachPoint, byte[] textureEntry, double priority) | 603 | UUID assetID, UUID ownerID, int attachPoint, byte[] textureEntry, double priority) |
604 | { | 604 | { |
605 | RegionHandle = regionHandle; | 605 | RegionHandle = regionHandle; |
@@ -610,7 +610,6 @@ namespace OpenSim.Framework | |||
610 | Velocity = velocity; | 610 | Velocity = velocity; |
611 | Acceleration = acceleration; | 611 | Acceleration = acceleration; |
612 | AngularVelocity = rotationalvelocity; | 612 | AngularVelocity = rotationalvelocity; |
613 | State = state; | ||
614 | AssetID = assetID; | 613 | AssetID = assetID; |
615 | OwnerID = ownerID; | 614 | OwnerID = ownerID; |
616 | AttachPoint = attachPoint; | 615 | AttachPoint = attachPoint; |
@@ -1023,6 +1022,7 @@ namespace OpenSim.Framework | |||
1023 | event PickInfoUpdate OnPickInfoUpdate; | 1022 | event PickInfoUpdate OnPickInfoUpdate; |
1024 | event AvatarNotesUpdate OnAvatarNotesUpdate; | 1023 | event AvatarNotesUpdate OnAvatarNotesUpdate; |
1025 | event AvatarInterestUpdate OnAvatarInterestUpdate; | 1024 | event AvatarInterestUpdate OnAvatarInterestUpdate; |
1025 | event GrantUserFriendRights OnGrantUserRights; | ||
1026 | 1026 | ||
1027 | event MuteListRequest OnMuteListRequest; | 1027 | event MuteListRequest OnMuteListRequest; |
1028 | 1028 | ||
@@ -1124,7 +1124,7 @@ namespace OpenSim.Framework | |||
1124 | void ReprioritizeUpdates(StateUpdateTypes type, UpdatePriorityHandler handler); | 1124 | void ReprioritizeUpdates(StateUpdateTypes type, UpdatePriorityHandler handler); |
1125 | 1125 | ||
1126 | void SendInventoryFolderDetails(UUID ownerID, UUID folderID, List<InventoryItemBase> items, | 1126 | void SendInventoryFolderDetails(UUID ownerID, UUID folderID, List<InventoryItemBase> items, |
1127 | List<InventoryFolderBase> folders, bool fetchFolders, | 1127 | List<InventoryFolderBase> folders, int version, bool fetchFolders, |
1128 | bool fetchItems); | 1128 | bool fetchItems); |
1129 | 1129 | ||
1130 | void FlushPrimUpdates(); | 1130 | void FlushPrimUpdates(); |
diff --git a/OpenSim/Framework/Parallel.cs b/OpenSim/Framework/Parallel.cs index 515852f..a0394f2 100644 --- a/OpenSim/Framework/Parallel.cs +++ b/OpenSim/Framework/Parallel.cs | |||
@@ -69,7 +69,7 @@ namespace OpenSim.Framework | |||
69 | Util.FireAndForget( | 69 | Util.FireAndForget( |
70 | delegate(object o) | 70 | delegate(object o) |
71 | { | 71 | { |
72 | int threadIndex = (int)o; | 72 | // int threadIndex = (int)o; |
73 | 73 | ||
74 | while (exception == null) | 74 | while (exception == null) |
75 | { | 75 | { |
@@ -126,7 +126,7 @@ namespace OpenSim.Framework | |||
126 | Util.FireAndForget( | 126 | Util.FireAndForget( |
127 | delegate(object o) | 127 | delegate(object o) |
128 | { | 128 | { |
129 | int threadIndex = (int)o; | 129 | // int threadIndex = (int)o; |
130 | 130 | ||
131 | while (exception == null) | 131 | while (exception == null) |
132 | { | 132 | { |
@@ -182,7 +182,7 @@ namespace OpenSim.Framework | |||
182 | Util.FireAndForget( | 182 | Util.FireAndForget( |
183 | delegate(object o) | 183 | delegate(object o) |
184 | { | 184 | { |
185 | int threadIndex = (int)o; | 185 | // int threadIndex = (int)o; |
186 | 186 | ||
187 | while (exception == null) | 187 | while (exception == null) |
188 | { | 188 | { |
diff --git a/OpenSim/Framework/PrimitiveBaseShape.cs b/OpenSim/Framework/PrimitiveBaseShape.cs index 5e4d175..97231ff 100644 --- a/OpenSim/Framework/PrimitiveBaseShape.cs +++ b/OpenSim/Framework/PrimitiveBaseShape.cs | |||
@@ -1066,5 +1066,106 @@ namespace OpenSim.Framework | |||
1066 | 1066 | ||
1067 | return data; | 1067 | return data; |
1068 | } | 1068 | } |
1069 | |||
1070 | |||
1071 | /// <summary> | ||
1072 | /// Creates a OpenMetaverse.Primitive and populates it with converted PrimitiveBaseShape values | ||
1073 | /// </summary> | ||
1074 | /// <returns></returns> | ||
1075 | public Primitive ToOmvPrimitive() | ||
1076 | { | ||
1077 | // position and rotation defaults here since they are not available in PrimitiveBaseShape | ||
1078 | return ToOmvPrimitive(new Vector3(0.0f, 0.0f, 0.0f), | ||
1079 | new Quaternion(0.0f, 0.0f, 0.0f, 1.0f)); | ||
1080 | } | ||
1081 | |||
1082 | |||
1083 | /// <summary> | ||
1084 | /// Creates a OpenMetaverse.Primitive and populates it with converted PrimitiveBaseShape values | ||
1085 | /// </summary> | ||
1086 | /// <param name="position"></param> | ||
1087 | /// <param name="rotation"></param> | ||
1088 | /// <returns></returns> | ||
1089 | public Primitive ToOmvPrimitive(Vector3 position, Quaternion rotation) | ||
1090 | { | ||
1091 | OpenMetaverse.Primitive prim = new OpenMetaverse.Primitive(); | ||
1092 | |||
1093 | prim.Scale = this.Scale; | ||
1094 | prim.Position = position; | ||
1095 | prim.Rotation = rotation; | ||
1096 | |||
1097 | if (this.SculptEntry) | ||
1098 | { | ||
1099 | prim.Sculpt = new Primitive.SculptData(); | ||
1100 | prim.Sculpt.Type = (OpenMetaverse.SculptType)this.SculptType; | ||
1101 | prim.Sculpt.SculptTexture = this.SculptTexture; | ||
1102 | |||
1103 | return prim; | ||
1104 | } | ||
1105 | |||
1106 | prim.PrimData.PathShearX = this.PathShearX < 128 ? (float)this.PathShearX * 0.01f : (float)(this.PathShearX - 256) * 0.01f; | ||
1107 | prim.PrimData.PathShearY = this.PathShearY < 128 ? (float)this.PathShearY * 0.01f : (float)(this.PathShearY - 256) * 0.01f; | ||
1108 | prim.PrimData.PathBegin = (float)this.PathBegin * 2.0e-5f; | ||
1109 | prim.PrimData.PathEnd = 1.0f - (float)this.PathEnd * 2.0e-5f; | ||
1110 | |||
1111 | prim.PrimData.PathScaleX = (200 - this.PathScaleX) * 0.01f; | ||
1112 | prim.PrimData.PathScaleY = (200 - this.PathScaleY) * 0.01f; | ||
1113 | |||
1114 | prim.PrimData.PathTaperX = this.PathTaperX * 0.01f; | ||
1115 | prim.PrimData.PathTaperY = this.PathTaperY * 0.01f; | ||
1116 | |||
1117 | prim.PrimData.PathTwistBegin = this.PathTwistBegin * 0.01f; | ||
1118 | prim.PrimData.PathTwist = this.PathTwist * 0.01f; | ||
1119 | |||
1120 | prim.PrimData.ProfileBegin = (float)this.ProfileBegin * 2.0e-5f; | ||
1121 | prim.PrimData.ProfileEnd = 1.0f - (float)this.ProfileEnd * 2.0e-5f; | ||
1122 | prim.PrimData.ProfileHollow = (float)this.ProfileHollow * 2.0e-5f; | ||
1123 | |||
1124 | prim.PrimData.profileCurve = this.ProfileCurve; | ||
1125 | prim.PrimData.ProfileHole = (HoleType)this.HollowShape; | ||
1126 | |||
1127 | prim.PrimData.PathCurve = (PathCurve)this.PathCurve; | ||
1128 | prim.PrimData.PathRadiusOffset = 0.01f * this.PathRadiusOffset; | ||
1129 | prim.PrimData.PathRevolutions = 1.0f + 0.015f * this.PathRevolutions; | ||
1130 | prim.PrimData.PathSkew = 0.01f * this.PathSkew; | ||
1131 | |||
1132 | prim.PrimData.PCode = OpenMetaverse.PCode.Prim; | ||
1133 | prim.PrimData.State = 0; | ||
1134 | |||
1135 | if (this.FlexiEntry) | ||
1136 | { | ||
1137 | prim.Flexible = new Primitive.FlexibleData(); | ||
1138 | prim.Flexible.Drag = this.FlexiDrag; | ||
1139 | prim.Flexible.Force = new Vector3(this.FlexiForceX, this.FlexiForceY, this.FlexiForceZ); | ||
1140 | prim.Flexible.Gravity = this.FlexiGravity; | ||
1141 | prim.Flexible.Softness = this.FlexiSoftness; | ||
1142 | prim.Flexible.Tension = this.FlexiTension; | ||
1143 | prim.Flexible.Wind = this.FlexiWind; | ||
1144 | } | ||
1145 | |||
1146 | if (this.LightEntry) | ||
1147 | { | ||
1148 | prim.Light = new Primitive.LightData(); | ||
1149 | prim.Light.Color = new Color4(this.LightColorR, this.LightColorG, this.LightColorB, this.LightColorA); | ||
1150 | prim.Light.Cutoff = this.LightCutoff; | ||
1151 | prim.Light.Falloff = this.LightFalloff; | ||
1152 | prim.Light.Intensity = this.LightIntensity; | ||
1153 | prim.Light.Radius = this.LightRadius; | ||
1154 | } | ||
1155 | |||
1156 | prim.Textures = new Primitive.TextureEntry(this.TextureEntry, 0, this.TextureEntry.Length); | ||
1157 | |||
1158 | prim.Properties = new Primitive.ObjectProperties(); | ||
1159 | prim.Properties.Name = "Primitive"; | ||
1160 | prim.Properties.Description = ""; | ||
1161 | prim.Properties.CreatorID = UUID.Zero; | ||
1162 | prim.Properties.GroupID = UUID.Zero; | ||
1163 | prim.Properties.OwnerID = UUID.Zero; | ||
1164 | prim.Properties.Permissions = new Permissions(); | ||
1165 | prim.Properties.SalePrice = 10; | ||
1166 | prim.Properties.SaleType = new SaleType(); | ||
1167 | |||
1168 | return prim; | ||
1169 | } | ||
1069 | } | 1170 | } |
1070 | } | 1171 | } |
diff --git a/OpenSim/Framework/Tests/ACLTest.cs b/OpenSim/Framework/Tests/ACLTest.cs new file mode 100644 index 0000000..d11f307 --- /dev/null +++ b/OpenSim/Framework/Tests/ACLTest.cs | |||
@@ -0,0 +1,98 @@ | |||
1 | using System; | ||
2 | using NUnit.Framework; | ||
3 | using System.Collections.Generic; | ||
4 | |||
5 | |||
6 | namespace OpenSim.Framework.Tests | ||
7 | { | ||
8 | [TestFixture] | ||
9 | public class ACLTest | ||
10 | { | ||
11 | #region Tests | ||
12 | |||
13 | /// <summary> | ||
14 | /// ACL Test class | ||
15 | /// </summary> | ||
16 | [Test] | ||
17 | public void ACLTest01() | ||
18 | { | ||
19 | ACL acl = new ACL(); | ||
20 | |||
21 | Role Guests = new Role("Guests"); | ||
22 | acl.AddRole(Guests); | ||
23 | |||
24 | Role[] parents = new Role[1]; | ||
25 | parents[0] = Guests; | ||
26 | |||
27 | Role JoeGuest = new Role("JoeGuest", parents); | ||
28 | acl.AddRole(JoeGuest); | ||
29 | |||
30 | Resource CanBuild = new Resource("CanBuild"); | ||
31 | acl.AddResource(CanBuild); | ||
32 | |||
33 | |||
34 | acl.GrantPermission("Guests", "CanBuild"); | ||
35 | |||
36 | Permission perm = acl.HasPermission("JoeGuest", "CanBuild"); | ||
37 | Assert.That(perm == Permission.Allow, "JoeGuest should have permission to build"); | ||
38 | perm = Permission.None; | ||
39 | try | ||
40 | { | ||
41 | perm = acl.HasPermission("unknownGuest", "CanBuild"); | ||
42 | |||
43 | } | ||
44 | catch (KeyNotFoundException) | ||
45 | { | ||
46 | |||
47 | |||
48 | } | ||
49 | catch (Exception) | ||
50 | { | ||
51 | Assert.That(false,"Exception thrown should have been KeyNotFoundException"); | ||
52 | } | ||
53 | Assert.That(perm == Permission.None,"Permission None should be set because exception should have been thrown"); | ||
54 | |||
55 | } | ||
56 | |||
57 | [Test] | ||
58 | public void KnownButPermissionDenyAndPermissionNoneUserTest() | ||
59 | { | ||
60 | ACL acl = new ACL(); | ||
61 | |||
62 | Role Guests = new Role("Guests"); | ||
63 | acl.AddRole(Guests); | ||
64 | Role Administrators = new Role("Administrators"); | ||
65 | acl.AddRole(Administrators); | ||
66 | Role[] Guestparents = new Role[1]; | ||
67 | Role[] Adminparents = new Role[1]; | ||
68 | |||
69 | Guestparents[0] = Guests; | ||
70 | Adminparents[0] = Administrators; | ||
71 | |||
72 | Role JoeGuest = new Role("JoeGuest", Guestparents); | ||
73 | acl.AddRole(JoeGuest); | ||
74 | |||
75 | Resource CanBuild = new Resource("CanBuild"); | ||
76 | acl.AddResource(CanBuild); | ||
77 | |||
78 | Resource CanScript = new Resource("CanScript"); | ||
79 | acl.AddResource(CanScript); | ||
80 | |||
81 | Resource CanRestart = new Resource("CanRestart"); | ||
82 | acl.AddResource(CanRestart); | ||
83 | |||
84 | acl.GrantPermission("Guests", "CanBuild"); | ||
85 | acl.DenyPermission("Guests", "CanRestart"); | ||
86 | |||
87 | acl.GrantPermission("Administrators", "CanScript"); | ||
88 | |||
89 | acl.GrantPermission("Administrators", "CanRestart"); | ||
90 | Permission setPermission = acl.HasPermission("JoeGuest", "CanRestart"); | ||
91 | Assert.That(setPermission == Permission.Deny, "Guests Should not be able to restart"); | ||
92 | Assert.That(acl.HasPermission("JoeGuest", "CanScript") == Permission.None, | ||
93 | "No Explicit Permissions set so should be Permission.None"); | ||
94 | } | ||
95 | |||
96 | #endregion | ||
97 | } | ||
98 | } | ||
diff --git a/OpenSim/Framework/Tests/AssetBaseTest.cs b/OpenSim/Framework/Tests/AssetBaseTest.cs index 3dc6b4e..18a3e01 100644 --- a/OpenSim/Framework/Tests/AssetBaseTest.cs +++ b/OpenSim/Framework/Tests/AssetBaseTest.cs | |||
@@ -67,8 +67,7 @@ namespace OpenSim.Framework.Tests | |||
67 | 67 | ||
68 | private void CheckContainsReferences(AssetType assetType, bool expected) | 68 | private void CheckContainsReferences(AssetType assetType, bool expected) |
69 | { | 69 | { |
70 | AssetBase asset = new AssetBase(); | 70 | AssetBase asset = new AssetBase(UUID.Zero, String.Empty, (sbyte)assetType); |
71 | asset.Type = (sbyte)assetType; | ||
72 | bool actual = asset.ContainsReferences; | 71 | bool actual = asset.ContainsReferences; |
73 | Assert.AreEqual(expected, actual, "Expected "+assetType+".ContainsReferences to be "+expected+" but was "+actual+"."); | 72 | Assert.AreEqual(expected, actual, "Expected "+assetType+".ContainsReferences to be "+expected+" but was "+actual+"."); |
74 | } | 73 | } |
diff --git a/OpenSim/Framework/Tests/CacheTests.cs b/OpenSim/Framework/Tests/CacheTests.cs new file mode 100644 index 0000000..8e97232 --- /dev/null +++ b/OpenSim/Framework/Tests/CacheTests.cs | |||
@@ -0,0 +1,75 @@ | |||
1 | using System; | ||
2 | using NUnit.Framework; | ||
3 | using OpenMetaverse; | ||
4 | |||
5 | namespace OpenSim.Framework.Tests | ||
6 | { | ||
7 | [TestFixture] | ||
8 | public class CacheTests | ||
9 | { | ||
10 | private Cache cache; | ||
11 | private UUID cacheItemUUID; | ||
12 | [SetUp] | ||
13 | public void Build() | ||
14 | { | ||
15 | cache = new Cache(); | ||
16 | cacheItemUUID = UUID.Random(); | ||
17 | MemoryCacheItem cachedItem = new MemoryCacheItem(cacheItemUUID.ToString(),DateTime.Now + TimeSpan.FromDays(1)); | ||
18 | byte[] foo = new byte[1]; | ||
19 | foo[0] = 255; | ||
20 | cachedItem.Store(foo); | ||
21 | cache.Store(cacheItemUUID.ToString(), cachedItem); | ||
22 | } | ||
23 | [Test] | ||
24 | public void TestRetreive() | ||
25 | { | ||
26 | CacheItemBase citem = (CacheItemBase)cache.Get(cacheItemUUID.ToString()); | ||
27 | byte[] data = (byte[]) citem.Retrieve(); | ||
28 | Assert.That(data.Length == 1, "Cached Item should have one byte element"); | ||
29 | Assert.That(data[0] == 255, "Cached Item element should be 255"); | ||
30 | } | ||
31 | |||
32 | [Test] | ||
33 | public void TestNotInCache() | ||
34 | { | ||
35 | UUID randomNotIn = UUID.Random(); | ||
36 | while (randomNotIn == cacheItemUUID) | ||
37 | { | ||
38 | randomNotIn = UUID.Random(); | ||
39 | } | ||
40 | object citem = cache.Get(randomNotIn.ToString()); | ||
41 | Assert.That(citem == null, "Item should not be in Cache" ); | ||
42 | } | ||
43 | |||
44 | //NOTE: Test Case disabled until Cache is fixed | ||
45 | [Test] | ||
46 | public void TestTTLExpiredEntry() | ||
47 | { | ||
48 | UUID ImmediateExpiryUUID = UUID.Random(); | ||
49 | MemoryCacheItem cachedItem = new MemoryCacheItem(ImmediateExpiryUUID.ToString(), TimeSpan.FromDays(-1)); | ||
50 | byte[] foo = new byte[1]; | ||
51 | foo[0] = 1; | ||
52 | cachedItem.Store(foo); | ||
53 | cache.Store(cacheItemUUID.ToString(), cachedItem); | ||
54 | |||
55 | object citem = cache.Get(cacheItemUUID.ToString()); | ||
56 | //Assert.That(citem == null, "Item should not be in Cache because the expiry time was before now"); | ||
57 | } | ||
58 | |||
59 | //NOTE: Test Case disabled until Cache is fixed | ||
60 | [Test] | ||
61 | public void ExpireItemManually() | ||
62 | { | ||
63 | UUID ImmediateExpiryUUID = UUID.Random(); | ||
64 | MemoryCacheItem cachedItem = new MemoryCacheItem(ImmediateExpiryUUID.ToString(), TimeSpan.FromDays(1)); | ||
65 | byte[] foo = new byte[1]; | ||
66 | foo[0] = 1; | ||
67 | cachedItem.Store(foo); | ||
68 | cache.Store(cacheItemUUID.ToString(), cachedItem); | ||
69 | cache.Invalidate(ImmediateExpiryUUID.ToString()); | ||
70 | object citem = cache.Get(cacheItemUUID.ToString()); | ||
71 | //Assert.That(citem == null, "Item should not be in Cache because we manually invalidated it"); | ||
72 | } | ||
73 | |||
74 | } | ||
75 | } | ||
diff --git a/OpenSim/Framework/ThreadTracker.cs b/OpenSim/Framework/ThreadTracker.cs index b68d9b3..069e98b 100644 --- a/OpenSim/Framework/ThreadTracker.cs +++ b/OpenSim/Framework/ThreadTracker.cs | |||
@@ -35,7 +35,7 @@ namespace OpenSim.Framework | |||
35 | { | 35 | { |
36 | public static class ThreadTracker | 36 | public static class ThreadTracker |
37 | { | 37 | { |
38 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 38 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
39 | 39 | ||
40 | public static ProcessThreadCollection GetThreads() | 40 | public static ProcessThreadCollection GetThreads() |
41 | { | 41 | { |
diff --git a/OpenSim/Grid/MessagingServer.Modules/MessageRegionModule.cs b/OpenSim/Grid/MessagingServer.Modules/MessageRegionModule.cs index dedf876..b9d3f22 100644 --- a/OpenSim/Grid/MessagingServer.Modules/MessageRegionModule.cs +++ b/OpenSim/Grid/MessagingServer.Modules/MessageRegionModule.cs | |||
@@ -48,7 +48,7 @@ namespace OpenSim.Grid.MessagingServer.Modules | |||
48 | { | 48 | { |
49 | public class MessageRegionModule : IMessageRegionLookup | 49 | public class MessageRegionModule : IMessageRegionLookup |
50 | { | 50 | { |
51 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 51 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
52 | 52 | ||
53 | private MessageServerConfig m_cfg; | 53 | private MessageServerConfig m_cfg; |
54 | 54 | ||
diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs index b448182..60c34df 100644 --- a/OpenSim/Region/Application/OpenSim.cs +++ b/OpenSim/Region/Application/OpenSim.cs | |||
@@ -343,6 +343,10 @@ namespace OpenSim | |||
343 | "Add-InventoryHost <host>", | 343 | "Add-InventoryHost <host>", |
344 | String.Empty, RunCommand); | 344 | String.Empty, RunCommand); |
345 | 345 | ||
346 | m_console.Commands.AddCommand("region", false, "kill uuid", | ||
347 | "kill uuid <UUID>", | ||
348 | "Kill an object by UUID", KillUUID); | ||
349 | |||
346 | if (ConfigurationSettings.Standalone) | 350 | if (ConfigurationSettings.Standalone) |
347 | { | 351 | { |
348 | m_console.Commands.AddCommand("region", false, "create user", | 352 | m_console.Commands.AddCommand("region", false, "create user", |
@@ -1332,6 +1336,58 @@ namespace OpenSim | |||
1332 | return result; | 1336 | return result; |
1333 | } | 1337 | } |
1334 | 1338 | ||
1339 | /// <summary> | ||
1340 | /// Kill an object given its UUID. | ||
1341 | /// </summary> | ||
1342 | /// <param name="cmdparams"></param> | ||
1343 | protected void KillUUID(string module, string[] cmdparams) | ||
1344 | { | ||
1345 | if (cmdparams.Length > 2) | ||
1346 | { | ||
1347 | UUID id = UUID.Zero; | ||
1348 | SceneObjectGroup grp = null; | ||
1349 | Scene sc = null; | ||
1350 | |||
1351 | if (!UUID.TryParse(cmdparams[2], out id)) | ||
1352 | { | ||
1353 | MainConsole.Instance.Output("[KillUUID]: Error bad UUID format!"); | ||
1354 | return; | ||
1355 | } | ||
1356 | |||
1357 | m_sceneManager.ForEachScene( | ||
1358 | delegate(Scene scene) | ||
1359 | { | ||
1360 | SceneObjectPart part = scene.GetSceneObjectPart(id); | ||
1361 | if (part == null) | ||
1362 | return; | ||
1363 | |||
1364 | grp = part.ParentGroup; | ||
1365 | sc = scene; | ||
1366 | }); | ||
1367 | |||
1368 | if (grp == null) | ||
1369 | { | ||
1370 | MainConsole.Instance.Output(String.Format("[KillUUID]: Given UUID {0} not found!", id)); | ||
1371 | } | ||
1372 | else | ||
1373 | { | ||
1374 | MainConsole.Instance.Output(String.Format("[KillUUID]: Found UUID {0} in scene {1}", id, sc.RegionInfo.RegionName)); | ||
1375 | try | ||
1376 | { | ||
1377 | sc.DeleteSceneObject(grp, false); | ||
1378 | } | ||
1379 | catch (Exception e) | ||
1380 | { | ||
1381 | m_log.ErrorFormat("[KillUUID]: Error while removing objects from scene: " + e); | ||
1382 | } | ||
1383 | } | ||
1384 | } | ||
1385 | else | ||
1386 | { | ||
1387 | MainConsole.Instance.Output("[KillUUID]: Usage: kill uuid <UUID>"); | ||
1388 | } | ||
1389 | } | ||
1390 | |||
1335 | #endregion | 1391 | #endregion |
1336 | } | 1392 | } |
1337 | } | 1393 | } |
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index f6a7a0c..49b9378 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs | |||
@@ -37,6 +37,7 @@ using System.Xml; | |||
37 | using log4net; | 37 | using log4net; |
38 | using OpenMetaverse; | 38 | using OpenMetaverse; |
39 | using OpenMetaverse.Packets; | 39 | using OpenMetaverse.Packets; |
40 | using OpenMetaverse.StructuredData; | ||
40 | using OpenSim.Framework; | 41 | using OpenSim.Framework; |
41 | using OpenSim.Framework.Client; | 42 | using OpenSim.Framework.Client; |
42 | using OpenSim.Framework.Communications.Cache; | 43 | using OpenSim.Framework.Communications.Cache; |
@@ -219,6 +220,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
219 | public event FriendActionDelegate OnApproveFriendRequest; | 220 | public event FriendActionDelegate OnApproveFriendRequest; |
220 | public event FriendActionDelegate OnDenyFriendRequest; | 221 | public event FriendActionDelegate OnDenyFriendRequest; |
221 | public event FriendshipTermination OnTerminateFriendship; | 222 | public event FriendshipTermination OnTerminateFriendship; |
223 | public event GrantUserFriendRights OnGrantUserRights; | ||
222 | public event MoneyTransferRequest OnMoneyTransferRequest; | 224 | public event MoneyTransferRequest OnMoneyTransferRequest; |
223 | public event EconomyDataRequest OnEconomyDataRequest; | 225 | public event EconomyDataRequest OnEconomyDataRequest; |
224 | public event MoneyBalanceRequest OnMoneyBalanceRequest; | 226 | public event MoneyBalanceRequest OnMoneyBalanceRequest; |
@@ -314,14 +316,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
314 | private readonly LLUDPClient m_udpClient; | 316 | private readonly LLUDPClient m_udpClient; |
315 | private readonly UUID m_sessionId; | 317 | private readonly UUID m_sessionId; |
316 | private readonly UUID m_secureSessionId; | 318 | private readonly UUID m_secureSessionId; |
317 | private readonly UUID m_agentId; | 319 | protected readonly UUID m_agentId; |
318 | private readonly uint m_circuitCode; | 320 | private readonly uint m_circuitCode; |
319 | private readonly byte[] m_channelVersion = Utils.EmptyBytes; | 321 | private readonly byte[] m_channelVersion = Utils.EmptyBytes; |
320 | private readonly Dictionary<string, UUID> m_defaultAnimations = new Dictionary<string, UUID>(); | 322 | private readonly Dictionary<string, UUID> m_defaultAnimations = new Dictionary<string, UUID>(); |
321 | private readonly IGroupsModule m_GroupsModule; | 323 | private readonly IGroupsModule m_GroupsModule; |
322 | 324 | ||
323 | private int m_cachedTextureSerial; | 325 | private int m_cachedTextureSerial; |
324 | private PriorityQueue<double, ImprovedTerseObjectUpdatePacket.ObjectDataBlock> m_avatarTerseUpdates; | 326 | protected PriorityQueue<double, ImprovedTerseObjectUpdatePacket.ObjectDataBlock> m_avatarTerseUpdates; |
325 | private PriorityQueue<double, ImprovedTerseObjectUpdatePacket.ObjectDataBlock> m_primTerseUpdates; | 327 | private PriorityQueue<double, ImprovedTerseObjectUpdatePacket.ObjectDataBlock> m_primTerseUpdates; |
326 | private PriorityQueue<double, ObjectUpdatePacket.ObjectDataBlock> m_primFullUpdates; | 328 | private PriorityQueue<double, ObjectUpdatePacket.ObjectDataBlock> m_primFullUpdates; |
327 | private int m_moneyBalance; | 329 | private int m_moneyBalance; |
@@ -783,6 +785,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
783 | public virtual void SendLayerData(float[] map) | 785 | public virtual void SendLayerData(float[] map) |
784 | { | 786 | { |
785 | Util.FireAndForget(DoSendLayerData, map); | 787 | Util.FireAndForget(DoSendLayerData, map); |
788 | |||
789 | // Send it sync, and async. It's not that much data | ||
790 | // and it improves user experience just so much! | ||
791 | DoSendLayerData(map); | ||
786 | } | 792 | } |
787 | 793 | ||
788 | /// <summary> | 794 | /// <summary> |
@@ -795,16 +801,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
795 | 801 | ||
796 | try | 802 | try |
797 | { | 803 | { |
798 | //for (int y = 0; y < 16; y++) | 804 | for (int y = 0; y < 16; y++) |
799 | //{ | 805 | { |
800 | // for (int x = 0; x < 16; x++) | 806 | for (int x = 0; x < 16; x+=4) |
801 | // { | 807 | { |
802 | // SendLayerData(x, y, map); | 808 | SendLayerPacket(x, y, map); |
803 | // } | 809 | } |
804 | //} | 810 | } |
805 | |||
806 | // Send LayerData in a spiral pattern. Fun! | ||
807 | SendLayerTopRight(map, 0, 0, 15, 15); | ||
808 | } | 811 | } |
809 | catch (Exception e) | 812 | catch (Exception e) |
810 | { | 813 | { |
@@ -812,51 +815,35 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
812 | } | 815 | } |
813 | } | 816 | } |
814 | 817 | ||
815 | private void SendLayerTopRight(float[] map, int x1, int y1, int x2, int y2) | ||
816 | { | ||
817 | // Row | ||
818 | for (int i = x1; i <= x2; i++) | ||
819 | SendLayerData(i, y1, map); | ||
820 | |||
821 | // Column | ||
822 | for (int j = y1 + 1; j <= y2; j++) | ||
823 | SendLayerData(x2, j, map); | ||
824 | |||
825 | if (x2 - x1 > 0) | ||
826 | SendLayerBottomLeft(map, x1, y1 + 1, x2 - 1, y2); | ||
827 | } | ||
828 | |||
829 | void SendLayerBottomLeft(float[] map, int x1, int y1, int x2, int y2) | ||
830 | { | ||
831 | // Row in reverse | ||
832 | for (int i = x2; i >= x1; i--) | ||
833 | SendLayerData(i, y2, map); | ||
834 | |||
835 | // Column in reverse | ||
836 | for (int j = y2 - 1; j >= y1; j--) | ||
837 | SendLayerData(x1, j, map); | ||
838 | |||
839 | if (x2 - x1 > 0) | ||
840 | SendLayerTopRight(map, x1 + 1, y1, x2, y2 - 1); | ||
841 | } | ||
842 | |||
843 | /// <summary> | 818 | /// <summary> |
844 | /// Sends a set of four patches (x, x+1, ..., x+3) to the client | 819 | /// Sends a set of four patches (x, x+1, ..., x+3) to the client |
845 | /// </summary> | 820 | /// </summary> |
846 | /// <param name="map">heightmap</param> | 821 | /// <param name="map">heightmap</param> |
847 | /// <param name="px">X coordinate for patches 0..12</param> | 822 | /// <param name="px">X coordinate for patches 0..12</param> |
848 | /// <param name="py">Y coordinate for patches 0..15</param> | 823 | /// <param name="py">Y coordinate for patches 0..15</param> |
849 | // private void SendLayerPacket(float[] map, int y, int x) | 824 | private void SendLayerPacket(int x, int y, float[] map) |
850 | // { | 825 | { |
851 | // int[] patches = new int[4]; | 826 | int[] patches = new int[4]; |
852 | // patches[0] = x + 0 + y * 16; | 827 | patches[0] = x + 0 + y * 16; |
853 | // patches[1] = x + 1 + y * 16; | 828 | patches[1] = x + 1 + y * 16; |
854 | // patches[2] = x + 2 + y * 16; | 829 | patches[2] = x + 2 + y * 16; |
855 | // patches[3] = x + 3 + y * 16; | 830 | patches[3] = x + 3 + y * 16; |
856 | 831 | ||
857 | // Packet layerpack = LLClientView.TerrainManager.CreateLandPacket(map, patches); | 832 | float[] heightmap = (map.Length == 65536) ? |
858 | // OutPacket(layerpack, ThrottleOutPacketType.Land); | 833 | map : |
859 | // } | 834 | LLHeightFieldMoronize(map); |
835 | |||
836 | try | ||
837 | { | ||
838 | Packet layerpack = TerrainCompressor.CreateLandPacket(heightmap, patches); | ||
839 | OutPacket(layerpack, ThrottleOutPacketType.Land); | ||
840 | } | ||
841 | catch | ||
842 | { | ||
843 | for (int px = x ; px < x + 4 ; px++) | ||
844 | SendLayerData(px, y, map); | ||
845 | } | ||
846 | } | ||
860 | 847 | ||
861 | /// <summary> | 848 | /// <summary> |
862 | /// Sends a specified patch to a client | 849 | /// Sends a specified patch to a client |
@@ -1250,7 +1237,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
1250 | /// <param name="fetchFolders">Do we need to send folder information?</param> | 1237 | /// <param name="fetchFolders">Do we need to send folder information?</param> |
1251 | /// <param name="fetchItems">Do we need to send item information?</param> | 1238 | /// <param name="fetchItems">Do we need to send item information?</param> |
1252 | public void SendInventoryFolderDetails(UUID ownerID, UUID folderID, List<InventoryItemBase> items, | 1239 | public void SendInventoryFolderDetails(UUID ownerID, UUID folderID, List<InventoryItemBase> items, |
1253 | List<InventoryFolderBase> folders, | 1240 | List<InventoryFolderBase> folders, int version, |
1254 | bool fetchFolders, bool fetchItems) | 1241 | bool fetchFolders, bool fetchItems) |
1255 | { | 1242 | { |
1256 | // An inventory descendents packet consists of a single agent section and an inventory details | 1243 | // An inventory descendents packet consists of a single agent section and an inventory details |
@@ -1263,174 +1250,107 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
1263 | // | 1250 | // |
1264 | // for one example of this kind of thing. In fact, the Linden servers appear to only send about | 1251 | // for one example of this kind of thing. In fact, the Linden servers appear to only send about |
1265 | // 6 to 7 items at a time, so let's stick with 6 | 1252 | // 6 to 7 items at a time, so let's stick with 6 |
1266 | int MAX_ITEMS_PER_PACKET = 6; | 1253 | int MAX_ITEMS_PER_PACKET = 5; |
1267 | 1254 | int MAX_FOLDERS_PER_PACKET = 6; | |
1268 | //Ckrinke This variable is not used, so comment out to remove the warning from the compiler (3-21-08) | ||
1269 | //Ckrinke uint FULL_MASK_PERMISSIONS = 2147483647; | ||
1270 | 1255 | ||
1256 | int totalItems = fetchItems ? items.Count : 0; | ||
1257 | int totalFolders = fetchFolders ? folders.Count : 0; | ||
1271 | int itemsSent = 0; | 1258 | int itemsSent = 0; |
1272 | if (fetchItems) | 1259 | int foldersSent = 0; |
1273 | { | 1260 | int foldersToSend = 0; |
1274 | InventoryDescendentsPacket descend = CreateInventoryDescendentsPacket(ownerID, folderID); | 1261 | int itemsToSend = 0; |
1275 | |||
1276 | if (items.Count < MAX_ITEMS_PER_PACKET) | ||
1277 | { | ||
1278 | descend.ItemData = new InventoryDescendentsPacket.ItemDataBlock[items.Count]; | ||
1279 | } | ||
1280 | else | ||
1281 | { | ||
1282 | descend.ItemData = new InventoryDescendentsPacket.ItemDataBlock[MAX_ITEMS_PER_PACKET]; | ||
1283 | } | ||
1284 | 1262 | ||
1285 | // Descendents must contain the *total* number of descendents (plus folders, whether we | 1263 | InventoryDescendentsPacket currentPacket = null; |
1286 | // fetch them or not), not the number of entries we send in this packet. For consistency, | ||
1287 | // I'll use it for folder-requests, too, although I wasn't able to get one with | ||
1288 | // FetchFolders = true. | ||
1289 | // TODO this should be checked with FetchFolders = true | ||
1290 | descend.AgentData.Descendents = items.Count + folders.Count; | ||
1291 | 1264 | ||
1292 | int count = 0; | 1265 | // Handle empty folders |
1293 | int i = 0; | 1266 | // |
1294 | foreach (InventoryItemBase item in items) | 1267 | if (totalItems == 0 && totalFolders == 0) |
1268 | currentPacket = CreateInventoryDescendentsPacket(ownerID, folderID, version, items.Count + folders.Count, 0, 0); | ||
1269 | |||
1270 | // To preserve SL compatibility, we will NOT combine folders and items in one packet | ||
1271 | // | ||
1272 | while(itemsSent < totalItems || foldersSent < totalFolders) | ||
1273 | { | ||
1274 | if (currentPacket == null) // Start a new packet | ||
1295 | { | 1275 | { |
1296 | descend.ItemData[i] = new InventoryDescendentsPacket.ItemDataBlock(); | 1276 | foldersToSend = totalFolders - foldersSent; |
1297 | descend.ItemData[i].ItemID = item.ID; | 1277 | if (foldersToSend > MAX_FOLDERS_PER_PACKET) |
1298 | descend.ItemData[i].AssetID = item.AssetID; | 1278 | foldersToSend = MAX_FOLDERS_PER_PACKET; |
1299 | descend.ItemData[i].CreatorID = item.CreatorIdAsUuid; | 1279 | |
1300 | descend.ItemData[i].BaseMask = item.BasePermissions; | 1280 | if (foldersToSend == 0) |
1301 | descend.ItemData[i].Description = Util.StringToBytes256(item.Description); | 1281 | { |
1302 | descend.ItemData[i].EveryoneMask = item.EveryOnePermissions; | 1282 | itemsToSend = totalItems - itemsSent; |
1303 | descend.ItemData[i].OwnerMask = item.CurrentPermissions; | 1283 | if (itemsToSend > MAX_ITEMS_PER_PACKET) |
1304 | descend.ItemData[i].FolderID = item.Folder; | 1284 | itemsToSend = MAX_ITEMS_PER_PACKET; |
1305 | descend.ItemData[i].InvType = (sbyte)item.InvType; | ||
1306 | descend.ItemData[i].Name = Util.StringToBytes256(item.Name); | ||
1307 | descend.ItemData[i].NextOwnerMask = item.NextPermissions; | ||
1308 | descend.ItemData[i].OwnerID = item.Owner; | ||
1309 | descend.ItemData[i].Type = (sbyte)item.AssetType; | ||
1310 | |||
1311 | descend.ItemData[i].GroupID = item.GroupID; | ||
1312 | descend.ItemData[i].GroupOwned = item.GroupOwned; | ||
1313 | descend.ItemData[i].GroupMask = item.GroupPermissions; | ||
1314 | descend.ItemData[i].CreationDate = item.CreationDate; | ||
1315 | descend.ItemData[i].SalePrice = item.SalePrice; | ||
1316 | descend.ItemData[i].SaleType = item.SaleType; | ||
1317 | descend.ItemData[i].Flags = item.Flags; | ||
1318 | |||
1319 | descend.ItemData[i].CRC = | ||
1320 | Helpers.InventoryCRC(descend.ItemData[i].CreationDate, descend.ItemData[i].SaleType, | ||
1321 | descend.ItemData[i].InvType, descend.ItemData[i].Type, | ||
1322 | descend.ItemData[i].AssetID, descend.ItemData[i].GroupID, | ||
1323 | descend.ItemData[i].SalePrice, | ||
1324 | descend.ItemData[i].OwnerID, descend.ItemData[i].CreatorID, | ||
1325 | descend.ItemData[i].ItemID, descend.ItemData[i].FolderID, | ||
1326 | descend.ItemData[i].EveryoneMask, | ||
1327 | descend.ItemData[i].Flags, descend.ItemData[i].OwnerMask, | ||
1328 | descend.ItemData[i].GroupMask, item.CurrentPermissions); | ||
1329 | |||
1330 | i++; | ||
1331 | count++; | ||
1332 | itemsSent++; | ||
1333 | if (i == MAX_ITEMS_PER_PACKET) | ||
1334 | { | ||
1335 | descend.Header.Zerocoded = true; | ||
1336 | AddNullFolderBlockToDecendentsPacket(ref descend); | ||
1337 | OutPacket(descend, ThrottleOutPacketType.Asset); | ||
1338 | |||
1339 | if ((items.Count - count) > 0) | ||
1340 | { | ||
1341 | descend = CreateInventoryDescendentsPacket(ownerID, folderID); | ||
1342 | if ((items.Count - count) < MAX_ITEMS_PER_PACKET) | ||
1343 | { | ||
1344 | descend.ItemData = new InventoryDescendentsPacket.ItemDataBlock[items.Count - count]; | ||
1345 | } | ||
1346 | else | ||
1347 | { | ||
1348 | descend.ItemData = new InventoryDescendentsPacket.ItemDataBlock[MAX_ITEMS_PER_PACKET]; | ||
1349 | } | ||
1350 | descend.AgentData.Descendents = items.Count + folders.Count; | ||
1351 | i = 0; | ||
1352 | } | ||
1353 | } | 1285 | } |
1354 | } | ||
1355 | 1286 | ||
1356 | if (0 < i && i < MAX_ITEMS_PER_PACKET) | 1287 | currentPacket = CreateInventoryDescendentsPacket(ownerID, folderID, version, items.Count + folders.Count, foldersToSend, itemsToSend); |
1357 | { | ||
1358 | AddNullFolderBlockToDecendentsPacket(ref descend); | ||
1359 | OutPacket(descend, ThrottleOutPacketType.Asset); | ||
1360 | } | 1288 | } |
1361 | } | ||
1362 | 1289 | ||
1363 | //send subfolders | 1290 | if (foldersToSend-- > 0) |
1364 | if (fetchFolders) | 1291 | currentPacket.FolderData[foldersSent % MAX_FOLDERS_PER_PACKET] = CreateFolderDataBlock(folders[foldersSent++]); |
1365 | { | 1292 | else if(itemsToSend-- > 0) |
1366 | InventoryDescendentsPacket descend = CreateInventoryDescendentsPacket(ownerID, folderID); | 1293 | currentPacket.ItemData[itemsSent % MAX_ITEMS_PER_PACKET] = CreateItemDataBlock(items[itemsSent++]); |
1367 | |||
1368 | if (folders.Count < MAX_ITEMS_PER_PACKET) | ||
1369 | { | ||
1370 | descend.FolderData = new InventoryDescendentsPacket.FolderDataBlock[folders.Count]; | ||
1371 | } | ||
1372 | else | 1294 | else |
1373 | { | 1295 | { |
1374 | descend.FolderData = new InventoryDescendentsPacket.FolderDataBlock[MAX_ITEMS_PER_PACKET]; | 1296 | OutPacket(currentPacket, ThrottleOutPacketType.Asset, false); |
1297 | currentPacket = null; | ||
1375 | } | 1298 | } |
1376 | 1299 | ||
1377 | // Not sure if this scenario ever actually occurs, but nonetheless we include the items | 1300 | } |
1378 | // count even if we're not sending item data for the same reasons as above. | ||
1379 | descend.AgentData.Descendents = items.Count + folders.Count; | ||
1380 | 1301 | ||
1381 | int i = 0; | 1302 | if (currentPacket != null) |
1382 | int count = 0; | 1303 | OutPacket(currentPacket, ThrottleOutPacketType.Asset, false); |
1383 | foreach (InventoryFolderBase folder in folders) | 1304 | } |
1384 | { | ||
1385 | descend.FolderData[i] = new InventoryDescendentsPacket.FolderDataBlock(); | ||
1386 | descend.FolderData[i].FolderID = folder.ID; | ||
1387 | descend.FolderData[i].Name = Util.StringToBytes256(folder.Name); | ||
1388 | descend.FolderData[i].ParentID = folder.ParentID; | ||
1389 | descend.FolderData[i].Type = (sbyte)folder.Type; | ||
1390 | 1305 | ||
1391 | i++; | 1306 | private InventoryDescendentsPacket.FolderDataBlock CreateFolderDataBlock(InventoryFolderBase folder) |
1392 | count++; | 1307 | { |
1393 | itemsSent++; | 1308 | InventoryDescendentsPacket.FolderDataBlock newBlock = new InventoryDescendentsPacket.FolderDataBlock(); |
1394 | if (i == MAX_ITEMS_PER_PACKET) | 1309 | newBlock.FolderID = folder.ID; |
1395 | { | 1310 | newBlock.Name = Util.StringToBytes256(folder.Name); |
1396 | AddNullItemBlockToDescendentsPacket(ref descend); | 1311 | newBlock.ParentID = folder.ParentID; |
1397 | OutPacket(descend, ThrottleOutPacketType.Asset); | 1312 | newBlock.Type = (sbyte)folder.Type; |
1398 | 1313 | ||
1399 | if ((folders.Count - count) > 0) | 1314 | return newBlock; |
1400 | { | 1315 | } |
1401 | descend = CreateInventoryDescendentsPacket(ownerID, folderID); | ||
1402 | if ((folders.Count - count) < MAX_ITEMS_PER_PACKET) | ||
1403 | { | ||
1404 | descend.FolderData = | ||
1405 | new InventoryDescendentsPacket.FolderDataBlock[folders.Count - count]; | ||
1406 | } | ||
1407 | else | ||
1408 | { | ||
1409 | descend.FolderData = | ||
1410 | new InventoryDescendentsPacket.FolderDataBlock[MAX_ITEMS_PER_PACKET]; | ||
1411 | } | ||
1412 | descend.AgentData.Descendents = items.Count + folders.Count; | ||
1413 | i = 0; | ||
1414 | } | ||
1415 | } | ||
1416 | } | ||
1417 | 1316 | ||
1418 | if (0 < i && i < MAX_ITEMS_PER_PACKET) | 1317 | private InventoryDescendentsPacket.ItemDataBlock CreateItemDataBlock(InventoryItemBase item) |
1419 | { | 1318 | { |
1420 | AddNullItemBlockToDescendentsPacket(ref descend); | 1319 | InventoryDescendentsPacket.ItemDataBlock newBlock = new InventoryDescendentsPacket.ItemDataBlock(); |
1421 | OutPacket(descend, ThrottleOutPacketType.Asset); | 1320 | newBlock.ItemID = item.ID; |
1422 | } | 1321 | newBlock.AssetID = item.AssetID; |
1423 | } | 1322 | newBlock.CreatorID = item.CreatorIdAsUuid; |
1323 | newBlock.BaseMask = item.BasePermissions; | ||
1324 | newBlock.Description = Util.StringToBytes256(item.Description); | ||
1325 | newBlock.EveryoneMask = item.EveryOnePermissions; | ||
1326 | newBlock.OwnerMask = item.CurrentPermissions; | ||
1327 | newBlock.FolderID = item.Folder; | ||
1328 | newBlock.InvType = (sbyte)item.InvType; | ||
1329 | newBlock.Name = Util.StringToBytes256(item.Name); | ||
1330 | newBlock.NextOwnerMask = item.NextPermissions; | ||
1331 | newBlock.OwnerID = item.Owner; | ||
1332 | newBlock.Type = (sbyte)item.AssetType; | ||
1424 | 1333 | ||
1425 | if (itemsSent == 0) | 1334 | newBlock.GroupID = item.GroupID; |
1426 | { | 1335 | newBlock.GroupOwned = item.GroupOwned; |
1427 | // no items found. | 1336 | newBlock.GroupMask = item.GroupPermissions; |
1428 | InventoryDescendentsPacket descend = CreateInventoryDescendentsPacket(ownerID, folderID); | 1337 | newBlock.CreationDate = item.CreationDate; |
1429 | descend.AgentData.Descendents = 0; | 1338 | newBlock.SalePrice = item.SalePrice; |
1430 | AddNullItemBlockToDescendentsPacket(ref descend); | 1339 | newBlock.SaleType = item.SaleType; |
1431 | AddNullFolderBlockToDecendentsPacket(ref descend); | 1340 | newBlock.Flags = item.Flags; |
1432 | OutPacket(descend, ThrottleOutPacketType.Asset); | 1341 | |
1433 | } | 1342 | newBlock.CRC = |
1343 | Helpers.InventoryCRC(newBlock.CreationDate, newBlock.SaleType, | ||
1344 | newBlock.InvType, newBlock.Type, | ||
1345 | newBlock.AssetID, newBlock.GroupID, | ||
1346 | newBlock.SalePrice, | ||
1347 | newBlock.OwnerID, newBlock.CreatorID, | ||
1348 | newBlock.ItemID, newBlock.FolderID, | ||
1349 | newBlock.EveryoneMask, | ||
1350 | newBlock.Flags, newBlock.OwnerMask, | ||
1351 | newBlock.GroupMask, newBlock.NextOwnerMask); | ||
1352 | |||
1353 | return newBlock; | ||
1434 | } | 1354 | } |
1435 | 1355 | ||
1436 | private void AddNullFolderBlockToDecendentsPacket(ref InventoryDescendentsPacket packet) | 1356 | private void AddNullFolderBlockToDecendentsPacket(ref InventoryDescendentsPacket packet) |
@@ -1472,14 +1392,25 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
1472 | // No need to add CRC | 1392 | // No need to add CRC |
1473 | } | 1393 | } |
1474 | 1394 | ||
1475 | private InventoryDescendentsPacket CreateInventoryDescendentsPacket(UUID ownerID, UUID folderID) | 1395 | private InventoryDescendentsPacket CreateInventoryDescendentsPacket(UUID ownerID, UUID folderID, int version, int descendents, int folders, int items) |
1476 | { | 1396 | { |
1477 | InventoryDescendentsPacket descend = (InventoryDescendentsPacket)PacketPool.Instance.GetPacket(PacketType.InventoryDescendents); | 1397 | InventoryDescendentsPacket descend = (InventoryDescendentsPacket)PacketPool.Instance.GetPacket(PacketType.InventoryDescendents); |
1478 | descend.Header.Zerocoded = true; | 1398 | descend.Header.Zerocoded = true; |
1479 | descend.AgentData.AgentID = AgentId; | 1399 | descend.AgentData.AgentID = AgentId; |
1480 | descend.AgentData.OwnerID = ownerID; | 1400 | descend.AgentData.OwnerID = ownerID; |
1481 | descend.AgentData.FolderID = folderID; | 1401 | descend.AgentData.FolderID = folderID; |
1482 | descend.AgentData.Version = 1; | 1402 | descend.AgentData.Version = version; |
1403 | descend.AgentData.Descendents = descendents; | ||
1404 | |||
1405 | if (folders > 0) | ||
1406 | descend.FolderData = new InventoryDescendentsPacket.FolderDataBlock[folders]; | ||
1407 | else | ||
1408 | AddNullFolderBlockToDecendentsPacket(ref descend); | ||
1409 | |||
1410 | if (items > 0) | ||
1411 | descend.ItemData = new InventoryDescendentsPacket.ItemDataBlock[items]; | ||
1412 | else | ||
1413 | AddNullItemBlockToDescendentsPacket(ref descend); | ||
1483 | 1414 | ||
1484 | return descend; | 1415 | return descend; |
1485 | } | 1416 | } |
@@ -1856,7 +1787,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
1856 | economyData.Info.TeleportMinPrice = TeleportMinPrice; | 1787 | economyData.Info.TeleportMinPrice = TeleportMinPrice; |
1857 | economyData.Info.TeleportPriceExponent = TeleportPriceExponent; | 1788 | economyData.Info.TeleportPriceExponent = TeleportPriceExponent; |
1858 | economyData.Header.Reliable = true; | 1789 | economyData.Header.Reliable = true; |
1859 | OutPacket(economyData, ThrottleOutPacketType.Unknown); | 1790 | OutPacket(economyData, ThrottleOutPacketType.Task); |
1860 | } | 1791 | } |
1861 | 1792 | ||
1862 | public void SendAvatarPickerReply(AvatarPickerReplyAgentDataArgs AgentData, List<AvatarPickerReplyDataArgs> Data) | 1793 | public void SendAvatarPickerReply(AvatarPickerReplyAgentDataArgs AgentData, List<AvatarPickerReplyDataArgs> Data) |
@@ -2786,30 +2717,37 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
2786 | 2717 | ||
2787 | public void SendAvatarGroupsReply(UUID avatarID, GroupMembershipData[] data) | 2718 | public void SendAvatarGroupsReply(UUID avatarID, GroupMembershipData[] data) |
2788 | { | 2719 | { |
2789 | AvatarGroupsReplyPacket p = (AvatarGroupsReplyPacket)PacketPool.Instance.GetPacket(PacketType.AvatarGroupsReply); | 2720 | OSDMap llsd = new OSDMap(3); |
2790 | 2721 | OSDArray AgentData = new OSDArray(1); | |
2791 | p.AgentData = new AvatarGroupsReplyPacket.AgentDataBlock(); | 2722 | OSDMap AgentDataMap = new OSDMap(1); |
2792 | p.AgentData.AgentID = AgentId; | 2723 | AgentDataMap.Add("AgentID", OSD.FromUUID(this.AgentId)); |
2793 | p.AgentData.AvatarID = avatarID; | 2724 | AgentDataMap.Add("AvatarID", OSD.FromUUID(avatarID)); |
2794 | 2725 | AgentData.Add(AgentDataMap); | |
2795 | p.GroupData = new AvatarGroupsReplyPacket.GroupDataBlock[data.Length]; | 2726 | llsd.Add("AgentData", AgentData); |
2796 | int i = 0; | 2727 | OSDArray GroupData = new OSDArray(data.Length); |
2797 | foreach (GroupMembershipData m in data) | 2728 | OSDArray NewGroupData = new OSDArray(data.Length); |
2798 | { | 2729 | foreach (GroupMembershipData m in data) |
2799 | p.GroupData[i] = new AvatarGroupsReplyPacket.GroupDataBlock(); | 2730 | { |
2800 | p.GroupData[i].GroupPowers = m.GroupPowers; | 2731 | OSDMap GroupDataMap = new OSDMap(6); |
2801 | p.GroupData[i].AcceptNotices = m.AcceptNotices; | 2732 | OSDMap NewGroupDataMap = new OSDMap(1); |
2802 | p.GroupData[i].GroupTitle = Utils.StringToBytes(m.GroupTitle); | 2733 | GroupDataMap.Add("GroupPowers", OSD.FromBinary(m.GroupPowers)); |
2803 | p.GroupData[i].GroupID = m.GroupID; | 2734 | GroupDataMap.Add("AcceptNotices", OSD.FromBoolean(m.AcceptNotices)); |
2804 | p.GroupData[i].GroupName = Utils.StringToBytes(m.GroupName); | 2735 | GroupDataMap.Add("GroupTitle", OSD.FromString(m.GroupTitle)); |
2805 | p.GroupData[i].GroupInsigniaID = m.GroupPicture; | 2736 | GroupDataMap.Add("GroupID", OSD.FromUUID(m.GroupID)); |
2806 | i++; | 2737 | GroupDataMap.Add("GroupName", OSD.FromString(m.GroupName)); |
2807 | } | 2738 | GroupDataMap.Add("GroupInsigniaID", OSD.FromUUID(m.GroupPicture)); |
2808 | 2739 | NewGroupDataMap.Add("ListInProfile", OSD.FromBoolean(m.ListInProfile)); | |
2809 | p.NewGroupData = new AvatarGroupsReplyPacket.NewGroupDataBlock(); | 2740 | GroupData.Add(GroupDataMap); |
2810 | p.NewGroupData.ListInProfile = true; | 2741 | NewGroupData.Add(NewGroupDataMap); |
2811 | 2742 | } | |
2812 | OutPacket(p, ThrottleOutPacketType.Task); | 2743 | llsd.Add("GroupData", GroupData); |
2744 | llsd.Add("NewGroupData", NewGroupData); | ||
2745 | |||
2746 | IEventQueue eq = this.Scene.RequestModuleInterface<IEventQueue>(); | ||
2747 | if (eq != null) | ||
2748 | { | ||
2749 | eq.Enqueue(BuildEvent("AvatarGroupsReply", llsd), this.AgentId); | ||
2750 | } | ||
2813 | } | 2751 | } |
2814 | 2752 | ||
2815 | public void SendJoinGroupReply(UUID groupID, bool success) | 2753 | public void SendJoinGroupReply(UUID groupID, bool success) |
@@ -3168,107 +3106,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
3168 | 3106 | ||
3169 | #endregion | 3107 | #endregion |
3170 | 3108 | ||
3171 | #region Prim/Avatar Updates | ||
3172 | |||
3173 | /*void SendObjectUpdate(SceneObjectPart obj, PrimFlags creatorFlags, PrimUpdateFlags updateFlags) | ||
3174 | { | ||
3175 | bool canUseCompressed, canUseImproved; | ||
3176 | UpdateFlagsToPacketType(creatorFlags, updateFlags, out canUseCompressed, out canUseImproved); | ||
3177 | |||
3178 | if (!canUseImproved && !canUseCompressed) | ||
3179 | SendFullObjectUpdate(obj, creatorFlags, updateFlags); | ||
3180 | else if (!canUseImproved) | ||
3181 | SendObjectUpdateCompressed(obj, creatorFlags, updateFlags); | ||
3182 | else | ||
3183 | SendImprovedTerseObjectUpdate(obj, creatorFlags, updateFlags); | ||
3184 | } | ||
3185 | |||
3186 | void SendFullObjectUpdate(SceneObjectPart obj, PrimFlags creatorFlags, PrimUpdateFlags updateFlags) | ||
3187 | { | ||
3188 | IClientAPI owner; | ||
3189 | if (m_scene.ClientManager.TryGetValue(obj.OwnerID, out owner) && owner is LLClientView) | ||
3190 | { | ||
3191 | LLClientView llOwner = (LLClientView)owner; | ||
3192 | |||
3193 | // Send an update out to the owner | ||
3194 | ObjectUpdatePacket updateToOwner = new ObjectUpdatePacket(); | ||
3195 | updateToOwner.RegionData.RegionHandle = obj.RegionHandle; | ||
3196 | //updateToOwner.RegionData.TimeDilation = (ushort)(timeDilation * (float)UInt16.MaxValue); | ||
3197 | updateToOwner.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[1]; | ||
3198 | updateToOwner.ObjectData[0] = BuildUpdateBlock(obj, obj.Flags | creatorFlags | PrimFlags.ObjectYouOwner, 0); | ||
3199 | |||
3200 | m_udpServer.SendPacket(llOwner.UDPClient, updateToOwner, ThrottleOutPacketType.State, true); | ||
3201 | } | ||
3202 | |||
3203 | // Send an update out to everyone else | ||
3204 | ObjectUpdatePacket updateToOthers = new ObjectUpdatePacket(); | ||
3205 | updateToOthers.RegionData.RegionHandle = obj.RegionHandle; | ||
3206 | //updateToOthers.RegionData.TimeDilation = (ushort)(timeDilation * (float)UInt16.MaxValue); | ||
3207 | updateToOthers.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[1]; | ||
3208 | updateToOthers.ObjectData[0] = BuildUpdateBlock(obj, obj.Flags, 0); | ||
3209 | |||
3210 | m_scene.ClientManager.ForEach( | ||
3211 | delegate(IClientAPI client) | ||
3212 | { | ||
3213 | if (client.AgentId != obj.OwnerID && client is LLClientView) | ||
3214 | { | ||
3215 | LLClientView llClient = (LLClientView)client; | ||
3216 | m_udpServer.SendPacket(llClient.UDPClient, updateToOthers, ThrottleOutPacketType.State, true); | ||
3217 | } | ||
3218 | } | ||
3219 | ); | ||
3220 | } | ||
3221 | |||
3222 | void SendObjectUpdateCompressed(SceneObjectPart obj, PrimFlags creatorFlags, PrimUpdateFlags updateFlags) | ||
3223 | { | ||
3224 | } | ||
3225 | |||
3226 | void SendImprovedTerseObjectUpdate(SceneObjectPart obj, PrimFlags creatorFlags, PrimUpdateFlags updateFlags) | ||
3227 | { | ||
3228 | } | ||
3229 | |||
3230 | void UpdateFlagsToPacketType(PrimFlags creatorFlags, PrimUpdateFlags updateFlags, out bool canUseCompressed, out bool canUseImproved) | ||
3231 | { | ||
3232 | canUseCompressed = true; | ||
3233 | canUseImproved = true; | ||
3234 | |||
3235 | if ((updateFlags & PrimUpdateFlags.FullUpdate) == PrimUpdateFlags.FullUpdate || creatorFlags != PrimFlags.None) | ||
3236 | { | ||
3237 | canUseCompressed = false; | ||
3238 | canUseImproved = false; | ||
3239 | } | ||
3240 | else | ||
3241 | { | ||
3242 | if ((updateFlags & PrimUpdateFlags.Velocity) != 0 || | ||
3243 | (updateFlags & PrimUpdateFlags.Acceleration) != 0 || | ||
3244 | (updateFlags & PrimUpdateFlags.CollisionPlane) != 0 || | ||
3245 | (updateFlags & PrimUpdateFlags.Joint) != 0) | ||
3246 | { | ||
3247 | canUseCompressed = false; | ||
3248 | } | ||
3249 | |||
3250 | if ((updateFlags & PrimUpdateFlags.PrimFlags) != 0 || | ||
3251 | (updateFlags & PrimUpdateFlags.ParentID) != 0 || | ||
3252 | (updateFlags & PrimUpdateFlags.Scale) != 0 || | ||
3253 | (updateFlags & PrimUpdateFlags.PrimData) != 0 || | ||
3254 | (updateFlags & PrimUpdateFlags.Text) != 0 || | ||
3255 | (updateFlags & PrimUpdateFlags.NameValue) != 0 || | ||
3256 | (updateFlags & PrimUpdateFlags.ExtraData) != 0 || | ||
3257 | (updateFlags & PrimUpdateFlags.TextureAnim) != 0 || | ||
3258 | (updateFlags & PrimUpdateFlags.Sound) != 0 || | ||
3259 | (updateFlags & PrimUpdateFlags.Particles) != 0 || | ||
3260 | (updateFlags & PrimUpdateFlags.Material) != 0 || | ||
3261 | (updateFlags & PrimUpdateFlags.ClickAction) != 0 || | ||
3262 | (updateFlags & PrimUpdateFlags.MediaURL) != 0 || | ||
3263 | (updateFlags & PrimUpdateFlags.Joint) != 0) | ||
3264 | { | ||
3265 | canUseImproved = false; | ||
3266 | } | ||
3267 | } | ||
3268 | }*/ | ||
3269 | |||
3270 | #endregion Prim/Avatar Updates | ||
3271 | |||
3272 | #region Avatar Packet/Data Sending Methods | 3109 | #region Avatar Packet/Data Sending Methods |
3273 | 3110 | ||
3274 | /// <summary> | 3111 | /// <summary> |
@@ -3314,7 +3151,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
3314 | ProcessAvatarTerseUpdates(); | 3151 | ProcessAvatarTerseUpdates(); |
3315 | } | 3152 | } |
3316 | 3153 | ||
3317 | private void ProcessAvatarTerseUpdates() | 3154 | protected void ProcessAvatarTerseUpdates() |
3318 | { | 3155 | { |
3319 | ImprovedTerseObjectUpdatePacket terse = (ImprovedTerseObjectUpdatePacket)PacketPool.Instance.GetPacket(PacketType.ImprovedTerseObjectUpdate); | 3156 | ImprovedTerseObjectUpdatePacket terse = (ImprovedTerseObjectUpdatePacket)PacketPool.Instance.GetPacket(PacketType.ImprovedTerseObjectUpdate); |
3320 | terse.Header.Reliable = false; | 3157 | terse.Header.Reliable = false; |
@@ -3335,6 +3172,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
3335 | terse.ObjectData[i] = m_avatarTerseUpdates.Dequeue(); | 3172 | terse.ObjectData[i] = m_avatarTerseUpdates.Dequeue(); |
3336 | } | 3173 | } |
3337 | 3174 | ||
3175 | // HACK: Using the task category until the tiered reprioritization code is in | ||
3338 | OutPacket(terse, ThrottleOutPacketType.Task); | 3176 | OutPacket(terse, ThrottleOutPacketType.Task); |
3339 | } | 3177 | } |
3340 | 3178 | ||
@@ -3343,12 +3181,17 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
3343 | if (!IsActive) return; // We don't need to update inactive clients. | 3181 | if (!IsActive) return; // We don't need to update inactive clients. |
3344 | 3182 | ||
3345 | CoarseLocationUpdatePacket loc = (CoarseLocationUpdatePacket)PacketPool.Instance.GetPacket(PacketType.CoarseLocationUpdate); | 3183 | CoarseLocationUpdatePacket loc = (CoarseLocationUpdatePacket)PacketPool.Instance.GetPacket(PacketType.CoarseLocationUpdate); |
3346 | // TODO: don't create new blocks if recycling an old packet | 3184 | loc.Header.Reliable = false; |
3347 | int total = CoarseLocations.Count; | 3185 | |
3348 | CoarseLocationUpdatePacket.IndexBlock ib = | 3186 | // Each packet can only hold around 62 avatar positions and the client clears the mini-map each time |
3349 | new CoarseLocationUpdatePacket.IndexBlock(); | 3187 | // a CoarseLocationUpdate packet is received. Oh well. |
3188 | int total = Math.Min(CoarseLocations.Count, 60); | ||
3189 | |||
3190 | CoarseLocationUpdatePacket.IndexBlock ib = new CoarseLocationUpdatePacket.IndexBlock(); | ||
3191 | |||
3350 | loc.Location = new CoarseLocationUpdatePacket.LocationBlock[total]; | 3192 | loc.Location = new CoarseLocationUpdatePacket.LocationBlock[total]; |
3351 | loc.AgentData = new CoarseLocationUpdatePacket.AgentDataBlock[total]; | 3193 | loc.AgentData = new CoarseLocationUpdatePacket.AgentDataBlock[total]; |
3194 | |||
3352 | int selfindex = -1; | 3195 | int selfindex = -1; |
3353 | for (int i = 0; i < total; i++) | 3196 | for (int i = 0; i < total; i++) |
3354 | { | 3197 | { |
@@ -3358,18 +3201,17 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
3358 | lb.X = (byte)CoarseLocations[i].X; | 3201 | lb.X = (byte)CoarseLocations[i].X; |
3359 | lb.Y = (byte)CoarseLocations[i].Y; | 3202 | lb.Y = (byte)CoarseLocations[i].Y; |
3360 | 3203 | ||
3361 | lb.Z = CoarseLocations[i].Z > 1024 ? (byte)0 : (byte)(CoarseLocations[i].Z * 0.25); | 3204 | lb.Z = CoarseLocations[i].Z > 1024 ? (byte)0 : (byte)(CoarseLocations[i].Z * 0.25f); |
3362 | loc.Location[i] = lb; | 3205 | loc.Location[i] = lb; |
3363 | loc.AgentData[i] = new CoarseLocationUpdatePacket.AgentDataBlock(); | 3206 | loc.AgentData[i] = new CoarseLocationUpdatePacket.AgentDataBlock(); |
3364 | loc.AgentData[i].AgentID = users[i]; | 3207 | loc.AgentData[i].AgentID = users[i]; |
3365 | if (users[i] == AgentId) | 3208 | if (users[i] == AgentId) |
3366 | selfindex = i; | 3209 | selfindex = i; |
3367 | } | 3210 | } |
3211 | |||
3368 | ib.You = (short)selfindex; | 3212 | ib.You = (short)selfindex; |
3369 | ib.Prey = -1; | 3213 | ib.Prey = -1; |
3370 | loc.Index = ib; | 3214 | loc.Index = ib; |
3371 | loc.Header.Reliable = false; | ||
3372 | loc.Header.Zerocoded = true; | ||
3373 | 3215 | ||
3374 | OutPacket(loc, ThrottleOutPacketType.Task); | 3216 | OutPacket(loc, ThrottleOutPacketType.Task); |
3375 | } | 3217 | } |
@@ -4180,11 +4022,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
4180 | 4022 | ||
4181 | protected ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateImprovedTerseBlock(SendPrimitiveTerseData data) | 4023 | protected ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateImprovedTerseBlock(SendPrimitiveTerseData data) |
4182 | { | 4024 | { |
4183 | return CreateImprovedTerseBlock(false, data.LocalID, data.State, Vector4.Zero, data.Position, data.Velocity, | 4025 | return CreateImprovedTerseBlock(false, data.LocalID, data.AttachPoint, Vector4.Zero, data.Position, data.Velocity, |
4184 | data.Acceleration, data.Rotation, data.AngularVelocity, data.TextureEntry); | 4026 | data.Acceleration, data.Rotation, data.AngularVelocity, data.TextureEntry); |
4185 | } | 4027 | } |
4186 | 4028 | ||
4187 | protected ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateImprovedTerseBlock(bool avatar, uint localID, byte state, | 4029 | protected ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateImprovedTerseBlock(bool avatar, uint localID, int attachPoint, |
4188 | Vector4 collisionPlane, Vector3 position, Vector3 velocity, Vector3 acceleration, Quaternion rotation, | 4030 | Vector4 collisionPlane, Vector3 position, Vector3 velocity, Vector3 acceleration, Quaternion rotation, |
4189 | Vector3 angularVelocity, byte[] textureEntry) | 4031 | Vector3 angularVelocity, byte[] textureEntry) |
4190 | { | 4032 | { |
@@ -4196,7 +4038,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
4196 | pos += 4; | 4038 | pos += 4; |
4197 | 4039 | ||
4198 | // Avatar/CollisionPlane | 4040 | // Avatar/CollisionPlane |
4199 | data[pos++] = state; | 4041 | data[pos++] = (byte)((attachPoint % 16) * 16 + (attachPoint / 16)); ; |
4200 | if (avatar) | 4042 | if (avatar) |
4201 | { | 4043 | { |
4202 | data[pos++] = 1; | 4044 | data[pos++] = 1; |
@@ -4430,11 +4272,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
4430 | /// </summary> | 4272 | /// </summary> |
4431 | protected virtual void RegisterLocalPacketHandlers() | 4273 | protected virtual void RegisterLocalPacketHandlers() |
4432 | { | 4274 | { |
4433 | AddLocalPacketHandler(PacketType.LogoutRequest, Logout); | 4275 | AddLocalPacketHandler(PacketType.LogoutRequest, HandleLogout); |
4434 | AddLocalPacketHandler(PacketType.AgentUpdate, HandleAgentUpdate); | 4276 | AddLocalPacketHandler(PacketType.AgentUpdate, HandleAgentUpdate); |
4435 | AddLocalPacketHandler(PacketType.ViewerEffect, HandleViewerEffect); | 4277 | AddLocalPacketHandler(PacketType.ViewerEffect, HandleViewerEffect); |
4436 | AddLocalPacketHandler(PacketType.AgentCachedTexture, AgentTextureCached); | 4278 | AddLocalPacketHandler(PacketType.AgentCachedTexture, HandleAgentTextureCached); |
4437 | AddLocalPacketHandler(PacketType.MultipleObjectUpdate, MultipleObjUpdate); | 4279 | AddLocalPacketHandler(PacketType.MultipleObjectUpdate, HandleMultipleObjUpdate); |
4438 | AddLocalPacketHandler(PacketType.MoneyTransferRequest, HandleMoneyTransferRequest); | 4280 | AddLocalPacketHandler(PacketType.MoneyTransferRequest, HandleMoneyTransferRequest); |
4439 | AddLocalPacketHandler(PacketType.ParcelBuy, HandleParcelBuyRequest); | 4281 | AddLocalPacketHandler(PacketType.ParcelBuy, HandleParcelBuyRequest); |
4440 | AddLocalPacketHandler(PacketType.UUIDGroupNameRequest, HandleUUIDGroupNameRequest); | 4282 | AddLocalPacketHandler(PacketType.UUIDGroupNameRequest, HandleUUIDGroupNameRequest); |
@@ -4703,7 +4545,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
4703 | /// <param name="client"></param> | 4545 | /// <param name="client"></param> |
4704 | /// <param name="packet"></param> | 4546 | /// <param name="packet"></param> |
4705 | /// <returns></returns> | 4547 | /// <returns></returns> |
4706 | protected virtual bool Logout(IClientAPI client, Packet packet) | 4548 | protected virtual bool HandleLogout(IClientAPI client, Packet packet) |
4707 | { | 4549 | { |
4708 | if (packet.Type == PacketType.LogoutRequest) | 4550 | if (packet.Type == PacketType.LogoutRequest) |
4709 | { | 4551 | { |
@@ -4741,7 +4583,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
4741 | /// <param name="simclient"></param> | 4583 | /// <param name="simclient"></param> |
4742 | /// <param name="packet"></param> | 4584 | /// <param name="packet"></param> |
4743 | /// <returns></returns> | 4585 | /// <returns></returns> |
4744 | protected bool AgentTextureCached(IClientAPI simclient, Packet packet) | 4586 | protected bool HandleAgentTextureCached(IClientAPI simclient, Packet packet) |
4745 | { | 4587 | { |
4746 | //m_log.Debug("texture cached: " + packet.ToString()); | 4588 | //m_log.Debug("texture cached: " + packet.ToString()); |
4747 | AgentCachedTexturePacket cachedtex = (AgentCachedTexturePacket)packet; | 4589 | AgentCachedTexturePacket cachedtex = (AgentCachedTexturePacket)packet; |
@@ -4771,7 +4613,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
4771 | return true; | 4613 | return true; |
4772 | } | 4614 | } |
4773 | 4615 | ||
4774 | protected bool MultipleObjUpdate(IClientAPI simClient, Packet packet) | 4616 | protected bool HandleMultipleObjUpdate(IClientAPI simClient, Packet packet) |
4775 | { | 4617 | { |
4776 | MultipleObjectUpdatePacket multipleupdate = (MultipleObjectUpdatePacket)packet; | 4618 | MultipleObjectUpdatePacket multipleupdate = (MultipleObjectUpdatePacket)packet; |
4777 | if (multipleupdate.AgentData.SessionID != SessionId) return false; | 4619 | if (multipleupdate.AgentData.SessionID != SessionId) return false; |
@@ -5050,11 +4892,28 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
5050 | /// </summary> | 4892 | /// </summary> |
5051 | /// <param name="packet">Packet to send</param> | 4893 | /// <param name="packet">Packet to send</param> |
5052 | /// <param name="throttlePacketType">Throttling category for the packet</param> | 4894 | /// <param name="throttlePacketType">Throttling category for the packet</param> |
5053 | private void OutPacket(Packet packet, ThrottleOutPacketType throttlePacketType) | 4895 | protected void OutPacket(Packet packet, ThrottleOutPacketType throttlePacketType) |
5054 | { | 4896 | { |
4897 | #region BinaryStats | ||
4898 | LLUDPServer.LogPacketHeader(false, m_circuitCode, 0, packet.Type, (ushort)packet.Length); | ||
4899 | #endregion BinaryStats | ||
4900 | |||
5055 | m_udpServer.SendPacket(m_udpClient, packet, throttlePacketType, true); | 4901 | m_udpServer.SendPacket(m_udpClient, packet, throttlePacketType, true); |
5056 | } | 4902 | } |
5057 | 4903 | ||
4904 | /// <summary> | ||
4905 | /// This is the starting point for sending a simulator packet out to the client | ||
4906 | /// </summary> | ||
4907 | /// <param name="packet">Packet to send</param> | ||
4908 | /// <param name="throttlePacketType">Throttling category for the packet</param> | ||
4909 | /// <param name="doAutomaticSplitting">True to automatically split oversized | ||
4910 | /// packets (the default), or false to disable splitting if the calling code | ||
4911 | /// handles splitting manually</param> | ||
4912 | protected void OutPacket(Packet packet, ThrottleOutPacketType throttlePacketType, bool doAutomaticSplitting) | ||
4913 | { | ||
4914 | m_udpServer.SendPacket(m_udpClient, packet, throttlePacketType, doAutomaticSplitting); | ||
4915 | } | ||
4916 | |||
5058 | public bool AddMoney(int debit) | 4917 | public bool AddMoney(int debit) |
5059 | { | 4918 | { |
5060 | if (m_moneyBalance + debit >= 0) | 4919 | if (m_moneyBalance + debit >= 0) |
@@ -9854,7 +9713,26 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
9854 | Utils.BytesToString(avatarInterestUpdate.PropertiesData.SkillsText), | 9713 | Utils.BytesToString(avatarInterestUpdate.PropertiesData.SkillsText), |
9855 | Utils.BytesToString(avatarInterestUpdate.PropertiesData.LanguagesText)); | 9714 | Utils.BytesToString(avatarInterestUpdate.PropertiesData.LanguagesText)); |
9856 | break; | 9715 | break; |
9857 | 9716 | ||
9717 | case PacketType.GrantUserRights: | ||
9718 | GrantUserRightsPacket GrantUserRights = | ||
9719 | (GrantUserRightsPacket)Pack; | ||
9720 | #region Packet Session and User Check | ||
9721 | if (m_checkPackets) | ||
9722 | { | ||
9723 | if (GrantUserRights.AgentData.SessionID != SessionId || | ||
9724 | GrantUserRights.AgentData.AgentID != AgentId) | ||
9725 | break; | ||
9726 | } | ||
9727 | #endregion | ||
9728 | GrantUserFriendRights GrantUserRightsHandler = OnGrantUserRights; | ||
9729 | if (GrantUserRightsHandler != null) | ||
9730 | GrantUserRightsHandler(this, | ||
9731 | GrantUserRights.AgentData.AgentID, | ||
9732 | GrantUserRights.Rights[0].AgentRelated, | ||
9733 | GrantUserRights.Rights[0].RelatedRights); | ||
9734 | break; | ||
9735 | |||
9858 | case PacketType.PlacesQuery: | 9736 | case PacketType.PlacesQuery: |
9859 | PlacesQueryPacket placesQueryPacket = | 9737 | PlacesQueryPacket placesQueryPacket = |
9860 | (PlacesQueryPacket)Pack; | 9738 | (PlacesQueryPacket)Pack; |
@@ -9944,7 +9822,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
9944 | commandMessagePacket.CommandBlock.Command = (uint)command; | 9822 | commandMessagePacket.CommandBlock.Command = (uint)command; |
9945 | commandMessagePacket.CommandBlock.Time = time; | 9823 | commandMessagePacket.CommandBlock.Time = time; |
9946 | 9824 | ||
9947 | OutPacket(commandMessagePacket, ThrottleOutPacketType.Unknown); | 9825 | OutPacket(commandMessagePacket, ThrottleOutPacketType.Task); |
9948 | } | 9826 | } |
9949 | 9827 | ||
9950 | public void SendParcelMediaUpdate(string mediaUrl, UUID mediaTextureID, | 9828 | public void SendParcelMediaUpdate(string mediaUrl, UUID mediaTextureID, |
@@ -9962,7 +9840,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
9962 | updatePacket.DataBlockExtended.MediaHeight = mediaHeight; | 9840 | updatePacket.DataBlockExtended.MediaHeight = mediaHeight; |
9963 | updatePacket.DataBlockExtended.MediaLoop = mediaLoop; | 9841 | updatePacket.DataBlockExtended.MediaLoop = mediaLoop; |
9964 | 9842 | ||
9965 | OutPacket(updatePacket, ThrottleOutPacketType.Unknown); | 9843 | OutPacket(updatePacket, ThrottleOutPacketType.Task); |
9966 | } | 9844 | } |
9967 | 9845 | ||
9968 | #endregion | 9846 | #endregion |
@@ -10236,7 +10114,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
10236 | } | 10114 | } |
10237 | 10115 | ||
10238 | #region PriorityQueue | 10116 | #region PriorityQueue |
10239 | private class PriorityQueue<TPriority, TValue> | 10117 | public class PriorityQueue<TPriority, TValue> |
10240 | { | 10118 | { |
10241 | internal delegate bool UpdatePriorityHandler(ref TPriority priority, uint local_id); | 10119 | internal delegate bool UpdatePriorityHandler(ref TPriority priority, uint local_id); |
10242 | 10120 | ||
@@ -10264,7 +10142,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
10264 | this.m_comparison = comparison; | 10142 | this.m_comparison = comparison; |
10265 | } | 10143 | } |
10266 | 10144 | ||
10267 | internal object SyncRoot { get { return this.m_syncRoot; } } | 10145 | public object SyncRoot { get { return this.m_syncRoot; } } |
10268 | internal int Count | 10146 | internal int Count |
10269 | { | 10147 | { |
10270 | get | 10148 | get |
@@ -10276,7 +10154,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
10276 | } | 10154 | } |
10277 | } | 10155 | } |
10278 | 10156 | ||
10279 | internal bool Enqueue(TPriority priority, TValue value, uint local_id) | 10157 | public bool Enqueue(TPriority priority, TValue value, uint local_id) |
10280 | { | 10158 | { |
10281 | LookupItem item; | 10159 | LookupItem item; |
10282 | 10160 | ||
@@ -10396,5 +10274,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
10396 | } | 10274 | } |
10397 | #endregion | 10275 | #endregion |
10398 | 10276 | ||
10277 | public static OSD BuildEvent(string eventName, OSD eventBody) | ||
10278 | { | ||
10279 | OSDMap osdEvent = new OSDMap(2); | ||
10280 | osdEvent.Add("message", new OSDString(eventName)); | ||
10281 | osdEvent.Add("body", eventBody); | ||
10282 | |||
10283 | return osdEvent; | ||
10284 | } | ||
10399 | } | 10285 | } |
10400 | } | 10286 | } |
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLFileTransfer.cs b/OpenSim/Region/ClientStack/LindenUDP/LLFileTransfer.cs index 697bbe6..adf171e 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLFileTransfer.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLFileTransfer.cs | |||
@@ -197,11 +197,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
197 | 197 | ||
198 | private void Initialise(UUID fileID, string fileName) | 198 | private void Initialise(UUID fileID, string fileName) |
199 | { | 199 | { |
200 | m_asset = new AssetBase(); | 200 | m_asset = new AssetBase(fileID, fileName, type); |
201 | m_asset.FullID = fileID; | ||
202 | m_asset.Type = type; | ||
203 | m_asset.Data = new byte[0]; | 201 | m_asset.Data = new byte[0]; |
204 | m_asset.Name = fileName; | ||
205 | m_asset.Description = "empty"; | 202 | m_asset.Description = "empty"; |
206 | m_asset.Local = true; | 203 | m_asset.Local = true; |
207 | m_asset.Temporary = true; | 204 | m_asset.Temporary = true; |
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs index 84a4959..9856a1c 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs | |||
@@ -135,8 +135,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
135 | private readonly TokenBucket m_throttle; | 135 | private readonly TokenBucket m_throttle; |
136 | /// <summary>Throttle buckets for each packet category</summary> | 136 | /// <summary>Throttle buckets for each packet category</summary> |
137 | private readonly TokenBucket[] m_throttleCategories; | 137 | private readonly TokenBucket[] m_throttleCategories; |
138 | /// <summary>Throttle rate defaults and limits</summary> | ||
139 | private readonly ThrottleRates m_defaultThrottleRates; | ||
140 | /// <summary>Outgoing queues for throttled packets</summary> | 138 | /// <summary>Outgoing queues for throttled packets</summary> |
141 | private readonly OpenSim.Framework.LocklessQueue<OutgoingPacket>[] m_packetOutboxes = new OpenSim.Framework.LocklessQueue<OutgoingPacket>[THROTTLE_CATEGORY_COUNT]; | 139 | private readonly OpenSim.Framework.LocklessQueue<OutgoingPacket>[] m_packetOutboxes = new OpenSim.Framework.LocklessQueue<OutgoingPacket>[THROTTLE_CATEGORY_COUNT]; |
142 | /// <summary>A container that can hold one packet for each outbox, used to store | 140 | /// <summary>A container that can hold one packet for each outbox, used to store |
@@ -145,6 +143,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
145 | /// <summary>A reference to the LLUDPServer that is managing this client</summary> | 143 | /// <summary>A reference to the LLUDPServer that is managing this client</summary> |
146 | private readonly LLUDPServer m_udpServer; | 144 | private readonly LLUDPServer m_udpServer; |
147 | 145 | ||
146 | private int m_defaultRTO = 3000; | ||
147 | private int m_maxRTO = 60000; | ||
148 | |||
148 | /// <summary> | 149 | /// <summary> |
149 | /// Default constructor | 150 | /// Default constructor |
150 | /// </summary> | 151 | /// </summary> |
@@ -155,13 +156,17 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
155 | /// <param name="circuitCode">Circuit code for this connection</param> | 156 | /// <param name="circuitCode">Circuit code for this connection</param> |
156 | /// <param name="agentID">AgentID for the connected agent</param> | 157 | /// <param name="agentID">AgentID for the connected agent</param> |
157 | /// <param name="remoteEndPoint">Remote endpoint for this connection</param> | 158 | /// <param name="remoteEndPoint">Remote endpoint for this connection</param> |
158 | public LLUDPClient(LLUDPServer server, ThrottleRates rates, TokenBucket parentThrottle, uint circuitCode, UUID agentID, IPEndPoint remoteEndPoint) | 159 | public LLUDPClient(LLUDPServer server, ThrottleRates rates, TokenBucket parentThrottle, uint circuitCode, UUID agentID, IPEndPoint remoteEndPoint, int defaultRTO, int maxRTO) |
159 | { | 160 | { |
160 | AgentID = agentID; | 161 | AgentID = agentID; |
161 | RemoteEndPoint = remoteEndPoint; | 162 | RemoteEndPoint = remoteEndPoint; |
162 | CircuitCode = circuitCode; | 163 | CircuitCode = circuitCode; |
163 | m_udpServer = server; | 164 | m_udpServer = server; |
164 | m_defaultThrottleRates = rates; | 165 | if (defaultRTO != 0) |
166 | m_defaultRTO = defaultRTO; | ||
167 | if (maxRTO != 0) | ||
168 | m_maxRTO = maxRTO; | ||
169 | |||
165 | // Create a token bucket throttle for this client that has the scene token bucket as a parent | 170 | // Create a token bucket throttle for this client that has the scene token bucket as a parent |
166 | m_throttle = new TokenBucket(parentThrottle, rates.TotalLimit, rates.Total); | 171 | m_throttle = new TokenBucket(parentThrottle, rates.TotalLimit, rates.Total); |
167 | // Create an array of token buckets for this clients different throttle categories | 172 | // Create an array of token buckets for this clients different throttle categories |
@@ -178,7 +183,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
178 | } | 183 | } |
179 | 184 | ||
180 | // Default the retransmission timeout to three seconds | 185 | // Default the retransmission timeout to three seconds |
181 | RTO = 3000; | 186 | RTO = m_defaultRTO; |
182 | 187 | ||
183 | // Initialize this to a sane value to prevent early disconnects | 188 | // Initialize this to a sane value to prevent early disconnects |
184 | TickLastPacketReceived = Environment.TickCount & Int32.MaxValue; | 189 | TickLastPacketReceived = Environment.TickCount & Int32.MaxValue; |
@@ -500,7 +505,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
500 | int rto = (int)(SRTT + Math.Max(m_udpServer.TickCountResolution, K * RTTVAR)); | 505 | int rto = (int)(SRTT + Math.Max(m_udpServer.TickCountResolution, K * RTTVAR)); |
501 | 506 | ||
502 | // Clamp the retransmission timeout to manageable values | 507 | // Clamp the retransmission timeout to manageable values |
503 | rto = Utils.Clamp(RTO, 3000, 60000); | 508 | rto = Utils.Clamp(RTO, m_defaultRTO, m_maxRTO); |
504 | 509 | ||
505 | RTO = rto; | 510 | RTO = rto; |
506 | 511 | ||
@@ -520,7 +525,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
520 | RTTVAR = 0.0f; | 525 | RTTVAR = 0.0f; |
521 | 526 | ||
522 | // Double the retransmission timeout | 527 | // Double the retransmission timeout |
523 | RTO = Math.Min(RTO * 2, 60000); | 528 | RTO = Math.Min(RTO * 2, m_maxRTO); |
524 | } | 529 | } |
525 | 530 | ||
526 | /// <summary> | 531 | /// <summary> |
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs index 74d3262..0b05ed9 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs | |||
@@ -27,6 +27,7 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.IO; | ||
30 | using System.Net; | 31 | using System.Net; |
31 | using System.Net.Sockets; | 32 | using System.Net.Sockets; |
32 | using System.Reflection; | 33 | using System.Reflection; |
@@ -118,13 +119,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
118 | /// <summary></summary> | 119 | /// <summary></summary> |
119 | //private UDPClientCollection m_clients = new UDPClientCollection(); | 120 | //private UDPClientCollection m_clients = new UDPClientCollection(); |
120 | /// <summary>Bandwidth throttle for this UDP server</summary> | 121 | /// <summary>Bandwidth throttle for this UDP server</summary> |
121 | private TokenBucket m_throttle; | 122 | protected TokenBucket m_throttle; |
122 | /// <summary>Bandwidth throttle rates for this UDP server</summary> | 123 | /// <summary>Bandwidth throttle rates for this UDP server</summary> |
123 | private ThrottleRates m_throttleRates; | 124 | protected ThrottleRates m_throttleRates; |
124 | /// <summary>Manages authentication for agent circuits</summary> | 125 | /// <summary>Manages authentication for agent circuits</summary> |
125 | private AgentCircuitManager m_circuitManager; | 126 | private AgentCircuitManager m_circuitManager; |
126 | /// <summary>Reference to the scene this UDP server is attached to</summary> | 127 | /// <summary>Reference to the scene this UDP server is attached to</summary> |
127 | private Scene m_scene; | 128 | protected Scene m_scene; |
128 | /// <summary>The X/Y coordinates of the scene this UDP server is attached to</summary> | 129 | /// <summary>The X/Y coordinates of the scene this UDP server is attached to</summary> |
129 | private Location m_location; | 130 | private Location m_location; |
130 | /// <summary>The size of the receive buffer for the UDP socket. This value | 131 | /// <summary>The size of the receive buffer for the UDP socket. This value |
@@ -153,6 +154,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
153 | /// <summary>Flag to signal when clients should send pings</summary> | 154 | /// <summary>Flag to signal when clients should send pings</summary> |
154 | private bool m_sendPing; | 155 | private bool m_sendPing; |
155 | 156 | ||
157 | private int m_defaultRTO = 0; | ||
158 | private int m_maxRTO = 0; | ||
159 | |||
156 | public Socket Server { get { return null; } } | 160 | public Socket Server { get { return null; } } |
157 | 161 | ||
158 | public LLUDPServer(IPAddress listenIP, ref uint port, int proxyPortOffsetParm, bool allow_alternate_port, IConfigSource configSource, AgentCircuitManager circuitManager) | 162 | public LLUDPServer(IPAddress listenIP, ref uint port, int proxyPortOffsetParm, bool allow_alternate_port, IConfigSource configSource, AgentCircuitManager circuitManager) |
@@ -189,6 +193,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
189 | AvatarTerseUpdatesPerPacket = config.GetInt("AvatarTerseUpdatesPerPacket", 10); | 193 | AvatarTerseUpdatesPerPacket = config.GetInt("AvatarTerseUpdatesPerPacket", 10); |
190 | PrimFullUpdatesPerPacket = config.GetInt("PrimFullUpdatesPerPacket", 100); | 194 | PrimFullUpdatesPerPacket = config.GetInt("PrimFullUpdatesPerPacket", 100); |
191 | TextureSendLimit = config.GetInt("TextureSendLimit", 20); | 195 | TextureSendLimit = config.GetInt("TextureSendLimit", 20); |
196 | |||
197 | m_defaultRTO = config.GetInt("DefaultRTO", 0); | ||
198 | m_maxRTO = config.GetInt("MaxRTO", 0); | ||
192 | } | 199 | } |
193 | else | 200 | else |
194 | { | 201 | { |
@@ -198,6 +205,31 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
198 | TextureSendLimit = 20; | 205 | TextureSendLimit = 20; |
199 | } | 206 | } |
200 | 207 | ||
208 | #region BinaryStats | ||
209 | config = configSource.Configs["Statistics.Binary"]; | ||
210 | m_shouldCollectStats = false; | ||
211 | if (config != null) | ||
212 | { | ||
213 | if (config.Contains("enabled") && config.GetBoolean("enabled")) | ||
214 | { | ||
215 | if (config.Contains("collect_packet_headers")) | ||
216 | m_shouldCollectStats = config.GetBoolean("collect_packet_headers"); | ||
217 | if (config.Contains("packet_headers_period_seconds")) | ||
218 | { | ||
219 | binStatsMaxFilesize = TimeSpan.FromSeconds(config.GetInt("region_stats_period_seconds")); | ||
220 | } | ||
221 | if (config.Contains("stats_dir")) | ||
222 | { | ||
223 | binStatsDir = config.GetString("stats_dir"); | ||
224 | } | ||
225 | } | ||
226 | else | ||
227 | { | ||
228 | m_shouldCollectStats = false; | ||
229 | } | ||
230 | } | ||
231 | #endregion BinaryStats | ||
232 | |||
201 | m_throttle = new TokenBucket(null, sceneThrottleBps, sceneThrottleBps); | 233 | m_throttle = new TokenBucket(null, sceneThrottleBps, sceneThrottleBps); |
202 | m_throttleRates = new ThrottleRates(configSource); | 234 | m_throttleRates = new ThrottleRates(configSource); |
203 | } | 235 | } |
@@ -247,8 +279,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
247 | 279 | ||
248 | public void BroadcastPacket(Packet packet, ThrottleOutPacketType category, bool sendToPausedAgents, bool allowSplitting) | 280 | public void BroadcastPacket(Packet packet, ThrottleOutPacketType category, bool sendToPausedAgents, bool allowSplitting) |
249 | { | 281 | { |
250 | // CoarseLocationUpdate packets cannot be split in an automated way | 282 | // CoarseLocationUpdate and AvatarGroupsReply packets cannot be split in an automated way |
251 | if (packet.Type == PacketType.CoarseLocationUpdate && allowSplitting) | 283 | if ((packet.Type == PacketType.CoarseLocationUpdate || packet.Type == PacketType.AvatarGroupsReply) && allowSplitting) |
252 | allowSplitting = false; | 284 | allowSplitting = false; |
253 | 285 | ||
254 | if (allowSplitting && packet.HasVariableBlocks) | 286 | if (allowSplitting && packet.HasVariableBlocks) |
@@ -256,8 +288,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
256 | byte[][] datas = packet.ToBytesMultiple(); | 288 | byte[][] datas = packet.ToBytesMultiple(); |
257 | int packetCount = datas.Length; | 289 | int packetCount = datas.Length; |
258 | 290 | ||
259 | //if (packetCount > 1) | 291 | if (packetCount < 1) |
260 | // m_log.Debug("[LLUDPSERVER]: Split " + packet.Type + " packet into " + packetCount + " packets"); | 292 | m_log.Error("[LLUDPSERVER]: Failed to split " + packet.Type + " with estimated length " + packet.Length); |
261 | 293 | ||
262 | for (int i = 0; i < packetCount; i++) | 294 | for (int i = 0; i < packetCount; i++) |
263 | { | 295 | { |
@@ -295,8 +327,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
295 | byte[][] datas = packet.ToBytesMultiple(); | 327 | byte[][] datas = packet.ToBytesMultiple(); |
296 | int packetCount = datas.Length; | 328 | int packetCount = datas.Length; |
297 | 329 | ||
298 | //if (packetCount > 1) | 330 | if (packetCount < 1) |
299 | // m_log.Debug("[LLUDPSERVER]: Split " + packet.Type + " packet into " + packetCount + " packets"); | 331 | m_log.Error("[LLUDPSERVER]: Failed to split " + packet.Type + " with estimated length " + packet.Length); |
300 | 332 | ||
301 | for (int i = 0; i < packetCount; i++) | 333 | for (int i = 0; i < packetCount; i++) |
302 | { | 334 | { |
@@ -353,9 +385,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
353 | } | 385 | } |
354 | else | 386 | else |
355 | { | 387 | { |
356 | m_log.Error("[LLUDPSERVER]: Packet exceeded buffer size! This could be an indication of packet assembly not obeying the MTU. Type=" + | 388 | bufferSize = dataLength; |
357 | type + ", DataLength=" + dataLength + ", BufferLength=" + buffer.Data.Length + ". Dropping packet"); | 389 | buffer = new UDPPacketBuffer(udpClient.RemoteEndPoint, bufferSize); |
358 | return; | 390 | |
391 | // m_log.Error("[LLUDPSERVER]: Packet exceeded buffer size! This could be an indication of packet assembly not obeying the MTU. Type=" + | ||
392 | // type + ", DataLength=" + dataLength + ", BufferLength=" + buffer.Data.Length + ". Dropping packet"); | ||
393 | Buffer.BlockCopy(data, 0, buffer.Data, 0, dataLength); | ||
359 | } | 394 | } |
360 | } | 395 | } |
361 | 396 | ||
@@ -364,6 +399,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
364 | #region Queue or Send | 399 | #region Queue or Send |
365 | 400 | ||
366 | OutgoingPacket outgoingPacket = new OutgoingPacket(udpClient, buffer, category); | 401 | OutgoingPacket outgoingPacket = new OutgoingPacket(udpClient, buffer, category); |
402 | outgoingPacket.Type = type; | ||
367 | 403 | ||
368 | if (!outgoingPacket.Client.EnqueueOutgoing(outgoingPacket)) | 404 | if (!outgoingPacket.Client.EnqueueOutgoing(outgoingPacket)) |
369 | SendPacketFinal(outgoingPacket); | 405 | SendPacketFinal(outgoingPacket); |
@@ -409,6 +445,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
409 | SendPacket(udpClient, pc, ThrottleOutPacketType.Unknown, false); | 445 | SendPacket(udpClient, pc, ThrottleOutPacketType.Unknown, false); |
410 | } | 446 | } |
411 | 447 | ||
448 | public void CompletePing(LLUDPClient udpClient, byte pingID) | ||
449 | { | ||
450 | CompletePingCheckPacket completePing = new CompletePingCheckPacket(); | ||
451 | completePing.PingID.PingID = pingID; | ||
452 | SendPacket(udpClient, completePing, ThrottleOutPacketType.Unknown, false); | ||
453 | } | ||
454 | |||
412 | public void ResendUnacked(LLUDPClient udpClient) | 455 | public void ResendUnacked(LLUDPClient udpClient) |
413 | { | 456 | { |
414 | if (!udpClient.IsConnected) | 457 | if (!udpClient.IsConnected) |
@@ -429,7 +472,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
429 | 472 | ||
430 | if (expiredPackets != null) | 473 | if (expiredPackets != null) |
431 | { | 474 | { |
432 | m_log.Debug("[LLUDPSERVER]: Resending " + expiredPackets.Count + " packets to " + udpClient.AgentID + ", RTO=" + udpClient.RTO); | 475 | //m_log.Debug("[LLUDPSERVER]: Resending " + expiredPackets.Count + " packets to " + udpClient.AgentID + ", RTO=" + udpClient.RTO); |
433 | 476 | ||
434 | // Exponential backoff of the retransmission timeout | 477 | // Exponential backoff of the retransmission timeout |
435 | udpClient.BackoffRTO(); | 478 | udpClient.BackoffRTO(); |
@@ -468,6 +511,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
468 | byte flags = buffer.Data[0]; | 511 | byte flags = buffer.Data[0]; |
469 | bool isResend = (flags & Helpers.MSG_RESENT) != 0; | 512 | bool isResend = (flags & Helpers.MSG_RESENT) != 0; |
470 | bool isReliable = (flags & Helpers.MSG_RELIABLE) != 0; | 513 | bool isReliable = (flags & Helpers.MSG_RELIABLE) != 0; |
514 | bool sendSynchronous = false; | ||
471 | LLUDPClient udpClient = outgoingPacket.Client; | 515 | LLUDPClient udpClient = outgoingPacket.Client; |
472 | 516 | ||
473 | if (!udpClient.IsConnected) | 517 | if (!udpClient.IsConnected) |
@@ -523,9 +567,27 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
523 | if (isReliable) | 567 | if (isReliable) |
524 | Interlocked.Add(ref udpClient.UnackedBytes, outgoingPacket.Buffer.DataLength); | 568 | Interlocked.Add(ref udpClient.UnackedBytes, outgoingPacket.Buffer.DataLength); |
525 | 569 | ||
526 | // Put the UDP payload on the wire | 570 | //Some packet types need to be sent synchonously. |
527 | AsyncBeginSend(buffer); | 571 | //Sorry, i know it's not optimal, but until the LL client |
572 | //manages packets correctly and re-orders them as required, this is necessary. | ||
528 | 573 | ||
574 | if (outgoingPacket.Type == PacketType.ImprovedTerseObjectUpdate | ||
575 | || outgoingPacket.Type == PacketType.ChatFromSimulator | ||
576 | || outgoingPacket.Type == PacketType.ObjectUpdate | ||
577 | || outgoingPacket.Type == PacketType.LayerData) | ||
578 | { | ||
579 | sendSynchronous = true; | ||
580 | } | ||
581 | |||
582 | // Put the UDP payload on the wire | ||
583 | if (sendSynchronous == true) | ||
584 | { | ||
585 | SyncBeginSend(buffer); | ||
586 | } | ||
587 | else | ||
588 | { | ||
589 | AsyncBeginSend(buffer); | ||
590 | } | ||
529 | // Keep track of when this packet was sent out (right now) | 591 | // Keep track of when this packet was sent out (right now) |
530 | outgoingPacket.TickCount = Environment.TickCount & Int32.MaxValue; | 592 | outgoingPacket.TickCount = Environment.TickCount & Int32.MaxValue; |
531 | } | 593 | } |
@@ -585,7 +647,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
585 | IClientAPI client; | 647 | IClientAPI client; |
586 | if (!m_scene.TryGetClient(address, out client) || !(client is LLClientView)) | 648 | if (!m_scene.TryGetClient(address, out client) || !(client is LLClientView)) |
587 | { | 649 | { |
588 | m_log.Debug("[LLUDPSERVER]: Received a " + packet.Type + " packet from an unrecognized source: " + address + " in " + m_scene.RegionInfo.RegionName); | 650 | //m_log.Debug("[LLUDPSERVER]: Received a " + packet.Type + " packet from an unrecognized source: " + address + " in " + m_scene.RegionInfo.RegionName); |
589 | return; | 651 | return; |
590 | } | 652 | } |
591 | 653 | ||
@@ -663,16 +725,17 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
663 | 725 | ||
664 | #endregion Incoming Packet Accounting | 726 | #endregion Incoming Packet Accounting |
665 | 727 | ||
728 | #region BinaryStats | ||
729 | LogPacketHeader(true, udpClient.CircuitCode, 0, packet.Type, (ushort)packet.Length); | ||
730 | #endregion BinaryStats | ||
731 | |||
666 | #region Ping Check Handling | 732 | #region Ping Check Handling |
667 | 733 | ||
668 | if (packet.Type == PacketType.StartPingCheck) | 734 | if (packet.Type == PacketType.StartPingCheck) |
669 | { | 735 | { |
670 | // We don't need to do anything else with ping checks | 736 | // We don't need to do anything else with ping checks |
671 | StartPingCheckPacket startPing = (StartPingCheckPacket)packet; | 737 | StartPingCheckPacket startPing = (StartPingCheckPacket)packet; |
672 | 738 | CompletePing(udpClient, startPing.PingID.PingID); | |
673 | CompletePingCheckPacket completePing = new CompletePingCheckPacket(); | ||
674 | completePing.PingID.PingID = startPing.PingID.PingID; | ||
675 | SendPacket(udpClient, completePing, ThrottleOutPacketType.Unknown, false); | ||
676 | return; | 739 | return; |
677 | } | 740 | } |
678 | else if (packet.Type == PacketType.CompletePingCheck) | 741 | else if (packet.Type == PacketType.CompletePingCheck) |
@@ -687,6 +750,87 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
687 | packetInbox.Enqueue(new IncomingPacket(udpClient, packet)); | 750 | packetInbox.Enqueue(new IncomingPacket(udpClient, packet)); |
688 | } | 751 | } |
689 | 752 | ||
753 | #region BinaryStats | ||
754 | |||
755 | public class PacketLogger | ||
756 | { | ||
757 | public DateTime StartTime; | ||
758 | public string Path = null; | ||
759 | public System.IO.BinaryWriter Log = null; | ||
760 | } | ||
761 | |||
762 | public static PacketLogger PacketLog; | ||
763 | |||
764 | protected static bool m_shouldCollectStats = false; | ||
765 | // Number of seconds to log for | ||
766 | static TimeSpan binStatsMaxFilesize = TimeSpan.FromSeconds(300); | ||
767 | static object binStatsLogLock = new object(); | ||
768 | static string binStatsDir = ""; | ||
769 | |||
770 | public static void LogPacketHeader(bool incoming, uint circuit, byte flags, PacketType packetType, ushort size) | ||
771 | { | ||
772 | if (!m_shouldCollectStats) return; | ||
773 | |||
774 | // Binary logging format is TTTTTTTTCCCCFPPPSS, T=Time, C=Circuit, F=Flags, P=PacketType, S=size | ||
775 | |||
776 | // Put the incoming bit into the least significant bit of the flags byte | ||
777 | if (incoming) | ||
778 | flags |= 0x01; | ||
779 | else | ||
780 | flags &= 0xFE; | ||
781 | |||
782 | // Put the flags byte into the most significant bits of the type integer | ||
783 | uint type = (uint)packetType; | ||
784 | type |= (uint)flags << 24; | ||
785 | |||
786 | // m_log.Debug("1 LogPacketHeader(): Outside lock"); | ||
787 | lock (binStatsLogLock) | ||
788 | { | ||
789 | DateTime now = DateTime.Now; | ||
790 | |||
791 | // m_log.Debug("2 LogPacketHeader(): Inside lock. now is " + now.Ticks); | ||
792 | try | ||
793 | { | ||
794 | if (PacketLog == null || (now > PacketLog.StartTime + binStatsMaxFilesize)) | ||
795 | { | ||
796 | if (PacketLog != null && PacketLog.Log != null) | ||
797 | { | ||
798 | PacketLog.Log.Close(); | ||
799 | } | ||
800 | |||
801 | // First log file or time has expired, start writing to a new log file | ||
802 | PacketLog = new PacketLogger(); | ||
803 | PacketLog.StartTime = now; | ||
804 | PacketLog.Path = (binStatsDir.Length > 0 ? binStatsDir + System.IO.Path.DirectorySeparatorChar.ToString() : "") | ||
805 | + String.Format("packets-{0}.log", now.ToString("yyyyMMddHHmmss")); | ||
806 | PacketLog.Log = new BinaryWriter(File.Open(PacketLog.Path, FileMode.Append, FileAccess.Write)); | ||
807 | } | ||
808 | |||
809 | // Serialize the data | ||
810 | byte[] output = new byte[18]; | ||
811 | Buffer.BlockCopy(BitConverter.GetBytes(now.Ticks), 0, output, 0, 8); | ||
812 | Buffer.BlockCopy(BitConverter.GetBytes(circuit), 0, output, 8, 4); | ||
813 | Buffer.BlockCopy(BitConverter.GetBytes(type), 0, output, 12, 4); | ||
814 | Buffer.BlockCopy(BitConverter.GetBytes(size), 0, output, 16, 2); | ||
815 | |||
816 | // Write the serialized data to disk | ||
817 | if (PacketLog != null && PacketLog.Log != null) | ||
818 | PacketLog.Log.Write(output); | ||
819 | } | ||
820 | catch (Exception ex) | ||
821 | { | ||
822 | m_log.Error("Packet statistics gathering failed: " + ex.Message, ex); | ||
823 | if (PacketLog.Log != null) | ||
824 | { | ||
825 | PacketLog.Log.Close(); | ||
826 | } | ||
827 | PacketLog = null; | ||
828 | } | ||
829 | } | ||
830 | } | ||
831 | |||
832 | #endregion BinaryStats | ||
833 | |||
690 | private void HandleUseCircuitCode(object o) | 834 | private void HandleUseCircuitCode(object o) |
691 | { | 835 | { |
692 | object[] array = (object[])o; | 836 | object[] array = (object[])o; |
@@ -759,10 +903,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
759 | } | 903 | } |
760 | } | 904 | } |
761 | 905 | ||
762 | private void AddClient(uint circuitCode, UUID agentID, UUID sessionID, IPEndPoint remoteEndPoint, AuthenticateResponse sessionInfo) | 906 | protected virtual void AddClient(uint circuitCode, UUID agentID, UUID sessionID, IPEndPoint remoteEndPoint, AuthenticateResponse sessionInfo) |
763 | { | 907 | { |
764 | // Create the LLUDPClient | 908 | // Create the LLUDPClient |
765 | LLUDPClient udpClient = new LLUDPClient(this, m_throttleRates, m_throttle, circuitCode, agentID, remoteEndPoint); | 909 | LLUDPClient udpClient = new LLUDPClient(this, m_throttleRates, m_throttle, circuitCode, agentID, remoteEndPoint, m_defaultRTO, m_maxRTO); |
766 | IClientAPI existingClient; | 910 | IClientAPI existingClient; |
767 | 911 | ||
768 | if (!m_scene.TryGetClient(agentID, out existingClient)) | 912 | if (!m_scene.TryGetClient(agentID, out existingClient)) |
@@ -976,7 +1120,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
976 | } | 1120 | } |
977 | } | 1121 | } |
978 | 1122 | ||
979 | private void LogoutHandler(IClientAPI client) | 1123 | protected void LogoutHandler(IClientAPI client) |
980 | { | 1124 | { |
981 | client.SendLogoutPacket(); | 1125 | client.SendLogoutPacket(); |
982 | if (client.IsActive) | 1126 | if (client.IsActive) |
diff --git a/OpenSim/Region/ClientStack/LindenUDP/OpenSimUDPBase.cs b/OpenSim/Region/ClientStack/LindenUDP/OpenSimUDPBase.cs index 552cc4a..63579ac 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/OpenSimUDPBase.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/OpenSimUDPBase.cs | |||
@@ -246,6 +246,24 @@ namespace OpenMetaverse | |||
246 | } | 246 | } |
247 | } | 247 | } |
248 | 248 | ||
249 | public void SyncBeginSend(UDPPacketBuffer buf) | ||
250 | { | ||
251 | if (!m_shutdownFlag) | ||
252 | { | ||
253 | try | ||
254 | { | ||
255 | m_udpSocket.SendTo( | ||
256 | buf.Data, | ||
257 | 0, | ||
258 | buf.DataLength, | ||
259 | SocketFlags.None, | ||
260 | buf.RemoteEndPoint); | ||
261 | } | ||
262 | catch (SocketException) { } | ||
263 | catch (ObjectDisposedException) { } | ||
264 | } | ||
265 | } | ||
266 | |||
249 | public void AsyncBeginSend(UDPPacketBuffer buf) | 267 | public void AsyncBeginSend(UDPPacketBuffer buf) |
250 | { | 268 | { |
251 | if (!m_shutdownFlag) | 269 | if (!m_shutdownFlag) |
@@ -270,8 +288,8 @@ namespace OpenMetaverse | |||
270 | { | 288 | { |
271 | try | 289 | try |
272 | { | 290 | { |
273 | UDPPacketBuffer buf = (UDPPacketBuffer)result.AsyncState; | 291 | // UDPPacketBuffer buf = (UDPPacketBuffer)result.AsyncState; |
274 | int bytesSent = m_udpSocket.EndSendTo(result); | 292 | m_udpSocket.EndSendTo(result); |
275 | } | 293 | } |
276 | catch (SocketException) { } | 294 | catch (SocketException) { } |
277 | catch (ObjectDisposedException) { } | 295 | catch (ObjectDisposedException) { } |
diff --git a/OpenSim/Region/ClientStack/LindenUDP/OutgoingPacket.cs b/OpenSim/Region/ClientStack/LindenUDP/OutgoingPacket.cs index 1a1a1cb..7dc42d3 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/OutgoingPacket.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/OutgoingPacket.cs | |||
@@ -28,6 +28,7 @@ | |||
28 | using System; | 28 | using System; |
29 | using OpenSim.Framework; | 29 | using OpenSim.Framework; |
30 | using OpenMetaverse; | 30 | using OpenMetaverse; |
31 | using OpenMetaverse.Packets; | ||
31 | 32 | ||
32 | namespace OpenSim.Region.ClientStack.LindenUDP | 33 | namespace OpenSim.Region.ClientStack.LindenUDP |
33 | { | 34 | { |
@@ -52,7 +53,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
52 | public int TickCount; | 53 | public int TickCount; |
53 | /// <summary>Category this packet belongs to</summary> | 54 | /// <summary>Category this packet belongs to</summary> |
54 | public ThrottleOutPacketType Category; | 55 | public ThrottleOutPacketType Category; |
55 | 56 | /// <summary>The type of packet so its delivery method can be determined</summary> | |
57 | public PacketType Type; | ||
56 | /// <summary> | 58 | /// <summary> |
57 | /// Default constructor | 59 | /// Default constructor |
58 | /// </summary> | 60 | /// </summary> |
diff --git a/OpenSim/Region/ClientStack/LindenUDP/ThrottleRates.cs b/OpenSim/Region/ClientStack/LindenUDP/ThrottleRates.cs index 008d827..aaf6e26 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/ThrottleRates.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/ThrottleRates.cs | |||
@@ -87,15 +87,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
87 | IConfig throttleConfig = config.Configs["ClientStack.LindenUDP"]; | 87 | IConfig throttleConfig = config.Configs["ClientStack.LindenUDP"]; |
88 | 88 | ||
89 | Resend = throttleConfig.GetInt("resend_default", 12500); | 89 | Resend = throttleConfig.GetInt("resend_default", 12500); |
90 | Land = throttleConfig.GetInt("land_default", 500); | 90 | Land = throttleConfig.GetInt("land_default", 1000); |
91 | Wind = throttleConfig.GetInt("wind_default", 500); | 91 | Wind = throttleConfig.GetInt("wind_default", 1000); |
92 | Cloud = throttleConfig.GetInt("cloud_default", 500); | 92 | Cloud = throttleConfig.GetInt("cloud_default", 1000); |
93 | Task = throttleConfig.GetInt("task_default", 500); | 93 | Task = throttleConfig.GetInt("task_default", 1000); |
94 | Texture = throttleConfig.GetInt("texture_default", 500); | 94 | Texture = throttleConfig.GetInt("texture_default", 1000); |
95 | Asset = throttleConfig.GetInt("asset_default", 500); | 95 | Asset = throttleConfig.GetInt("asset_default", 1000); |
96 | State = throttleConfig.GetInt("state_default", 500); | 96 | State = throttleConfig.GetInt("state_default", 1000); |
97 | |||
98 | Total = throttleConfig.GetInt("client_throttle_max_bps", 0); | ||
99 | 97 | ||
100 | ResendLimit = throttleConfig.GetInt("resend_limit", 18750); | 98 | ResendLimit = throttleConfig.GetInt("resend_limit", 18750); |
101 | LandLimit = throttleConfig.GetInt("land_limit", 29750); | 99 | LandLimit = throttleConfig.GetInt("land_limit", 29750); |
@@ -104,9 +102,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
104 | TaskLimit = throttleConfig.GetInt("task_limit", 18750); | 102 | TaskLimit = throttleConfig.GetInt("task_limit", 18750); |
105 | TextureLimit = throttleConfig.GetInt("texture_limit", 55750); | 103 | TextureLimit = throttleConfig.GetInt("texture_limit", 55750); |
106 | AssetLimit = throttleConfig.GetInt("asset_limit", 27500); | 104 | AssetLimit = throttleConfig.GetInt("asset_limit", 27500); |
107 | State = throttleConfig.GetInt("state_limit", 37000); | 105 | StateLimit = throttleConfig.GetInt("state_limit", 37000); |
108 | 106 | ||
109 | TotalLimit = throttleConfig.GetInt("client_throttle_max_bps", 0); | 107 | Total = throttleConfig.GetInt("client_throttle_max_bps", 0); |
108 | TotalLimit = Total; | ||
110 | } | 109 | } |
111 | catch (Exception) { } | 110 | catch (Exception) { } |
112 | } | 111 | } |
diff --git a/OpenSim/Region/Communications/Hypergrid/HGUserServices.cs b/OpenSim/Region/Communications/Hypergrid/HGUserServices.cs index 49a2261..09d8285 100644 --- a/OpenSim/Region/Communications/Hypergrid/HGUserServices.cs +++ b/OpenSim/Region/Communications/Hypergrid/HGUserServices.cs | |||
@@ -204,6 +204,14 @@ namespace OpenSim.Region.Communications.Hypergrid | |||
204 | return base.UpdateUserProfile(userProfile); | 204 | return base.UpdateUserProfile(userProfile); |
205 | } | 205 | } |
206 | 206 | ||
207 | public override bool AuthenticateUserByPassword(UUID userID, string password) | ||
208 | { | ||
209 | if (m_localUserServices != null) | ||
210 | return m_localUserServices.AuthenticateUserByPassword(userID, password); | ||
211 | else | ||
212 | return base.AuthenticateUserByPassword(userID, password); | ||
213 | } | ||
214 | |||
207 | #region IUserServices Friend Methods | 215 | #region IUserServices Friend Methods |
208 | 216 | ||
209 | // NOTE: We're still not dealing with foreign user friends | 217 | // NOTE: We're still not dealing with foreign user friends |
diff --git a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs index e192b81..f698ea1 100644 --- a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs +++ b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs | |||
@@ -112,11 +112,8 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction | |||
112 | bool storeLocal, bool tempFile) | 112 | bool storeLocal, bool tempFile) |
113 | { | 113 | { |
114 | ourClient = remoteClient; | 114 | ourClient = remoteClient; |
115 | m_asset = new AssetBase(); | 115 | m_asset = new AssetBase(assetID, "blank", type); |
116 | m_asset.FullID = assetID; | ||
117 | m_asset.Type = type; | ||
118 | m_asset.Data = data; | 116 | m_asset.Data = data; |
119 | m_asset.Name = "blank"; | ||
120 | m_asset.Description = "empty"; | 117 | m_asset.Description = "empty"; |
121 | m_asset.Local = storeLocal; | 118 | m_asset.Local = storeLocal; |
122 | m_asset.Temporary = tempFile; | 119 | m_asset.Temporary = tempFile; |
diff --git a/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs b/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs index 7456e8c..7ac8bed 100644 --- a/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs +++ b/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs | |||
@@ -144,8 +144,8 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender | |||
144 | /// <param name="j2kData">JPEG2000 data</param> | 144 | /// <param name="j2kData">JPEG2000 data</param> |
145 | private void DoJ2KDecode(UUID assetID, byte[] j2kData) | 145 | private void DoJ2KDecode(UUID assetID, byte[] j2kData) |
146 | { | 146 | { |
147 | int DecodeTime = 0; | 147 | // int DecodeTime = 0; |
148 | DecodeTime = Environment.TickCount; | 148 | // DecodeTime = Environment.TickCount; |
149 | OpenJPEG.J2KLayerInfo[] layers; | 149 | OpenJPEG.J2KLayerInfo[] layers; |
150 | 150 | ||
151 | if (!TryLoadCacheForAsset(assetID, out layers)) | 151 | if (!TryLoadCacheForAsset(assetID, out layers)) |
@@ -238,12 +238,11 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender | |||
238 | 238 | ||
239 | if (m_cache != null) | 239 | if (m_cache != null) |
240 | { | 240 | { |
241 | AssetBase layerDecodeAsset = new AssetBase(); | 241 | string assetID = "j2kCache_" + AssetId.ToString(); |
242 | layerDecodeAsset.ID = "j2kCache_" + AssetId.ToString(); | 242 | |
243 | AssetBase layerDecodeAsset = new AssetBase(assetID, assetID, (sbyte)AssetType.Notecard); | ||
243 | layerDecodeAsset.Local = true; | 244 | layerDecodeAsset.Local = true; |
244 | layerDecodeAsset.Name = layerDecodeAsset.ID; | ||
245 | layerDecodeAsset.Temporary = true; | 245 | layerDecodeAsset.Temporary = true; |
246 | layerDecodeAsset.Type = (sbyte)AssetType.Notecard; | ||
247 | 246 | ||
248 | #region Serialize Layer Data | 247 | #region Serialize Layer Data |
249 | 248 | ||
diff --git a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs index c6af806..adcf6bd 100644 --- a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs | |||
@@ -831,7 +831,7 @@ namespace Flotsam.RegionModules.AssetCache | |||
831 | 831 | ||
832 | public string Store(AssetBase asset) | 832 | public string Store(AssetBase asset) |
833 | { | 833 | { |
834 | if ((asset.FullID == null) || (asset.FullID == UUID.Zero)) | 834 | if (asset.FullID == UUID.Zero) |
835 | { | 835 | { |
836 | asset.FullID = UUID.Random(); | 836 | asset.FullID = UUID.Random(); |
837 | } | 837 | } |
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs index fc7d63a..bb4e032 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs | |||
@@ -395,6 +395,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
395 | 395 | ||
396 | // if it leaves, we want to know, too | 396 | // if it leaves, we want to know, too |
397 | client.OnLogout += OnLogout; | 397 | client.OnLogout += OnLogout; |
398 | client.OnGrantUserRights += GrantUserFriendRights; | ||
399 | |||
398 | } | 400 | } |
399 | 401 | ||
400 | private void ClientClosed(UUID AgentId, Scene scene) | 402 | private void ClientClosed(UUID AgentId, Scene scene) |
@@ -1108,7 +1110,22 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
1108 | // tell everyone that we are offline | 1110 | // tell everyone that we are offline |
1109 | SendPresenceState(remoteClient, fl, false); | 1111 | SendPresenceState(remoteClient, fl, false); |
1110 | } | 1112 | } |
1111 | } | 1113 | private void GrantUserFriendRights(IClientAPI remoteClient, UUID requester, UUID target, int rights) |
1114 | { | ||
1115 | ((Scene)remoteClient.Scene).CommsManager.UpdateUserFriendPerms(requester, target, (uint)rights); | ||
1116 | } | ||
1112 | 1117 | ||
1118 | public List<FriendListItem> GetUserFriends(UUID agentID) | ||
1119 | { | ||
1120 | List<FriendListItem> fl; | ||
1121 | lock (m_friendLists) | ||
1122 | { | ||
1123 | fl = (List<FriendListItem>)m_friendLists.Get(agentID.ToString(), | ||
1124 | m_initialScene.GetFriendList); | ||
1125 | } | ||
1126 | |||
1127 | return fl; | ||
1128 | } | ||
1129 | } | ||
1113 | #endregion | 1130 | #endregion |
1114 | } | 1131 | } |
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs index 1614b70..7f9e5af 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs | |||
@@ -164,19 +164,22 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
164 | List<GridInstantMessage>msglist = SynchronousRestObjectPoster.BeginPostObject<UUID, List<GridInstantMessage>>( | 164 | List<GridInstantMessage>msglist = SynchronousRestObjectPoster.BeginPostObject<UUID, List<GridInstantMessage>>( |
165 | "POST", m_RestURL+"/RetrieveMessages/", client.AgentId); | 165 | "POST", m_RestURL+"/RetrieveMessages/", client.AgentId); |
166 | 166 | ||
167 | foreach (GridInstantMessage im in msglist) | 167 | if (msglist != null) |
168 | { | 168 | { |
169 | // client.SendInstantMessage(im); | 169 | foreach (GridInstantMessage im in msglist) |
170 | 170 | { | |
171 | // Send through scene event manager so all modules get a chance | 171 | // client.SendInstantMessage(im); |
172 | // to look at this message before it gets delivered. | 172 | |
173 | // | 173 | // Send through scene event manager so all modules get a chance |
174 | // Needed for proper state management for stored group | 174 | // to look at this message before it gets delivered. |
175 | // invitations | 175 | // |
176 | // | 176 | // Needed for proper state management for stored group |
177 | Scene s = FindScene(client.AgentId); | 177 | // invitations |
178 | if (s != null) | 178 | // |
179 | s.EventManager.TriggerIncomingInstantMessage(im); | 179 | Scene s = FindScene(client.AgentId); |
180 | if (s != null) | ||
181 | s.EventManager.TriggerIncomingInstantMessage(im); | ||
182 | } | ||
180 | } | 183 | } |
181 | } | 184 | } |
182 | 185 | ||
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs index f761bf0..aafcfa2 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs | |||
@@ -99,36 +99,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
99 | int failedAssetRestores = 0; | 99 | int failedAssetRestores = 0; |
100 | int successfulItemRestores = 0; | 100 | int successfulItemRestores = 0; |
101 | List<InventoryNodeBase> nodesLoaded = new List<InventoryNodeBase>(); | 101 | List<InventoryNodeBase> nodesLoaded = new List<InventoryNodeBase>(); |
102 | |||
103 | /* | ||
104 | if (!m_userInfo.HasReceivedInventory) | ||
105 | { | ||
106 | // If the region server has access to the user admin service (by which users are created), | ||
107 | // then we'll assume that it's okay to fiddle with the user's inventory even if they are not on the | ||
108 | // server. | ||
109 | // | ||
110 | // FIXME: FetchInventory should probably be assumed to by async anyway, since even standalones might | ||
111 | // use a remote inventory service, though this is vanishingly rare at the moment. | ||
112 | if (null == m_scene.CommsManager.UserAdminService) | ||
113 | { | ||
114 | m_log.ErrorFormat( | ||
115 | "[INVENTORY ARCHIVER]: Have not yet received inventory info for user {0} {1}", | ||
116 | m_userInfo.UserProfile.Name, m_userInfo.UserProfile.ID); | ||
117 | |||
118 | return nodesLoaded; | ||
119 | } | ||
120 | else | ||
121 | { | ||
122 | m_userInfo.FetchInventory(); | ||
123 | for (int i = 0 ; i < 50 ; i++) | ||
124 | { | ||
125 | if (m_userInfo.HasReceivedInventory == true) | ||
126 | break; | ||
127 | Thread.Sleep(200); | ||
128 | } | ||
129 | } | ||
130 | } | ||
131 | */ | ||
132 | 102 | ||
133 | //InventoryFolderImpl rootDestinationFolder = m_userInfo.RootFolder.FindFolderByPath(m_invPath); | 103 | //InventoryFolderImpl rootDestinationFolder = m_userInfo.RootFolder.FindFolderByPath(m_invPath); |
134 | InventoryFolderBase rootDestinationFolder | 104 | InventoryFolderBase rootDestinationFolder |
@@ -159,9 +129,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
159 | successfulAssetRestores++; | 129 | successfulAssetRestores++; |
160 | else | 130 | else |
161 | failedAssetRestores++; | 131 | failedAssetRestores++; |
132 | |||
133 | if ((successfulAssetRestores) % 50 == 0) | ||
134 | m_log.DebugFormat( | ||
135 | "[INVENTORY ARCHIVER]: Loaded {0} assets...", | ||
136 | successfulAssetRestores); | ||
162 | } | 137 | } |
163 | else if (filePath.StartsWith(ArchiveConstants.INVENTORY_PATH)) | 138 | else if (filePath.StartsWith(ArchiveConstants.INVENTORY_PATH)) |
164 | { | 139 | { |
165 | InventoryFolderBase foundFolder | 140 | InventoryFolderBase foundFolder |
166 | = ReplicateArchivePathToUserInventory( | 141 | = ReplicateArchivePathToUserInventory( |
167 | filePath, TarArchiveReader.TarEntryType.TYPE_DIRECTORY == entryType, | 142 | filePath, TarArchiveReader.TarEntryType.TYPE_DIRECTORY == entryType, |
@@ -169,38 +144,27 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
169 | 144 | ||
170 | if (TarArchiveReader.TarEntryType.TYPE_DIRECTORY != entryType) | 145 | if (TarArchiveReader.TarEntryType.TYPE_DIRECTORY != entryType) |
171 | { | 146 | { |
172 | InventoryItemBase item = UserInventoryItemSerializer.Deserialize(data); | 147 | InventoryItemBase item = LoadItem(data, foundFolder); |
173 | |||
174 | // Don't use the item ID that's in the file | ||
175 | item.ID = UUID.Random(); | ||
176 | |||
177 | UUID ospResolvedId = OspResolver.ResolveOspa(item.CreatorId, m_scene.CommsManager); | ||
178 | if (UUID.Zero != ospResolvedId) | ||
179 | item.CreatorIdAsUuid = ospResolvedId; | ||
180 | else | ||
181 | item.CreatorIdAsUuid = m_userInfo.UserProfile.ID; | ||
182 | |||
183 | item.Owner = m_userInfo.UserProfile.ID; | ||
184 | |||
185 | // Reset folder ID to the one in which we want to load it | ||
186 | item.Folder = foundFolder.ID; | ||
187 | 148 | ||
188 | //m_userInfo.AddItem(item); | 149 | if (item != null) |
189 | m_scene.InventoryService.AddItem(item); | 150 | { |
190 | successfulItemRestores++; | 151 | successfulItemRestores++; |
191 | 152 | ||
192 | // If we're loading an item directly into the given destination folder then we need to record | 153 | // If we're loading an item directly into the given destination folder then we need to record |
193 | // it separately from any loaded root folders | 154 | // it separately from any loaded root folders |
194 | if (rootDestinationFolder == foundFolder) | 155 | if (rootDestinationFolder == foundFolder) |
195 | nodesLoaded.Add(item); | 156 | nodesLoaded.Add(item); |
157 | } | ||
196 | } | 158 | } |
197 | } | 159 | } |
198 | } | 160 | } |
199 | 161 | ||
200 | archive.Close(); | 162 | archive.Close(); |
201 | 163 | ||
202 | m_log.DebugFormat("[INVENTORY ARCHIVER]: Restored {0} assets", successfulAssetRestores); | 164 | m_log.DebugFormat( |
203 | m_log.InfoFormat("[INVENTORY ARCHIVER]: Restored {0} items", successfulItemRestores); | 165 | "[INVENTORY ARCHIVER]: Successfully loaded {0} assets with {1} failures", |
166 | successfulAssetRestores, failedAssetRestores); | ||
167 | m_log.InfoFormat("[INVENTORY ARCHIVER]: Successfully loaded {0} items", successfulItemRestores); | ||
204 | 168 | ||
205 | return nodesLoaded; | 169 | return nodesLoaded; |
206 | } | 170 | } |
@@ -234,8 +198,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
234 | 198 | ||
235 | string originalArchivePath = archivePath; | 199 | string originalArchivePath = archivePath; |
236 | 200 | ||
237 | m_log.DebugFormat( | 201 | // m_log.DebugFormat( |
238 | "[INVENTORY ARCHIVER]: Loading to folder {0} {1}", rootDestFolder.Name, rootDestFolder.ID); | 202 | // "[INVENTORY ARCHIVER]: Loading folder {0} {1}", rootDestFolder.Name, rootDestFolder.ID); |
239 | 203 | ||
240 | InventoryFolderBase destFolder = null; | 204 | InventoryFolderBase destFolder = null; |
241 | 205 | ||
@@ -246,8 +210,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
246 | { | 210 | { |
247 | if (foldersCreated.ContainsKey(archivePath)) | 211 | if (foldersCreated.ContainsKey(archivePath)) |
248 | { | 212 | { |
249 | m_log.DebugFormat( | 213 | // m_log.DebugFormat( |
250 | "[INVENTORY ARCHIVER]: Found previously created folder from archive path {0}", archivePath); | 214 | // "[INVENTORY ARCHIVER]: Found previously created folder from archive path {0}", archivePath); |
251 | destFolder = foldersCreated[archivePath]; | 215 | destFolder = foldersCreated[archivePath]; |
252 | } | 216 | } |
253 | else | 217 | else |
@@ -289,6 +253,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
289 | ArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR); | 253 | ArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR); |
290 | 254 | ||
291 | string newFolderName = rawDirsToCreate[i].Remove(identicalNameIdentifierIndex); | 255 | string newFolderName = rawDirsToCreate[i].Remove(identicalNameIdentifierIndex); |
256 | |||
257 | newFolderName = InventoryArchiveUtils.UnescapeArchivePath(newFolderName); | ||
292 | UUID newFolderId = UUID.Random(); | 258 | UUID newFolderId = UUID.Random(); |
293 | 259 | ||
294 | // Asset type has to be Unknown here rather than Folder, otherwise the created folder can't be | 260 | // Asset type has to be Unknown here rather than Folder, otherwise the created folder can't be |
@@ -361,6 +327,37 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
361 | } | 327 | } |
362 | 328 | ||
363 | /// <summary> | 329 | /// <summary> |
330 | /// Load an item from the archive | ||
331 | /// </summary> | ||
332 | /// <param name="filePath">The archive path for the item</param> | ||
333 | /// <param name="data">The raw item data</param> | ||
334 | /// <param name="rootDestinationFolder">The root destination folder for loaded items</param> | ||
335 | /// <param name="nodesLoaded">All the inventory nodes (items and folders) loaded so far</param> | ||
336 | protected InventoryItemBase LoadItem(byte[] data, InventoryFolderBase loadFolder) | ||
337 | { | ||
338 | InventoryItemBase item = UserInventoryItemSerializer.Deserialize(data); | ||
339 | |||
340 | // Don't use the item ID that's in the file | ||
341 | item.ID = UUID.Random(); | ||
342 | |||
343 | UUID ospResolvedId = OspResolver.ResolveOspa(item.CreatorId, m_scene.CommsManager); | ||
344 | if (UUID.Zero != ospResolvedId) | ||
345 | item.CreatorIdAsUuid = ospResolvedId; | ||
346 | else | ||
347 | item.CreatorIdAsUuid = m_userInfo.UserProfile.ID; | ||
348 | |||
349 | item.Owner = m_userInfo.UserProfile.ID; | ||
350 | |||
351 | // Reset folder ID to the one in which we want to load it | ||
352 | item.Folder = loadFolder.ID; | ||
353 | |||
354 | //m_userInfo.AddItem(item); | ||
355 | m_scene.InventoryService.AddItem(item); | ||
356 | |||
357 | return item; | ||
358 | } | ||
359 | |||
360 | /// <summary> | ||
364 | /// Load an asset | 361 | /// Load an asset |
365 | /// </summary> | 362 | /// </summary> |
366 | /// <param name="assetFilename"></param> | 363 | /// <param name="assetFilename"></param> |
@@ -389,11 +386,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
389 | { | 386 | { |
390 | sbyte assetType = ArchiveConstants.EXTENSION_TO_ASSET_TYPE[extension]; | 387 | sbyte assetType = ArchiveConstants.EXTENSION_TO_ASSET_TYPE[extension]; |
391 | 388 | ||
392 | //m_log.DebugFormat("[INVENTORY ARCHIVER]: Importing asset {0}, type {1}", uuid, assetType); | 389 | if (assetType == (sbyte)AssetType.Unknown) |
390 | m_log.WarnFormat("[INVENTORY ARCHIVER]: Importing {0} byte asset {1} with unknown type", data.Length, uuid); | ||
393 | 391 | ||
394 | AssetBase asset = new AssetBase(new UUID(uuid), "RandomName"); | 392 | //m_log.DebugFormat("[INVENTORY ARCHIVER]: Importing asset {0}, type {1}", uuid, assetType); |
395 | 393 | ||
396 | asset.Type = assetType; | 394 | AssetBase asset = new AssetBase(new UUID(uuid), "RandomName", assetType); |
397 | asset.Data = data; | 395 | asset.Data = data; |
398 | 396 | ||
399 | m_scene.AssetService.Store(asset); | 397 | m_scene.AssetService.Store(asset); |
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs index a822d10..247cee4 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs | |||
@@ -27,6 +27,9 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Reflection; | ||
31 | using System.Text; | ||
32 | using log4net; | ||
30 | using OpenMetaverse; | 33 | using OpenMetaverse; |
31 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
32 | using OpenSim.Services.Interfaces; | 35 | using OpenSim.Services.Interfaces; |
@@ -38,7 +41,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
38 | /// </summary> | 41 | /// </summary> |
39 | public static class InventoryArchiveUtils | 42 | public static class InventoryArchiveUtils |
40 | { | 43 | { |
41 | public static readonly string PATH_DELIMITER = "/"; | 44 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
45 | |||
46 | // Character used for escaping the path delimter ("\/") and itself ("\\") in human escaped strings | ||
47 | public static readonly char ESCAPE_CHARACTER = '\\'; | ||
48 | |||
49 | // The character used to separate inventory path components (different folders and items) | ||
50 | public static readonly char PATH_DELIMITER = '/'; | ||
42 | 51 | ||
43 | /// <summary> | 52 | /// <summary> |
44 | /// Find a folder given a PATH_DELIMITER delimited path starting from a user's root folder | 53 | /// Find a folder given a PATH_DELIMITER delimited path starting from a user's root folder |
@@ -103,10 +112,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
103 | 112 | ||
104 | path = path.Trim(); | 113 | path = path.Trim(); |
105 | 114 | ||
106 | if (path == PATH_DELIMITER) | 115 | if (path == PATH_DELIMITER.ToString()) |
107 | return startFolder; | 116 | return startFolder; |
108 | 117 | ||
109 | string[] components = path.Split(new string[] { PATH_DELIMITER }, 2, StringSplitOptions.None); | 118 | string[] components = SplitEscapedPath(path); |
119 | components[0] = UnescapePath(components[0]); | ||
120 | |||
121 | //string[] components = path.Split(new string[] { PATH_DELIMITER.ToString() }, 2, StringSplitOptions.None); | ||
122 | |||
110 | InventoryCollection contents = inventoryService.GetFolderContent(startFolder.Owner, startFolder.ID); | 123 | InventoryCollection contents = inventoryService.GetFolderContent(startFolder.Owner, startFolder.ID); |
111 | 124 | ||
112 | foreach (InventoryFolderBase folder in contents.Folders) | 125 | foreach (InventoryFolderBase folder in contents.Folders) |
@@ -181,10 +194,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
181 | public static InventoryItemBase FindItemByPath( | 194 | public static InventoryItemBase FindItemByPath( |
182 | IInventoryService inventoryService, InventoryFolderBase startFolder, string path) | 195 | IInventoryService inventoryService, InventoryFolderBase startFolder, string path) |
183 | { | 196 | { |
184 | string[] components = path.Split(new string[] { PATH_DELIMITER }, 2, StringSplitOptions.None); | 197 | string[] components = SplitEscapedPath(path); |
198 | components[0] = UnescapePath(components[0]); | ||
199 | |||
200 | //string[] components = path.Split(new string[] { PATH_DELIMITER }, 2, StringSplitOptions.None); | ||
185 | 201 | ||
186 | if (components.Length == 1) | 202 | if (components.Length == 1) |
187 | { | 203 | { |
204 | // m_log.DebugFormat("FOUND SINGLE COMPONENT [{0}]", components[0]); | ||
205 | |||
188 | List<InventoryItemBase> items = inventoryService.GetFolderItems(startFolder.Owner, startFolder.ID); | 206 | List<InventoryItemBase> items = inventoryService.GetFolderItems(startFolder.Owner, startFolder.ID); |
189 | foreach (InventoryItemBase item in items) | 207 | foreach (InventoryItemBase item in items) |
190 | { | 208 | { |
@@ -194,6 +212,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
194 | } | 212 | } |
195 | else | 213 | else |
196 | { | 214 | { |
215 | // m_log.DebugFormat("FOUND COMPONENTS [{0}] and [{1}]", components[0], components[1]); | ||
216 | |||
197 | InventoryCollection contents = inventoryService.GetFolderContent(startFolder.Owner, startFolder.ID); | 217 | InventoryCollection contents = inventoryService.GetFolderContent(startFolder.Owner, startFolder.ID); |
198 | 218 | ||
199 | foreach (InventoryFolderBase folder in contents.Folders) | 219 | foreach (InventoryFolderBase folder in contents.Folders) |
@@ -206,5 +226,97 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
206 | // We didn't find an item or intermediate folder with the given name | 226 | // We didn't find an item or intermediate folder with the given name |
207 | return null; | 227 | return null; |
208 | } | 228 | } |
229 | |||
230 | /// <summary> | ||
231 | /// Split a human escaped path into two components if it contains an unescaped path delimiter, or one component | ||
232 | /// if no delimiter is present | ||
233 | /// </summary> | ||
234 | /// <param name="path"></param> | ||
235 | /// <returns> | ||
236 | /// The split path. We leave the components in their originally unescaped state (though we remove the delimiter | ||
237 | /// which originally split them if applicable). | ||
238 | /// </returns> | ||
239 | public static string[] SplitEscapedPath(string path) | ||
240 | { | ||
241 | // m_log.DebugFormat("SPLITTING PATH {0}", path); | ||
242 | |||
243 | bool singleEscapeChar = false; | ||
244 | |||
245 | for (int i = 0; i < path.Length; i++) | ||
246 | { | ||
247 | if (path[i] == ESCAPE_CHARACTER && !singleEscapeChar) | ||
248 | { | ||
249 | singleEscapeChar = true; | ||
250 | } | ||
251 | else | ||
252 | { | ||
253 | if (PATH_DELIMITER == path[i] && !singleEscapeChar) | ||
254 | return new string[2] { path.Remove(i), path.Substring(i + 1) }; | ||
255 | else | ||
256 | singleEscapeChar = false; | ||
257 | } | ||
258 | } | ||
259 | |||
260 | // We didn't find a delimiter | ||
261 | return new string[1] { path }; | ||
262 | } | ||
263 | |||
264 | /// <summary> | ||
265 | /// Unescapes a human escaped path. This means that "\\" goes to "\", and "\/" goes to "/" | ||
266 | /// </summary> | ||
267 | /// <param name="path"></param> | ||
268 | /// <returns></returns> | ||
269 | public static string UnescapePath(string path) | ||
270 | { | ||
271 | // m_log.DebugFormat("ESCAPING PATH {0}", path); | ||
272 | |||
273 | StringBuilder sb = new StringBuilder(); | ||
274 | |||
275 | bool singleEscapeChar = false; | ||
276 | for (int i = 0; i < path.Length; i++) | ||
277 | { | ||
278 | if (path[i] == ESCAPE_CHARACTER && !singleEscapeChar) | ||
279 | singleEscapeChar = true; | ||
280 | else | ||
281 | singleEscapeChar = false; | ||
282 | |||
283 | if (singleEscapeChar) | ||
284 | { | ||
285 | if (PATH_DELIMITER == path[i]) | ||
286 | sb.Append(PATH_DELIMITER); | ||
287 | } | ||
288 | else | ||
289 | { | ||
290 | sb.Append(path[i]); | ||
291 | } | ||
292 | } | ||
293 | |||
294 | // m_log.DebugFormat("ESCAPED PATH TO {0}", sb); | ||
295 | |||
296 | return sb.ToString(); | ||
297 | } | ||
298 | |||
299 | /// <summary> | ||
300 | /// Escape an archive path. | ||
301 | /// </summary> | ||
302 | /// This has to be done differently from human paths because we can't leave in any "/" characters (due to | ||
303 | /// problems if the archive is built from or extracted to a filesystem | ||
304 | /// <param name="path"></param> | ||
305 | /// <returns></returns> | ||
306 | public static string EscapeArchivePath(string path) | ||
307 | { | ||
308 | // Only encode ampersands (for escaping anything) and / (since this is used as general dir separator). | ||
309 | return path.Replace("&", "&").Replace("/", "/"); | ||
310 | } | ||
311 | |||
312 | /// <summary> | ||
313 | /// Unescape an archive path. | ||
314 | /// </summary> | ||
315 | /// <param name="path"></param> | ||
316 | /// <returns></returns> | ||
317 | public static string UnescapeArchivePath(string path) | ||
318 | { | ||
319 | return path.Replace("/", "/").Replace("&", "&"); | ||
320 | } | ||
209 | } | 321 | } |
210 | } \ No newline at end of file | 322 | } \ No newline at end of file |
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs index 499c552..bbb49f6 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs | |||
@@ -217,37 +217,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
217 | InventoryItemBase inventoryItem = null; | 217 | InventoryItemBase inventoryItem = null; |
218 | InventoryFolderBase rootFolder = m_scene.InventoryService.GetRootFolder(m_userInfo.UserProfile.ID); | 218 | InventoryFolderBase rootFolder = m_scene.InventoryService.GetRootFolder(m_userInfo.UserProfile.ID); |
219 | 219 | ||
220 | // XXX: Very temporarily, drop and refetch inventory to make sure we have any newly created items in cache | ||
221 | // This will disappear very soon once we stop using the old cached inventory. | ||
222 | /* | ||
223 | m_userInfo.DropInventory(); | ||
224 | m_userInfo.FetchInventory(); | ||
225 | */ | ||
226 | |||
227 | /* | ||
228 | if (!m_userInfo.HasReceivedInventory) | ||
229 | { | ||
230 | // If the region server has access to the user admin service (by which users are created), | ||
231 | // then we'll assume that it's okay to fiddle with the user's inventory even if they are not on the | ||
232 | // server. | ||
233 | // | ||
234 | // FIXME: FetchInventory should probably be assumed to by async anyway, since even standalones might | ||
235 | // use a remote inventory service, though this is vanishingly rare at the moment. | ||
236 | if (null == m_scene.CommsManager.UserAdminService) | ||
237 | { | ||
238 | m_log.ErrorFormat( | ||
239 | "[INVENTORY ARCHIVER]: Have not yet received inventory info for user {0} {1}", | ||
240 | m_userInfo.UserProfile.Name, m_userInfo.UserProfile.ID); | ||
241 | |||
242 | return; | ||
243 | } | ||
244 | else | ||
245 | { | ||
246 | m_userInfo.FetchInventory(); | ||
247 | } | ||
248 | } | ||
249 | */ | ||
250 | |||
251 | bool foundStar = false; | 220 | bool foundStar = false; |
252 | 221 | ||
253 | // Eliminate double slashes and any leading / on the path. | 222 | // Eliminate double slashes and any leading / on the path. |
@@ -294,34 +263,33 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
294 | 263 | ||
295 | m_archiveWriter = new TarArchiveWriter(m_saveStream); | 264 | m_archiveWriter = new TarArchiveWriter(m_saveStream); |
296 | 265 | ||
297 | if (null == inventoryFolder) | 266 | if (inventoryFolder != null) |
298 | { | ||
299 | if (null == inventoryItem) | ||
300 | { | ||
301 | // We couldn't find the path indicated | ||
302 | m_saveStream.Close(); | ||
303 | m_module.TriggerInventoryArchiveSaved( | ||
304 | m_id, false, m_userInfo, m_invPath, m_saveStream, | ||
305 | new Exception(string.Format("Could not find inventory entry at path {0}", m_invPath))); | ||
306 | return; | ||
307 | } | ||
308 | else | ||
309 | { | ||
310 | m_log.DebugFormat( | ||
311 | "[INVENTORY ARCHIVER]: Found item {0} {1} at {2}", | ||
312 | inventoryItem.Name, inventoryItem.ID, m_invPath); | ||
313 | |||
314 | SaveInvItem(inventoryItem, ArchiveConstants.INVENTORY_PATH); | ||
315 | } | ||
316 | } | ||
317 | else | ||
318 | { | 267 | { |
319 | m_log.DebugFormat( | 268 | m_log.DebugFormat( |
320 | "[INVENTORY ARCHIVER]: Found folder {0} {1} at {2}", | 269 | "[INVENTORY ARCHIVER]: Found folder {0} {1} at {2}", |
321 | inventoryFolder.Name, inventoryFolder.ID, m_invPath); | 270 | inventoryFolder.Name, inventoryFolder.ID, m_invPath); |
322 | 271 | ||
323 | //recurse through all dirs getting dirs and files | 272 | //recurse through all dirs getting dirs and files |
324 | SaveInvFolder(inventoryFolder, ArchiveConstants.INVENTORY_PATH, !foundStar); | 273 | SaveInvFolder(inventoryFolder, ArchiveConstants.INVENTORY_PATH, !foundStar); |
274 | } | ||
275 | else if (inventoryItem != null) | ||
276 | { | ||
277 | m_log.DebugFormat( | ||
278 | "[INVENTORY ARCHIVER]: Found item {0} {1} at {2}", | ||
279 | inventoryItem.Name, inventoryItem.ID, m_invPath); | ||
280 | |||
281 | SaveInvItem(inventoryItem, ArchiveConstants.INVENTORY_PATH); | ||
282 | } | ||
283 | else | ||
284 | { | ||
285 | // We couldn't find the path indicated | ||
286 | m_saveStream.Close(); | ||
287 | string errorMessage = string.Format("Aborted save. Could not find inventory path {0}", m_invPath); | ||
288 | m_log.ErrorFormat("[INVENTORY ARCHIVER]: {0}", errorMessage); | ||
289 | m_module.TriggerInventoryArchiveSaved( | ||
290 | m_id, false, m_userInfo, m_invPath, m_saveStream, | ||
291 | new Exception(errorMessage)); | ||
292 | return; | ||
325 | } | 293 | } |
326 | 294 | ||
327 | // Don't put all this profile information into the archive right now. | 295 | // Don't put all this profile information into the archive right now. |
@@ -396,7 +364,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
396 | { | 364 | { |
397 | return string.Format( | 365 | return string.Format( |
398 | "{0}{1}{2}/", | 366 | "{0}{1}{2}/", |
399 | name, | 367 | InventoryArchiveUtils.EscapeArchivePath(name), |
400 | ArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR, | 368 | ArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR, |
401 | id); | 369 | id); |
402 | } | 370 | } |
@@ -411,7 +379,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
411 | { | 379 | { |
412 | return string.Format( | 380 | return string.Format( |
413 | "{0}{1}{2}.xml", | 381 | "{0}{1}{2}.xml", |
414 | name, | 382 | InventoryArchiveUtils.EscapeArchivePath(name), |
415 | ArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR, | 383 | ArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR, |
416 | id); | 384 | id); |
417 | } | 385 | } |
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs index b0fdcd6..f8a010c 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs | |||
@@ -29,7 +29,6 @@ using System; | |||
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.IO; | 30 | using System.IO; |
31 | using System.Reflection; | 31 | using System.Reflection; |
32 | using System.Text; | ||
33 | using System.Threading; | 32 | using System.Threading; |
34 | using NUnit.Framework; | 33 | using NUnit.Framework; |
35 | using NUnit.Framework.SyntaxHelpers; | 34 | using NUnit.Framework.SyntaxHelpers; |
@@ -122,9 +121,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
122 | } | 121 | } |
123 | 122 | ||
124 | UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); | 123 | UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); |
125 | AssetBase asset1 = new AssetBase(); | 124 | AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1); |
126 | asset1.FullID = asset1Id; | ||
127 | asset1.Data = Encoding.ASCII.GetBytes(SceneObjectSerializer.ToXml2Format(object1)); | ||
128 | scene.AssetService.Store(asset1); | 125 | scene.AssetService.Store(asset1); |
129 | 126 | ||
130 | // Create item | 127 | // Create item |
@@ -136,7 +133,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
136 | InventoryFolderBase objsFolder | 133 | InventoryFolderBase objsFolder |
137 | = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userId, "Objects"); | 134 | = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userId, "Objects"); |
138 | item1.Folder = objsFolder.ID; | 135 | item1.Folder = objsFolder.ID; |
139 | scene.AddInventoryItem(userId, item1); | 136 | scene.AddInventoryItem(userId, item1); |
140 | 137 | ||
141 | MemoryStream archiveWriteStream = new MemoryStream(); | 138 | MemoryStream archiveWriteStream = new MemoryStream(); |
142 | archiverModule.OnInventoryArchiveSaved += SaveCompleted; | 139 | archiverModule.OnInventoryArchiveSaved += SaveCompleted; |
@@ -218,14 +215,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
218 | string userItemCreatorLastName = "Lucan"; | 215 | string userItemCreatorLastName = "Lucan"; |
219 | UUID userItemCreatorUuid = UUID.Parse("00000000-0000-0000-0000-000000000666"); | 216 | UUID userItemCreatorUuid = UUID.Parse("00000000-0000-0000-0000-000000000666"); |
220 | 217 | ||
221 | string itemName = "b.lsl"; | 218 | string item1Name = "b.lsl"; |
222 | string archiveItemName = InventoryArchiveWriteRequest.CreateArchiveItemName(itemName, UUID.Random()); | 219 | string archiveItemName = InventoryArchiveWriteRequest.CreateArchiveItemName(item1Name, UUID.Random()); |
223 | 220 | ||
224 | MemoryStream archiveWriteStream = new MemoryStream(); | 221 | MemoryStream archiveWriteStream = new MemoryStream(); |
225 | TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream); | 222 | TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream); |
226 | 223 | ||
227 | InventoryItemBase item1 = new InventoryItemBase(); | 224 | InventoryItemBase item1 = new InventoryItemBase(); |
228 | item1.Name = itemName; | 225 | item1.Name = item1Name; |
229 | item1.AssetID = UUID.Random(); | 226 | item1.AssetID = UUID.Random(); |
230 | item1.GroupID = UUID.Random(); | 227 | item1.GroupID = UUID.Random(); |
231 | item1.CreatorId = OspResolver.MakeOspa(userItemCreatorFirstName, userItemCreatorLastName); | 228 | item1.CreatorId = OspResolver.MakeOspa(userItemCreatorFirstName, userItemCreatorLastName); |
@@ -259,7 +256,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
259 | = scene.CommsManager.UserProfileCacheService.GetUserDetails(userFirstName, userLastName); | 256 | = scene.CommsManager.UserProfileCacheService.GetUserDetails(userFirstName, userLastName); |
260 | 257 | ||
261 | InventoryItemBase foundItem1 | 258 | InventoryItemBase foundItem1 |
262 | = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, userInfo.UserProfile.ID, itemName); | 259 | = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, userInfo.UserProfile.ID, item1Name); |
263 | 260 | ||
264 | Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1"); | 261 | Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1"); |
265 | Assert.That( | 262 | Assert.That( |
@@ -277,7 +274,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
277 | archiverModule.DearchiveInventory(userFirstName, userLastName, "xA", "meowfood", archiveReadStream); | 274 | archiverModule.DearchiveInventory(userFirstName, userLastName, "xA", "meowfood", archiveReadStream); |
278 | 275 | ||
279 | InventoryItemBase foundItem2 | 276 | InventoryItemBase foundItem2 |
280 | = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, userInfo.UserProfile.ID, "xA/" + itemName); | 277 | = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, userInfo.UserProfile.ID, "xA/" + item1Name); |
281 | Assert.That(foundItem2, Is.Not.Null, "Didn't find loaded item 2"); | 278 | Assert.That(foundItem2, Is.Not.Null, "Didn't find loaded item 2"); |
282 | 279 | ||
283 | // Now try loading to a more deeply nested folder | 280 | // Now try loading to a more deeply nested folder |
@@ -286,10 +283,99 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
286 | archiverModule.DearchiveInventory(userFirstName, userLastName, "xB/xC", "meowfood", archiveReadStream); | 283 | archiverModule.DearchiveInventory(userFirstName, userLastName, "xB/xC", "meowfood", archiveReadStream); |
287 | 284 | ||
288 | InventoryItemBase foundItem3 | 285 | InventoryItemBase foundItem3 |
289 | = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, userInfo.UserProfile.ID, "xB/xC/" + itemName); | 286 | = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, userInfo.UserProfile.ID, "xB/xC/" + item1Name); |
290 | Assert.That(foundItem3, Is.Not.Null, "Didn't find loaded item 3"); | 287 | Assert.That(foundItem3, Is.Not.Null, "Didn't find loaded item 3"); |
291 | } | 288 | } |
292 | 289 | ||
290 | [Test] | ||
291 | public void TestIarV0_1WithEscapedChars() | ||
292 | { | ||
293 | TestHelper.InMethod(); | ||
294 | // log4net.Config.XmlConfigurator.Configure(); | ||
295 | |||
296 | string itemName = "You & you are a mean/man/"; | ||
297 | string humanEscapedItemName = @"You & you are a mean\/man\/"; | ||
298 | string userPassword = "meowfood"; | ||
299 | |||
300 | InventoryArchiverModule archiverModule = new InventoryArchiverModule(true); | ||
301 | |||
302 | Scene scene = SceneSetupHelpers.SetupScene("Inventory"); | ||
303 | SceneSetupHelpers.SetupSceneModules(scene, archiverModule); | ||
304 | CommunicationsManager cm = scene.CommsManager; | ||
305 | |||
306 | // Create user | ||
307 | string userFirstName = "Jock"; | ||
308 | string userLastName = "Stirrup"; | ||
309 | UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020"); | ||
310 | |||
311 | lock (this) | ||
312 | { | ||
313 | UserProfileTestUtils.CreateUserWithInventory( | ||
314 | cm, userFirstName, userLastName, userPassword, userId, InventoryReceived); | ||
315 | Monitor.Wait(this, 60000); | ||
316 | } | ||
317 | |||
318 | // Create asset | ||
319 | SceneObjectGroup object1; | ||
320 | SceneObjectPart part1; | ||
321 | { | ||
322 | string partName = "part name"; | ||
323 | UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040"); | ||
324 | PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere(); | ||
325 | Vector3 groupPosition = new Vector3(10, 20, 30); | ||
326 | Quaternion rotationOffset = new Quaternion(20, 30, 40, 50); | ||
327 | Vector3 offsetPosition = new Vector3(5, 10, 15); | ||
328 | |||
329 | part1 | ||
330 | = new SceneObjectPart( | ||
331 | ownerId, shape, groupPosition, rotationOffset, offsetPosition); | ||
332 | part1.Name = partName; | ||
333 | |||
334 | object1 = new SceneObjectGroup(part1); | ||
335 | scene.AddNewSceneObject(object1, false); | ||
336 | } | ||
337 | |||
338 | UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); | ||
339 | AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1); | ||
340 | scene.AssetService.Store(asset1); | ||
341 | |||
342 | // Create item | ||
343 | UUID item1Id = UUID.Parse("00000000-0000-0000-0000-000000000080"); | ||
344 | InventoryItemBase item1 = new InventoryItemBase(); | ||
345 | item1.Name = itemName; | ||
346 | item1.AssetID = asset1.FullID; | ||
347 | item1.ID = item1Id; | ||
348 | InventoryFolderBase objsFolder | ||
349 | = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userId, "Objects"); | ||
350 | item1.Folder = objsFolder.ID; | ||
351 | scene.AddInventoryItem(userId, item1); | ||
352 | |||
353 | MemoryStream archiveWriteStream = new MemoryStream(); | ||
354 | archiverModule.OnInventoryArchiveSaved += SaveCompleted; | ||
355 | |||
356 | mre.Reset(); | ||
357 | archiverModule.ArchiveInventory( | ||
358 | Guid.NewGuid(), userFirstName, userLastName, "Objects", userPassword, archiveWriteStream); | ||
359 | mre.WaitOne(60000, false); | ||
360 | |||
361 | // LOAD ITEM | ||
362 | MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray()); | ||
363 | |||
364 | archiverModule.DearchiveInventory(userFirstName, userLastName, "Scripts", userPassword, archiveReadStream); | ||
365 | |||
366 | InventoryItemBase foundItem1 | ||
367 | = InventoryArchiveUtils.FindItemByPath( | ||
368 | scene.InventoryService, userId, "Scripts/Objects/" + humanEscapedItemName); | ||
369 | |||
370 | Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1"); | ||
371 | // Assert.That( | ||
372 | // foundItem1.CreatorId, Is.EqualTo(userUuid), | ||
373 | // "Loaded item non-uuid creator doesn't match that of the loading user"); | ||
374 | Assert.That( | ||
375 | foundItem1.Name, Is.EqualTo(itemName), | ||
376 | "Loaded item name doesn't match saved name"); | ||
377 | } | ||
378 | |||
293 | /// <summary> | 379 | /// <summary> |
294 | /// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where | 380 | /// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where |
295 | /// embedded creators do not exist in the system | 381 | /// embedded creators do not exist in the system |
@@ -302,7 +388,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
302 | { | 388 | { |
303 | TestHelper.InMethod(); | 389 | TestHelper.InMethod(); |
304 | 390 | ||
305 | log4net.Config.XmlConfigurator.Configure(); | 391 | //log4net.Config.XmlConfigurator.Configure(); |
306 | 392 | ||
307 | string userFirstName = "Charlie"; | 393 | string userFirstName = "Charlie"; |
308 | string userLastName = "Chan"; | 394 | string userLastName = "Chan"; |
@@ -370,7 +456,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
370 | { | 456 | { |
371 | TestHelper.InMethod(); | 457 | TestHelper.InMethod(); |
372 | 458 | ||
373 | log4net.Config.XmlConfigurator.Configure(); | 459 | //log4net.Config.XmlConfigurator.Configure(); |
374 | 460 | ||
375 | string userFirstName = "Dennis"; | 461 | string userFirstName = "Dennis"; |
376 | string userLastName = "Menace"; | 462 | string userLastName = "Menace"; |
diff --git a/OpenSim/Region/CoreModules/Framework/Monitoring/Alerts/DeadlockAlert.cs b/OpenSim/Region/CoreModules/Framework/Monitoring/Alerts/DeadlockAlert.cs new file mode 100644 index 0000000..b546ccb --- /dev/null +++ b/OpenSim/Region/CoreModules/Framework/Monitoring/Alerts/DeadlockAlert.cs | |||
@@ -0,0 +1,37 @@ | |||
1 | using OpenSim.Region.CoreModules.Framework.Monitoring.Monitors; | ||
2 | |||
3 | namespace OpenSim.Region.CoreModules.Framework.Monitoring.Alerts | ||
4 | { | ||
5 | class DeadlockAlert : IAlert | ||
6 | { | ||
7 | private LastFrameTimeMonitor m_monitor; | ||
8 | |||
9 | public DeadlockAlert(LastFrameTimeMonitor m_monitor) | ||
10 | { | ||
11 | this.m_monitor = m_monitor; | ||
12 | } | ||
13 | |||
14 | #region Implementation of IAlert | ||
15 | |||
16 | public string GetName() | ||
17 | { | ||
18 | return "Potential Deadlock Alert"; | ||
19 | } | ||
20 | |||
21 | public void Test() | ||
22 | { | ||
23 | if (m_monitor.GetValue() > 60 * 1000) | ||
24 | { | ||
25 | if(OnTriggerAlert != null) | ||
26 | { | ||
27 | OnTriggerAlert(typeof (DeadlockAlert), | ||
28 | (int) (m_monitor.GetValue()/1000) + " second(s) since last frame processed.", true); | ||
29 | } | ||
30 | } | ||
31 | } | ||
32 | |||
33 | public event Alert OnTriggerAlert; | ||
34 | |||
35 | #endregion | ||
36 | } | ||
37 | } | ||
diff --git a/OpenSim/Region/CoreModules/Framework/Monitoring/IAlert.cs b/OpenSim/Region/CoreModules/Framework/Monitoring/IAlert.cs new file mode 100644 index 0000000..b533df9 --- /dev/null +++ b/OpenSim/Region/CoreModules/Framework/Monitoring/IAlert.cs | |||
@@ -0,0 +1,13 @@ | |||
1 | using System; | ||
2 | |||
3 | namespace OpenSim.Region.CoreModules.Framework.Monitoring | ||
4 | { | ||
5 | internal delegate void Alert(Type reporter, string reason, bool fatal); | ||
6 | |||
7 | interface IAlert | ||
8 | { | ||
9 | string GetName(); | ||
10 | void Test(); | ||
11 | event Alert OnTriggerAlert; | ||
12 | } | ||
13 | } | ||
diff --git a/OpenSim/Region/CoreModules/Framework/Monitoring/IMonitor.cs b/OpenSim/Region/CoreModules/Framework/Monitoring/IMonitor.cs new file mode 100644 index 0000000..a51dccd --- /dev/null +++ b/OpenSim/Region/CoreModules/Framework/Monitoring/IMonitor.cs | |||
@@ -0,0 +1,9 @@ | |||
1 | namespace OpenSim.Region.CoreModules.Framework.Monitoring | ||
2 | { | ||
3 | interface IMonitor | ||
4 | { | ||
5 | double GetValue(); | ||
6 | string GetName(); | ||
7 | string GetFriendlyValue(); // Convert to readable numbers | ||
8 | } | ||
9 | } | ||
diff --git a/OpenSim/Region/CoreModules/Framework/Monitoring/MonitorModule.cs b/OpenSim/Region/CoreModules/Framework/Monitoring/MonitorModule.cs new file mode 100644 index 0000000..11aca99 --- /dev/null +++ b/OpenSim/Region/CoreModules/Framework/Monitoring/MonitorModule.cs | |||
@@ -0,0 +1,146 @@ | |||
1 | using System.Collections; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Reflection; | ||
4 | using log4net; | ||
5 | using Nini.Config; | ||
6 | using OpenMetaverse; | ||
7 | using OpenSim.Framework; | ||
8 | using OpenSim.Region.CoreModules.Framework.Monitoring.Alerts; | ||
9 | using OpenSim.Region.CoreModules.Framework.Monitoring.Monitors; | ||
10 | using OpenSim.Region.Framework.Interfaces; | ||
11 | using OpenSim.Region.Framework.Scenes; | ||
12 | |||
13 | namespace OpenSim.Region.CoreModules.Framework.Monitoring | ||
14 | { | ||
15 | public class MonitorModule : IRegionModule | ||
16 | { | ||
17 | private Scene m_scene; | ||
18 | private readonly List<IMonitor> m_monitors = new List<IMonitor>(); | ||
19 | private readonly List<IAlert> m_alerts = new List<IAlert>(); | ||
20 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
21 | |||
22 | public void DebugMonitors(string module, string[] args) | ||
23 | { | ||
24 | foreach (IMonitor monitor in m_monitors) | ||
25 | { | ||
26 | m_log.Info("[MonitorModule] " + m_scene.RegionInfo.RegionName + " reports " + monitor.GetName() + " = " + monitor.GetFriendlyValue()); | ||
27 | } | ||
28 | } | ||
29 | |||
30 | public void TestAlerts() | ||
31 | { | ||
32 | foreach (IAlert alert in m_alerts) | ||
33 | { | ||
34 | alert.Test(); | ||
35 | } | ||
36 | } | ||
37 | |||
38 | #region Implementation of IRegionModule | ||
39 | |||
40 | public void Initialise(Scene scene, IConfigSource source) | ||
41 | { | ||
42 | m_scene = scene; | ||
43 | |||
44 | |||
45 | m_scene.AddCommand(this, "monitor report", | ||
46 | "monitor report", | ||
47 | "Returns a variety of statistics about the current region and/or simulator", | ||
48 | DebugMonitors); | ||
49 | |||
50 | MainServer.Instance.AddHTTPHandler("/monitorstats/" + m_scene.RegionInfo.RegionID + "/", StatsPage); | ||
51 | } | ||
52 | |||
53 | public Hashtable StatsPage(Hashtable request) | ||
54 | { | ||
55 | // If request was for a specific monitor | ||
56 | // eg url/?monitor=Monitor.Name | ||
57 | if (request.ContainsKey("monitor")) | ||
58 | { | ||
59 | string monID = (string) request["monitor"]; | ||
60 | |||
61 | foreach (IMonitor monitor in m_monitors) | ||
62 | { | ||
63 | if (monitor.ToString() == monID) | ||
64 | { | ||
65 | Hashtable ereply3 = new Hashtable(); | ||
66 | |||
67 | ereply3["int_response_code"] = 404; // 200 OK | ||
68 | ereply3["str_response_string"] = monitor.GetValue().ToString(); | ||
69 | ereply3["content_type"] = "text/plain"; | ||
70 | |||
71 | return ereply3; | ||
72 | } | ||
73 | } | ||
74 | |||
75 | // No monitor with that name | ||
76 | Hashtable ereply2 = new Hashtable(); | ||
77 | |||
78 | ereply2["int_response_code"] = 404; // 200 OK | ||
79 | ereply2["str_response_string"] = "No such monitor"; | ||
80 | ereply2["content_type"] = "text/plain"; | ||
81 | |||
82 | return ereply2; | ||
83 | } | ||
84 | |||
85 | string xml = "<data>"; | ||
86 | foreach (IMonitor monitor in m_monitors) | ||
87 | { | ||
88 | xml += "<" + monitor.ToString() + ">" + monitor.GetValue() + "</" + monitor.ToString() + ">"; | ||
89 | } | ||
90 | xml += "</data>"; | ||
91 | |||
92 | Hashtable ereply = new Hashtable(); | ||
93 | |||
94 | ereply["int_response_code"] = 200; // 200 OK | ||
95 | ereply["str_response_string"] = xml; | ||
96 | ereply["content_type"] = "text/xml"; | ||
97 | |||
98 | return ereply; | ||
99 | } | ||
100 | |||
101 | public void PostInitialise() | ||
102 | { | ||
103 | m_monitors.Add(new AgentCountMonitor(m_scene)); | ||
104 | m_monitors.Add(new ChildAgentCountMonitor(m_scene)); | ||
105 | m_monitors.Add(new GCMemoryMonitor()); | ||
106 | m_monitors.Add(new ObjectCountMonitor(m_scene)); | ||
107 | m_monitors.Add(new PhysicsFrameMonitor(m_scene)); | ||
108 | m_monitors.Add(new PhysicsUpdateFrameMonitor(m_scene)); | ||
109 | m_monitors.Add(new PWSMemoryMonitor()); | ||
110 | m_monitors.Add(new ThreadCountMonitor()); | ||
111 | m_monitors.Add(new TotalFrameMonitor(m_scene)); | ||
112 | m_monitors.Add(new EventFrameMonitor(m_scene)); | ||
113 | m_monitors.Add(new LandFrameMonitor(m_scene)); | ||
114 | m_monitors.Add(new LastFrameTimeMonitor(m_scene)); | ||
115 | |||
116 | m_alerts.Add(new DeadlockAlert(m_monitors.Find(x => x is LastFrameTimeMonitor) as LastFrameTimeMonitor)); | ||
117 | |||
118 | foreach (IAlert alert in m_alerts) | ||
119 | { | ||
120 | alert.OnTriggerAlert += OnTriggerAlert; | ||
121 | } | ||
122 | } | ||
123 | |||
124 | void OnTriggerAlert(System.Type reporter, string reason, bool fatal) | ||
125 | { | ||
126 | m_log.Error("[Monitor] " + reporter.Name + " for " + m_scene.RegionInfo.RegionName + " reports " + reason + " (Fatal: " + fatal + ")"); | ||
127 | } | ||
128 | |||
129 | public void Close() | ||
130 | { | ||
131 | |||
132 | } | ||
133 | |||
134 | public string Name | ||
135 | { | ||
136 | get { return "Region Health Monitoring Module"; } | ||
137 | } | ||
138 | |||
139 | public bool IsSharedModule | ||
140 | { | ||
141 | get { return false; } | ||
142 | } | ||
143 | |||
144 | #endregion | ||
145 | } | ||
146 | } | ||
diff --git a/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/AgentCountMonitor.cs b/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/AgentCountMonitor.cs new file mode 100644 index 0000000..edc6e6b --- /dev/null +++ b/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/AgentCountMonitor.cs | |||
@@ -0,0 +1,33 @@ | |||
1 | using OpenSim.Region.Framework.Scenes; | ||
2 | |||
3 | namespace OpenSim.Region.CoreModules.Framework.Monitoring.Monitors | ||
4 | { | ||
5 | class AgentCountMonitor : IMonitor | ||
6 | { | ||
7 | private readonly Scene m_scene; | ||
8 | |||
9 | public AgentCountMonitor(Scene scene) | ||
10 | { | ||
11 | m_scene = scene; | ||
12 | } | ||
13 | |||
14 | #region Implementation of IMonitor | ||
15 | |||
16 | public double GetValue() | ||
17 | { | ||
18 | return m_scene.SceneGraph.GetRootAgentCount(); | ||
19 | } | ||
20 | |||
21 | public string GetName() | ||
22 | { | ||
23 | return "Root Agent Count"; | ||
24 | } | ||
25 | |||
26 | public string GetFriendlyValue() | ||
27 | { | ||
28 | return (int)GetValue() + " agent(s)"; | ||
29 | } | ||
30 | |||
31 | #endregion | ||
32 | } | ||
33 | } | ||
diff --git a/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/ChildAgentCountMonitor.cs b/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/ChildAgentCountMonitor.cs new file mode 100644 index 0000000..afe6b79 --- /dev/null +++ b/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/ChildAgentCountMonitor.cs | |||
@@ -0,0 +1,33 @@ | |||
1 | using OpenSim.Region.Framework.Scenes; | ||
2 | |||
3 | namespace OpenSim.Region.CoreModules.Framework.Monitoring.Monitors | ||
4 | { | ||
5 | class ChildAgentCountMonitor : IMonitor | ||
6 | { | ||
7 | private readonly Scene m_scene; | ||
8 | |||
9 | public ChildAgentCountMonitor(Scene scene) | ||
10 | { | ||
11 | m_scene = scene; | ||
12 | } | ||
13 | |||
14 | #region Implementation of IMonitor | ||
15 | |||
16 | public double GetValue() | ||
17 | { | ||
18 | return m_scene.SceneGraph.GetChildAgentCount(); | ||
19 | } | ||
20 | |||
21 | public string GetName() | ||
22 | { | ||
23 | return "Child Agent Count"; | ||
24 | } | ||
25 | |||
26 | public string GetFriendlyValue() | ||
27 | { | ||
28 | return (int)GetValue() + " child agent(s)"; | ||
29 | } | ||
30 | |||
31 | #endregion | ||
32 | } | ||
33 | } | ||
diff --git a/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/EventFrameMonitor.cs b/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/EventFrameMonitor.cs new file mode 100644 index 0000000..dec5a9e --- /dev/null +++ b/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/EventFrameMonitor.cs | |||
@@ -0,0 +1,33 @@ | |||
1 | using OpenSim.Region.Framework.Scenes; | ||
2 | |||
3 | namespace OpenSim.Region.CoreModules.Framework.Monitoring.Monitors | ||
4 | { | ||
5 | class EventFrameMonitor : IMonitor | ||
6 | { | ||
7 | private readonly Scene m_scene; | ||
8 | |||
9 | public EventFrameMonitor(Scene scene) | ||
10 | { | ||
11 | m_scene = scene; | ||
12 | } | ||
13 | |||
14 | #region Implementation of IMonitor | ||
15 | |||
16 | public double GetValue() | ||
17 | { | ||
18 | return m_scene.MonitorEventTime; | ||
19 | } | ||
20 | |||
21 | public string GetName() | ||
22 | { | ||
23 | return "Total Event Frame Time"; | ||
24 | } | ||
25 | |||
26 | public string GetFriendlyValue() | ||
27 | { | ||
28 | return (int)GetValue() + "ms"; | ||
29 | } | ||
30 | |||
31 | #endregion | ||
32 | } | ||
33 | } | ||
diff --git a/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/GCMemoryMonitor.cs b/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/GCMemoryMonitor.cs new file mode 100644 index 0000000..cd67fea --- /dev/null +++ b/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/GCMemoryMonitor.cs | |||
@@ -0,0 +1,26 @@ | |||
1 | using System; | ||
2 | |||
3 | namespace OpenSim.Region.CoreModules.Framework.Monitoring.Monitors | ||
4 | { | ||
5 | class GCMemoryMonitor : IMonitor | ||
6 | { | ||
7 | #region Implementation of IMonitor | ||
8 | |||
9 | public double GetValue() | ||
10 | { | ||
11 | return GC.GetTotalMemory(false); | ||
12 | } | ||
13 | |||
14 | public string GetName() | ||
15 | { | ||
16 | return "GC Reported Memory"; | ||
17 | } | ||
18 | |||
19 | public string GetFriendlyValue() | ||
20 | { | ||
21 | return (int)(GetValue() / (1024*1024)) + "MB (Global)"; | ||
22 | } | ||
23 | |||
24 | #endregion | ||
25 | } | ||
26 | } | ||
diff --git a/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/LandFrameMonitor.cs b/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/LandFrameMonitor.cs new file mode 100644 index 0000000..d883fc7 --- /dev/null +++ b/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/LandFrameMonitor.cs | |||
@@ -0,0 +1,33 @@ | |||
1 | using OpenSim.Region.Framework.Scenes; | ||
2 | |||
3 | namespace OpenSim.Region.CoreModules.Framework.Monitoring.Monitors | ||
4 | { | ||
5 | class LandFrameMonitor : IMonitor | ||
6 | { | ||
7 | private readonly Scene m_scene; | ||
8 | |||
9 | public LandFrameMonitor(Scene scene) | ||
10 | { | ||
11 | m_scene = scene; | ||
12 | } | ||
13 | |||
14 | #region Implementation of IMonitor | ||
15 | |||
16 | public double GetValue() | ||
17 | { | ||
18 | return m_scene.MonitorLandTime; | ||
19 | } | ||
20 | |||
21 | public string GetName() | ||
22 | { | ||
23 | return "Land Frame Time"; | ||
24 | } | ||
25 | |||
26 | public string GetFriendlyValue() | ||
27 | { | ||
28 | return (int)GetValue() + "ms"; | ||
29 | } | ||
30 | |||
31 | #endregion | ||
32 | } | ||
33 | } | ||
diff --git a/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/LastFrameTimeMonitor.cs b/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/LastFrameTimeMonitor.cs new file mode 100644 index 0000000..36363f8 --- /dev/null +++ b/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/LastFrameTimeMonitor.cs | |||
@@ -0,0 +1,34 @@ | |||
1 | using System; | ||
2 | using OpenSim.Region.Framework.Scenes; | ||
3 | |||
4 | namespace OpenSim.Region.CoreModules.Framework.Monitoring.Monitors | ||
5 | { | ||
6 | class LastFrameTimeMonitor : IMonitor | ||
7 | { | ||
8 | private readonly Scene m_scene; | ||
9 | |||
10 | public LastFrameTimeMonitor(Scene scene) | ||
11 | { | ||
12 | m_scene = scene; | ||
13 | } | ||
14 | |||
15 | #region Implementation of IMonitor | ||
16 | |||
17 | public double GetValue() | ||
18 | { | ||
19 | return Environment.TickCount - m_scene.MonitorLastFrameTick; | ||
20 | } | ||
21 | |||
22 | public string GetName() | ||
23 | { | ||
24 | return "Last Completed Frame At"; | ||
25 | } | ||
26 | |||
27 | public string GetFriendlyValue() | ||
28 | { | ||
29 | return (int)GetValue() + "ms ago"; | ||
30 | } | ||
31 | |||
32 | #endregion | ||
33 | } | ||
34 | } | ||
diff --git a/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/ObjectCountMonitor.cs b/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/ObjectCountMonitor.cs new file mode 100644 index 0000000..dd9b19d --- /dev/null +++ b/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/ObjectCountMonitor.cs | |||
@@ -0,0 +1,33 @@ | |||
1 | using OpenSim.Region.Framework.Scenes; | ||
2 | |||
3 | namespace OpenSim.Region.CoreModules.Framework.Monitoring.Monitors | ||
4 | { | ||
5 | class ObjectCountMonitor : IMonitor | ||
6 | { | ||
7 | private readonly Scene m_scene; | ||
8 | |||
9 | public ObjectCountMonitor(Scene scene) | ||
10 | { | ||
11 | m_scene = scene; | ||
12 | } | ||
13 | |||
14 | #region Implementation of IMonitor | ||
15 | |||
16 | public double GetValue() | ||
17 | { | ||
18 | return m_scene.SceneGraph.GetTotalObjectsCount(); | ||
19 | } | ||
20 | |||
21 | public string GetName() | ||
22 | { | ||
23 | return "Total Objects Count"; | ||
24 | } | ||
25 | |||
26 | public string GetFriendlyValue() | ||
27 | { | ||
28 | return (int)GetValue() + " Object(s)"; | ||
29 | } | ||
30 | |||
31 | #endregion | ||
32 | } | ||
33 | } | ||
diff --git a/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/PWSMemoryMonitor.cs b/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/PWSMemoryMonitor.cs new file mode 100644 index 0000000..88f2938 --- /dev/null +++ b/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/PWSMemoryMonitor.cs | |||
@@ -0,0 +1,26 @@ | |||
1 | using System; | ||
2 | |||
3 | namespace OpenSim.Region.CoreModules.Framework.Monitoring.Monitors | ||
4 | { | ||
5 | class PWSMemoryMonitor : IMonitor | ||
6 | { | ||
7 | #region Implementation of IMonitor | ||
8 | |||
9 | public double GetValue() | ||
10 | { | ||
11 | return System.Diagnostics.Process.GetCurrentProcess().PrivateMemorySize64; | ||
12 | } | ||
13 | |||
14 | public string GetName() | ||
15 | { | ||
16 | return "Private Working Set Memory"; | ||
17 | } | ||
18 | |||
19 | public string GetFriendlyValue() | ||
20 | { | ||
21 | return (int)(GetValue() / (1024 * 1024)) + "MB (Global)"; | ||
22 | } | ||
23 | |||
24 | #endregion | ||
25 | } | ||
26 | } | ||
diff --git a/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/PhysicsFrameMonitor.cs b/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/PhysicsFrameMonitor.cs new file mode 100644 index 0000000..4d62e4f --- /dev/null +++ b/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/PhysicsFrameMonitor.cs | |||
@@ -0,0 +1,33 @@ | |||
1 | using OpenSim.Region.Framework.Scenes; | ||
2 | |||
3 | namespace OpenSim.Region.CoreModules.Framework.Monitoring.Monitors | ||
4 | { | ||
5 | class PhysicsFrameMonitor : IMonitor | ||
6 | { | ||
7 | private readonly Scene m_scene; | ||
8 | |||
9 | public PhysicsFrameMonitor(Scene scene) | ||
10 | { | ||
11 | m_scene = scene; | ||
12 | } | ||
13 | |||
14 | #region Implementation of IMonitor | ||
15 | |||
16 | public double GetValue() | ||
17 | { | ||
18 | return m_scene.MonitorPhysicsSyncTime + m_scene.MonitorPhysicsUpdateTime; | ||
19 | } | ||
20 | |||
21 | public string GetName() | ||
22 | { | ||
23 | return "Total Physics Frame Time"; | ||
24 | } | ||
25 | |||
26 | public string GetFriendlyValue() | ||
27 | { | ||
28 | return (int)GetValue() + "ms"; | ||
29 | } | ||
30 | |||
31 | #endregion | ||
32 | } | ||
33 | } | ||
diff --git a/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/PhysicsUpdateFrameMonitor.cs b/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/PhysicsUpdateFrameMonitor.cs new file mode 100644 index 0000000..91ac282 --- /dev/null +++ b/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/PhysicsUpdateFrameMonitor.cs | |||
@@ -0,0 +1,33 @@ | |||
1 | using OpenSim.Region.Framework.Scenes; | ||
2 | |||
3 | namespace OpenSim.Region.CoreModules.Framework.Monitoring.Monitors | ||
4 | { | ||
5 | class PhysicsUpdateFrameMonitor : IMonitor | ||
6 | { | ||
7 | private readonly Scene m_scene; | ||
8 | |||
9 | public PhysicsUpdateFrameMonitor(Scene scene) | ||
10 | { | ||
11 | m_scene = scene; | ||
12 | } | ||
13 | |||
14 | #region Implementation of IMonitor | ||
15 | |||
16 | public double GetValue() | ||
17 | { | ||
18 | return m_scene.MonitorPhysicsUpdateTime; | ||
19 | } | ||
20 | |||
21 | public string GetName() | ||
22 | { | ||
23 | return "Physics Update Frame Time"; | ||
24 | } | ||
25 | |||
26 | public string GetFriendlyValue() | ||
27 | { | ||
28 | return (int)GetValue() + "ms"; | ||
29 | } | ||
30 | |||
31 | #endregion | ||
32 | } | ||
33 | } | ||
diff --git a/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/ThreadCountMonitor.cs b/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/ThreadCountMonitor.cs new file mode 100644 index 0000000..9300a93 --- /dev/null +++ b/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/ThreadCountMonitor.cs | |||
@@ -0,0 +1,25 @@ | |||
1 |  | ||
2 | namespace OpenSim.Region.CoreModules.Framework.Monitoring.Monitors | ||
3 | { | ||
4 | class ThreadCountMonitor : IMonitor | ||
5 | { | ||
6 | #region Implementation of IMonitor | ||
7 | |||
8 | public double GetValue() | ||
9 | { | ||
10 | return System.Diagnostics.Process.GetCurrentProcess().Threads.Count; | ||
11 | } | ||
12 | |||
13 | public string GetName() | ||
14 | { | ||
15 | return "Total Threads"; | ||
16 | } | ||
17 | |||
18 | public string GetFriendlyValue() | ||
19 | { | ||
20 | return (int)GetValue() + " Thread(s) (Global)"; | ||
21 | } | ||
22 | |||
23 | #endregion | ||
24 | } | ||
25 | } | ||
diff --git a/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/TotalFrameMonitor.cs b/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/TotalFrameMonitor.cs new file mode 100644 index 0000000..dea1f94 --- /dev/null +++ b/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/TotalFrameMonitor.cs | |||
@@ -0,0 +1,33 @@ | |||
1 | using OpenSim.Region.Framework.Scenes; | ||
2 | |||
3 | namespace OpenSim.Region.CoreModules.Framework.Monitoring.Monitors | ||
4 | { | ||
5 | class TotalFrameMonitor : IMonitor | ||
6 | { | ||
7 | private readonly Scene m_scene; | ||
8 | |||
9 | public TotalFrameMonitor(Scene scene) | ||
10 | { | ||
11 | m_scene = scene; | ||
12 | } | ||
13 | |||
14 | #region Implementation of IMonitor | ||
15 | |||
16 | public double GetValue() | ||
17 | { | ||
18 | return m_scene.MonitorFrameTime; | ||
19 | } | ||
20 | |||
21 | public string GetName() | ||
22 | { | ||
23 | return "Total Frame Time"; | ||
24 | } | ||
25 | |||
26 | public string GetFriendlyValue() | ||
27 | { | ||
28 | return (int)GetValue() + "ms"; | ||
29 | } | ||
30 | |||
31 | #endregion | ||
32 | } | ||
33 | } | ||
diff --git a/OpenSim/Region/CoreModules/Hypergrid/HGStandaloneLoginModule.cs b/OpenSim/Region/CoreModules/Hypergrid/HGStandaloneLoginModule.cs index 4199c98..46ee3c0 100644 --- a/OpenSim/Region/CoreModules/Hypergrid/HGStandaloneLoginModule.cs +++ b/OpenSim/Region/CoreModules/Hypergrid/HGStandaloneLoginModule.cs | |||
@@ -193,6 +193,10 @@ namespace OpenSim.Region.CoreModules.Hypergrid | |||
193 | { | 193 | { |
194 | return scene.RegionInfo; | 194 | return scene.RegionInfo; |
195 | } | 195 | } |
196 | else if (m_scenes.Count > 0) | ||
197 | { | ||
198 | return m_scenes[0].RegionInfo; | ||
199 | } | ||
196 | return null; | 200 | return null; |
197 | } | 201 | } |
198 | 202 | ||
@@ -248,7 +252,7 @@ namespace OpenSim.Region.CoreModules.Hypergrid | |||
248 | { | 252 | { |
249 | foreach (Scene nextScene in m_scenes) | 253 | foreach (Scene nextScene in m_scenes) |
250 | { | 254 | { |
251 | if (nextScene.RegionInfo.RegionName == regionName) | 255 | if (nextScene.RegionInfo.RegionName.Equals(regionName, StringComparison.InvariantCultureIgnoreCase)) |
252 | { | 256 | { |
253 | scene = nextScene; | 257 | scene = nextScene; |
254 | return true; | 258 | return true; |
diff --git a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml index 8f82718..9757072 100644 --- a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml +++ b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml | |||
@@ -13,7 +13,6 @@ | |||
13 | <RegionModule id="ArchiverModule" type="OpenSim.Region.CoreModules.World.Archiver.ArchiverModule" /> | 13 | <RegionModule id="ArchiverModule" type="OpenSim.Region.CoreModules.World.Archiver.ArchiverModule" /> |
14 | <RegionModule id="CapabilitiesModule" type="OpenSim.Region.CoreModules.Agent.Capabilities.CapabilitiesModule" /> | 14 | <RegionModule id="CapabilitiesModule" type="OpenSim.Region.CoreModules.Agent.Capabilities.CapabilitiesModule" /> |
15 | <RegionModule id="TerrainModule" type="OpenSim.Region.CoreModules.World.Terrain.TerrainModule" /> | 15 | <RegionModule id="TerrainModule" type="OpenSim.Region.CoreModules.World.Terrain.TerrainModule" /> |
16 | <RegionModule id="RegionCombinerModule" type="OpenSim.Region.CoreModules.World.Land.RegionCombinerModule" /> | ||
17 | <RegionModule id="WorldMapModule" type="OpenSim.Region.CoreModules.World.WorldMap.WorldMapModule" /> | 16 | <RegionModule id="WorldMapModule" type="OpenSim.Region.CoreModules.World.WorldMap.WorldMapModule" /> |
18 | <RegionModule id="HGWorldMapModule" type="OpenSim.Region.CoreModules.Hypergrid.HGWorldMapModule" /> | 17 | <RegionModule id="HGWorldMapModule" type="OpenSim.Region.CoreModules.Hypergrid.HGWorldMapModule" /> |
19 | <RegionModule id="UrlModule" type="OpenSim.Region.CoreModules.Scripting.LSLHttp.UrlModule" /> | 18 | <RegionModule id="UrlModule" type="OpenSim.Region.CoreModules.Scripting.LSLHttp.UrlModule" /> |
diff --git a/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs b/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs index 9a6c49a..43761fc 100644 --- a/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs | |||
@@ -311,11 +311,8 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture | |||
311 | } | 311 | } |
312 | 312 | ||
313 | // Create a new asset for user | 313 | // Create a new asset for user |
314 | AssetBase asset = new AssetBase(); | 314 | AssetBase asset = new AssetBase(UUID.Random(), "DynamicImage" + Util.RandomClass.Next(1, 10000), (sbyte)AssetType.Texture); |
315 | asset.FullID = UUID.Random(); | ||
316 | asset.Data = assetData; | 315 | asset.Data = assetData; |
317 | asset.Name = "DynamicImage" + Util.RandomClass.Next(1, 10000); | ||
318 | asset.Type = 0; | ||
319 | asset.Description = String.Format("URL image : {0}", Url); | 316 | asset.Description = String.Format("URL image : {0}", Url); |
320 | asset.Local = false; | 317 | asset.Local = false; |
321 | asset.Temporary = ((Disp & DISP_TEMP) != 0); | 318 | asset.Temporary = ((Disp & DISP_TEMP) != 0); |
diff --git a/OpenSim/Region/CoreModules/Scripting/XMLRPC/XMLRPCModule.cs b/OpenSim/Region/CoreModules/Scripting/XMLRPC/XMLRPCModule.cs index 97899a7..27b64bf 100644 --- a/OpenSim/Region/CoreModules/Scripting/XMLRPC/XMLRPCModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/XMLRPC/XMLRPCModule.cs | |||
@@ -689,7 +689,7 @@ namespace OpenSim.Region.CoreModules.Scripting.XMLRPC | |||
689 | } | 689 | } |
690 | if (respParms.Contains("IntValue")) | 690 | if (respParms.Contains("IntValue")) |
691 | { | 691 | { |
692 | Idata = Convert.ToInt32((string) respParms["IntValue"]); | 692 | Idata = Convert.ToInt32(respParms["IntValue"]); |
693 | } | 693 | } |
694 | if (respParms.Contains("faultString")) | 694 | if (respParms.Contains("faultString")) |
695 | { | 695 | { |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/HypergridServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/HypergridServiceInConnectorModule.cs index 92db15b..b12d778 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/HypergridServiceInConnectorModule.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/HypergridServiceInConnectorModule.cs | |||
@@ -118,7 +118,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Grid | |||
118 | 118 | ||
119 | m_log.Info("[HypergridService]: Starting..."); | 119 | m_log.Info("[HypergridService]: Starting..."); |
120 | 120 | ||
121 | Object[] args = new Object[] { m_Config, MainServer.Instance }; | 121 | // Object[] args = new Object[] { m_Config, MainServer.Instance }; |
122 | 122 | ||
123 | m_HypergridHandler = new HypergridServiceInConnector(m_Config, MainServer.Instance, scene.RequestModuleInterface<IHyperlinkService>()); | 123 | m_HypergridHandler = new HypergridServiceInConnector(m_Config, MainServer.Instance, scene.RequestModuleInterface<IHyperlinkService>()); |
124 | //ServerUtils.LoadPlugin<HypergridServiceInConnector>("OpenSim.Server.Handlers.dll:HypergridServiceInConnector", args); | 124 | //ServerUtils.LoadPlugin<HypergridServiceInConnector>("OpenSim.Server.Handlers.dll:HypergridServiceInConnector", args); |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs index 046bee5..f2d8579 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs | |||
@@ -322,10 +322,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid | |||
322 | { | 322 | { |
323 | List<GridRegion> rinfos = new List<GridRegion>(); | 323 | List<GridRegion> rinfos = new List<GridRegion>(); |
324 | 324 | ||
325 | // Commenting until regionname exists | 325 | if (name == string.Empty) |
326 | //foreach (SimpleRegionInfo r in m_HyperlinkRegions.Values) | 326 | return rinfos; |
327 | // if ((r.RegionName != null) && r.RegionName.StartsWith(name)) | 327 | |
328 | // rinfos.Add(r); | 328 | foreach (GridRegion r in m_HyperlinkRegions.Values) |
329 | if ((r.RegionName != null) && r.RegionName.ToLower().StartsWith(name.ToLower())) | ||
330 | rinfos.Add(r); | ||
329 | 331 | ||
330 | rinfos.AddRange(m_GridServiceConnector.GetRegionsByName(scopeID, name, maxNumber)); | 332 | rinfos.AddRange(m_GridServiceConnector.GetRegionsByName(scopeID, name, maxNumber)); |
331 | return rinfos; | 333 | return rinfos; |
@@ -334,7 +336,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid | |||
334 | public List<GridRegion> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax) | 336 | public List<GridRegion> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax) |
335 | { | 337 | { |
336 | int snapXmin = (int)(xmin / Constants.RegionSize) * (int)Constants.RegionSize; | 338 | int snapXmin = (int)(xmin / Constants.RegionSize) * (int)Constants.RegionSize; |
337 | int snapXmax = (int)(xmax / Constants.RegionSize) * (int)Constants.RegionSize; | 339 | // int snapXmax = (int)(xmax / Constants.RegionSize) * (int)Constants.RegionSize; |
338 | int snapYmin = (int)(ymin / Constants.RegionSize) * (int)Constants.RegionSize; | 340 | int snapYmin = (int)(ymin / Constants.RegionSize) * (int)Constants.RegionSize; |
339 | int snapYmax = (int)(ymax / Constants.RegionSize) * (int)Constants.RegionSize; | 341 | int snapYmax = (int)(ymax / Constants.RegionSize) * (int)Constants.RegionSize; |
340 | 342 | ||
@@ -602,13 +604,16 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid | |||
602 | { | 604 | { |
603 | CachedUserInfo uinfo = m_aScene.CommsManager.UserProfileCacheService.GetUserDetails(agentData.AgentID); | 605 | CachedUserInfo uinfo = m_aScene.CommsManager.UserProfileCacheService.GetUserDetails(agentData.AgentID); |
604 | 606 | ||
607 | if (uinfo == null) | ||
608 | return false; | ||
609 | |||
605 | if ((IsLocalUser(uinfo) && (GetHyperlinkRegion(regInfo.RegionHandle) != null)) || | 610 | if ((IsLocalUser(uinfo) && (GetHyperlinkRegion(regInfo.RegionHandle) != null)) || |
606 | (!IsLocalUser(uinfo) && !IsGoingHome(uinfo, regInfo))) | 611 | (!IsLocalUser(uinfo) && !IsGoingHome(uinfo, regInfo))) |
607 | { | 612 | { |
608 | m_log.Info("[HGrid]: Local user is going to foreign region or foreign user is going elsewhere"); | 613 | m_log.Info("[HGrid]: Local user is going to foreign region or foreign user is going elsewhere"); |
609 | 614 | ||
610 | // Set the position of the region on the remote grid | 615 | // Set the position of the region on the remote grid |
611 | ulong realHandle = FindRegionHandle(regInfo.RegionHandle); | 616 | // ulong realHandle = FindRegionHandle(regInfo.RegionHandle); |
612 | uint x = 0, y = 0; | 617 | uint x = 0, y = 0; |
613 | Utils.LongToUInts(regInfo.RegionHandle, out x, out y); | 618 | Utils.LongToUInts(regInfo.RegionHandle, out x, out y); |
614 | GridRegion clonedRegion = new GridRegion(regInfo); | 619 | GridRegion clonedRegion = new GridRegion(regInfo); |
@@ -735,6 +740,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid | |||
735 | // Is the user going back to the home region or the home grid? | 740 | // Is the user going back to the home region or the home grid? |
736 | protected bool IsGoingHome(CachedUserInfo uinfo, GridRegion rinfo) | 741 | protected bool IsGoingHome(CachedUserInfo uinfo, GridRegion rinfo) |
737 | { | 742 | { |
743 | if (uinfo == null) | ||
744 | return false; | ||
745 | |||
738 | if (uinfo.UserProfile == null) | 746 | if (uinfo.UserProfile == null) |
739 | return false; | 747 | return false; |
740 | 748 | ||
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs index 54acbc4..70a225e 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs | |||
@@ -129,6 +129,9 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
129 | successfulAssetRestores++; | 129 | successfulAssetRestores++; |
130 | else | 130 | else |
131 | failedAssetRestores++; | 131 | failedAssetRestores++; |
132 | |||
133 | if ((successfulAssetRestores + failedAssetRestores) % 250 == 0) | ||
134 | m_log.Debug("[ARCHIVER]: Loaded " + successfulAssetRestores + " assets and failed to load " + failedAssetRestores + " assets..."); | ||
132 | } | 135 | } |
133 | else if (!m_merge && filePath.StartsWith(ArchiveConstants.TERRAINS_PATH)) | 136 | else if (!m_merge && filePath.StartsWith(ArchiveConstants.TERRAINS_PATH)) |
134 | { | 137 | { |
@@ -329,10 +332,12 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
329 | { | 332 | { |
330 | sbyte assetType = ArchiveConstants.EXTENSION_TO_ASSET_TYPE[extension]; | 333 | sbyte assetType = ArchiveConstants.EXTENSION_TO_ASSET_TYPE[extension]; |
331 | 334 | ||
335 | if (assetType == (sbyte)AssetType.Unknown) | ||
336 | m_log.WarnFormat("[ARCHIVER]: Importing {0} byte asset {1} with unknown type", data.Length, uuid); | ||
337 | |||
332 | //m_log.DebugFormat("[ARCHIVER]: Importing asset {0}, type {1}", uuid, assetType); | 338 | //m_log.DebugFormat("[ARCHIVER]: Importing asset {0}, type {1}", uuid, assetType); |
333 | 339 | ||
334 | AssetBase asset = new AssetBase(new UUID(uuid), String.Empty); | 340 | AssetBase asset = new AssetBase(new UUID(uuid), String.Empty, assetType); |
335 | asset.Type = assetType; | ||
336 | asset.Data = data; | 341 | asset.Data = data; |
337 | 342 | ||
338 | // We're relying on the asset service to do the sensible thing and not store the asset if it already | 343 | // We're relying on the asset service to do the sensible thing and not store the asset if it already |
diff --git a/OpenSim/Region/CoreModules/World/Archiver/AssetsDearchiver.cs b/OpenSim/Region/CoreModules/World/Archiver/AssetsDearchiver.cs index 5208e7a..2d2c570 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/AssetsDearchiver.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/AssetsDearchiver.cs | |||
@@ -158,9 +158,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
158 | 158 | ||
159 | m_log.DebugFormat("[ARCHIVER]: Importing asset {0}", filename); | 159 | m_log.DebugFormat("[ARCHIVER]: Importing asset {0}", filename); |
160 | 160 | ||
161 | AssetBase asset = new AssetBase(new UUID(filename), metadata.Name); | 161 | AssetBase asset = new AssetBase(new UUID(filename), metadata.Name, metadata.AssetType); |
162 | asset.Description = metadata.Description; | 162 | asset.Description = metadata.Description; |
163 | asset.Type = metadata.AssetType; | ||
164 | asset.Data = data; | 163 | asset.Data = data; |
165 | 164 | ||
166 | m_cache.Store(asset); | 165 | m_cache.Store(asset); |
diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateTerrainXferHandler.cs b/OpenSim/Region/CoreModules/World/Estate/EstateTerrainXferHandler.cs index ddac515..2ff635b 100644 --- a/OpenSim/Region/CoreModules/World/Estate/EstateTerrainXferHandler.cs +++ b/OpenSim/Region/CoreModules/World/Estate/EstateTerrainXferHandler.cs | |||
@@ -52,16 +52,11 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
52 | 52 | ||
53 | public EstateTerrainXferHandler(IClientAPI pRemoteClient, string pClientFilename) | 53 | public EstateTerrainXferHandler(IClientAPI pRemoteClient, string pClientFilename) |
54 | { | 54 | { |
55 | 55 | m_asset = new AssetBase(UUID.Zero, pClientFilename, type); | |
56 | m_asset = new AssetBase(); | ||
57 | m_asset.FullID = UUID.Zero; | ||
58 | m_asset.Type = type; | ||
59 | m_asset.Data = new byte[0]; | 56 | m_asset.Data = new byte[0]; |
60 | m_asset.Name = pClientFilename; | ||
61 | m_asset.Description = "empty"; | 57 | m_asset.Description = "empty"; |
62 | m_asset.Local = true; | 58 | m_asset.Local = true; |
63 | m_asset.Temporary = true; | 59 | m_asset.Temporary = true; |
64 | |||
65 | } | 60 | } |
66 | 61 | ||
67 | public ulong XferID | 62 | public ulong XferID |
diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs index 93a949a..968f46a 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs | |||
@@ -1059,9 +1059,11 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
1059 | if (m_scene.Permissions.IsGod(remote_client.AgentId)) | 1059 | if (m_scene.Permissions.IsGod(remote_client.AgentId)) |
1060 | { | 1060 | { |
1061 | land.LandData.OwnerID = ownerID; | 1061 | land.LandData.OwnerID = ownerID; |
1062 | land.LandData.GroupID = UUID.Zero; | ||
1063 | land.LandData.IsGroupOwned = false; | ||
1062 | 1064 | ||
1063 | m_scene.ForEachClient(SendParcelOverlay); | 1065 | m_scene.ForEachClient(SendParcelOverlay); |
1064 | land.SendLandUpdateToClient(remote_client); | 1066 | land.SendLandUpdateToClient(true, remote_client); |
1065 | } | 1067 | } |
1066 | } | 1068 | } |
1067 | } | 1069 | } |
@@ -1082,8 +1084,10 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
1082 | land.LandData.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner; | 1084 | land.LandData.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner; |
1083 | else | 1085 | else |
1084 | land.LandData.OwnerID = m_scene.RegionInfo.MasterAvatarAssignedUUID; | 1086 | land.LandData.OwnerID = m_scene.RegionInfo.MasterAvatarAssignedUUID; |
1087 | land.LandData.GroupID = UUID.Zero; | ||
1088 | land.LandData.IsGroupOwned = false; | ||
1085 | m_scene.ForEachClient(SendParcelOverlay); | 1089 | m_scene.ForEachClient(SendParcelOverlay); |
1086 | land.SendLandUpdateToClient(remote_client); | 1090 | land.SendLandUpdateToClient(true, remote_client); |
1087 | } | 1091 | } |
1088 | } | 1092 | } |
1089 | } | 1093 | } |
@@ -1105,9 +1109,10 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
1105 | else | 1109 | else |
1106 | land.LandData.OwnerID = m_scene.RegionInfo.MasterAvatarAssignedUUID; | 1110 | land.LandData.OwnerID = m_scene.RegionInfo.MasterAvatarAssignedUUID; |
1107 | land.LandData.ClaimDate = Util.UnixTimeSinceEpoch(); | 1111 | land.LandData.ClaimDate = Util.UnixTimeSinceEpoch(); |
1112 | land.LandData.GroupID = UUID.Zero; | ||
1108 | land.LandData.IsGroupOwned = false; | 1113 | land.LandData.IsGroupOwned = false; |
1109 | m_scene.ForEachClient(SendParcelOverlay); | 1114 | m_scene.ForEachClient(SendParcelOverlay); |
1110 | land.SendLandUpdateToClient(remote_client); | 1115 | land.SendLandUpdateToClient(true, remote_client); |
1111 | } | 1116 | } |
1112 | } | 1117 | } |
1113 | } | 1118 | } |
diff --git a/OpenSim/Region/CoreModules/World/Land/LandObject.cs b/OpenSim/Region/CoreModules/World/Land/LandObject.cs index bfe85f1..0bd225e 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandObject.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandObject.cs | |||
@@ -49,6 +49,8 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
49 | #pragma warning restore 0429 | 49 | #pragma warning restore 0429 |
50 | private bool[,] m_landBitmap = new bool[landArrayMax,landArrayMax]; | 50 | private bool[,] m_landBitmap = new bool[landArrayMax,landArrayMax]; |
51 | 51 | ||
52 | private int m_lastSeqId = 0; | ||
53 | |||
52 | protected LandData m_landData = new LandData(); | 54 | protected LandData m_landData = new LandData(); |
53 | protected Scene m_scene; | 55 | protected Scene m_scene; |
54 | protected List<SceneObjectGroup> primsOverMe = new List<SceneObjectGroup>(); | 56 | protected List<SceneObjectGroup> primsOverMe = new List<SceneObjectGroup>(); |
@@ -81,6 +83,10 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
81 | { | 83 | { |
82 | m_scene = scene; | 84 | m_scene = scene; |
83 | LandData.OwnerID = owner_id; | 85 | LandData.OwnerID = owner_id; |
86 | if (is_group_owned) | ||
87 | LandData.GroupID = owner_id; | ||
88 | else | ||
89 | LandData.GroupID = UUID.Zero; | ||
84 | LandData.IsGroupOwned = is_group_owned; | 90 | LandData.IsGroupOwned = is_group_owned; |
85 | } | 91 | } |
86 | 92 | ||
@@ -172,7 +178,19 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
172 | // regionFlags |= (uint)RegionFlags.AllowLandmark; | 178 | // regionFlags |= (uint)RegionFlags.AllowLandmark; |
173 | // if (landData.OwnerID == remote_client.AgentId) | 179 | // if (landData.OwnerID == remote_client.AgentId) |
174 | // regionFlags |= (uint)RegionFlags.AllowSetHome; | 180 | // regionFlags |= (uint)RegionFlags.AllowSetHome; |
175 | remote_client.SendLandProperties(sequence_id, | 181 | |
182 | int seq_id; | ||
183 | if (snap_selection && (sequence_id == 0)) | ||
184 | { | ||
185 | seq_id = m_lastSeqId; | ||
186 | } | ||
187 | else | ||
188 | { | ||
189 | seq_id = sequence_id; | ||
190 | m_lastSeqId = seq_id; | ||
191 | } | ||
192 | |||
193 | remote_client.SendLandProperties(seq_id, | ||
176 | snap_selection, request_result, LandData, | 194 | snap_selection, request_result, LandData, |
177 | (float)m_scene.RegionInfo.RegionSettings.ObjectBonus, | 195 | (float)m_scene.RegionInfo.RegionSettings.ObjectBonus, |
178 | GetParcelMaxPrimCount(this), | 196 | GetParcelMaxPrimCount(this), |
@@ -184,6 +202,7 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
184 | if (m_scene.Permissions.CanEditParcel(remote_client.AgentId,this)) | 202 | if (m_scene.Permissions.CanEditParcel(remote_client.AgentId,this)) |
185 | { | 203 | { |
186 | //Needs later group support | 204 | //Needs later group support |
205 | bool snap_selection = false; | ||
187 | LandData newData = LandData.Copy(); | 206 | LandData newData = LandData.Copy(); |
188 | 207 | ||
189 | if (args.AuthBuyerID != newData.AuthBuyerID || args.SalePrice != newData.SalePrice) | 208 | if (args.AuthBuyerID != newData.AuthBuyerID || args.SalePrice != newData.SalePrice) |
@@ -192,6 +211,7 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
192 | { | 211 | { |
193 | newData.AuthBuyerID = args.AuthBuyerID; | 212 | newData.AuthBuyerID = args.AuthBuyerID; |
194 | newData.SalePrice = args.SalePrice; | 213 | newData.SalePrice = args.SalePrice; |
214 | snap_selection = true; | ||
195 | } | 215 | } |
196 | } | 216 | } |
197 | newData.Category = args.Category; | 217 | newData.Category = args.Category; |
@@ -212,7 +232,7 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
212 | 232 | ||
213 | m_scene.LandChannel.UpdateLandObject(LandData.LocalID, newData); | 233 | m_scene.LandChannel.UpdateLandObject(LandData.LocalID, newData); |
214 | 234 | ||
215 | SendLandUpdateToAvatarsOverMe(); | 235 | SendLandUpdateToAvatarsOverMe(snap_selection); |
216 | } | 236 | } |
217 | } | 237 | } |
218 | 238 | ||
@@ -230,7 +250,7 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
230 | newData.Flags &= ~(uint) (ParcelFlags.ForSale | ParcelFlags.ForSaleObjects | ParcelFlags.SellParcelObjects); | 250 | newData.Flags &= ~(uint) (ParcelFlags.ForSale | ParcelFlags.ForSaleObjects | ParcelFlags.SellParcelObjects); |
231 | m_scene.LandChannel.UpdateLandObject(LandData.LocalID, newData); | 251 | m_scene.LandChannel.UpdateLandObject(LandData.LocalID, newData); |
232 | 252 | ||
233 | SendLandUpdateToAvatarsOverMe(); | 253 | SendLandUpdateToAvatarsOverMe(true); |
234 | } | 254 | } |
235 | 255 | ||
236 | public void DeedToGroup(UUID groupID) | 256 | public void DeedToGroup(UUID groupID) |
@@ -242,7 +262,7 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
242 | 262 | ||
243 | m_scene.LandChannel.UpdateLandObject(LandData.LocalID, newData); | 263 | m_scene.LandChannel.UpdateLandObject(LandData.LocalID, newData); |
244 | 264 | ||
245 | SendLandUpdateToAvatarsOverMe(); | 265 | SendLandUpdateToAvatarsOverMe(true); |
246 | } | 266 | } |
247 | 267 | ||
248 | public bool IsEitherBannedOrRestricted(UUID avatar) | 268 | public bool IsEitherBannedOrRestricted(UUID avatar) |
@@ -297,8 +317,18 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
297 | SendLandProperties(0, false, 0, remote_client); | 317 | SendLandProperties(0, false, 0, remote_client); |
298 | } | 318 | } |
299 | 319 | ||
320 | public void SendLandUpdateToClient(bool snap_selection, IClientAPI remote_client) | ||
321 | { | ||
322 | SendLandProperties(0, snap_selection, 0, remote_client); | ||
323 | } | ||
324 | |||
300 | public void SendLandUpdateToAvatarsOverMe() | 325 | public void SendLandUpdateToAvatarsOverMe() |
301 | { | 326 | { |
327 | SendLandUpdateToAvatarsOverMe(false); | ||
328 | } | ||
329 | |||
330 | public void SendLandUpdateToAvatarsOverMe(bool snap_selection) | ||
331 | { | ||
302 | List<ScenePresence> avatars = m_scene.GetAvatars(); | 332 | List<ScenePresence> avatars = m_scene.GetAvatars(); |
303 | ILandObject over = null; | 333 | ILandObject over = null; |
304 | for (int i = 0; i < avatars.Count; i++) | 334 | for (int i = 0; i < avatars.Count; i++) |
@@ -325,7 +355,7 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
325 | else | 355 | else |
326 | avatars[i].Invulnerable = true; | 356 | avatars[i].Invulnerable = true; |
327 | 357 | ||
328 | SendLandUpdateToClient(avatars[i].ControllingClient); | 358 | SendLandUpdateToClient(snap_selection, avatars[i].ControllingClient); |
329 | } | 359 | } |
330 | } | 360 | } |
331 | } | 361 | } |
diff --git a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs index fe9de1b..c790624 100644 --- a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs +++ b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs | |||
@@ -144,6 +144,8 @@ namespace OpenSim.Region.CoreModules.World.Permissions | |||
144 | private Dictionary<string, bool> GrantVB = new Dictionary<string, bool>(); | 144 | private Dictionary<string, bool> GrantVB = new Dictionary<string, bool>(); |
145 | private Dictionary<string, bool> GrantJS = new Dictionary<string, bool>(); | 145 | private Dictionary<string, bool> GrantJS = new Dictionary<string, bool>(); |
146 | private Dictionary<string, bool> GrantYP = new Dictionary<string, bool>(); | 146 | private Dictionary<string, bool> GrantYP = new Dictionary<string, bool>(); |
147 | private IFriendsModule m_friendsModule = null; | ||
148 | |||
147 | #endregion | 149 | #endregion |
148 | 150 | ||
149 | #region IRegionModule Members | 151 | #region IRegionModule Members |
@@ -363,6 +365,12 @@ namespace OpenSim.Region.CoreModules.World.Permissions | |||
363 | 365 | ||
364 | public void PostInitialise() | 366 | public void PostInitialise() |
365 | { | 367 | { |
368 | m_friendsModule = m_scene.RequestModuleInterface<IFriendsModule>(); | ||
369 | |||
370 | if (m_friendsModule == null) | ||
371 | m_log.Error("[PERMISSIONS]: Friends module not found, friend permissions will not work"); | ||
372 | else | ||
373 | m_log.Info("[PERMISSIONS]: Friends module found, friend permissions enabled"); | ||
366 | } | 374 | } |
367 | 375 | ||
368 | public void Close() | 376 | public void Close() |
@@ -476,6 +484,24 @@ namespace OpenSim.Region.CoreModules.World.Permissions | |||
476 | 484 | ||
477 | return false; | 485 | return false; |
478 | } | 486 | } |
487 | protected bool IsFriendWithPerms(UUID user,UUID objectOwner) | ||
488 | { | ||
489 | |||
490 | if (user == UUID.Zero) | ||
491 | return false; | ||
492 | |||
493 | if (m_friendsModule == null) | ||
494 | return false; | ||
495 | |||
496 | List<FriendListItem> profile = m_friendsModule.GetUserFriends(user); | ||
497 | |||
498 | foreach (FriendListItem item in profile) | ||
499 | { | ||
500 | if(item.Friend == objectOwner && (item.FriendPerms & (uint)FriendRights.CanModifyObjects) != 0) | ||
501 | return true; | ||
502 | } | ||
503 | return false; | ||
504 | } | ||
479 | 505 | ||
480 | protected bool IsEstateManager(UUID user) | 506 | protected bool IsEstateManager(UUID user) |
481 | { | 507 | { |
@@ -565,6 +591,9 @@ namespace OpenSim.Region.CoreModules.World.Permissions | |||
565 | // Object owners should be able to edit their own content | 591 | // Object owners should be able to edit their own content |
566 | if (user == objectOwner) | 592 | if (user == objectOwner) |
567 | return objectOwnerMask; | 593 | return objectOwnerMask; |
594 | |||
595 | if (IsFriendWithPerms(user, objectOwner)) | ||
596 | return objectOwnerMask; | ||
568 | 597 | ||
569 | // Estate users should be able to edit anything in the sim | 598 | // Estate users should be able to edit anything in the sim |
570 | if (IsEstateManager(user) && m_RegionOwnerIsGod && !IsAdministrator(objectOwner)) | 599 | if (IsEstateManager(user) && m_RegionOwnerIsGod && !IsAdministrator(objectOwner)) |
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs index f4b54aa..44a651f 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs | |||
@@ -1077,14 +1077,12 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
1077 | 1077 | ||
1078 | m_scene.RegionInfo.RegionSettings.TerrainImageID = TerrainImageUUID; | 1078 | m_scene.RegionInfo.RegionSettings.TerrainImageID = TerrainImageUUID; |
1079 | 1079 | ||
1080 | AssetBase asset = new AssetBase(); | 1080 | AssetBase asset = new AssetBase( |
1081 | asset.FullID = m_scene.RegionInfo.RegionSettings.TerrainImageID; | 1081 | m_scene.RegionInfo.RegionSettings.TerrainImageID, |
1082 | "terrainImage_" + m_scene.RegionInfo.RegionID.ToString() + "_" + lastMapRefresh.ToString(), | ||
1083 | (sbyte)AssetType.Texture); | ||
1082 | asset.Data = data; | 1084 | asset.Data = data; |
1083 | asset.Name | ||
1084 | = "terrainImage_" + m_scene.RegionInfo.RegionID.ToString() + "_" + lastMapRefresh.ToString(); | ||
1085 | asset.Description = m_scene.RegionInfo.RegionName; | 1085 | asset.Description = m_scene.RegionInfo.RegionName; |
1086 | |||
1087 | asset.Type = 0; | ||
1088 | asset.Temporary = temporary; | 1086 | asset.Temporary = temporary; |
1089 | m_scene.AssetService.Store(asset); | 1087 | m_scene.AssetService.Store(asset); |
1090 | } | 1088 | } |
diff --git a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs index 5a5fcfe..9754da3 100644 --- a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs +++ b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs | |||
@@ -179,6 +179,7 @@ namespace OpenSim.Region.Examples.SimpleModule | |||
179 | public event FriendActionDelegate OnApproveFriendRequest; | 179 | public event FriendActionDelegate OnApproveFriendRequest; |
180 | public event FriendActionDelegate OnDenyFriendRequest; | 180 | public event FriendActionDelegate OnDenyFriendRequest; |
181 | public event FriendshipTermination OnTerminateFriendship; | 181 | public event FriendshipTermination OnTerminateFriendship; |
182 | public event GrantUserFriendRights OnGrantUserRights; | ||
182 | 183 | ||
183 | public event EconomyDataRequest OnEconomyDataRequest; | 184 | public event EconomyDataRequest OnEconomyDataRequest; |
184 | public event MoneyBalanceRequest OnMoneyBalanceRequest; | 185 | public event MoneyBalanceRequest OnMoneyBalanceRequest; |
@@ -538,6 +539,7 @@ namespace OpenSim.Region.Examples.SimpleModule | |||
538 | public virtual void SendInventoryFolderDetails(UUID ownerID, UUID folderID, | 539 | public virtual void SendInventoryFolderDetails(UUID ownerID, UUID folderID, |
539 | List<InventoryItemBase> items, | 540 | List<InventoryItemBase> items, |
540 | List<InventoryFolderBase> folders, | 541 | List<InventoryFolderBase> folders, |
542 | int version, | ||
541 | bool fetchFolders, | 543 | bool fetchFolders, |
542 | bool fetchItems) | 544 | bool fetchItems) |
543 | { | 545 | { |
diff --git a/OpenSim/Region/Framework/Interfaces/IFriendsModule.cs b/OpenSim/Region/Framework/Interfaces/IFriendsModule.cs index 7a8aba2..8386030 100644 --- a/OpenSim/Region/Framework/Interfaces/IFriendsModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IFriendsModule.cs | |||
@@ -27,6 +27,7 @@ | |||
27 | 27 | ||
28 | using OpenMetaverse; | 28 | using OpenMetaverse; |
29 | using OpenSim.Framework; | 29 | using OpenSim.Framework; |
30 | using System.Collections.Generic; | ||
30 | 31 | ||
31 | namespace OpenSim.Region.Framework.Interfaces | 32 | namespace OpenSim.Region.Framework.Interfaces |
32 | { | 33 | { |
@@ -45,5 +46,6 @@ namespace OpenSim.Region.Framework.Interfaces | |||
45 | /// </param> | 46 | /// </param> |
46 | /// <param name="offerMessage"></param> | 47 | /// <param name="offerMessage"></param> |
47 | void OfferFriendship(UUID fromUserId, IClientAPI toUserClient, string offerMessage); | 48 | void OfferFriendship(UUID fromUserId, IClientAPI toUserClient, string offerMessage); |
49 | List<FriendListItem> GetUserFriends(UUID agentID); | ||
48 | } | 50 | } |
49 | } | 51 | } |
diff --git a/OpenSim/Region/Framework/Interfaces/ILandObject.cs b/OpenSim/Region/Framework/Interfaces/ILandObject.cs index c2b1292..084184f 100644 --- a/OpenSim/Region/Framework/Interfaces/ILandObject.cs +++ b/OpenSim/Region/Framework/Interfaces/ILandObject.cs | |||
@@ -54,6 +54,7 @@ namespace OpenSim.Region.Framework.Interfaces | |||
54 | bool IsBannedFromLand(UUID avatar); | 54 | bool IsBannedFromLand(UUID avatar); |
55 | bool IsRestrictedFromLand(UUID avatar); | 55 | bool IsRestrictedFromLand(UUID avatar); |
56 | void SendLandUpdateToClient(IClientAPI remote_client); | 56 | void SendLandUpdateToClient(IClientAPI remote_client); |
57 | void SendLandUpdateToClient(bool snap_selection, IClientAPI remote_client); | ||
57 | List<UUID> CreateAccessListArrayByFlag(AccessList flag); | 58 | List<UUID> CreateAccessListArrayByFlag(AccessList flag); |
58 | void SendAccessList(UUID agentID, UUID sessionID, uint flags, int sequenceID, IClientAPI remote_client); | 59 | void SendAccessList(UUID agentID, UUID sessionID, uint flags, int sequenceID, IClientAPI remote_client); |
59 | void UpdateAccessList(uint flags, List<ParcelManager.ParcelAccessEntry> entries, IClientAPI remote_client); | 60 | void UpdateAccessList(uint flags, List<ParcelManager.ParcelAccessEntry> entries, IClientAPI remote_client); |
diff --git a/OpenSim/Grid/GridServer/Program.cs b/OpenSim/Region/Framework/Interfaces/IScriptModuleComms.cs index 741a01b..5cdf191 100644 --- a/OpenSim/Grid/GridServer/Program.cs +++ b/OpenSim/Region/Framework/Interfaces/IScriptModuleComms.cs | |||
@@ -25,41 +25,20 @@ | |||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using log4net.Config; | 28 | using System; |
29 | using Nini.Config; | 29 | using OpenMetaverse; |
30 | 30 | ||
31 | namespace OpenSim.Grid.GridServer | 31 | namespace OpenSim.Region.Framework.Interfaces |
32 | { | 32 | { |
33 | public class Program | 33 | public delegate void ScriptCommand(UUID script, string id, string module, string command, string k); |
34 | { | ||
35 | public static void Main(string[] args) | ||
36 | { | ||
37 | ArgvConfigSource argvSource = new ArgvConfigSource(args); | ||
38 | argvSource.AddSwitch("Startup", "console", "c"); | ||
39 | argvSource.AddSwitch("Startup", "xmlfile", "x"); | ||
40 | |||
41 | XmlConfigurator.Configure(); | ||
42 | 34 | ||
43 | GridServerBase app = new GridServerBase(); | 35 | public interface IScriptModuleComms |
44 | 36 | { | |
45 | IConfig startupConfig = argvSource.Configs["Startup"]; | 37 | event ScriptCommand OnScriptCommand; |
46 | if (startupConfig != null) | ||
47 | { | ||
48 | app.m_consoleType = startupConfig.GetString("console", "local"); | ||
49 | app.m_configFile = startupConfig.GetString("xmlfile", "GridServer_Config.xml"); | ||
50 | } | ||
51 | 38 | ||
52 | app.m_configSource = argvSource; | 39 | void DispatchReply(UUID script, int code, string text, string k); |
53 | 40 | ||
54 | // if (args.Length > 0 && args[0] == "-setuponly") | 41 | // For use ONLY by the script API |
55 | // { | 42 | void RaiseEvent(UUID script, string id, string module, string command, string k); |
56 | // app.Config(); | ||
57 | // } | ||
58 | // else | ||
59 | // { | ||
60 | app.Startup(); | ||
61 | app.Work(); | ||
62 | // } | ||
63 | } | ||
64 | } | 43 | } |
65 | } | 44 | } |
diff --git a/OpenSim/Region/Framework/Scenes/EntityBase.cs b/OpenSim/Region/Framework/Scenes/EntityBase.cs index c2ec6a5..1c76c54 100644 --- a/OpenSim/Region/Framework/Scenes/EntityBase.cs +++ b/OpenSim/Region/Framework/Scenes/EntityBase.cs | |||
@@ -94,14 +94,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
94 | set { m_velocity = value; } | 94 | set { m_velocity = value; } |
95 | } | 95 | } |
96 | 96 | ||
97 | protected Quaternion m_rotation = new Quaternion(0f, 0f, 1f, 0f); | ||
98 | |||
99 | public virtual Quaternion Rotation | ||
100 | { | ||
101 | get { return m_rotation; } | ||
102 | set { m_rotation = value; } | ||
103 | } | ||
104 | |||
105 | protected uint m_localId; | 97 | protected uint m_localId; |
106 | 98 | ||
107 | public virtual uint LocalId | 99 | public virtual uint LocalId |
@@ -115,13 +107,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
115 | /// </summary> | 107 | /// </summary> |
116 | public EntityBase() | 108 | public EntityBase() |
117 | { | 109 | { |
118 | m_uuid = UUID.Zero; | ||
119 | |||
120 | m_pos = Vector3.Zero; | ||
121 | m_velocity = Vector3.Zero; | ||
122 | Rotation = Quaternion.Identity; | ||
123 | m_name = "(basic entity)"; | 110 | m_name = "(basic entity)"; |
124 | m_rotationalvelocity = Vector3.Zero; | ||
125 | } | 111 | } |
126 | 112 | ||
127 | /// <summary> | 113 | /// <summary> |
diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs index 244ac3b..ec50598 100644 --- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs +++ b/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs | |||
@@ -77,13 +77,13 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid | |||
77 | 77 | ||
78 | #region Internal functions | 78 | #region Internal functions |
79 | 79 | ||
80 | private string UserAssetURL(UUID userID) | 80 | // private string UserAssetURL(UUID userID) |
81 | { | 81 | // { |
82 | CachedUserInfo uinfo = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(userID); | 82 | // CachedUserInfo uinfo = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(userID); |
83 | if (uinfo != null) | 83 | // if (uinfo != null) |
84 | return (uinfo.UserProfile.UserAssetURI == "") ? null : uinfo.UserProfile.UserAssetURI; | 84 | // return (uinfo.UserProfile.UserAssetURI == "") ? null : uinfo.UserProfile.UserAssetURI; |
85 | return null; | 85 | // return null; |
86 | } | 86 | // } |
87 | 87 | ||
88 | // private string UserInventoryURL(UUID userID) | 88 | // private string UserInventoryURL(UUID userID) |
89 | // { | 89 | // { |
@@ -118,7 +118,7 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid | |||
118 | // HGAssetService dispatches it to the remote grid. | 118 | // HGAssetService dispatches it to the remote grid. |
119 | // It's not pretty, but the best that can be done while | 119 | // It's not pretty, but the best that can be done while |
120 | // not having a global naming infrastructure | 120 | // not having a global naming infrastructure |
121 | AssetBase asset1 = new AssetBase(); | 121 | AssetBase asset1 = new AssetBase(asset.FullID, asset.Name, asset.Type); |
122 | Copy(asset, asset1); | 122 | Copy(asset, asset1); |
123 | try | 123 | try |
124 | { | 124 | { |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 4d76b4ef..66fb918 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | |||
@@ -93,7 +93,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
93 | 93 | ||
94 | public void AddInventoryItem(UUID AgentID, InventoryItemBase item) | 94 | public void AddInventoryItem(UUID AgentID, InventoryItemBase item) |
95 | { | 95 | { |
96 | |||
97 | if (InventoryService.AddItem(item)) | 96 | if (InventoryService.AddItem(item)) |
98 | { | 97 | { |
99 | int userlevel = 0; | 98 | int userlevel = 0; |
@@ -627,11 +626,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
627 | /// <returns></returns> | 626 | /// <returns></returns> |
628 | private AssetBase CreateAsset(string name, string description, sbyte assetType, byte[] data) | 627 | private AssetBase CreateAsset(string name, string description, sbyte assetType, byte[] data) |
629 | { | 628 | { |
630 | AssetBase asset = new AssetBase(); | 629 | AssetBase asset = new AssetBase(UUID.Random(), name, assetType); |
631 | asset.Name = name; | ||
632 | asset.Description = description; | 630 | asset.Description = description; |
633 | asset.Type = assetType; | ||
634 | asset.FullID = UUID.Random(); | ||
635 | asset.Data = (data == null) ? new byte[1] : data; | 631 | asset.Data = (data == null) ? new byte[1] : data; |
636 | 632 | ||
637 | return asset; | 633 | return asset; |
@@ -807,20 +803,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
807 | InventoryService.DeleteFolders(remoteClient.AgentId, folderIDs); | 803 | InventoryService.DeleteFolders(remoteClient.AgentId, folderIDs); |
808 | } | 804 | } |
809 | 805 | ||
810 | private SceneObjectGroup GetGroupByPrim(uint localID) | ||
811 | { | ||
812 | List<EntityBase> EntityList = GetEntities(); | ||
813 | |||
814 | foreach (EntityBase ent in EntityList) | ||
815 | { | ||
816 | if (ent is SceneObjectGroup) | ||
817 | { | ||
818 | if (((SceneObjectGroup) ent).HasChildPrim(localID)) | ||
819 | return (SceneObjectGroup) ent; | ||
820 | } | ||
821 | } | ||
822 | return null; | ||
823 | } | ||
824 | 806 | ||
825 | /// <summary> | 807 | /// <summary> |
826 | /// Send the details of a prim's inventory to the client. | 808 | /// Send the details of a prim's inventory to the client. |
@@ -1175,7 +1157,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
1175 | { | 1157 | { |
1176 | m_log.DebugFormat("[AGENT INVENTORY]: Send Inventory Folder {0} Update to {1} {2}", folder.Name, client.FirstName, client.LastName); | 1158 | m_log.DebugFormat("[AGENT INVENTORY]: Send Inventory Folder {0} Update to {1} {2}", folder.Name, client.FirstName, client.LastName); |
1177 | InventoryCollection contents = InventoryService.GetFolderContent(client.AgentId, folder.ID); | 1159 | InventoryCollection contents = InventoryService.GetFolderContent(client.AgentId, folder.ID); |
1178 | client.SendInventoryFolderDetails(client.AgentId, folder.ID, contents.Items, contents.Folders, fetchFolders, fetchItems); | 1160 | InventoryFolderBase containingFolder = new InventoryFolderBase(); |
1161 | containingFolder.ID = folder.ID; | ||
1162 | containingFolder.Owner = client.AgentId; | ||
1163 | containingFolder = InventoryService.GetFolder(containingFolder); | ||
1164 | int version = containingFolder.Version; | ||
1165 | |||
1166 | client.SendInventoryFolderDetails(client.AgentId, folder.ID, contents.Items, contents.Folders, version, fetchFolders, fetchItems); | ||
1179 | } | 1167 | } |
1180 | 1168 | ||
1181 | /// <summary> | 1169 | /// <summary> |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs index 1a91f0c..47fbeb4 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs | |||
@@ -462,7 +462,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
462 | { | 462 | { |
463 | remoteClient.SendInventoryFolderDetails( | 463 | remoteClient.SendInventoryFolderDetails( |
464 | fold.Owner, folderID, fold.RequestListOfItems(), | 464 | fold.Owner, folderID, fold.RequestListOfItems(), |
465 | fold.RequestListOfFolders(), fetchFolders, fetchItems); | 465 | fold.RequestListOfFolders(), fold.Version, fetchFolders, fetchItems); |
466 | return; | 466 | return; |
467 | } | 467 | } |
468 | 468 | ||
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs b/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs index d01cef7..d1d6b6a 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs | |||
@@ -35,7 +35,7 @@ using OpenSim.Region.Framework.Interfaces; | |||
35 | namespace OpenSim.Region.Framework.Scenes | 35 | namespace OpenSim.Region.Framework.Scenes |
36 | { | 36 | { |
37 | #region Delegates | 37 | #region Delegates |
38 | public delegate uint GenerateClientFlagsHandler(UUID userID, UUID objectIDID); | 38 | public delegate uint GenerateClientFlagsHandler(UUID userID, UUID objectID); |
39 | public delegate void SetBypassPermissionsHandler(bool value); | 39 | public delegate void SetBypassPermissionsHandler(bool value); |
40 | public delegate bool BypassPermissionsHandler(); | 40 | public delegate bool BypassPermissionsHandler(); |
41 | public delegate bool PropagatePermissionsHandler(); | 41 | public delegate bool PropagatePermissionsHandler(); |
@@ -147,28 +147,28 @@ namespace OpenSim.Region.Framework.Scenes | |||
147 | 147 | ||
148 | public uint GenerateClientFlags(UUID userID, UUID objectID) | 148 | public uint GenerateClientFlags(UUID userID, UUID objectID) |
149 | { | 149 | { |
150 | SceneObjectPart part=m_scene.GetSceneObjectPart(objectID); | 150 | // libomv will moan about PrimFlags.ObjectYouOfficer being |
151 | // obsolete... | ||
152 | #pragma warning disable 0612 | ||
153 | const PrimFlags DEFAULT_FLAGS = | ||
154 | PrimFlags.ObjectModify | | ||
155 | PrimFlags.ObjectCopy | | ||
156 | PrimFlags.ObjectMove | | ||
157 | PrimFlags.ObjectTransfer | | ||
158 | PrimFlags.ObjectYouOwner | | ||
159 | PrimFlags.ObjectAnyOwner | | ||
160 | PrimFlags.ObjectOwnerModify | | ||
161 | PrimFlags.ObjectYouOfficer; | ||
162 | #pragma warning restore 0612 | ||
163 | |||
164 | SceneObjectPart part = m_scene.GetSceneObjectPart(objectID); | ||
151 | 165 | ||
152 | if (part == null) | 166 | if (part == null) |
153 | return 0; | 167 | return 0; |
154 | 168 | ||
155 | // libomv will moan about PrimFlags.ObjectYouOfficer being | 169 | uint perms = part.GetEffectiveObjectFlags() | (uint)DEFAULT_FLAGS; |
156 | // obsolete... | ||
157 | #pragma warning disable 0612 | ||
158 | uint perms=part.GetEffectiveObjectFlags() | | ||
159 | (uint)PrimFlags.ObjectModify | | ||
160 | (uint)PrimFlags.ObjectCopy | | ||
161 | (uint)PrimFlags.ObjectMove | | ||
162 | (uint)PrimFlags.ObjectTransfer | | ||
163 | (uint)PrimFlags.ObjectYouOwner | | ||
164 | (uint)PrimFlags.ObjectAnyOwner | | ||
165 | (uint)PrimFlags.ObjectOwnerModify | | ||
166 | (uint)PrimFlags.ObjectYouOfficer; | ||
167 | #pragma warning restore 0612 | ||
168 | |||
169 | GenerateClientFlagsHandler handlerGenerateClientFlags = | ||
170 | OnGenerateClientFlags; | ||
171 | 170 | ||
171 | GenerateClientFlagsHandler handlerGenerateClientFlags = OnGenerateClientFlags; | ||
172 | if (handlerGenerateClientFlags != null) | 172 | if (handlerGenerateClientFlags != null) |
173 | { | 173 | { |
174 | Delegate[] list = handlerGenerateClientFlags.GetInvocationList(); | 174 | Delegate[] list = handlerGenerateClientFlags.GetInvocationList(); |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 7c3875d..aeca7df 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -36,6 +36,7 @@ using System.Timers; | |||
36 | using System.Xml; | 36 | using System.Xml; |
37 | using Nini.Config; | 37 | using Nini.Config; |
38 | using OpenMetaverse; | 38 | using OpenMetaverse; |
39 | using OpenMetaverse.Packets; | ||
39 | using OpenMetaverse.Imaging; | 40 | using OpenMetaverse.Imaging; |
40 | using OpenSim.Framework; | 41 | using OpenSim.Framework; |
41 | using OpenSim.Services.Interfaces; | 42 | using OpenSim.Services.Interfaces; |
@@ -87,8 +88,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
87 | protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>(); | 88 | protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>(); |
88 | protected List<RegionInfo> m_neighbours = new List<RegionInfo>(); | 89 | protected List<RegionInfo> m_neighbours = new List<RegionInfo>(); |
89 | 90 | ||
90 | public volatile bool BordersLocked = false; | 91 | private volatile int m_bordersLocked = 0; |
91 | 92 | public bool BordersLocked | |
93 | { | ||
94 | get { return m_bordersLocked == 1; } | ||
95 | set | ||
96 | { | ||
97 | if (value == true) | ||
98 | m_bordersLocked = 1; | ||
99 | else | ||
100 | m_bordersLocked = 0; | ||
101 | } | ||
102 | } | ||
92 | public List<Border> NorthBorders = new List<Border>(); | 103 | public List<Border> NorthBorders = new List<Border>(); |
93 | public List<Border> EastBorders = new List<Border>(); | 104 | public List<Border> EastBorders = new List<Border>(); |
94 | public List<Border> SouthBorders = new List<Border>(); | 105 | public List<Border> SouthBorders = new List<Border>(); |
@@ -135,6 +146,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
135 | protected SceneCommunicationService m_sceneGridService; | 146 | protected SceneCommunicationService m_sceneGridService; |
136 | public bool loginsdisabled = true; | 147 | public bool loginsdisabled = true; |
137 | 148 | ||
149 | public new float TimeDilation | ||
150 | { | ||
151 | get { return m_sceneGraph.PhysicsScene.TimeDilation; } | ||
152 | } | ||
153 | |||
138 | public SceneCommunicationService SceneGridService | 154 | public SceneCommunicationService SceneGridService |
139 | { | 155 | { |
140 | get { return m_sceneGridService; } | 156 | get { return m_sceneGridService; } |
@@ -252,7 +268,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
252 | // Central Update Loop | 268 | // Central Update Loop |
253 | 269 | ||
254 | protected int m_fps = 10; | 270 | protected int m_fps = 10; |
255 | protected int m_frame; | 271 | protected uint m_frame; |
256 | protected float m_timespan = 0.089f; | 272 | protected float m_timespan = 0.089f; |
257 | protected DateTime m_lastupdate = DateTime.UtcNow; | 273 | protected DateTime m_lastupdate = DateTime.UtcNow; |
258 | 274 | ||
@@ -269,6 +285,23 @@ namespace OpenSim.Region.Framework.Scenes | |||
269 | private int physicsMS2; | 285 | private int physicsMS2; |
270 | private int physicsMS; | 286 | private int physicsMS; |
271 | private int otherMS; | 287 | private int otherMS; |
288 | private int tempOnRezMS; | ||
289 | private int eventMS; | ||
290 | private int backupMS; | ||
291 | private int terrainMS; | ||
292 | private int landMS; | ||
293 | private int lastCompletedFrame; | ||
294 | |||
295 | public int MonitorFrameTime { get { return frameMS; } } | ||
296 | public int MonitorPhysicsUpdateTime { get { return physicsMS; } } | ||
297 | public int MonitorPhysicsSyncTime { get { return physicsMS2; } } | ||
298 | public int MonitorOtherTime { get { return otherMS; } } | ||
299 | public int MonitorTempOnRezTime { get { return tempOnRezMS; } } | ||
300 | public int MonitorEventTime { get { return eventMS; } } // This may need to be divided into each event? | ||
301 | public int MonitorBackupTime { get { return backupMS; } } | ||
302 | public int MonitorTerrainTime { get { return terrainMS; } } | ||
303 | public int MonitorLandTime { get { return landMS; } } | ||
304 | public int MonitorLastFrameTick { get { return lastCompletedFrame; } } | ||
272 | 305 | ||
273 | private bool m_physics_enabled = true; | 306 | private bool m_physics_enabled = true; |
274 | private bool m_scripts_enabled = true; | 307 | private bool m_scripts_enabled = true; |
@@ -375,6 +408,73 @@ namespace OpenSim.Region.Framework.Scenes | |||
375 | 408 | ||
376 | #endregion | 409 | #endregion |
377 | 410 | ||
411 | #region BinaryStats | ||
412 | |||
413 | public class StatLogger | ||
414 | { | ||
415 | public DateTime StartTime; | ||
416 | public string Path; | ||
417 | public System.IO.BinaryWriter Log; | ||
418 | } | ||
419 | static StatLogger m_statLog = null; | ||
420 | static TimeSpan m_statLogPeriod = TimeSpan.FromSeconds(300); | ||
421 | static string m_statsDir = String.Empty; | ||
422 | static Object m_statLockObject = new Object(); | ||
423 | private void LogSimStats(SimStats stats) | ||
424 | { | ||
425 | SimStatsPacket pack = new SimStatsPacket(); | ||
426 | pack.Region = new SimStatsPacket.RegionBlock(); | ||
427 | pack.Region.RegionX = stats.RegionX; | ||
428 | pack.Region.RegionY = stats.RegionY; | ||
429 | pack.Region.RegionFlags = stats.RegionFlags; | ||
430 | pack.Region.ObjectCapacity = stats.ObjectCapacity; | ||
431 | //pack.Region = //stats.RegionBlock; | ||
432 | pack.Stat = stats.StatsBlock; | ||
433 | pack.Header.Reliable = false; | ||
434 | |||
435 | // note that we are inside the reporter lock when called | ||
436 | DateTime now = DateTime.Now; | ||
437 | |||
438 | // hide some time information into the packet | ||
439 | pack.Header.Sequence = (uint)now.Ticks; | ||
440 | |||
441 | lock (m_statLockObject) // m_statLog is shared so make sure there is only executer here | ||
442 | { | ||
443 | try | ||
444 | { | ||
445 | if (m_statLog == null || now > m_statLog.StartTime + m_statLogPeriod) | ||
446 | { | ||
447 | // First log file or time has expired, start writing to a new log file | ||
448 | if (m_statLog != null && m_statLog.Log != null) | ||
449 | { | ||
450 | m_statLog.Log.Close(); | ||
451 | } | ||
452 | m_statLog = new StatLogger(); | ||
453 | m_statLog.StartTime = now; | ||
454 | m_statLog.Path = (m_statsDir.Length > 0 ? m_statsDir + System.IO.Path.DirectorySeparatorChar.ToString() : "") | ||
455 | + String.Format("stats-{0}.log", now.ToString("yyyyMMddHHmmss")); | ||
456 | m_statLog.Log = new BinaryWriter(File.Open(m_statLog.Path, FileMode.Append, FileAccess.Write)); | ||
457 | } | ||
458 | |||
459 | // Write the serialized data to disk | ||
460 | if (m_statLog != null && m_statLog.Log != null) | ||
461 | m_statLog.Log.Write(pack.ToBytes()); | ||
462 | } | ||
463 | catch (Exception ex) | ||
464 | { | ||
465 | m_log.Error("statistics gathering failed: " + ex.Message, ex); | ||
466 | if (m_statLog != null && m_statLog.Log != null) | ||
467 | { | ||
468 | m_statLog.Log.Close(); | ||
469 | } | ||
470 | m_statLog = null; | ||
471 | } | ||
472 | } | ||
473 | return; | ||
474 | } | ||
475 | |||
476 | #endregion | ||
477 | |||
378 | #region Constructors | 478 | #region Constructors |
379 | 479 | ||
380 | public Scene(RegionInfo regInfo, AgentCircuitManager authen, | 480 | public Scene(RegionInfo regInfo, AgentCircuitManager authen, |
@@ -560,6 +660,38 @@ namespace OpenSim.Region.Framework.Scenes | |||
560 | } | 660 | } |
561 | 661 | ||
562 | m_log.Info("[SCENE]: Using the " + m_update_prioritization_scheme + " prioritization scheme"); | 662 | m_log.Info("[SCENE]: Using the " + m_update_prioritization_scheme + " prioritization scheme"); |
663 | |||
664 | #region BinaryStats | ||
665 | |||
666 | try | ||
667 | { | ||
668 | IConfig statConfig = m_config.Configs["Statistics.Binary"]; | ||
669 | if (statConfig.Contains("enabled") && statConfig.GetBoolean("enabled")) | ||
670 | { | ||
671 | if (statConfig.Contains("collect_region_stats")) | ||
672 | { | ||
673 | if (statConfig.GetBoolean("collect_region_stats")) | ||
674 | { | ||
675 | // if enabled, add us to the event. If not enabled, I won't get called | ||
676 | StatsReporter.OnSendStatsResult += LogSimStats; | ||
677 | } | ||
678 | } | ||
679 | if (statConfig.Contains("region_stats_period_seconds")) | ||
680 | { | ||
681 | m_statLogPeriod = TimeSpan.FromSeconds(statConfig.GetInt("region_stats_period_seconds")); | ||
682 | } | ||
683 | if (statConfig.Contains("stats_dir")) | ||
684 | { | ||
685 | m_statsDir = statConfig.GetString("stats_dir"); | ||
686 | } | ||
687 | } | ||
688 | } | ||
689 | catch | ||
690 | { | ||
691 | // if it doesn't work, we don't collect anything | ||
692 | } | ||
693 | |||
694 | #endregion BinaryStats | ||
563 | } | 695 | } |
564 | catch | 696 | catch |
565 | { | 697 | { |
@@ -1013,36 +1145,25 @@ namespace OpenSim.Region.Framework.Scenes | |||
1013 | /// </summary> | 1145 | /// </summary> |
1014 | public override void Update() | 1146 | public override void Update() |
1015 | { | 1147 | { |
1016 | int maintc = 0; | 1148 | float physicsFPS; |
1149 | int maintc; | ||
1150 | |||
1017 | while (!shuttingdown) | 1151 | while (!shuttingdown) |
1018 | { | 1152 | { |
1019 | //#if DEBUG | ||
1020 | // int w = 0, io = 0; | ||
1021 | // ThreadPool.GetAvailableThreads(out w, out io); | ||
1022 | // if ((w < 10) || (io < 10)) | ||
1023 | // m_log.DebugFormat("[WARNING]: ThreadPool reaching exhaustion. workers = {0}; io = {1}", w, io); | ||
1024 | //#endif | ||
1025 | maintc = Environment.TickCount; | ||
1026 | |||
1027 | TimeSpan SinceLastFrame = DateTime.UtcNow - m_lastupdate; | 1153 | TimeSpan SinceLastFrame = DateTime.UtcNow - m_lastupdate; |
1028 | float physicsFPS = 0; | 1154 | physicsFPS = 0f; |
1029 | 1155 | ||
1030 | frameMS = Environment.TickCount; | 1156 | maintc = otherMS = Environment.TickCount; |
1157 | int tmpFrameMS = maintc; | ||
1158 | |||
1159 | // Increment the frame counter | ||
1160 | ++m_frame; | ||
1031 | 1161 | ||
1032 | try | 1162 | try |
1033 | { | 1163 | { |
1034 | // Increment the frame counter | ||
1035 | m_frame++; | ||
1036 | |||
1037 | // Loop it | ||
1038 | if (m_frame == Int32.MaxValue) | ||
1039 | m_frame = 0; | ||
1040 | |||
1041 | otherMS = Environment.TickCount; | ||
1042 | |||
1043 | // Check if any objects have reached their targets | 1164 | // Check if any objects have reached their targets |
1044 | CheckAtTargets(); | 1165 | CheckAtTargets(); |
1045 | 1166 | ||
1046 | // Update SceneObjectGroups that have scheduled themselves for updates | 1167 | // Update SceneObjectGroups that have scheduled themselves for updates |
1047 | // Objects queue their updates onto all scene presences | 1168 | // Objects queue their updates onto all scene presences |
1048 | if (m_frame % m_update_objects == 0) | 1169 | if (m_frame % m_update_objects == 0) |
@@ -1053,62 +1174,92 @@ namespace OpenSim.Region.Framework.Scenes | |||
1053 | if (m_frame % m_update_presences == 0) | 1174 | if (m_frame % m_update_presences == 0) |
1054 | m_sceneGraph.UpdatePresences(); | 1175 | m_sceneGraph.UpdatePresences(); |
1055 | 1176 | ||
1056 | physicsMS2 = Environment.TickCount; | 1177 | int TempPhysicsMS2 = Environment.TickCount; |
1057 | if ((m_frame % m_update_physics == 0) && m_physics_enabled) | 1178 | if ((m_frame % m_update_physics == 0) && m_physics_enabled) |
1058 | m_sceneGraph.UpdatePreparePhysics(); | 1179 | m_sceneGraph.UpdatePreparePhysics(); |
1059 | physicsMS2 = Environment.TickCount - physicsMS2; | 1180 | TempPhysicsMS2 = Environment.TickCount - TempPhysicsMS2; |
1181 | physicsMS2 = TempPhysicsMS2; | ||
1060 | 1182 | ||
1061 | if (m_frame % m_update_entitymovement == 0) | 1183 | if (m_frame % m_update_entitymovement == 0) |
1062 | m_sceneGraph.UpdateScenePresenceMovement(); | 1184 | m_sceneGraph.UpdateScenePresenceMovement(); |
1063 | 1185 | ||
1064 | physicsMS = Environment.TickCount; | 1186 | int TempPhysicsMS = Environment.TickCount; |
1065 | if ((m_frame % m_update_physics == 0) && m_physics_enabled) | 1187 | if (m_frame % m_update_physics == 0) |
1066 | physicsFPS = m_sceneGraph.UpdatePhysics( | 1188 | { |
1067 | Math.Max(SinceLastFrame.TotalSeconds, m_timespan) | 1189 | if (m_physics_enabled) |
1068 | ); | 1190 | physicsFPS = m_sceneGraph.UpdatePhysics(Math.Max(SinceLastFrame.TotalSeconds, m_timespan)); |
1069 | if (m_frame % m_update_physics == 0 && SynchronizeScene != null) | 1191 | if (SynchronizeScene != null) |
1070 | SynchronizeScene(this); | 1192 | SynchronizeScene(this); |
1071 | 1193 | } | |
1072 | physicsMS = Environment.TickCount - physicsMS; | 1194 | TempPhysicsMS = Environment.TickCount - TempPhysicsMS; |
1073 | physicsMS += physicsMS2; | 1195 | physicsMS = TempPhysicsMS; |
1074 | 1196 | ||
1075 | // Delete temp-on-rez stuff | 1197 | // Delete temp-on-rez stuff |
1076 | if (m_frame % m_update_backup == 0) | 1198 | if (m_frame % m_update_backup == 0) |
1199 | { | ||
1200 | int tozMS = Environment.TickCount; | ||
1077 | CleanTempObjects(); | 1201 | CleanTempObjects(); |
1202 | tozMS -= Environment.TickCount; | ||
1203 | tempOnRezMS = tozMS; | ||
1204 | } | ||
1078 | 1205 | ||
1079 | if (RegionStatus != RegionStatus.SlaveScene) | 1206 | if (RegionStatus != RegionStatus.SlaveScene) |
1080 | { | 1207 | { |
1081 | if (m_frame % m_update_events == 0) | 1208 | if (m_frame % m_update_events == 0) |
1209 | { | ||
1210 | int evMS = Environment.TickCount; | ||
1082 | UpdateEvents(); | 1211 | UpdateEvents(); |
1212 | evMS -= Environment.TickCount; | ||
1213 | eventMS = evMS; | ||
1214 | } | ||
1083 | 1215 | ||
1084 | if (m_frame % m_update_backup == 0) | 1216 | if (m_frame % m_update_backup == 0) |
1217 | { | ||
1218 | int backMS = Environment.TickCount; | ||
1085 | UpdateStorageBackup(); | 1219 | UpdateStorageBackup(); |
1220 | backMS -= Environment.TickCount; | ||
1221 | backupMS = backMS; | ||
1222 | } | ||
1086 | 1223 | ||
1087 | if (m_frame % m_update_terrain == 0) | 1224 | if (m_frame % m_update_terrain == 0) |
1225 | { | ||
1226 | int terMS = Environment.TickCount; | ||
1088 | UpdateTerrain(); | 1227 | UpdateTerrain(); |
1228 | terMS -= Environment.TickCount; | ||
1229 | terrainMS = terMS; | ||
1230 | } | ||
1089 | 1231 | ||
1090 | if (m_frame % m_update_land == 0) | 1232 | if (m_frame % m_update_land == 0) |
1233 | { | ||
1234 | int ldMS = Environment.TickCount; | ||
1091 | UpdateLand(); | 1235 | UpdateLand(); |
1236 | ldMS -= Environment.TickCount; | ||
1237 | landMS = ldMS; | ||
1238 | } | ||
1239 | |||
1240 | int tickCount = Environment.TickCount; | ||
1241 | otherMS = tickCount - otherMS; | ||
1242 | tmpFrameMS -= tickCount; | ||
1243 | frameMS = tmpFrameMS; | ||
1244 | lastCompletedFrame = tickCount; | ||
1092 | 1245 | ||
1093 | otherMS = Environment.TickCount - otherMS; | ||
1094 | // if (m_frame%m_update_avatars == 0) | 1246 | // if (m_frame%m_update_avatars == 0) |
1095 | // UpdateInWorldTime(); | 1247 | // UpdateInWorldTime(); |
1096 | StatsReporter.AddPhysicsFPS(physicsFPS); | 1248 | StatsReporter.AddPhysicsFPS(physicsFPS); |
1097 | StatsReporter.AddTimeDilation(m_timedilation); | 1249 | StatsReporter.AddTimeDilation(TimeDilation); |
1098 | StatsReporter.AddFPS(1); | 1250 | StatsReporter.AddFPS(1); |
1099 | StatsReporter.AddInPackets(0); | ||
1100 | StatsReporter.SetRootAgents(m_sceneGraph.GetRootAgentCount()); | 1251 | StatsReporter.SetRootAgents(m_sceneGraph.GetRootAgentCount()); |
1101 | StatsReporter.SetChildAgents(m_sceneGraph.GetChildAgentCount()); | 1252 | StatsReporter.SetChildAgents(m_sceneGraph.GetChildAgentCount()); |
1102 | StatsReporter.SetObjects(m_sceneGraph.GetTotalObjectsCount()); | 1253 | StatsReporter.SetObjects(m_sceneGraph.GetTotalObjectsCount()); |
1103 | StatsReporter.SetActiveObjects(m_sceneGraph.GetActiveObjectsCount()); | 1254 | StatsReporter.SetActiveObjects(m_sceneGraph.GetActiveObjectsCount()); |
1104 | frameMS = Environment.TickCount - frameMS; | ||
1105 | StatsReporter.addFrameMS(frameMS); | 1255 | StatsReporter.addFrameMS(frameMS); |
1106 | StatsReporter.addPhysicsMS(physicsMS); | 1256 | StatsReporter.addPhysicsMS(physicsMS + physicsMS2); |
1107 | StatsReporter.addOtherMS(otherMS); | 1257 | StatsReporter.addOtherMS(otherMS); |
1108 | StatsReporter.SetActiveScripts(m_sceneGraph.GetActiveScriptsCount()); | 1258 | StatsReporter.SetActiveScripts(m_sceneGraph.GetActiveScriptsCount()); |
1109 | StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS()); | 1259 | StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS()); |
1110 | } | 1260 | } |
1111 | if (loginsdisabled && (m_frame > 20)) | 1261 | |
1262 | if (loginsdisabled && m_frame > 20) | ||
1112 | { | 1263 | { |
1113 | // In 99.9% of cases it is a bad idea to manually force garbage collection. However, | 1264 | // In 99.9% of cases it is a bad idea to manually force garbage collection. However, |
1114 | // this is a rare case where we know we have just went through a long cycle of heap | 1265 | // this is a rare case where we know we have just went through a long cycle of heap |
@@ -1141,18 +1292,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1141 | } | 1292 | } |
1142 | finally | 1293 | finally |
1143 | { | 1294 | { |
1144 | //updateLock.ReleaseMutex(); | ||
1145 | // Get actual time dilation | ||
1146 | float tmpval = (m_timespan / (float)SinceLastFrame.TotalSeconds); | ||
1147 | |||
1148 | // If actual time dilation is greater then one, we're catching up, so subtract | ||
1149 | // the amount that's greater then 1 from the time dilation | ||
1150 | if (tmpval > 1.0) | ||
1151 | { | ||
1152 | tmpval = tmpval - (tmpval - 1.0f); | ||
1153 | } | ||
1154 | m_timedilation = tmpval; | ||
1155 | |||
1156 | m_lastupdate = DateTime.UtcNow; | 1295 | m_lastupdate = DateTime.UtcNow; |
1157 | } | 1296 | } |
1158 | maintc = Environment.TickCount - maintc; | 1297 | maintc = Environment.TickCount - maintc; |
@@ -1183,9 +1322,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1183 | { | 1322 | { |
1184 | lock (m_groupsWithTargets) | 1323 | lock (m_groupsWithTargets) |
1185 | { | 1324 | { |
1186 | foreach (KeyValuePair<UUID, SceneObjectGroup> kvp in m_groupsWithTargets) | 1325 | foreach (SceneObjectGroup entry in m_groupsWithTargets.Values) |
1187 | { | 1326 | { |
1188 | kvp.Value.checkAtTargets(); | 1327 | entry.checkAtTargets(); |
1189 | } | 1328 | } |
1190 | } | 1329 | } |
1191 | } | 1330 | } |
@@ -4244,6 +4383,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
4244 | return m_sceneGraph.GetSceneObjectPart(fullID); | 4383 | return m_sceneGraph.GetSceneObjectPart(fullID); |
4245 | } | 4384 | } |
4246 | 4385 | ||
4386 | /// <summary> | ||
4387 | /// Get a scene object group that contains the prim with the given local id | ||
4388 | /// </summary> | ||
4389 | /// <param name="localID"></param> | ||
4390 | /// <returns>null if no scene object group containing that prim is found</returns> | ||
4391 | public SceneObjectGroup GetGroupByPrim(uint localID) | ||
4392 | { | ||
4393 | return m_sceneGraph.GetGroupByPrim(localID); | ||
4394 | } | ||
4395 | |||
4247 | public bool TryGetAvatar(UUID avatarId, out ScenePresence avatar) | 4396 | public bool TryGetAvatar(UUID avatarId, out ScenePresence avatar) |
4248 | { | 4397 | { |
4249 | return m_sceneGraph.TryGetAvatar(avatarId, out avatar); | 4398 | return m_sceneGraph.TryGetAvatar(avatarId, out avatar); |
@@ -4606,7 +4755,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4606 | SceneObjectPart trackedBody = GetSceneObjectPart(joint.TrackedBodyName); // FIXME: causes a sequential lookup | 4755 | SceneObjectPart trackedBody = GetSceneObjectPart(joint.TrackedBodyName); // FIXME: causes a sequential lookup |
4607 | if (trackedBody == null) return; // the actor may have been deleted but the joint still lingers around a few frames waiting for deletion. during this time, trackedBody is NULL to prevent further motion of the joint proxy. | 4756 | if (trackedBody == null) return; // the actor may have been deleted but the joint still lingers around a few frames waiting for deletion. during this time, trackedBody is NULL to prevent further motion of the joint proxy. |
4608 | jointProxyObject.Velocity = trackedBody.Velocity; | 4757 | jointProxyObject.Velocity = trackedBody.Velocity; |
4609 | jointProxyObject.RotationalVelocity = trackedBody.RotationalVelocity; | 4758 | jointProxyObject.AngularVelocity = trackedBody.AngularVelocity; |
4610 | switch (joint.Type) | 4759 | switch (joint.Type) |
4611 | { | 4760 | { |
4612 | case PhysicsJointType.Ball: | 4761 | case PhysicsJointType.Ball: |
diff --git a/OpenSim/Region/Framework/Scenes/SceneBase.cs b/OpenSim/Region/Framework/Scenes/SceneBase.cs index 82731d1..1547f9a 100644 --- a/OpenSim/Region/Framework/Scenes/SceneBase.cs +++ b/OpenSim/Region/Framework/Scenes/SceneBase.cs | |||
@@ -106,9 +106,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
106 | 106 | ||
107 | public float TimeDilation | 107 | public float TimeDilation |
108 | { | 108 | { |
109 | get { return m_timedilation; } | 109 | get { return 1.0f; } |
110 | } | 110 | } |
111 | protected float m_timedilation = 1.0f; | ||
112 | 111 | ||
113 | protected ulong m_regionHandle; | 112 | protected ulong m_regionHandle; |
114 | protected string m_regionName; | 113 | protected string m_regionName; |
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index db055f9..2fdb48d 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs | |||
@@ -369,26 +369,30 @@ namespace OpenSim.Region.Framework.Scenes | |||
369 | /// </summary> | 369 | /// </summary> |
370 | protected internal void UpdateObjectGroups() | 370 | protected internal void UpdateObjectGroups() |
371 | { | 371 | { |
372 | Dictionary<UUID, SceneObjectGroup> updates; | 372 | List<SceneObjectGroup> updates; |
373 | |||
373 | // Some updates add more updates to the updateList. | 374 | // Some updates add more updates to the updateList. |
374 | // Get the current list of updates and clear the list before iterating | 375 | // Get the current list of updates and clear the list before iterating |
375 | lock (m_updateList) | 376 | lock (m_updateList) |
376 | { | 377 | { |
377 | updates = new Dictionary<UUID, SceneObjectGroup>(m_updateList); | 378 | updates = new List<SceneObjectGroup>(m_updateList.Values); |
378 | m_updateList.Clear(); | 379 | m_updateList.Clear(); |
379 | } | 380 | } |
381 | |||
380 | // Go through all updates | 382 | // Go through all updates |
381 | foreach (KeyValuePair<UUID, SceneObjectGroup> kvp in updates) | 383 | for (int i = 0; i < updates.Count; i++) |
382 | { | 384 | { |
385 | SceneObjectGroup sog = updates[i]; | ||
386 | |||
383 | // Don't abort the whole update if one entity happens to give us an exception. | 387 | // Don't abort the whole update if one entity happens to give us an exception. |
384 | try | 388 | try |
385 | { | 389 | { |
386 | kvp.Value.Update(); | 390 | sog.Update(); |
387 | } | 391 | } |
388 | catch (Exception e) | 392 | catch (Exception e) |
389 | { | 393 | { |
390 | m_log.ErrorFormat( | 394 | m_log.ErrorFormat( |
391 | "[INNER SCENE]: Failed to update {0}, {1} - {2}", kvp.Value.Name, kvp.Value.UUID, e); | 395 | "[INNER SCENE]: Failed to update {0}, {1} - {2}", sog.Name, sog.UUID, e); |
392 | } | 396 | } |
393 | } | 397 | } |
394 | } | 398 | } |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index ab7abbe..ea4f2c7 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | |||
@@ -204,6 +204,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
204 | get { return m_parts.Count; } | 204 | get { return m_parts.Count; } |
205 | } | 205 | } |
206 | 206 | ||
207 | protected Quaternion m_rotation = Quaternion.Identity; | ||
208 | |||
209 | public virtual Quaternion Rotation | ||
210 | { | ||
211 | get { return m_rotation; } | ||
212 | set { m_rotation = value; } | ||
213 | } | ||
214 | |||
207 | public Quaternion GroupRotation | 215 | public Quaternion GroupRotation |
208 | { | 216 | { |
209 | get { return m_rootPart.RotationOffset; } | 217 | get { return m_rootPart.RotationOffset; } |
@@ -1015,9 +1023,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1015 | } | 1023 | } |
1016 | } | 1024 | } |
1017 | 1025 | ||
1018 | public float GetTimeDilation() | 1026 | public ushort GetTimeDilation() |
1019 | { | 1027 | { |
1020 | return m_scene.TimeDilation; | 1028 | return Utils.FloatToUInt16(m_scene.TimeDilation, 0.0f, 1.0f); |
1021 | } | 1029 | } |
1022 | 1030 | ||
1023 | /// <summary> | 1031 | /// <summary> |
@@ -1896,28 +1904,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
1896 | { | 1904 | { |
1897 | bool UsePhysics = ((RootPart.Flags & PrimFlags.Physics) != 0); | 1905 | bool UsePhysics = ((RootPart.Flags & PrimFlags.Physics) != 0); |
1898 | 1906 | ||
1899 | //if (IsAttachment) | 1907 | if (UsePhysics && !AbsolutePosition.ApproxEquals(lastPhysGroupPos, 0.02f)) |
1900 | //{ | ||
1901 | //foreach (SceneObjectPart part in m_parts.Values) | ||
1902 | //{ | ||
1903 | //part.SendScheduledUpdates(); | ||
1904 | //} | ||
1905 | //return; | ||
1906 | //} | ||
1907 | |||
1908 | if (UsePhysics && Util.DistanceLessThan(lastPhysGroupPos, AbsolutePosition, 0.02)) | ||
1909 | { | 1908 | { |
1910 | m_rootPart.UpdateFlag = 1; | 1909 | m_rootPart.UpdateFlag = 1; |
1911 | lastPhysGroupPos = AbsolutePosition; | 1910 | lastPhysGroupPos = AbsolutePosition; |
1912 | } | 1911 | } |
1913 | 1912 | ||
1914 | if (UsePhysics && ((Math.Abs(lastPhysGroupRot.W - GroupRotation.W) > 0.1) | 1913 | if (UsePhysics && !GroupRotation.ApproxEquals(lastPhysGroupRot, 0.1f)) |
1915 | || (Math.Abs(lastPhysGroupRot.X - GroupRotation.X) > 0.1) | ||
1916 | || (Math.Abs(lastPhysGroupRot.Y - GroupRotation.Y) > 0.1) | ||
1917 | || (Math.Abs(lastPhysGroupRot.Z - GroupRotation.Z) > 0.1))) | ||
1918 | { | 1914 | { |
1919 | m_rootPart.UpdateFlag = 1; | 1915 | m_rootPart.UpdateFlag = 1; |
1920 | |||
1921 | lastPhysGroupRot = GroupRotation; | 1916 | lastPhysGroupRot = GroupRotation; |
1922 | } | 1917 | } |
1923 | 1918 | ||
@@ -2011,12 +2006,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2011 | /// Note: this may not be cused by opensim (it probably should) but it's used by | 2006 | /// Note: this may not be cused by opensim (it probably should) but it's used by |
2012 | /// external modules. | 2007 | /// external modules. |
2013 | /// </summary> | 2008 | /// </summary> |
2014 | public void SendGroupRootUpdate() | 2009 | public void SendGroupRootTerseUpdate() |
2015 | { | 2010 | { |
2016 | if (IsDeleted) | 2011 | if (IsDeleted) |
2017 | return; | 2012 | return; |
2018 | 2013 | ||
2019 | RootPart.SendFullUpdateToAllClients(); | 2014 | RootPart.SendTerseUpdateToAllClients(); |
2020 | } | 2015 | } |
2021 | 2016 | ||
2022 | public void QueueForUpdateCheck() | 2017 | public void QueueForUpdateCheck() |
@@ -2998,12 +2993,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
2998 | /// <param name="rot"></param> | 2993 | /// <param name="rot"></param> |
2999 | public void UpdateGroupRotationR(Quaternion rot) | 2994 | public void UpdateGroupRotationR(Quaternion rot) |
3000 | { | 2995 | { |
3001 | |||
3002 | m_rootPart.UpdateRotation(rot); | 2996 | m_rootPart.UpdateRotation(rot); |
3003 | if (m_rootPart.PhysActor != null) | 2997 | |
2998 | PhysicsActor actor = m_rootPart.PhysActor; | ||
2999 | if (actor != null) | ||
3004 | { | 3000 | { |
3005 | m_rootPart.PhysActor.Orientation = m_rootPart.RotationOffset; | 3001 | actor.Orientation = m_rootPart.RotationOffset; |
3006 | m_scene.PhysicsScene.AddPhysicsActorTaint(m_rootPart.PhysActor); | 3002 | m_scene.PhysicsScene.AddPhysicsActorTaint(actor); |
3007 | } | 3003 | } |
3008 | 3004 | ||
3009 | HasGroupChanged = true; | 3005 | HasGroupChanged = true; |
@@ -3018,11 +3014,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
3018 | public void UpdateGroupRotationPR(Vector3 pos, Quaternion rot) | 3014 | public void UpdateGroupRotationPR(Vector3 pos, Quaternion rot) |
3019 | { | 3015 | { |
3020 | m_rootPart.UpdateRotation(rot); | 3016 | m_rootPart.UpdateRotation(rot); |
3021 | if (m_rootPart.PhysActor != null) | 3017 | |
3018 | PhysicsActor actor = m_rootPart.PhysActor; | ||
3019 | if (actor != null) | ||
3022 | { | 3020 | { |
3023 | m_rootPart.PhysActor.Orientation = m_rootPart.RotationOffset; | 3021 | actor.Orientation = m_rootPart.RotationOffset; |
3024 | m_scene.PhysicsScene.AddPhysicsActorTaint(m_rootPart.PhysActor); | 3022 | m_scene.PhysicsScene.AddPhysicsActorTaint(actor); |
3025 | } | 3023 | } |
3024 | |||
3026 | AbsolutePosition = pos; | 3025 | AbsolutePosition = pos; |
3027 | 3026 | ||
3028 | HasGroupChanged = true; | 3027 | HasGroupChanged = true; |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 7d889ee..bf2f3d3 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | |||
@@ -243,7 +243,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
243 | protected SceneObjectGroup m_parentGroup; | 243 | protected SceneObjectGroup m_parentGroup; |
244 | protected byte[] m_particleSystem = Utils.EmptyBytes; | 244 | protected byte[] m_particleSystem = Utils.EmptyBytes; |
245 | protected ulong m_regionHandle; | 245 | protected ulong m_regionHandle; |
246 | protected Quaternion m_rotationOffset; | 246 | protected Quaternion m_rotationOffset = Quaternion.Identity; |
247 | protected PrimitiveBaseShape m_shape; | 247 | protected PrimitiveBaseShape m_shape; |
248 | protected UUID m_uuid; | 248 | protected UUID m_uuid; |
249 | protected Vector3 m_velocity; | 249 | protected Vector3 m_velocity; |
@@ -253,6 +253,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
253 | protected Vector3 m_lastVelocity; | 253 | protected Vector3 m_lastVelocity; |
254 | protected Vector3 m_lastAcceleration; | 254 | protected Vector3 m_lastAcceleration; |
255 | protected Vector3 m_lastAngularVelocity; | 255 | protected Vector3 m_lastAngularVelocity; |
256 | protected int m_lastTerseSent; | ||
256 | 257 | ||
257 | // TODO: Those have to be changed into persistent properties at some later point, | 258 | // TODO: Those have to be changed into persistent properties at some later point, |
258 | // or sit-camera on vehicles will break on sim-crossing. | 259 | // or sit-camera on vehicles will break on sim-crossing. |
@@ -506,20 +507,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
506 | get | 507 | get |
507 | { | 508 | { |
508 | // If this is a linkset, we don't want the physics engine mucking up our group position here. | 509 | // If this is a linkset, we don't want the physics engine mucking up our group position here. |
509 | if (PhysActor != null && _parentID == 0) | 510 | PhysicsActor actor = PhysActor; |
511 | if (actor != null && _parentID == 0) | ||
510 | { | 512 | { |
511 | m_groupPosition.X = PhysActor.Position.X; | 513 | m_groupPosition = actor.Position; |
512 | m_groupPosition.Y = PhysActor.Position.Y; | ||
513 | m_groupPosition.Z = PhysActor.Position.Z; | ||
514 | } | 514 | } |
515 | 515 | ||
516 | if (IsAttachment) | 516 | if (IsAttachment) |
517 | { | 517 | { |
518 | ScenePresence sp = m_parentGroup.Scene.GetScenePresence(AttachedAvatar); | 518 | ScenePresence sp = m_parentGroup.Scene.GetScenePresence(AttachedAvatar); |
519 | if (sp != null) | 519 | if (sp != null) |
520 | { | ||
521 | return sp.AbsolutePosition; | 520 | return sp.AbsolutePosition; |
522 | } | ||
523 | } | 521 | } |
524 | 522 | ||
525 | return m_groupPosition; | 523 | return m_groupPosition; |
@@ -530,26 +528,25 @@ namespace OpenSim.Region.Framework.Scenes | |||
530 | 528 | ||
531 | m_groupPosition = value; | 529 | m_groupPosition = value; |
532 | 530 | ||
533 | if (PhysActor != null) | 531 | PhysicsActor actor = PhysActor; |
532 | if (actor != null) | ||
534 | { | 533 | { |
535 | try | 534 | try |
536 | { | 535 | { |
537 | // Root prim actually goes at Position | 536 | // Root prim actually goes at Position |
538 | if (_parentID == 0) | 537 | if (_parentID == 0) |
539 | { | 538 | { |
540 | PhysActor.Position = value; | 539 | actor.Position = value; |
541 | } | 540 | } |
542 | else | 541 | else |
543 | { | 542 | { |
544 | // To move the child prim in respect to the group position and rotation we have to calculate | 543 | // To move the child prim in respect to the group position and rotation we have to calculate |
545 | Vector3 resultingposition = GetWorldPosition(); | 544 | actor.Position = GetWorldPosition(); |
546 | PhysActor.Position = resultingposition; | 545 | actor.Orientation = GetWorldRotation(); |
547 | Quaternion resultingrot = GetWorldRotation(); | ||
548 | PhysActor.Orientation = resultingrot; | ||
549 | } | 546 | } |
550 | 547 | ||
551 | // Tell the physics engines that this prim changed. | 548 | // Tell the physics engines that this prim changed. |
552 | m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor); | 549 | m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor); |
553 | } | 550 | } |
554 | catch (Exception e) | 551 | catch (Exception e) |
555 | { | 552 | { |
@@ -582,15 +579,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
582 | 579 | ||
583 | if (ParentGroup != null && !ParentGroup.IsDeleted) | 580 | if (ParentGroup != null && !ParentGroup.IsDeleted) |
584 | { | 581 | { |
585 | if (_parentID != 0 && PhysActor != null) | 582 | PhysicsActor actor = PhysActor; |
583 | if (_parentID != 0 && actor != null) | ||
586 | { | 584 | { |
587 | Vector3 resultingposition = GetWorldPosition(); | 585 | actor.Position = GetWorldPosition(); |
588 | PhysActor.Position = resultingposition; | 586 | actor.Orientation = GetWorldRotation(); |
589 | Quaternion resultingrot = GetWorldRotation(); | ||
590 | PhysActor.Orientation = resultingrot; | ||
591 | 587 | ||
592 | // Tell the physics engines that this prim changed. | 588 | // Tell the physics engines that this prim changed. |
593 | m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor); | 589 | m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor); |
594 | } | 590 | } |
595 | } | 591 | } |
596 | } | 592 | } |
@@ -601,12 +597,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
601 | get | 597 | get |
602 | { | 598 | { |
603 | // We don't want the physics engine mucking up the rotations in a linkset | 599 | // We don't want the physics engine mucking up the rotations in a linkset |
604 | if ((_parentID == 0) && (Shape.PCode != 9 || Shape.State == 0) && (PhysActor != null)) | 600 | PhysicsActor actor = PhysActor; |
601 | if (_parentID == 0 && (Shape.PCode != 9 || Shape.State == 0) && actor != null) | ||
605 | { | 602 | { |
606 | if (PhysActor.Orientation.X != 0 || PhysActor.Orientation.Y != 0 | 603 | if (actor.Orientation.X != 0f || actor.Orientation.Y != 0f |
607 | || PhysActor.Orientation.Z != 0 || PhysActor.Orientation.W != 0) | 604 | || actor.Orientation.Z != 0f || actor.Orientation.W != 0f) |
608 | { | 605 | { |
609 | m_rotationOffset = PhysActor.Orientation; | 606 | m_rotationOffset = actor.Orientation; |
610 | } | 607 | } |
611 | } | 608 | } |
612 | 609 | ||
@@ -618,24 +615,25 @@ namespace OpenSim.Region.Framework.Scenes | |||
618 | StoreUndoState(); | 615 | StoreUndoState(); |
619 | m_rotationOffset = value; | 616 | m_rotationOffset = value; |
620 | 617 | ||
621 | if (PhysActor != null) | 618 | PhysicsActor actor = PhysActor; |
619 | if (actor != null) | ||
622 | { | 620 | { |
623 | try | 621 | try |
624 | { | 622 | { |
625 | // Root prim gets value directly | 623 | // Root prim gets value directly |
626 | if (_parentID == 0) | 624 | if (_parentID == 0) |
627 | { | 625 | { |
628 | PhysActor.Orientation = value; | 626 | actor.Orientation = value; |
629 | //m_log.Info("[PART]: RO1:" + PhysActor.Orientation.ToString()); | 627 | //m_log.Info("[PART]: RO1:" + actor.Orientation.ToString()); |
630 | } | 628 | } |
631 | else | 629 | else |
632 | { | 630 | { |
633 | // Child prim we have to calculate it's world rotationwel | 631 | // Child prim we have to calculate it's world rotationwel |
634 | Quaternion resultingrotation = GetWorldRotation(); | 632 | Quaternion resultingrotation = GetWorldRotation(); |
635 | PhysActor.Orientation = resultingrotation; | 633 | actor.Orientation = resultingrotation; |
636 | //m_log.Info("[PART]: RO2:" + PhysActor.Orientation.ToString()); | 634 | //m_log.Info("[PART]: RO2:" + actor.Orientation.ToString()); |
637 | } | 635 | } |
638 | m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor); | 636 | m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor); |
639 | //} | 637 | //} |
640 | } | 638 | } |
641 | catch (Exception ex) | 639 | catch (Exception ex) |
@@ -652,16 +650,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
652 | { | 650 | { |
653 | get | 651 | get |
654 | { | 652 | { |
655 | //if (PhysActor.Velocity.X != 0 || PhysActor.Velocity.Y != 0 | 653 | PhysicsActor actor = PhysActor; |
656 | //|| PhysActor.Velocity.Z != 0) | 654 | if (actor != null) |
657 | //{ | ||
658 | if (PhysActor != null) | ||
659 | { | 655 | { |
660 | if (PhysActor.IsPhysical) | 656 | if (actor.IsPhysical) |
661 | { | 657 | { |
662 | m_velocity.X = PhysActor.Velocity.X; | 658 | m_velocity = actor.Velocity; |
663 | m_velocity.Y = PhysActor.Velocity.Y; | ||
664 | m_velocity.Z = PhysActor.Velocity.Z; | ||
665 | } | 659 | } |
666 | } | 660 | } |
667 | 661 | ||
@@ -671,31 +665,28 @@ namespace OpenSim.Region.Framework.Scenes | |||
671 | set | 665 | set |
672 | { | 666 | { |
673 | m_velocity = value; | 667 | m_velocity = value; |
674 | if (PhysActor != null) | 668 | |
669 | PhysicsActor actor = PhysActor; | ||
670 | if (actor != null) | ||
675 | { | 671 | { |
676 | if (PhysActor.IsPhysical) | 672 | if (actor.IsPhysical) |
677 | { | 673 | { |
678 | PhysActor.Velocity = value; | 674 | actor.Velocity = value; |
679 | m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor); | 675 | m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor); |
680 | } | 676 | } |
681 | } | 677 | } |
682 | } | 678 | } |
683 | } | 679 | } |
684 | 680 | ||
685 | public Vector3 RotationalVelocity | ||
686 | { | ||
687 | get { return AngularVelocity; } | ||
688 | set { AngularVelocity = value; } | ||
689 | } | ||
690 | |||
691 | /// <summary></summary> | 681 | /// <summary></summary> |
692 | public Vector3 AngularVelocity | 682 | public Vector3 AngularVelocity |
693 | { | 683 | { |
694 | get | 684 | get |
695 | { | 685 | { |
696 | if ((PhysActor != null) && PhysActor.IsPhysical) | 686 | PhysicsActor actor = PhysActor; |
687 | if ((actor != null) && actor.IsPhysical) | ||
697 | { | 688 | { |
698 | m_angularVelocity.FromBytes(PhysActor.RotationalVelocity.GetBytes(), 0); | 689 | m_angularVelocity = actor.RotationalVelocity; |
699 | } | 690 | } |
700 | return m_angularVelocity; | 691 | return m_angularVelocity; |
701 | } | 692 | } |
@@ -715,9 +706,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
715 | set | 706 | set |
716 | { | 707 | { |
717 | m_description = value; | 708 | m_description = value; |
718 | if (PhysActor != null) | 709 | PhysicsActor actor = PhysActor; |
710 | if (actor != null) | ||
719 | { | 711 | { |
720 | PhysActor.SOPDescription = value; | 712 | actor.SOPDescription = value; |
721 | } | 713 | } |
722 | } | 714 | } |
723 | } | 715 | } |
@@ -808,21 +800,23 @@ namespace OpenSim.Region.Framework.Scenes | |||
808 | set | 800 | set |
809 | { | 801 | { |
810 | StoreUndoState(); | 802 | StoreUndoState(); |
811 | if (m_shape != null) { | 803 | if (m_shape != null) |
812 | m_shape.Scale = value; | ||
813 | |||
814 | if (PhysActor != null && m_parentGroup != null) | ||
815 | { | 804 | { |
816 | if (m_parentGroup.Scene != null) | 805 | m_shape.Scale = value; |
806 | |||
807 | PhysicsActor actor = PhysActor; | ||
808 | if (actor != null && m_parentGroup != null) | ||
817 | { | 809 | { |
818 | if (m_parentGroup.Scene.PhysicsScene != null) | 810 | if (m_parentGroup.Scene != null) |
819 | { | 811 | { |
820 | PhysActor.Size = m_shape.Scale; | 812 | if (m_parentGroup.Scene.PhysicsScene != null) |
821 | m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor); | 813 | { |
814 | actor.Size = m_shape.Scale; | ||
815 | m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor); | ||
816 | } | ||
822 | } | 817 | } |
823 | } | 818 | } |
824 | } | 819 | } |
825 | } | ||
826 | TriggerScriptChangedEvent(Changed.SCALE); | 820 | TriggerScriptChangedEvent(Changed.SCALE); |
827 | } | 821 | } |
828 | } | 822 | } |
@@ -1056,8 +1050,6 @@ if (m_shape != null) { | |||
1056 | 1050 | ||
1057 | #endregion Public Properties with only Get | 1051 | #endregion Public Properties with only Get |
1058 | 1052 | ||
1059 | |||
1060 | |||
1061 | #region Private Methods | 1053 | #region Private Methods |
1062 | 1054 | ||
1063 | private uint ApplyMask(uint val, bool set, uint mask) | 1055 | private uint ApplyMask(uint val, bool set, uint mask) |
@@ -1072,14 +1064,6 @@ if (m_shape != null) { | |||
1072 | } | 1064 | } |
1073 | } | 1065 | } |
1074 | 1066 | ||
1075 | /// <summary> | ||
1076 | /// Clear all pending updates of parts to clients | ||
1077 | /// </summary> | ||
1078 | private void ClearUpdateSchedule() | ||
1079 | { | ||
1080 | m_updateFlag = 0; | ||
1081 | } | ||
1082 | |||
1083 | private void SendObjectPropertiesToClient(UUID AgentID) | 1067 | private void SendObjectPropertiesToClient(UUID AgentID) |
1084 | { | 1068 | { |
1085 | ScenePresence[] avatars = m_parentGroup.Scene.GetScenePresences(); | 1069 | ScenePresence[] avatars = m_parentGroup.Scene.GetScenePresences(); |
@@ -1551,9 +1535,9 @@ if (m_shape != null) { | |||
1551 | m_parentGroup.Scene.PhysicsScene.RequestJointDeletion(Name); // FIXME: what if the name changed? | 1535 | m_parentGroup.Scene.PhysicsScene.RequestJointDeletion(Name); // FIXME: what if the name changed? |
1552 | 1536 | ||
1553 | // make sure client isn't interpolating the joint proxy object | 1537 | // make sure client isn't interpolating the joint proxy object |
1554 | Velocity = new Vector3(0, 0, 0); | 1538 | Velocity = Vector3.Zero; |
1555 | RotationalVelocity = new Vector3(0, 0, 0); | 1539 | AngularVelocity = Vector3.Zero; |
1556 | Acceleration = new Vector3(0, 0, 0); | 1540 | Acceleration = Vector3.Zero; |
1557 | } | 1541 | } |
1558 | } | 1542 | } |
1559 | } | 1543 | } |
@@ -1816,7 +1800,7 @@ if (m_shape != null) { | |||
1816 | } | 1800 | } |
1817 | 1801 | ||
1818 | CollisionEventUpdate a = (CollisionEventUpdate)e; | 1802 | CollisionEventUpdate a = (CollisionEventUpdate)e; |
1819 | Dictionary<uint, float> collissionswith = a.m_objCollisionList; | 1803 | Dictionary<uint, ContactPoint> collissionswith = a.m_objCollisionList; |
1820 | List<uint> thisHitColliders = new List<uint>(); | 1804 | List<uint> thisHitColliders = new List<uint>(); |
1821 | List<uint> endedColliders = new List<uint>(); | 1805 | List<uint> endedColliders = new List<uint>(); |
1822 | List<uint> startedColliders = new List<uint>(); | 1806 | List<uint> startedColliders = new List<uint>(); |
@@ -2387,8 +2371,8 @@ if (m_shape != null) { | |||
2387 | //isattachment = ParentGroup.RootPart.IsAttachment; | 2371 | //isattachment = ParentGroup.RootPart.IsAttachment; |
2388 | 2372 | ||
2389 | byte[] color = new byte[] {m_color.R, m_color.G, m_color.B, m_color.A}; | 2373 | byte[] color = new byte[] {m_color.R, m_color.G, m_color.B, m_color.A}; |
2390 | remoteClient.SendPrimitiveToClient(new SendPrimitiveData(m_regionHandle, (ushort)(m_parentGroup.GetTimeDilation() * (float)ushort.MaxValue), LocalId, m_shape, | 2374 | remoteClient.SendPrimitiveToClient(new SendPrimitiveData(m_regionHandle, m_parentGroup.GetTimeDilation(), LocalId, m_shape, |
2391 | lPos, Velocity, Acceleration, RotationOffset, RotationalVelocity, clientFlags, m_uuid, _ownerID, | 2375 | lPos, Velocity, Acceleration, RotationOffset, AngularVelocity, clientFlags, m_uuid, _ownerID, |
2392 | m_text, color, _parentID, m_particleSystem, m_clickAction, (byte)m_material, m_TextureAnimation, IsAttachment, | 2376 | m_text, color, _parentID, m_particleSystem, m_clickAction, (byte)m_material, m_TextureAnimation, IsAttachment, |
2393 | AttachmentPoint,FromItemID, Sound, SoundGain, SoundFlags, SoundRadius, ParentGroup.GetUpdatePriority(remoteClient))); | 2377 | AttachmentPoint,FromItemID, Sound, SoundGain, SoundFlags, SoundRadius, ParentGroup.GetUpdatePriority(remoteClient))); |
2394 | } | 2378 | } |
@@ -2398,20 +2382,23 @@ if (m_shape != null) { | |||
2398 | /// </summary> | 2382 | /// </summary> |
2399 | public void SendScheduledUpdates() | 2383 | public void SendScheduledUpdates() |
2400 | { | 2384 | { |
2401 | const float VELOCITY_TOLERANCE = 0.01f; | 2385 | const float ROTATION_TOLERANCE = 0.01f; |
2402 | const float POSITION_TOLERANCE = 0.1f; | 2386 | const float VELOCITY_TOLERANCE = 0.001f; |
2387 | const float POSITION_TOLERANCE = 0.05f; // I don't like this, but I suppose it's necessary | ||
2388 | const int TIME_MS_TOLERANCE = 200; //llSetPos has a 200ms delay. This should NOT be 3 seconds. | ||
2403 | 2389 | ||
2404 | if (m_updateFlag == 1) | 2390 | if (m_updateFlag == 1) |
2405 | { | 2391 | { |
2406 | // Throw away duplicate or insignificant updates | 2392 | // Throw away duplicate or insignificant updates |
2407 | if (RotationOffset != m_lastRotation || | 2393 | if (!RotationOffset.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE) || |
2408 | Acceleration != m_lastAcceleration || | 2394 | !Acceleration.Equals(m_lastAcceleration) || |
2409 | (Velocity - m_lastVelocity).Length() > VELOCITY_TOLERANCE || | 2395 | !Velocity.ApproxEquals(m_lastVelocity, VELOCITY_TOLERANCE) || |
2410 | (RotationalVelocity - m_lastAngularVelocity).Length() > VELOCITY_TOLERANCE || | 2396 | !AngularVelocity.ApproxEquals(m_lastAngularVelocity, VELOCITY_TOLERANCE) || |
2411 | (OffsetPosition - m_lastPosition).Length() > POSITION_TOLERANCE) | 2397 | !OffsetPosition.ApproxEquals(m_lastPosition, POSITION_TOLERANCE) || |
2398 | Environment.TickCount - m_lastTerseSent > TIME_MS_TOLERANCE) | ||
2412 | { | 2399 | { |
2413 | AddTerseUpdateToAllAvatars(); | 2400 | AddTerseUpdateToAllAvatars(); |
2414 | ClearUpdateSchedule(); | 2401 | |
2415 | 2402 | ||
2416 | // This causes the Scene to 'poll' physical objects every couple of frames | 2403 | // This causes the Scene to 'poll' physical objects every couple of frames |
2417 | // bad, so it's been replaced by an event driven method. | 2404 | // bad, so it's been replaced by an event driven method. |
@@ -2426,15 +2413,18 @@ if (m_shape != null) { | |||
2426 | m_lastRotation = RotationOffset; | 2413 | m_lastRotation = RotationOffset; |
2427 | m_lastVelocity = Velocity; | 2414 | m_lastVelocity = Velocity; |
2428 | m_lastAcceleration = Acceleration; | 2415 | m_lastAcceleration = Acceleration; |
2429 | m_lastAngularVelocity = RotationalVelocity; | 2416 | m_lastAngularVelocity = AngularVelocity; |
2417 | m_lastTerseSent = Environment.TickCount; | ||
2430 | } | 2418 | } |
2419 | //Moved this outside of the if clause so updates don't get blocked.. *sigh* | ||
2420 | m_updateFlag = 0; //Why were we calling a function to do this? Inefficient! *screams* | ||
2431 | } | 2421 | } |
2432 | else | 2422 | else |
2433 | { | 2423 | { |
2434 | if (m_updateFlag == 2) // is a new prim, just created/reloaded or has major changes | 2424 | if (m_updateFlag == 2) // is a new prim, just created/reloaded or has major changes |
2435 | { | 2425 | { |
2436 | AddFullUpdateToAllAvatars(); | 2426 | AddFullUpdateToAllAvatars(); |
2437 | ClearUpdateSchedule(); | 2427 | m_updateFlag = 0; //Same here |
2438 | } | 2428 | } |
2439 | } | 2429 | } |
2440 | } | 2430 | } |
@@ -3774,14 +3764,12 @@ if (m_shape != null) { | |||
3774 | 3764 | ||
3775 | Vector3 lPos = OffsetPosition; | 3765 | Vector3 lPos = OffsetPosition; |
3776 | 3766 | ||
3777 | byte state = Shape.State; | ||
3778 | if (IsAttachment) | 3767 | if (IsAttachment) |
3779 | { | 3768 | { |
3780 | if (ParentGroup.RootPart != this) | 3769 | if (ParentGroup.RootPart != this) |
3781 | return; | 3770 | return; |
3782 | 3771 | ||
3783 | lPos = ParentGroup.RootPart.AttachedPos; | 3772 | lPos = ParentGroup.RootPart.AttachedPos; |
3784 | state = (byte)AttachmentPoint; | ||
3785 | } | 3773 | } |
3786 | else | 3774 | else |
3787 | { | 3775 | { |
@@ -3792,10 +3780,9 @@ if (m_shape != null) { | |||
3792 | // Causes this thread to dig into the Client Thread Data. | 3780 | // Causes this thread to dig into the Client Thread Data. |
3793 | // Remember your locking here! | 3781 | // Remember your locking here! |
3794 | remoteClient.SendPrimTerseUpdate(new SendPrimitiveTerseData(m_regionHandle, | 3782 | remoteClient.SendPrimTerseUpdate(new SendPrimitiveTerseData(m_regionHandle, |
3795 | (ushort)(m_parentGroup.GetTimeDilation() * | 3783 | m_parentGroup.GetTimeDilation(), LocalId, lPos, |
3796 | (float)ushort.MaxValue), LocalId, lPos, | ||
3797 | RotationOffset, Velocity, Acceleration, | 3784 | RotationOffset, Velocity, Acceleration, |
3798 | RotationalVelocity, state, FromItemID, | 3785 | AngularVelocity, FromItemID, |
3799 | OwnerID, (int)AttachmentPoint, null, ParentGroup.GetUpdatePriority(remoteClient))); | 3786 | OwnerID, (int)AttachmentPoint, null, ParentGroup.GetUpdatePriority(remoteClient))); |
3800 | } | 3787 | } |
3801 | 3788 | ||
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 87fac0c..08c144a 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -76,8 +76,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
76 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 76 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
77 | 77 | ||
78 | private static readonly byte[] BAKE_INDICES = new byte[] { 8, 9, 10, 11, 19, 20 }; | 78 | private static readonly byte[] BAKE_INDICES = new byte[] { 8, 9, 10, 11, 19, 20 }; |
79 | 79 | // private static readonly byte[] DEFAULT_TEXTURE = AvatarAppearance.GetDefaultTexture().GetBytes(); | |
80 | public static byte[] DefaultTexture; | 80 | private static readonly Array DIR_CONTROL_FLAGS = Enum.GetValues(typeof(Dir_ControlFlags)); |
81 | private static readonly Vector3 HEAD_ADJUSTMENT = new Vector3(0f, 0f, 0.3f); | ||
82 | /// <summary> | ||
83 | /// Experimentally determined "fudge factor" to make sit-target positions | ||
84 | /// the same as in SecondLife. Fudge factor was tested for 36 different | ||
85 | /// test cases including prims of type box, sphere, cylinder, and torus, | ||
86 | /// with varying parameters for sit target location, prim size, prim | ||
87 | /// rotation, prim cut, prim twist, prim taper, and prim shear. See mantis | ||
88 | /// issue #1716 | ||
89 | /// </summary> | ||
90 | private static readonly Vector3 SIT_TARGET_ADJUSTMENT = new Vector3(0.1f, 0.0f, 0.3f); | ||
81 | 91 | ||
82 | public UUID currentParcelUUID = UUID.Zero; | 92 | public UUID currentParcelUUID = UUID.Zero; |
83 | 93 | ||
@@ -92,16 +102,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
92 | //private SceneObjectPart proxyObjectPart = null; | 102 | //private SceneObjectPart proxyObjectPart = null; |
93 | public Vector3 lastKnownAllowedPosition; | 103 | public Vector3 lastKnownAllowedPosition; |
94 | public bool sentMessageAboutRestrictedParcelFlyingDown; | 104 | public bool sentMessageAboutRestrictedParcelFlyingDown; |
105 | public Vector4 CollisionPlane = Vector4.UnitW; | ||
95 | 106 | ||
96 | private Vector3 m_lastPosition; | 107 | private Vector3 m_lastPosition; |
97 | private Quaternion m_lastRotation; | 108 | private Quaternion m_lastRotation; |
98 | private Vector3 m_lastVelocity; | 109 | private Vector3 m_lastVelocity; |
110 | //private int m_lastTerseSent; | ||
99 | 111 | ||
100 | private bool m_updateflag; | 112 | private bool m_updateflag; |
101 | private byte m_movementflag; | 113 | private byte m_movementflag; |
102 | private readonly List<NewForce> m_forcesList = new List<NewForce>(); | 114 | private Vector3? m_forceToApply; |
103 | private uint m_requestedSitTargetID; | 115 | private uint m_requestedSitTargetID; |
104 | private UUID m_requestedSitTargetUUID = UUID.Zero; | 116 | private UUID m_requestedSitTargetUUID; |
105 | private SendCourseLocationsMethod m_sendCourseLocationsMethod; | 117 | private SendCourseLocationsMethod m_sendCourseLocationsMethod; |
106 | 118 | ||
107 | private bool m_startAnimationSet; | 119 | private bool m_startAnimationSet; |
@@ -112,30 +124,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
112 | 124 | ||
113 | private float m_sitAvatarHeight = 2.0f; | 125 | private float m_sitAvatarHeight = 2.0f; |
114 | 126 | ||
115 | // experimentally determined "fudge factor" to make sit-target positions | ||
116 | // the same as in SecondLife. Fudge factor was tested for 36 different | ||
117 | // test cases including prims of type box, sphere, cylinder, and torus, | ||
118 | // with varying parameters for sit target location, prim size, prim | ||
119 | // rotation, prim cut, prim twist, prim taper, and prim shear. See mantis | ||
120 | // issue #1716 | ||
121 | private static readonly Vector3 m_sitTargetCorrectionOffset = new Vector3(0.1f, 0.0f, 0.3f); | ||
122 | private float m_godlevel; | 127 | private float m_godlevel; |
123 | 128 | ||
124 | private bool m_invulnerable = true; | 129 | private bool m_invulnerable = true; |
125 | 130 | ||
126 | private Vector3 m_LastChildAgentUpdatePosition; | 131 | private Vector3 m_lastChildAgentUpdatePosition; |
132 | private Vector3 m_lastChildAgentUpdateCamPosition; | ||
127 | 133 | ||
128 | private int m_perfMonMS; | 134 | private int m_perfMonMS; |
129 | 135 | ||
130 | private bool m_setAlwaysRun; | 136 | private bool m_setAlwaysRun; |
131 | 137 | ||
132 | private string m_movementAnimation = "DEFAULT"; | 138 | private string m_movementAnimation = "DEFAULT"; |
133 | private long m_animPersistUntil = 0; | 139 | private int m_animTickFall; |
134 | private bool m_allowFalling = false; | 140 | private int m_animTickJump; |
135 | private bool m_useFlySlow = false; | 141 | private bool m_useFlySlow; |
136 | private bool m_usePreJump = false; | 142 | private bool m_usePreJump; |
137 | private bool m_forceFly = false; | 143 | private bool m_forceFly; |
138 | private bool m_flyDisabled = false; | 144 | private bool m_flyDisabled; |
139 | 145 | ||
140 | private float m_speedModifier = 1.0f; | 146 | private float m_speedModifier = 1.0f; |
141 | 147 | ||
@@ -143,7 +149,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
143 | 149 | ||
144 | public bool IsRestrictedToRegion; | 150 | public bool IsRestrictedToRegion; |
145 | 151 | ||
146 | public string JID = string.Empty; | 152 | public string JID = String.Empty; |
147 | 153 | ||
148 | // Agent moves with a PID controller causing a force to be exerted. | 154 | // Agent moves with a PID controller causing a force to be exerted. |
149 | private bool m_newCoarseLocations = true; | 155 | private bool m_newCoarseLocations = true; |
@@ -158,43 +164,43 @@ namespace OpenSim.Region.Framework.Scenes | |||
158 | private readonly Vector3[] Dir_Vectors = new Vector3[6]; | 164 | private readonly Vector3[] Dir_Vectors = new Vector3[6]; |
159 | 165 | ||
160 | // Position of agent's camera in world (region cordinates) | 166 | // Position of agent's camera in world (region cordinates) |
161 | protected Vector3 m_CameraCenter = Vector3.Zero; | 167 | protected Vector3 m_CameraCenter; |
162 | protected Vector3 m_lastCameraCenter = Vector3.Zero; | 168 | protected Vector3 m_lastCameraCenter; |
163 | 169 | ||
164 | protected Timer m_reprioritization_timer; | 170 | protected Timer m_reprioritization_timer; |
165 | protected bool m_reprioritizing = false; | 171 | protected bool m_reprioritizing; |
166 | protected bool m_reprioritization_called = false; | 172 | protected bool m_reprioritization_called; |
167 | 173 | ||
168 | // Use these three vectors to figure out what the agent is looking at | 174 | // Use these three vectors to figure out what the agent is looking at |
169 | // Convert it to a Matrix and/or Quaternion | 175 | // Convert it to a Matrix and/or Quaternion |
170 | protected Vector3 m_CameraAtAxis = Vector3.Zero; | 176 | protected Vector3 m_CameraAtAxis; |
171 | protected Vector3 m_CameraLeftAxis = Vector3.Zero; | 177 | protected Vector3 m_CameraLeftAxis; |
172 | protected Vector3 m_CameraUpAxis = Vector3.Zero; | 178 | protected Vector3 m_CameraUpAxis; |
173 | private uint m_AgentControlFlags; | 179 | private AgentManager.ControlFlags m_AgentControlFlags; |
174 | private Quaternion m_headrotation = Quaternion.Identity; | 180 | private Quaternion m_headrotation = Quaternion.Identity; |
175 | private byte m_state; | 181 | private byte m_state; |
176 | 182 | ||
177 | //Reuse the Vector3 instead of creating a new one on the UpdateMovement method | 183 | //Reuse the Vector3 instead of creating a new one on the UpdateMovement method |
178 | private Vector3 movementvector = Vector3.Zero; | 184 | // private Vector3 movementvector; |
179 | 185 | ||
180 | private bool m_autopilotMoving; | 186 | private bool m_autopilotMoving; |
181 | private Vector3 m_autoPilotTarget = Vector3.Zero; | 187 | private Vector3 m_autoPilotTarget; |
182 | private bool m_sitAtAutoTarget; | 188 | private bool m_sitAtAutoTarget; |
183 | 189 | ||
184 | private string m_nextSitAnimation = String.Empty; | 190 | private string m_nextSitAnimation = String.Empty; |
185 | 191 | ||
186 | //PauPaw:Proper PID Controler for autopilot************ | 192 | //PauPaw:Proper PID Controler for autopilot************ |
187 | private bool m_moveToPositionInProgress; | 193 | private bool m_moveToPositionInProgress; |
188 | private Vector3 m_moveToPositionTarget = Vector3.Zero; | 194 | private Vector3 m_moveToPositionTarget; |
189 | 195 | ||
190 | private bool m_followCamAuto = false; | 196 | private bool m_followCamAuto; |
191 | 197 | ||
192 | private int m_movementUpdateCount = 0; | 198 | private int m_movementUpdateCount; |
193 | 199 | ||
194 | private const int NumMovementsBetweenRayCast = 5; | 200 | private const int NumMovementsBetweenRayCast = 5; |
195 | 201 | ||
196 | private bool CameraConstraintActive = false; | 202 | private bool CameraConstraintActive; |
197 | //private int m_moveToPositionStateStatus = 0; | 203 | //private int m_moveToPositionStateStatus; |
198 | //***************************************************** | 204 | //***************************************************** |
199 | 205 | ||
200 | // Agent's Draw distance. | 206 | // Agent's Draw distance. |
@@ -268,11 +274,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
268 | get { return m_godlevel; } | 274 | get { return m_godlevel; } |
269 | } | 275 | } |
270 | 276 | ||
271 | private readonly ulong m_regionHandle; | ||
272 | |||
273 | public ulong RegionHandle | 277 | public ulong RegionHandle |
274 | { | 278 | { |
275 | get { return m_regionHandle; } | 279 | get { return m_rootRegionHandle; } |
276 | } | 280 | } |
277 | 281 | ||
278 | public Vector3 CameraPosition | 282 | public Vector3 CameraPosition |
@@ -379,8 +383,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
379 | 383 | ||
380 | public uint AgentControlFlags | 384 | public uint AgentControlFlags |
381 | { | 385 | { |
382 | get { return m_AgentControlFlags; } | 386 | get { return (uint)m_AgentControlFlags; } |
383 | set { m_AgentControlFlags = value; } | 387 | set { m_AgentControlFlags = (AgentManager.ControlFlags)value; } |
384 | } | 388 | } |
385 | 389 | ||
386 | /// <summary> | 390 | /// <summary> |
@@ -411,31 +415,27 @@ namespace OpenSim.Region.Framework.Scenes | |||
411 | } | 415 | } |
412 | 416 | ||
413 | /// <summary> | 417 | /// <summary> |
414 | /// Absolute position of this avatar in 'region cordinates' | 418 | /// Position of this avatar relative to the region the avatar is in |
415 | /// </summary> | 419 | /// </summary> |
416 | public override Vector3 AbsolutePosition | 420 | public override Vector3 AbsolutePosition |
417 | { | 421 | { |
418 | get | 422 | get |
419 | { | 423 | { |
420 | if (m_physicsActor != null) | 424 | PhysicsActor actor = m_physicsActor; |
421 | { | 425 | if (actor != null) |
422 | m_pos.X = m_physicsActor.Position.X; | 426 | m_pos = actor.Position; |
423 | m_pos.Y = m_physicsActor.Position.Y; | ||
424 | m_pos.Z = m_physicsActor.Position.Z; | ||
425 | } | ||
426 | 427 | ||
427 | return m_parentPosition + m_pos; | 428 | return m_parentPosition + m_pos; |
428 | } | 429 | } |
429 | set | 430 | set |
430 | { | 431 | { |
431 | if (m_physicsActor != null) | 432 | PhysicsActor actor = m_physicsActor; |
433 | if (actor != null) | ||
432 | { | 434 | { |
433 | try | 435 | try |
434 | { | 436 | { |
435 | lock (m_scene.SyncRoot) | 437 | lock (m_scene.SyncRoot) |
436 | { | ||
437 | m_physicsActor.Position = value; | 438 | m_physicsActor.Position = value; |
438 | } | ||
439 | } | 439 | } |
440 | catch (Exception e) | 440 | catch (Exception e) |
441 | { | 441 | { |
@@ -444,7 +444,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
444 | } | 444 | } |
445 | 445 | ||
446 | m_pos = value; | 446 | m_pos = value; |
447 | m_parentPosition = new Vector3(0, 0, 0); | 447 | m_parentPosition = Vector3.Zero; |
448 | } | 448 | } |
449 | } | 449 | } |
450 | 450 | ||
@@ -455,27 +455,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
455 | { | 455 | { |
456 | get | 456 | get |
457 | { | 457 | { |
458 | if (m_physicsActor != null) | 458 | PhysicsActor actor = m_physicsActor; |
459 | { | 459 | if (actor != null) |
460 | m_velocity.X = m_physicsActor.Velocity.X; | 460 | m_velocity = actor.Velocity; |
461 | m_velocity.Y = m_physicsActor.Velocity.Y; | ||
462 | m_velocity.Z = m_physicsActor.Velocity.Z; | ||
463 | } | ||
464 | 461 | ||
465 | return m_velocity; | 462 | return m_velocity; |
466 | } | 463 | } |
467 | set | 464 | set |
468 | { | 465 | { |
469 | //m_log.DebugFormat("In {0} setting velocity of {1} to {2}", m_scene.RegionInfo.RegionName, Name, value); | 466 | PhysicsActor actor = m_physicsActor; |
470 | 467 | if (actor != null) | |
471 | if (m_physicsActor != null) | ||
472 | { | 468 | { |
473 | try | 469 | try |
474 | { | 470 | { |
475 | lock (m_scene.SyncRoot) | 471 | lock (m_scene.SyncRoot) |
476 | { | 472 | actor.Velocity = value; |
477 | m_physicsActor.Velocity = value; | ||
478 | } | ||
479 | } | 473 | } |
480 | catch (Exception e) | 474 | catch (Exception e) |
481 | { | 475 | { |
@@ -487,6 +481,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
487 | } | 481 | } |
488 | } | 482 | } |
489 | 483 | ||
484 | public Quaternion Rotation | ||
485 | { | ||
486 | get { return m_bodyRot; } | ||
487 | set { m_bodyRot = value; } | ||
488 | } | ||
489 | |||
490 | /// <summary> | 490 | /// <summary> |
491 | /// If this is true, agent doesn't have a representation in this scene. | 491 | /// If this is true, agent doesn't have a representation in this scene. |
492 | /// this is an agent 'looking into' this scene from a nearby scene(region) | 492 | /// this is an agent 'looking into' this scene from a nearby scene(region) |
@@ -627,7 +627,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
627 | { | 627 | { |
628 | m_sendCourseLocationsMethod = SendCoarseLocationsDefault; | 628 | m_sendCourseLocationsMethod = SendCoarseLocationsDefault; |
629 | CreateSceneViewer(); | 629 | CreateSceneViewer(); |
630 | m_regionHandle = reginfo.RegionHandle; | 630 | m_rootRegionHandle = reginfo.RegionHandle; |
631 | m_controllingClient = client; | 631 | m_controllingClient = client; |
632 | m_firstname = m_controllingClient.FirstName; | 632 | m_firstname = m_controllingClient.FirstName; |
633 | m_lastname = m_controllingClient.LastName; | 633 | m_lastname = m_controllingClient.LastName; |
@@ -710,25 +710,25 @@ namespace OpenSim.Region.Framework.Scenes | |||
710 | 710 | ||
711 | private void SetDirectionVectors() | 711 | private void SetDirectionVectors() |
712 | { | 712 | { |
713 | Dir_Vectors[0] = new Vector3(1, 0, 0); //FORWARD | 713 | Dir_Vectors[0] = Vector3.UnitX; //FORWARD |
714 | Dir_Vectors[1] = new Vector3(-1, 0, 0); //BACK | 714 | Dir_Vectors[1] = -Vector3.UnitX; //BACK |
715 | Dir_Vectors[2] = new Vector3(0, 1, 0); //LEFT | 715 | Dir_Vectors[2] = Vector3.UnitY; //LEFT |
716 | Dir_Vectors[3] = new Vector3(0, -1, 0); //RIGHT | 716 | Dir_Vectors[3] = -Vector3.UnitY; //RIGHT |
717 | Dir_Vectors[4] = new Vector3(0, 0, 1); //UP | 717 | Dir_Vectors[4] = Vector3.UnitZ; //UP |
718 | Dir_Vectors[5] = new Vector3(0, 0, -1); //DOWN | 718 | Dir_Vectors[5] = -Vector3.UnitZ; //DOWN |
719 | Dir_Vectors[5] = new Vector3(0, 0, -0.5f); //DOWN_Nudge | 719 | Dir_Vectors[5] = new Vector3(0f, 0f, -0.5f); //DOWN_Nudge |
720 | } | 720 | } |
721 | 721 | ||
722 | private Vector3[] GetWalkDirectionVectors() | 722 | private Vector3[] GetWalkDirectionVectors() |
723 | { | 723 | { |
724 | Vector3[] vector = new Vector3[6]; | 724 | Vector3[] vector = new Vector3[6]; |
725 | vector[0] = new Vector3(m_CameraUpAxis.Z, 0, -m_CameraAtAxis.Z); //FORWARD | 725 | vector[0] = new Vector3(m_CameraUpAxis.Z, 0f, -m_CameraAtAxis.Z); //FORWARD |
726 | vector[1] = new Vector3(-m_CameraUpAxis.Z, 0, m_CameraAtAxis.Z); //BACK | 726 | vector[1] = new Vector3(-m_CameraUpAxis.Z, 0f, m_CameraAtAxis.Z); //BACK |
727 | vector[2] = new Vector3(0, 1, 0); //LEFT | 727 | vector[2] = Vector3.UnitY; //LEFT |
728 | vector[3] = new Vector3(0, -1, 0); //RIGHT | 728 | vector[3] = -Vector3.UnitY; //RIGHT |
729 | vector[4] = new Vector3(m_CameraAtAxis.Z, 0, m_CameraUpAxis.Z); //UP | 729 | vector[4] = new Vector3(m_CameraAtAxis.Z, 0f, m_CameraUpAxis.Z); //UP |
730 | vector[5] = new Vector3(-m_CameraAtAxis.Z, 0, -m_CameraUpAxis.Z); //DOWN | 730 | vector[5] = new Vector3(-m_CameraAtAxis.Z, 0f, -m_CameraUpAxis.Z); //DOWN |
731 | vector[5] = new Vector3(-m_CameraAtAxis.Z, 0, -m_CameraUpAxis.Z); //DOWN_Nudge | 731 | vector[5] = new Vector3(-m_CameraAtAxis.Z, 0f, -m_CameraUpAxis.Z); //DOWN_Nudge |
732 | return vector; | 732 | return vector; |
733 | } | 733 | } |
734 | 734 | ||
@@ -781,6 +781,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
781 | if (gm != null) | 781 | if (gm != null) |
782 | m_grouptitle = gm.GetGroupTitle(m_uuid); | 782 | m_grouptitle = gm.GetGroupTitle(m_uuid); |
783 | 783 | ||
784 | m_rootRegionHandle = m_scene.RegionInfo.RegionHandle; | ||
785 | |||
784 | m_scene.SetRootAgentScene(m_uuid); | 786 | m_scene.SetRootAgentScene(m_uuid); |
785 | 787 | ||
786 | // Moved this from SendInitialData to ensure that m_appearance is initialized | 788 | // Moved this from SendInitialData to ensure that m_appearance is initialized |
@@ -811,7 +813,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
811 | pos = emergencyPos; | 813 | pos = emergencyPos; |
812 | } | 814 | } |
813 | 815 | ||
814 | |||
815 | float localAVHeight = 1.56f; | 816 | float localAVHeight = 1.56f; |
816 | if (m_avHeight != 127.0f) | 817 | if (m_avHeight != 127.0f) |
817 | { | 818 | { |
@@ -906,6 +907,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
906 | m_isChildAgent = true; | 907 | m_isChildAgent = true; |
907 | m_scene.SwapRootAgentCount(true); | 908 | m_scene.SwapRootAgentCount(true); |
908 | RemoveFromPhysicalScene(); | 909 | RemoveFromPhysicalScene(); |
910 | |||
911 | // FIXME: Set m_rootRegionHandle to the region handle of the scene this agent is moving into | ||
909 | 912 | ||
910 | m_scene.EventManager.TriggerOnMakeChildAgent(this); | 913 | m_scene.EventManager.TriggerOnMakeChildAgent(this); |
911 | } | 914 | } |
@@ -937,7 +940,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
937 | isFlying = m_physicsActor.Flying; | 940 | isFlying = m_physicsActor.Flying; |
938 | 941 | ||
939 | RemoveFromPhysicalScene(); | 942 | RemoveFromPhysicalScene(); |
940 | Velocity = new Vector3(0, 0, 0); | 943 | Velocity = Vector3.Zero; |
941 | AbsolutePosition = pos; | 944 | AbsolutePosition = pos; |
942 | AddToPhysicalScene(isFlying); | 945 | AddToPhysicalScene(isFlying); |
943 | if (m_appearance != null) | 946 | if (m_appearance != null) |
@@ -985,12 +988,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
985 | 988 | ||
986 | if (m_avHeight != 127.0f) | 989 | if (m_avHeight != 127.0f) |
987 | { | 990 | { |
988 | AbsolutePosition = AbsolutePosition + new Vector3(0, 0, (m_avHeight / 6f)); | 991 | AbsolutePosition = AbsolutePosition + new Vector3(0f, 0f, (m_avHeight / 6f)); |
989 | } | 992 | } |
990 | else | 993 | else |
991 | { | 994 | { |
992 | AbsolutePosition = AbsolutePosition + new Vector3(0, 0, (1.56f / 6f)); | 995 | AbsolutePosition = AbsolutePosition + new Vector3(0f, 0f, (1.56f / 6f)); |
993 | } | 996 | } |
997 | |||
994 | TrySetMovementAnimation("LAND"); | 998 | TrySetMovementAnimation("LAND"); |
995 | SendFullUpdateToAllClients(); | 999 | SendFullUpdateToAllClients(); |
996 | } | 1000 | } |
@@ -1076,7 +1080,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1076 | } | 1080 | } |
1077 | 1081 | ||
1078 | m_isChildAgent = false; | 1082 | m_isChildAgent = false; |
1079 | bool m_flying = ((m_AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0); | 1083 | bool m_flying = ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0); |
1080 | MakeRootAgent(AbsolutePosition, m_flying); | 1084 | MakeRootAgent(AbsolutePosition, m_flying); |
1081 | 1085 | ||
1082 | if ((m_callbackURI != null) && !m_callbackURI.Equals("")) | 1086 | if ((m_callbackURI != null) && !m_callbackURI.Equals("")) |
@@ -1103,9 +1107,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1103 | /// <param name="distance"></param> | 1107 | /// <param name="distance"></param> |
1104 | public void RayCastCameraCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance) | 1108 | public void RayCastCameraCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance) |
1105 | { | 1109 | { |
1110 | const float POSITION_TOLERANCE = 0.02f; | ||
1111 | const float VELOCITY_TOLERANCE = 0.02f; | ||
1112 | const float ROTATION_TOLERANCE = 0.02f; | ||
1113 | |||
1106 | if (m_followCamAuto) | 1114 | if (m_followCamAuto) |
1107 | { | 1115 | { |
1108 | |||
1109 | if (hitYN) | 1116 | if (hitYN) |
1110 | { | 1117 | { |
1111 | CameraConstraintActive = true; | 1118 | CameraConstraintActive = true; |
@@ -1114,11 +1121,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
1114 | Vector3 normal = Vector3.Normalize(new Vector3(0f, 0f, collisionPoint.Z) - collisionPoint); | 1121 | Vector3 normal = Vector3.Normalize(new Vector3(0f, 0f, collisionPoint.Z) - collisionPoint); |
1115 | ControllingClient.SendCameraConstraint(new Vector4(normal.X, normal.Y, normal.Z, -1 * Vector3.Distance(new Vector3(0,0,collisionPoint.Z),collisionPoint))); | 1122 | ControllingClient.SendCameraConstraint(new Vector4(normal.X, normal.Y, normal.Z, -1 * Vector3.Distance(new Vector3(0,0,collisionPoint.Z),collisionPoint))); |
1116 | } | 1123 | } |
1117 | else | 1124 | else |
1118 | { | 1125 | { |
1119 | if ((m_pos - m_lastPosition).Length() > 0.02f || | 1126 | if (!m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE) || |
1120 | (m_velocity - m_lastVelocity).Length() > 0.02f || | 1127 | !Velocity.ApproxEquals(m_lastVelocity, VELOCITY_TOLERANCE) || |
1121 | m_bodyRot != m_lastRotation) | 1128 | !m_bodyRot.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE)) |
1122 | { | 1129 | { |
1123 | if (CameraConstraintActive) | 1130 | if (CameraConstraintActive) |
1124 | { | 1131 | { |
@@ -1127,13 +1134,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
1127 | } | 1134 | } |
1128 | } | 1135 | } |
1129 | } | 1136 | } |
1130 | } | 1137 | } |
1131 | } | 1138 | } |
1132 | 1139 | ||
1133 | Array m_dirControlFlags = Enum.GetValues(typeof(Dir_ControlFlags)); | ||
1134 | |||
1135 | /// <summary> | 1140 | /// <summary> |
1136 | /// This is the event handler for client movement. If a client is moving, this event is triggering. | 1141 | /// This is the event handler for client movement. If a client is moving, this event is triggering. |
1137 | /// </summary> | 1142 | /// </summary> |
1138 | public void HandleAgentUpdate(IClientAPI remoteClient, AgentUpdateArgs agentData) | 1143 | public void HandleAgentUpdate(IClientAPI remoteClient, AgentUpdateArgs agentData) |
1139 | { | 1144 | { |
@@ -1149,15 +1154,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
1149 | if (m_movementUpdateCount < 1) | 1154 | if (m_movementUpdateCount < 1) |
1150 | m_movementUpdateCount = 1; | 1155 | m_movementUpdateCount = 1; |
1151 | 1156 | ||
1152 | // Must check for standing up even when PhysicsActor is null, | 1157 | #region Sanity Checking |
1153 | // since sitting currently removes avatar from physical scene | ||
1154 | //m_log.Debug("agentPos:" + AbsolutePosition.ToString()); | ||
1155 | 1158 | ||
1156 | // This is irritating. Really. | 1159 | // This is irritating. Really. |
1157 | if (!AbsolutePosition.IsFinite()) | 1160 | if (!AbsolutePosition.IsFinite()) |
1158 | { | 1161 | { |
1159 | RemoveFromPhysicalScene(); | 1162 | RemoveFromPhysicalScene(); |
1160 | m_log.Error("[AVATAR]: NonFinite Avatar position detected... Reset Position. Mantis this please. Error# 9999902"); | 1163 | m_log.Error("[AVATAR]: NonFinite Avatar position detected... Reset Position. Mantis this please. Error #9999902"); |
1161 | 1164 | ||
1162 | m_pos = m_LastFinitePos; | 1165 | m_pos = m_LastFinitePos; |
1163 | if (!m_pos.IsFinite()) | 1166 | if (!m_pos.IsFinite()) |
@@ -1165,7 +1168,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1165 | m_pos.X = 127f; | 1168 | m_pos.X = 127f; |
1166 | m_pos.Y = 127f; | 1169 | m_pos.Y = 127f; |
1167 | m_pos.Z = 127f; | 1170 | m_pos.Z = 127f; |
1168 | m_log.Error("[AVATAR]: NonFinite Avatar position detected... Reset Position. Mantis this please. Error# 9999903"); | 1171 | m_log.Error("[AVATAR]: NonFinite Avatar position detected... Reset Position. Mantis this please. Error #9999903"); |
1169 | } | 1172 | } |
1170 | 1173 | ||
1171 | AddToPhysicalScene(false); | 1174 | AddToPhysicalScene(false); |
@@ -1175,18 +1178,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
1175 | m_LastFinitePos = m_pos; | 1178 | m_LastFinitePos = m_pos; |
1176 | } | 1179 | } |
1177 | 1180 | ||
1178 | //m_physicsActor.AddForce(new PhysicsVector(999999999, 99999999, 999999999999999), true); | 1181 | #endregion Sanity Checking |
1179 | 1182 | ||
1180 | //ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); | 1183 | #region Inputs |
1181 | //if (land != null) | ||
1182 | //{ | ||
1183 | //if (land.landData.landingType == (byte)1 && land.landData.userLocation != Vector3.Zero) | ||
1184 | //{ | ||
1185 | // agent.startpos = land.landData.userLocation; | ||
1186 | //} | ||
1187 | //} | ||
1188 | 1184 | ||
1189 | uint flags = agentData.ControlFlags; | 1185 | AgentManager.ControlFlags flags = (AgentManager.ControlFlags)agentData.ControlFlags; |
1190 | Quaternion bodyRotation = agentData.BodyRotation; | 1186 | Quaternion bodyRotation = agentData.BodyRotation; |
1191 | 1187 | ||
1192 | // Camera location in world. We'll need to raytrace | 1188 | // Camera location in world. We'll need to raytrace |
@@ -1207,87 +1203,85 @@ namespace OpenSim.Region.Framework.Scenes | |||
1207 | // The Agent's Draw distance setting | 1203 | // The Agent's Draw distance setting |
1208 | m_DrawDistance = agentData.Far; | 1204 | m_DrawDistance = agentData.Far; |
1209 | 1205 | ||
1210 | if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_STAND_UP) != 0) | ||
1211 | { | ||
1212 | StandUp(); | ||
1213 | } | ||
1214 | |||
1215 | // Check if Client has camera in 'follow cam' or 'build' mode. | 1206 | // Check if Client has camera in 'follow cam' or 'build' mode. |
1216 | Vector3 camdif = (Vector3.One * m_bodyRot - Vector3.One * CameraRotation); | 1207 | Vector3 camdif = (Vector3.One * m_bodyRot - Vector3.One * CameraRotation); |
1217 | 1208 | ||
1218 | m_followCamAuto = ((m_CameraUpAxis.Z > 0.959f && m_CameraUpAxis.Z < 0.98f) | 1209 | m_followCamAuto = ((m_CameraUpAxis.Z > 0.959f && m_CameraUpAxis.Z < 0.98f) |
1219 | && (Math.Abs(camdif.X) < 0.4f && Math.Abs(camdif.Y) < 0.4f)) ? true : false; | 1210 | && (Math.Abs(camdif.X) < 0.4f && Math.Abs(camdif.Y) < 0.4f)) ? true : false; |
1220 | 1211 | ||
1212 | m_mouseLook = (flags & AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK) != 0; | ||
1213 | m_leftButtonDown = (flags & AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_DOWN) != 0; | ||
1214 | |||
1215 | #endregion Inputs | ||
1216 | |||
1217 | if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_STAND_UP) != 0) | ||
1218 | { | ||
1219 | StandUp(); | ||
1220 | } | ||
1221 | |||
1221 | //m_log.DebugFormat("[FollowCam]: {0}", m_followCamAuto); | 1222 | //m_log.DebugFormat("[FollowCam]: {0}", m_followCamAuto); |
1222 | // Raycast from the avatar's head to the camera to see if there's anything blocking the view | 1223 | // Raycast from the avatar's head to the camera to see if there's anything blocking the view |
1223 | if ((m_movementUpdateCount % NumMovementsBetweenRayCast) == 0 && m_scene.PhysicsScene.SupportsRayCast()) | 1224 | if ((m_movementUpdateCount % NumMovementsBetweenRayCast) == 0 && m_scene.PhysicsScene.SupportsRayCast()) |
1224 | { | 1225 | { |
1225 | if (m_followCamAuto) | 1226 | if (m_followCamAuto) |
1226 | { | 1227 | { |
1227 | Vector3 headadjustment = new Vector3(0, 0, 0.3f); | 1228 | Vector3 posAdjusted = m_pos + HEAD_ADJUSTMENT; |
1228 | m_scene.PhysicsScene.RaycastWorld(m_pos, Vector3.Normalize(m_CameraCenter - (m_pos + headadjustment)), Vector3.Distance(m_CameraCenter, (m_pos + headadjustment)) + 0.3f, RayCastCameraCallback); | 1229 | m_scene.PhysicsScene.RaycastWorld(m_pos, Vector3.Normalize(m_CameraCenter - posAdjusted), Vector3.Distance(m_CameraCenter, posAdjusted) + 0.3f, RayCastCameraCallback); |
1229 | } | 1230 | } |
1230 | } | 1231 | } |
1231 | 1232 | ||
1232 | m_mouseLook = (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK) != 0; | ||
1233 | m_leftButtonDown = (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_DOWN) != 0; | ||
1234 | |||
1235 | lock (scriptedcontrols) | 1233 | lock (scriptedcontrols) |
1236 | { | 1234 | { |
1237 | if (scriptedcontrols.Count > 0) | 1235 | if (scriptedcontrols.Count > 0) |
1238 | { | 1236 | { |
1239 | SendControlToScripts(flags); | 1237 | SendControlToScripts((uint)flags); |
1240 | flags = RemoveIgnoredControls(flags, IgnoredControls); | 1238 | flags = RemoveIgnoredControls(flags, IgnoredControls); |
1241 | } | 1239 | } |
1242 | } | 1240 | } |
1243 | 1241 | ||
1244 | if (PhysicsActor == null) | ||
1245 | { | ||
1246 | return; | ||
1247 | } | ||
1248 | |||
1249 | if (m_autopilotMoving) | 1242 | if (m_autopilotMoving) |
1250 | CheckAtSitTarget(); | 1243 | CheckAtSitTarget(); |
1251 | 1244 | ||
1252 | if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_SIT_ON_GROUND) != 0) | 1245 | if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_SIT_ON_GROUND) != 0) |
1253 | { | 1246 | { |
1254 | // TODO: This doesn't prevent the user from walking yet. | 1247 | // TODO: This doesn't prevent the user from walking yet. |
1255 | // Setting parent ID would fix this, if we knew what value | 1248 | // Setting parent ID would fix this, if we knew what value |
1256 | // to use. Or we could add a m_isSitting variable. | 1249 | // to use. Or we could add a m_isSitting variable. |
1257 | |||
1258 | TrySetMovementAnimation("SIT_GROUND_CONSTRAINED"); | 1250 | TrySetMovementAnimation("SIT_GROUND_CONSTRAINED"); |
1259 | } | 1251 | } |
1252 | |||
1260 | // In the future, these values might need to go global. | 1253 | // In the future, these values might need to go global. |
1261 | // Here's where you get them. | 1254 | // Here's where you get them. |
1262 | |||
1263 | m_AgentControlFlags = flags; | 1255 | m_AgentControlFlags = flags; |
1264 | m_headrotation = agentData.HeadRotation; | 1256 | m_headrotation = agentData.HeadRotation; |
1265 | m_state = agentData.State; | 1257 | m_state = agentData.State; |
1266 | 1258 | ||
1259 | PhysicsActor actor = PhysicsActor; | ||
1260 | if (actor == null) | ||
1261 | { | ||
1262 | return; | ||
1263 | } | ||
1264 | |||
1267 | if (m_allowMovement) | 1265 | if (m_allowMovement) |
1268 | { | 1266 | { |
1269 | int i = 0; | 1267 | int i = 0; |
1270 | bool update_movementflag = false; | 1268 | bool update_movementflag = false; |
1271 | bool update_rotation = false; | 1269 | bool update_rotation = false; |
1272 | bool DCFlagKeyPressed = false; | 1270 | bool DCFlagKeyPressed = false; |
1273 | Vector3 agent_control_v3 = new Vector3(0, 0, 0); | 1271 | Vector3 agent_control_v3 = Vector3.Zero; |
1274 | Quaternion q = bodyRotation; | 1272 | Quaternion q = bodyRotation; |
1275 | if (PhysicsActor != null) | ||
1276 | { | ||
1277 | bool oldflying = PhysicsActor.Flying; | ||
1278 | 1273 | ||
1279 | if (m_forceFly) | 1274 | bool oldflying = PhysicsActor.Flying; |
1280 | PhysicsActor.Flying = true; | ||
1281 | else if (m_flyDisabled) | ||
1282 | PhysicsActor.Flying = false; | ||
1283 | else | ||
1284 | PhysicsActor.Flying = ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0); | ||
1285 | 1275 | ||
1286 | if (PhysicsActor.Flying != oldflying) | 1276 | if (m_forceFly) |
1287 | { | 1277 | actor.Flying = true; |
1288 | update_movementflag = true; | 1278 | else if (m_flyDisabled) |
1289 | } | 1279 | actor.Flying = false; |
1290 | } | 1280 | else |
1281 | actor.Flying = ((flags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0); | ||
1282 | |||
1283 | if (actor.Flying != oldflying) | ||
1284 | update_movementflag = true; | ||
1291 | 1285 | ||
1292 | if (q != m_bodyRot) | 1286 | if (q != m_bodyRot) |
1293 | { | 1287 | { |
@@ -1309,10 +1303,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1309 | else | 1303 | else |
1310 | dirVectors = Dir_Vectors; | 1304 | dirVectors = Dir_Vectors; |
1311 | 1305 | ||
1312 | 1306 | foreach (Dir_ControlFlags DCF in DIR_CONTROL_FLAGS) | |
1313 | foreach (Dir_ControlFlags DCF in m_dirControlFlags) | ||
1314 | { | 1307 | { |
1315 | if ((flags & (uint)DCF) != 0) | 1308 | if (((uint)flags & (uint)DCF) != 0) |
1316 | { | 1309 | { |
1317 | bResetMoveToPosition = true; | 1310 | bResetMoveToPosition = true; |
1318 | DCFlagKeyPressed = true; | 1311 | DCFlagKeyPressed = true; |
@@ -1358,7 +1351,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1358 | if (bAllowUpdateMoveToPosition && (m_moveToPositionInProgress && !m_autopilotMoving)) | 1351 | if (bAllowUpdateMoveToPosition && (m_moveToPositionInProgress && !m_autopilotMoving)) |
1359 | { | 1352 | { |
1360 | //Check the error term of the current position in relation to the target position | 1353 | //Check the error term of the current position in relation to the target position |
1361 | if (Util.GetDistanceTo(AbsolutePosition, m_moveToPositionTarget) <= 1.5) | 1354 | if (Util.GetDistanceTo(AbsolutePosition, m_moveToPositionTarget) <= 1.5f) |
1362 | { | 1355 | { |
1363 | // we are close enough to the target | 1356 | // we are close enough to the target |
1364 | m_moveToPositionTarget = Vector3.Zero; | 1357 | m_moveToPositionTarget = Vector3.Zero; |
@@ -1439,8 +1432,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1439 | if (m_physicsActor != null && m_physicsActor.Flying && !m_forceFly) | 1432 | if (m_physicsActor != null && m_physicsActor.Flying && !m_forceFly) |
1440 | { | 1433 | { |
1441 | // Are the landing controls requirements filled? | 1434 | // Are the landing controls requirements filled? |
1442 | bool controlland = (((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) || | 1435 | bool controlland = (((flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) || |
1443 | ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)); | 1436 | ((flags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)); |
1444 | 1437 | ||
1445 | // Are the collision requirements fulfilled? | 1438 | // Are the collision requirements fulfilled? |
1446 | bool colliding = (m_physicsActor.IsColliding == true); | 1439 | bool colliding = (m_physicsActor.IsColliding == true); |
@@ -1537,7 +1530,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1537 | if (part != null) | 1530 | if (part != null) |
1538 | { | 1531 | { |
1539 | AbsolutePosition = part.AbsolutePosition; | 1532 | AbsolutePosition = part.AbsolutePosition; |
1540 | Velocity = new Vector3(0, 0, 0); | 1533 | Velocity = Vector3.Zero; |
1541 | SendFullUpdateToAllClients(); | 1534 | SendFullUpdateToAllClients(); |
1542 | 1535 | ||
1543 | //HandleAgentSit(ControllingClient, m_requestedSitTargetUUID); | 1536 | //HandleAgentSit(ControllingClient, m_requestedSitTargetUUID); |
@@ -1607,7 +1600,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1607 | } | 1600 | } |
1608 | 1601 | ||
1609 | m_pos += m_parentPosition + new Vector3(0.0f, 0.0f, 2.0f*m_sitAvatarHeight); | 1602 | m_pos += m_parentPosition + new Vector3(0.0f, 0.0f, 2.0f*m_sitAvatarHeight); |
1610 | m_parentPosition = new Vector3(); | 1603 | m_parentPosition = Vector3.Zero; |
1611 | 1604 | ||
1612 | m_parentID = 0; | 1605 | m_parentID = 0; |
1613 | SendFullUpdateToAllClients(); | 1606 | SendFullUpdateToAllClients(); |
@@ -1834,7 +1827,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1834 | //Quaternion result = (sitTargetOrient * vq) * nq; | 1827 | //Quaternion result = (sitTargetOrient * vq) * nq; |
1835 | 1828 | ||
1836 | m_pos = new Vector3(sitTargetPos.X, sitTargetPos.Y, sitTargetPos.Z); | 1829 | m_pos = new Vector3(sitTargetPos.X, sitTargetPos.Y, sitTargetPos.Z); |
1837 | m_pos += m_sitTargetCorrectionOffset; | 1830 | m_pos += SIT_TARGET_ADJUSTMENT; |
1838 | m_bodyRot = sitTargetOrient; | 1831 | m_bodyRot = sitTargetOrient; |
1839 | //Rotation = sitTargetOrient; | 1832 | //Rotation = sitTargetOrient; |
1840 | m_parentPosition = part.AbsolutePosition; | 1833 | m_parentPosition = part.AbsolutePosition; |
@@ -1854,7 +1847,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1854 | } | 1847 | } |
1855 | m_parentID = m_requestedSitTargetID; | 1848 | m_parentID = m_requestedSitTargetID; |
1856 | 1849 | ||
1857 | Velocity = new Vector3(0, 0, 0); | 1850 | Velocity = Vector3.Zero; |
1858 | RemoveFromPhysicalScene(); | 1851 | RemoveFromPhysicalScene(); |
1859 | 1852 | ||
1860 | TrySetMovementAnimation(sitAnimation); | 1853 | TrySetMovementAnimation(sitAnimation); |
@@ -1925,14 +1918,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1925 | } | 1918 | } |
1926 | 1919 | ||
1927 | 1920 | ||
1928 | AssetBase Animasset = new AssetBase(); | 1921 | AssetBase Animasset = new AssetBase(UUID.Random(), "Random Animation", (sbyte)AssetType.Animation); |
1929 | Animasset.Data = anim.ToBytes(); | 1922 | Animasset.Data = anim.ToBytes(); |
1930 | Animasset.Temporary = true; | 1923 | Animasset.Temporary = true; |
1931 | Animasset.Local = true; | 1924 | Animasset.Local = true; |
1932 | Animasset.FullID = UUID.Random(); | ||
1933 | Animasset.ID = Animasset.FullID.ToString(); | ||
1934 | Animasset.Name = "Random Animation"; | ||
1935 | Animasset.Type = (sbyte)AssetType.Animation; | ||
1936 | Animasset.Description = "dance"; | 1925 | Animasset.Description = "dance"; |
1937 | //BinBVHAnimation bbvhanim = new BinBVHAnimation(Animasset.Data); | 1926 | //BinBVHAnimation bbvhanim = new BinBVHAnimation(Animasset.Data); |
1938 | 1927 | ||
@@ -2011,7 +2000,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2011 | protected void TrySetMovementAnimation(string anim) | 2000 | protected void TrySetMovementAnimation(string anim) |
2012 | { | 2001 | { |
2013 | //m_log.DebugFormat("Updating movement animation to {0}", anim); | 2002 | //m_log.DebugFormat("Updating movement animation to {0}", anim); |
2014 | 2003 | ||
2015 | if (!m_isChildAgent) | 2004 | if (!m_isChildAgent) |
2016 | { | 2005 | { |
2017 | if (m_animations.TrySetDefaultAnimation(anim, m_controllingClient.NextAnimationSequenceNumber, UUID.Zero)) | 2006 | if (m_animations.TrySetDefaultAnimation(anim, m_controllingClient.NextAnimationSequenceNumber, UUID.Zero)) |
@@ -2046,200 +2035,169 @@ namespace OpenSim.Region.Framework.Scenes | |||
2046 | /// </summary> | 2035 | /// </summary> |
2047 | public string GetMovementAnimation() | 2036 | public string GetMovementAnimation() |
2048 | { | 2037 | { |
2049 | if ((m_animPersistUntil > 0) && (m_animPersistUntil > DateTime.Now.Ticks)) | 2038 | const float FALL_DELAY = 0.33f; |
2050 | { | 2039 | const float PREJUMP_DELAY = 0.25f; |
2051 | //We don't want our existing state to end yet. | ||
2052 | return m_movementAnimation; | ||
2053 | 2040 | ||
2054 | } | 2041 | #region Inputs |
2055 | else if (m_movementflag != 0) | 2042 | |
2043 | AgentManager.ControlFlags controlFlags = (AgentManager.ControlFlags)m_AgentControlFlags; | ||
2044 | PhysicsActor actor = m_physicsActor; | ||
2045 | |||
2046 | // Create forward and left vectors from the current avatar rotation | ||
2047 | Matrix4 rotMatrix = Matrix4.CreateFromQuaternion(m_bodyRot); | ||
2048 | Vector3 fwd = Vector3.Transform(Vector3.UnitX, rotMatrix); | ||
2049 | Vector3 left = Vector3.Transform(Vector3.UnitY, rotMatrix); | ||
2050 | |||
2051 | // Check control flags | ||
2052 | bool heldForward = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_AT_POS) == AgentManager.ControlFlags.AGENT_CONTROL_AT_POS; | ||
2053 | bool heldBack = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG; | ||
2054 | bool heldLeft = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS) == AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS; | ||
2055 | bool heldRight = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG; | ||
2056 | //bool heldTurnLeft = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_LEFT) == AgentManager.ControlFlags.AGENT_CONTROL_TURN_LEFT; | ||
2057 | //bool heldTurnRight = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_RIGHT) == AgentManager.ControlFlags.AGENT_CONTROL_TURN_RIGHT; | ||
2058 | bool heldUp = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) == AgentManager.ControlFlags.AGENT_CONTROL_UP_POS; | ||
2059 | bool heldDown = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG; | ||
2060 | //bool flying = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) == AgentManager.ControlFlags.AGENT_CONTROL_FLY; | ||
2061 | //bool mouselook = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK) == AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK; | ||
2062 | |||
2063 | // Direction in which the avatar is trying to move | ||
2064 | Vector3 move = Vector3.Zero; | ||
2065 | if (heldForward) { move.X += fwd.X; move.Y += fwd.Y; } | ||
2066 | if (heldBack) { move.X -= fwd.X; move.Y -= fwd.Y; } | ||
2067 | if (heldLeft) { move.X += left.X; move.Y += left.Y; } | ||
2068 | if (heldRight) { move.X -= left.X; move.Y -= left.Y; } | ||
2069 | if (heldUp) { move.Z += 1; } | ||
2070 | if (heldDown) { move.Z -= 1; } | ||
2071 | |||
2072 | // Is the avatar trying to move? | ||
2073 | // bool moving = (move != Vector3.Zero); | ||
2074 | bool jumping = m_animTickJump != 0; | ||
2075 | |||
2076 | #endregion Inputs | ||
2077 | |||
2078 | #region Flying | ||
2079 | |||
2080 | if (actor != null && actor.Flying) | ||
2056 | { | 2081 | { |
2057 | //We're moving | 2082 | m_animTickFall = 0; |
2058 | m_allowFalling = true; | 2083 | m_animTickJump = 0; |
2059 | if (PhysicsActor != null && PhysicsActor.IsColliding) | 2084 | |
2085 | if (move.X != 0f || move.Y != 0f) | ||
2060 | { | 2086 | { |
2061 | //And colliding. Can you guess what it is yet? | 2087 | return (m_useFlySlow ? "FLYSLOW" : "FLY"); |
2062 | if ((m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) | 2088 | } |
2063 | { | 2089 | else if (move.Z > 0f) |
2064 | //Down key is being pressed. | 2090 | { |
2065 | if ((m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG) + (m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_POS) != 0) | 2091 | return "HOVER_UP"; |
2066 | { | 2092 | } |
2067 | return "CROUCHWALK"; | 2093 | else if (move.Z < 0f) |
2068 | } | 2094 | { |
2069 | else | 2095 | if (actor != null && actor.IsColliding) |
2070 | { | 2096 | return "LAND"; |
2071 | return "CROUCH"; | ||
2072 | } | ||
2073 | } | ||
2074 | else if (m_setAlwaysRun) | ||
2075 | { | ||
2076 | return "RUN"; | ||
2077 | } | ||
2078 | else | 2097 | else |
2079 | { | 2098 | return "HOVER_DOWN"; |
2080 | //If we're prejumping then inhibit this, it's a problem | ||
2081 | //caused by a false positive on IsColliding | ||
2082 | if (m_movementAnimation == "PREJUMP") | ||
2083 | { | ||
2084 | return "PREJUMP"; | ||
2085 | } | ||
2086 | else | ||
2087 | { | ||
2088 | return "WALK"; | ||
2089 | } | ||
2090 | } | ||
2091 | |||
2092 | } | 2099 | } |
2093 | else | 2100 | else |
2094 | { | 2101 | { |
2095 | //We're not colliding. Colliding isn't cool these days. | 2102 | return "HOVER"; |
2096 | if (PhysicsActor != null && PhysicsActor.Flying) | 2103 | } |
2097 | { | 2104 | } |
2098 | //Are we moving forwards or backwards? | ||
2099 | if ((m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_POS) != 0 || (m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG) != 0) | ||
2100 | { | ||
2101 | //Then we really are flying | ||
2102 | if (m_setAlwaysRun) | ||
2103 | { | ||
2104 | return "FLY"; | ||
2105 | } | ||
2106 | else | ||
2107 | { | ||
2108 | if (m_useFlySlow == false) | ||
2109 | { | ||
2110 | return "FLY"; | ||
2111 | } | ||
2112 | else | ||
2113 | { | ||
2114 | return "FLYSLOW"; | ||
2115 | } | ||
2116 | } | ||
2117 | } | ||
2118 | else | ||
2119 | { | ||
2120 | if ((m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0) | ||
2121 | { | ||
2122 | return "HOVER_UP"; | ||
2123 | } | ||
2124 | else | ||
2125 | { | ||
2126 | return "HOVER_DOWN"; | ||
2127 | } | ||
2128 | } | ||
2129 | 2105 | ||
2130 | } | 2106 | #endregion Flying |
2131 | else if (m_movementAnimation == "JUMP") | ||
2132 | { | ||
2133 | //If we were already jumping, continue to jump until we collide | ||
2134 | return "JUMP"; | ||
2135 | 2107 | ||
2136 | } | 2108 | #region Falling/Floating/Landing |
2137 | else if (m_movementAnimation == "PREJUMP" && (m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) == 0) | ||
2138 | { | ||
2139 | //If we were in a prejump, and the UP key is no longer being held down | ||
2140 | //then we're not going to fly, so we're jumping | ||
2141 | return "JUMP"; | ||
2142 | 2109 | ||
2143 | } | 2110 | if (actor == null || !actor.IsColliding) |
2144 | else if ((m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0) | 2111 | { |
2145 | { | 2112 | float fallElapsed = (float)(Environment.TickCount - m_animTickFall) / 1000f; |
2146 | //They're pressing up, so we're either going to fly or jump | 2113 | float fallVelocity = (actor != null) ? actor.Velocity.Z : 0.0f; |
2147 | return "PREJUMP"; | 2114 | |
2148 | } | 2115 | if (m_animTickFall == 0 || (fallElapsed > FALL_DELAY && fallVelocity >= 0.0f)) |
2149 | else | 2116 | { |
2150 | { | 2117 | // Just started falling |
2151 | //If we're moving and not flying and not jumping and not colliding.. | 2118 | m_animTickFall = Environment.TickCount; |
2152 | 2119 | } | |
2153 | if (m_movementAnimation == "WALK" || m_movementAnimation == "RUN") | 2120 | else if (!jumping && fallElapsed > FALL_DELAY) |
2154 | { | 2121 | { |
2155 | //Let's not enter a FALLDOWN state here, since we're probably | 2122 | // Falling long enough to trigger the animation |
2156 | //not colliding because we're going down hill. | 2123 | return "FALLDOWN"; |
2157 | return m_movementAnimation; | ||
2158 | } | ||
2159 | //Record the time we enter this state so we know whether to "land" or not | ||
2160 | m_animPersistUntil = DateTime.Now.Ticks; | ||
2161 | return "FALLDOWN"; | ||
2162 | |||
2163 | } | ||
2164 | } | 2124 | } |
2125 | |||
2126 | return m_movementAnimation; | ||
2165 | } | 2127 | } |
2166 | else | 2128 | |
2129 | #endregion Falling/Floating/Landing | ||
2130 | |||
2131 | #region Ground Movement | ||
2132 | |||
2133 | if (m_movementAnimation == "FALLDOWN") | ||
2167 | { | 2134 | { |
2168 | //We're not moving. | 2135 | m_animTickFall = Environment.TickCount; |
2169 | if (PhysicsActor != null && PhysicsActor.IsColliding) | ||
2170 | { | ||
2171 | //But we are colliding. | ||
2172 | if (m_movementAnimation == "FALLDOWN") | ||
2173 | { | ||
2174 | //We're re-using the m_animPersistUntil value here to see how long we've been falling | ||
2175 | if ((DateTime.Now.Ticks - m_animPersistUntil) > TimeSpan.TicksPerSecond) | ||
2176 | { | ||
2177 | //Make sure we don't change state for a bit | ||
2178 | m_animPersistUntil = DateTime.Now.Ticks + TimeSpan.TicksPerSecond; | ||
2179 | return "LAND"; | ||
2180 | } | ||
2181 | else | ||
2182 | { | ||
2183 | //We haven't been falling very long, we were probably just walking down hill | ||
2184 | return "STAND"; | ||
2185 | } | ||
2186 | } | ||
2187 | else if (m_movementAnimation == "JUMP" || m_movementAnimation == "HOVER_DOWN") | ||
2188 | { | ||
2189 | //Make sure we don't change state for a bit | ||
2190 | m_animPersistUntil = DateTime.Now.Ticks + (1 * TimeSpan.TicksPerSecond); | ||
2191 | return "SOFT_LAND"; | ||
2192 | 2136 | ||
2193 | } | 2137 | // TODO: SOFT_LAND support |
2194 | else if ((m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0) | 2138 | return "LAND"; |
2195 | { | 2139 | } |
2196 | return "PREJUMP"; | 2140 | else if (m_movementAnimation == "LAND") |
2197 | } | 2141 | { |
2198 | else if (PhysicsActor != null && PhysicsActor.Flying) | 2142 | float landElapsed = (float)(Environment.TickCount - m_animTickFall) / 1000f; |
2199 | { | 2143 | |
2200 | m_allowFalling = true; | 2144 | if (landElapsed <= FALL_DELAY) |
2201 | if ((m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0) | 2145 | return "LAND"; |
2202 | { | 2146 | } |
2203 | return "HOVER_UP"; | ||
2204 | } | ||
2205 | else if ((m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) | ||
2206 | { | ||
2207 | return "HOVER_DOWN"; | ||
2208 | } | ||
2209 | else | ||
2210 | { | ||
2211 | return "HOVER"; | ||
2212 | } | ||
2213 | } | ||
2214 | else | ||
2215 | { | ||
2216 | return "STAND"; | ||
2217 | } | ||
2218 | 2147 | ||
2148 | m_animTickFall = 0; | ||
2149 | |||
2150 | if (move.Z > 0f) | ||
2151 | { | ||
2152 | // Jumping | ||
2153 | if (!jumping) | ||
2154 | { | ||
2155 | // Begin prejump | ||
2156 | m_animTickJump = Environment.TickCount; | ||
2157 | return "PREJUMP"; | ||
2219 | } | 2158 | } |
2220 | else | 2159 | else if (Environment.TickCount - m_animTickJump > PREJUMP_DELAY * 1000.0f) |
2221 | { | 2160 | { |
2222 | //We're not colliding. | 2161 | // Start actual jump |
2223 | if (PhysicsActor != null && PhysicsActor.Flying) | 2162 | if (m_animTickJump == -1) |
2224 | { | 2163 | { |
2225 | 2164 | // Already jumping! End the current jump | |
2226 | return "HOVER"; | 2165 | m_animTickJump = 0; |
2227 | 2166 | return "JUMP"; | |
2228 | } | 2167 | } |
2229 | else if ((m_movementAnimation == "JUMP" || m_movementAnimation == "PREJUMP") && (m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) == 0) | ||
2230 | { | ||
2231 | 2168 | ||
2232 | return "JUMP"; | 2169 | m_animTickJump = -1; |
2170 | return "JUMP"; | ||
2171 | } | ||
2172 | } | ||
2173 | else | ||
2174 | { | ||
2175 | // Not jumping | ||
2176 | m_animTickJump = 0; | ||
2233 | 2177 | ||
2234 | } | 2178 | if (move.X != 0f || move.Y != 0f) |
2179 | { | ||
2180 | // Walking / crouchwalking / running | ||
2181 | if (move.Z < 0f) | ||
2182 | return "CROUCHWALK"; | ||
2183 | else if (m_setAlwaysRun) | ||
2184 | return "RUN"; | ||
2235 | else | 2185 | else |
2236 | { | 2186 | return "WALK"; |
2237 | //Record the time we enter this state so we know whether to "land" or not | 2187 | } |
2238 | m_animPersistUntil = DateTime.Now.Ticks; | 2188 | else |
2239 | return "FALLDOWN"; // this falling animation is invoked too frequently when capsule tilt correction is used - why? | 2189 | { |
2240 | } | 2190 | // Not walking |
2191 | if (move.Z < 0f) | ||
2192 | return "CROUCH"; | ||
2193 | else | ||
2194 | return "STAND"; | ||
2241 | } | 2195 | } |
2242 | } | 2196 | } |
2197 | |||
2198 | #endregion Ground Movement | ||
2199 | |||
2200 | return m_movementAnimation; | ||
2243 | } | 2201 | } |
2244 | 2202 | ||
2245 | /// <summary> | 2203 | /// <summary> |
@@ -2247,24 +2205,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
2247 | /// </summary> | 2205 | /// </summary> |
2248 | protected void UpdateMovementAnimations() | 2206 | protected void UpdateMovementAnimations() |
2249 | { | 2207 | { |
2250 | string movementAnimation = GetMovementAnimation(); | 2208 | m_movementAnimation = GetMovementAnimation(); |
2251 | 2209 | ||
2252 | if (movementAnimation == "FALLDOWN" && m_allowFalling == false) | 2210 | if (m_movementAnimation == "PREJUMP" && !m_usePreJump) |
2253 | { | ||
2254 | movementAnimation = m_movementAnimation; | ||
2255 | } | ||
2256 | else | ||
2257 | { | ||
2258 | m_movementAnimation = movementAnimation; | ||
2259 | } | ||
2260 | if (movementAnimation == "PREJUMP" && m_usePreJump == false) | ||
2261 | { | 2211 | { |
2262 | //This was the previous behavior before PREJUMP | 2212 | // This was the previous behavior before PREJUMP |
2263 | TrySetMovementAnimation("JUMP"); | 2213 | TrySetMovementAnimation("JUMP"); |
2264 | } | 2214 | } |
2265 | else | 2215 | else |
2266 | { | 2216 | { |
2267 | TrySetMovementAnimation(movementAnimation); | 2217 | TrySetMovementAnimation(m_movementAnimation); |
2268 | } | 2218 | } |
2269 | } | 2219 | } |
2270 | 2220 | ||
@@ -2277,7 +2227,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2277 | { | 2227 | { |
2278 | if (m_isChildAgent) | 2228 | if (m_isChildAgent) |
2279 | { | 2229 | { |
2280 | m_log.Debug("DEBUG: AddNewMovement: child agent, Making root agent!"); | 2230 | m_log.Debug("[SCENEPRESENCE]: AddNewMovement() called on child agent, making root agent!"); |
2281 | 2231 | ||
2282 | // we have to reset the user's child agent connections. | 2232 | // we have to reset the user's child agent connections. |
2283 | // Likely, here they've lost the eventqueue for other regions so border | 2233 | // Likely, here they've lost the eventqueue for other regions so border |
@@ -2286,7 +2236,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2286 | List<ulong> regions = new List<ulong>(KnownChildRegionHandles); | 2236 | List<ulong> regions = new List<ulong>(KnownChildRegionHandles); |
2287 | regions.Remove(m_scene.RegionInfo.RegionHandle); | 2237 | regions.Remove(m_scene.RegionInfo.RegionHandle); |
2288 | 2238 | ||
2289 | MakeRootAgent(new Vector3(127, 127, 127), true); | 2239 | MakeRootAgent(new Vector3(127f, 127f, 127f), true); |
2290 | 2240 | ||
2291 | // Async command | 2241 | // Async command |
2292 | if (m_scene.SceneGridService != null) | 2242 | if (m_scene.SceneGridService != null) |
@@ -2298,47 +2248,45 @@ namespace OpenSim.Region.Framework.Scenes | |||
2298 | System.Threading.Thread.Sleep(500); | 2248 | System.Threading.Thread.Sleep(500); |
2299 | } | 2249 | } |
2300 | 2250 | ||
2301 | |||
2302 | if (m_scene.SceneGridService != null) | 2251 | if (m_scene.SceneGridService != null) |
2303 | { | 2252 | { |
2304 | m_scene.SceneGridService.EnableNeighbourChildAgents(this, new List<RegionInfo>()); | 2253 | m_scene.SceneGridService.EnableNeighbourChildAgents(this, new List<RegionInfo>()); |
2305 | } | 2254 | } |
2306 | 2255 | ||
2307 | |||
2308 | |||
2309 | return; | 2256 | return; |
2310 | } | 2257 | } |
2311 | 2258 | ||
2312 | m_perfMonMS = Environment.TickCount; | 2259 | m_perfMonMS = Environment.TickCount; |
2313 | 2260 | ||
2314 | m_rotation = rotation; | 2261 | Rotation = rotation; |
2315 | NewForce newVelocity = new NewForce(); | ||
2316 | Vector3 direc = vec * rotation; | 2262 | Vector3 direc = vec * rotation; |
2317 | direc.Normalize(); | 2263 | direc.Normalize(); |
2318 | 2264 | ||
2319 | direc *= 0.03f * 128f * m_speedModifier; | 2265 | direc *= 0.03f * 128f * m_speedModifier; |
2320 | if (m_physicsActor.Flying) | 2266 | |
2321 | { | 2267 | PhysicsActor actor = m_physicsActor; |
2322 | direc *= 4; | 2268 | if (actor != null) |
2323 | //bool controlland = (((m_AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) || ((m_AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)); | ||
2324 | //bool colliding = (m_physicsActor.IsColliding==true); | ||
2325 | //if (controlland) | ||
2326 | // m_log.Info("[AGENT]: landCommand"); | ||
2327 | //if (colliding) | ||
2328 | // m_log.Info("[AGENT]: colliding"); | ||
2329 | //if (m_physicsActor.Flying && colliding && controlland) | ||
2330 | //{ | ||
2331 | // StopFlying(); | ||
2332 | // m_log.Info("[AGENT]: Stop FLying"); | ||
2333 | //} | ||
2334 | } | ||
2335 | else | ||
2336 | { | 2269 | { |
2337 | if (!m_physicsActor.Flying && m_physicsActor.IsColliding) | 2270 | if (actor.Flying) |
2271 | { | ||
2272 | direc *= 4.0f; | ||
2273 | //bool controlland = (((m_AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) || ((m_AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)); | ||
2274 | //bool colliding = (m_physicsActor.IsColliding==true); | ||
2275 | //if (controlland) | ||
2276 | // m_log.Info("[AGENT]: landCommand"); | ||
2277 | //if (colliding) | ||
2278 | // m_log.Info("[AGENT]: colliding"); | ||
2279 | //if (m_physicsActor.Flying && colliding && controlland) | ||
2280 | //{ | ||
2281 | // StopFlying(); | ||
2282 | // m_log.Info("[AGENT]: Stop FLying"); | ||
2283 | //} | ||
2284 | } | ||
2285 | else if (!actor.Flying && actor.IsColliding) | ||
2338 | { | 2286 | { |
2339 | if (direc.Z > 2.0f) | 2287 | if (direc.Z > 2.0f) |
2340 | { | 2288 | { |
2341 | direc.Z *= 3; | 2289 | direc.Z *= 3.0f; |
2342 | 2290 | ||
2343 | // TODO: PreJump and jump happen too quickly. Many times prejump gets ignored. | 2291 | // TODO: PreJump and jump happen too quickly. Many times prejump gets ignored. |
2344 | TrySetMovementAnimation("PREJUMP"); | 2292 | TrySetMovementAnimation("PREJUMP"); |
@@ -2347,10 +2295,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2347 | } | 2295 | } |
2348 | } | 2296 | } |
2349 | 2297 | ||
2350 | newVelocity.X = direc.X; | 2298 | // TODO: Add the force instead of only setting it to support multiple forces per frame? |
2351 | newVelocity.Y = direc.Y; | 2299 | m_forceToApply = direc; |
2352 | newVelocity.Z = direc.Z; | ||
2353 | m_forcesList.Add(newVelocity); | ||
2354 | 2300 | ||
2355 | m_scene.StatsReporter.AddAgentTime(Environment.TickCount - m_perfMonMS); | 2301 | m_scene.StatsReporter.AddAgentTime(Environment.TickCount - m_perfMonMS); |
2356 | } | 2302 | } |
@@ -2361,8 +2307,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
2361 | 2307 | ||
2362 | public override void Update() | 2308 | public override void Update() |
2363 | { | 2309 | { |
2364 | const float VELOCITY_TOLERANCE = 0.01f; | 2310 | const float ROTATION_TOLERANCE = 0.01f; |
2365 | const float POSITION_TOLERANCE = 10.0f; | 2311 | const float VELOCITY_TOLERANCE = 0.001f; |
2312 | const float POSITION_TOLERANCE = 0.05f; | ||
2313 | //const int TIME_MS_TOLERANCE = 3000; | ||
2366 | 2314 | ||
2367 | SendPrimUpdates(); | 2315 | SendPrimUpdates(); |
2368 | 2316 | ||
@@ -2374,17 +2322,25 @@ namespace OpenSim.Region.Framework.Scenes | |||
2374 | 2322 | ||
2375 | if (m_isChildAgent == false) | 2323 | if (m_isChildAgent == false) |
2376 | { | 2324 | { |
2325 | // PhysicsActor actor = m_physicsActor; | ||
2326 | |||
2327 | // NOTE: Velocity is not the same as m_velocity. Velocity will attempt to | ||
2328 | // grab the latest PhysicsActor velocity, whereas m_velocity is often | ||
2329 | // storing a requested force instead of an actual traveling velocity | ||
2330 | |||
2377 | // Throw away duplicate or insignificant updates | 2331 | // Throw away duplicate or insignificant updates |
2378 | if (m_bodyRot != m_lastRotation || | 2332 | if (!m_bodyRot.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE) || |
2379 | (m_velocity - m_lastVelocity).Length() > VELOCITY_TOLERANCE || | 2333 | !Velocity.ApproxEquals(m_lastVelocity, VELOCITY_TOLERANCE) || |
2380 | (m_pos - m_lastPosition).Length() > POSITION_TOLERANCE) | 2334 | !m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE)) |
2335 | //Environment.TickCount - m_lastTerseSent > TIME_MS_TOLERANCE) | ||
2381 | { | 2336 | { |
2382 | SendTerseUpdateToAllClients(); | 2337 | SendTerseUpdateToAllClients(); |
2383 | 2338 | ||
2384 | // Update the "last" values | 2339 | // Update the "last" values |
2385 | m_lastPosition = m_pos; | 2340 | m_lastPosition = m_pos; |
2386 | m_lastRotation = m_bodyRot; | 2341 | m_lastRotation = m_bodyRot; |
2387 | m_lastVelocity = m_velocity; | 2342 | m_lastVelocity = Velocity; |
2343 | //m_lastTerseSent = Environment.TickCount; | ||
2388 | } | 2344 | } |
2389 | 2345 | ||
2390 | // followed suggestion from mic bowman. reversed the two lines below. | 2346 | // followed suggestion from mic bowman. reversed the two lines below. |
@@ -2410,11 +2366,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
2410 | { | 2366 | { |
2411 | m_perfMonMS = Environment.TickCount; | 2367 | m_perfMonMS = Environment.TickCount; |
2412 | 2368 | ||
2369 | PhysicsActor actor = m_physicsActor; | ||
2370 | Vector3 velocity = (actor != null) ? actor.Velocity : Vector3.Zero; | ||
2371 | |||
2413 | Vector3 pos = m_pos; | 2372 | Vector3 pos = m_pos; |
2414 | pos.Z -= m_appearance.HipOffset; | 2373 | pos.Z += m_appearance.HipOffset; |
2415 | 2374 | ||
2416 | remoteClient.SendAvatarTerseUpdate(new SendAvatarTerseData(m_regionHandle, (ushort)(m_scene.TimeDilation * ushort.MaxValue), LocalId, | 2375 | //m_log.DebugFormat("[SCENEPRESENCE]: TerseUpdate: Pos={0} Rot={1} Vel={2}", m_pos, m_bodyRot, m_velocity); |
2417 | pos, m_velocity, Vector3.Zero, m_bodyRot, Vector4.UnitW, m_uuid, null, GetUpdatePriority(remoteClient))); | 2376 | |
2377 | remoteClient.SendAvatarTerseUpdate(new SendAvatarTerseData(m_rootRegionHandle, (ushort)(m_scene.TimeDilation * ushort.MaxValue), LocalId, | ||
2378 | pos, velocity, Vector3.Zero, m_bodyRot, CollisionPlane, m_uuid, null, GetUpdatePriority(remoteClient))); | ||
2418 | 2379 | ||
2419 | m_scene.StatsReporter.AddAgentTime(Environment.TickCount - m_perfMonMS); | 2380 | m_scene.StatsReporter.AddAgentTime(Environment.TickCount - m_perfMonMS); |
2420 | m_scene.StatsReporter.AddAgentUpdates(1); | 2381 | m_scene.StatsReporter.AddAgentUpdates(1); |
@@ -2510,7 +2471,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2510 | return; | 2471 | return; |
2511 | 2472 | ||
2512 | Vector3 pos = m_pos; | 2473 | Vector3 pos = m_pos; |
2513 | pos.Z -= m_appearance.HipOffset; | 2474 | pos.Z += m_appearance.HipOffset; |
2514 | 2475 | ||
2515 | remoteAvatar.m_controllingClient.SendAvatarData(new SendAvatarData(m_regionInfo.RegionHandle, m_firstname, m_lastname, m_grouptitle, m_uuid, | 2476 | remoteAvatar.m_controllingClient.SendAvatarData(new SendAvatarData(m_regionInfo.RegionHandle, m_firstname, m_lastname, m_grouptitle, m_uuid, |
2516 | LocalId, pos, m_appearance.Texture.GetBytes(), | 2477 | LocalId, pos, m_appearance.Texture.GetBytes(), |
@@ -2581,7 +2542,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2581 | // m_scene.GetAvatarAppearance(m_controllingClient, out m_appearance); | 2542 | // m_scene.GetAvatarAppearance(m_controllingClient, out m_appearance); |
2582 | 2543 | ||
2583 | Vector3 pos = m_pos; | 2544 | Vector3 pos = m_pos; |
2584 | pos.Z -= m_appearance.HipOffset; | 2545 | pos.Z += m_appearance.HipOffset; |
2585 | 2546 | ||
2586 | m_controllingClient.SendAvatarData(new SendAvatarData(m_regionInfo.RegionHandle, m_firstname, m_lastname, m_grouptitle, m_uuid, LocalId, | 2547 | m_controllingClient.SendAvatarData(new SendAvatarData(m_regionInfo.RegionHandle, m_firstname, m_lastname, m_grouptitle, m_uuid, LocalId, |
2587 | pos, m_appearance.Texture.GetBytes(), m_parentID, m_bodyRot)); | 2548 | pos, m_appearance.Texture.GetBytes(), m_parentID, m_bodyRot)); |
@@ -2690,7 +2651,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2690 | } | 2651 | } |
2691 | 2652 | ||
2692 | Vector3 pos = m_pos; | 2653 | Vector3 pos = m_pos; |
2693 | pos.Z -= m_appearance.HipOffset; | 2654 | pos.Z += m_appearance.HipOffset; |
2694 | 2655 | ||
2695 | m_controllingClient.SendAvatarData(new SendAvatarData(m_regionInfo.RegionHandle, m_firstname, m_lastname, m_grouptitle, m_uuid, LocalId, | 2656 | m_controllingClient.SendAvatarData(new SendAvatarData(m_regionInfo.RegionHandle, m_firstname, m_lastname, m_grouptitle, m_uuid, LocalId, |
2696 | pos, m_appearance.Texture.GetBytes(), m_parentID, m_bodyRot)); | 2657 | pos, m_appearance.Texture.GetBytes(), m_parentID, m_bodyRot)); |
@@ -2778,7 +2739,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2778 | } | 2739 | } |
2779 | 2740 | ||
2780 | // Minimum Draw distance is 64 meters, the Radius of the draw distance sphere is 32m | 2741 | // Minimum Draw distance is 64 meters, the Radius of the draw distance sphere is 32m |
2781 | if (Util.GetDistanceTo(AbsolutePosition, m_LastChildAgentUpdatePosition) >= Scene.ChildReprioritizationDistance) | 2742 | if (Util.GetDistanceTo(AbsolutePosition, m_lastChildAgentUpdatePosition) >= Scene.ChildReprioritizationDistance || |
2743 | Util.GetDistanceTo(CameraPosition, m_lastChildAgentUpdateCamPosition) >= Scene.ChildReprioritizationDistance) | ||
2782 | { | 2744 | { |
2783 | ChildAgentDataUpdate cadu = new ChildAgentDataUpdate(); | 2745 | ChildAgentDataUpdate cadu = new ChildAgentDataUpdate(); |
2784 | cadu.ActiveGroupID = UUID.Zero.Guid; | 2746 | cadu.ActiveGroupID = UUID.Zero.Guid; |
@@ -2792,7 +2754,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2792 | cadu.godlevel = m_godlevel; | 2754 | cadu.godlevel = m_godlevel; |
2793 | cadu.GroupAccess = 0; | 2755 | cadu.GroupAccess = 0; |
2794 | cadu.Position = new sLLVector3(AbsolutePosition); | 2756 | cadu.Position = new sLLVector3(AbsolutePosition); |
2795 | cadu.regionHandle = m_scene.RegionInfo.RegionHandle; | 2757 | cadu.regionHandle = m_rootRegionHandle; |
2796 | float multiplier = 1; | 2758 | float multiplier = 1; |
2797 | int innacurateNeighbors = m_scene.GetInaccurateNeighborCount(); | 2759 | int innacurateNeighbors = m_scene.GetInaccurateNeighborCount(); |
2798 | if (innacurateNeighbors != 0) | 2760 | if (innacurateNeighbors != 0) |
@@ -2812,11 +2774,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
2812 | agentpos.CopyFrom(cadu); | 2774 | agentpos.CopyFrom(cadu); |
2813 | 2775 | ||
2814 | m_scene.SendOutChildAgentUpdates(agentpos, this); | 2776 | m_scene.SendOutChildAgentUpdates(agentpos, this); |
2815 | |||
2816 | m_LastChildAgentUpdatePosition.X = AbsolutePosition.X; | ||
2817 | m_LastChildAgentUpdatePosition.Y = AbsolutePosition.Y; | ||
2818 | m_LastChildAgentUpdatePosition.Z = AbsolutePosition.Z; | ||
2819 | 2777 | ||
2778 | m_lastChildAgentUpdatePosition = AbsolutePosition; | ||
2779 | m_lastChildAgentUpdateCamPosition = CameraPosition; | ||
2820 | } | 2780 | } |
2821 | } | 2781 | } |
2822 | 2782 | ||
@@ -2941,9 +2901,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
2941 | m_inTransit = true; | 2901 | m_inTransit = true; |
2942 | 2902 | ||
2943 | if ((m_physicsActor != null) && m_physicsActor.Flying) | 2903 | if ((m_physicsActor != null) && m_physicsActor.Flying) |
2944 | m_AgentControlFlags |= (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY; | 2904 | m_AgentControlFlags |= AgentManager.ControlFlags.AGENT_CONTROL_FLY; |
2945 | else if ((m_AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0) | 2905 | else if ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0) |
2946 | m_AgentControlFlags &= ~(uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY; | 2906 | m_AgentControlFlags &= ~AgentManager.ControlFlags.AGENT_CONTROL_FLY; |
2947 | } | 2907 | } |
2948 | 2908 | ||
2949 | public void NotInTransit() | 2909 | public void NotInTransit() |
@@ -2959,7 +2919,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2959 | public void Reset() | 2919 | public void Reset() |
2960 | { | 2920 | { |
2961 | // Put the child agent back at the center | 2921 | // Put the child agent back at the center |
2962 | AbsolutePosition = new Vector3(((int)Constants.RegionSize * 0.5f), ((int)Constants.RegionSize * 0.5f), 70); | 2922 | AbsolutePosition = new Vector3(((float)Constants.RegionSize * 0.5f), ((float)Constants.RegionSize * 0.5f), 70); |
2963 | ResetAnimations(); | 2923 | ResetAnimations(); |
2964 | } | 2924 | } |
2965 | 2925 | ||
@@ -3069,9 +3029,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
3069 | int shiftx = ((int)rRegionX - (int)tRegionX) * (int)Constants.RegionSize; | 3029 | int shiftx = ((int)rRegionX - (int)tRegionX) * (int)Constants.RegionSize; |
3070 | int shifty = ((int)rRegionY - (int)tRegionY) * (int)Constants.RegionSize; | 3030 | int shifty = ((int)rRegionY - (int)tRegionY) * (int)Constants.RegionSize; |
3071 | 3031 | ||
3032 | Vector3 offset = new Vector3(shiftx, shifty, 0f); | ||
3033 | |||
3072 | m_DrawDistance = cAgentData.Far; | 3034 | m_DrawDistance = cAgentData.Far; |
3073 | if (cAgentData.Position != new Vector3(-1, -1, -1)) // UGH!! | 3035 | if (cAgentData.Position != new Vector3(-1f, -1f, -1f)) // UGH!! |
3074 | m_pos = new Vector3(cAgentData.Position.X + shiftx, cAgentData.Position.Y + shifty, cAgentData.Position.Z); | 3036 | m_pos = cAgentData.Position + offset; |
3075 | 3037 | ||
3076 | if (Vector3.Distance(AbsolutePosition, posLastSignificantMove) >= Scene.ChildReprioritizationDistance) | 3038 | if (Vector3.Distance(AbsolutePosition, posLastSignificantMove) >= Scene.ChildReprioritizationDistance) |
3077 | { | 3039 | { |
@@ -3079,8 +3041,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3079 | ReprioritizeUpdates(); | 3041 | ReprioritizeUpdates(); |
3080 | } | 3042 | } |
3081 | 3043 | ||
3082 | // 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 | 3044 | m_CameraCenter = cAgentData.Center + offset; |
3083 | m_CameraCenter = cAgentData.Center; | ||
3084 | 3045 | ||
3085 | m_avHeight = cAgentData.Size.Z; | 3046 | m_avHeight = cAgentData.Size.Z; |
3086 | //SetHeight(cAgentData.AVHeight); | 3047 | //SetHeight(cAgentData.AVHeight); |
@@ -3093,16 +3054,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
3093 | m_sceneViewer.Reset(); | 3054 | m_sceneViewer.Reset(); |
3094 | 3055 | ||
3095 | //cAgentData.AVHeight; | 3056 | //cAgentData.AVHeight; |
3096 | //cAgentData.regionHandle; | 3057 | m_rootRegionHandle = cAgentData.RegionHandle; |
3097 | //m_velocity = cAgentData.Velocity; | 3058 | //m_velocity = cAgentData.Velocity; |
3098 | } | 3059 | } |
3099 | 3060 | ||
3100 | public void CopyTo(AgentData cAgent) | 3061 | public void CopyTo(AgentData cAgent) |
3101 | { | 3062 | { |
3102 | cAgent.AgentID = UUID; | 3063 | cAgent.AgentID = UUID; |
3103 | cAgent.RegionHandle = m_scene.RegionInfo.RegionHandle; | 3064 | cAgent.RegionHandle = m_rootRegionHandle; |
3104 | 3065 | ||
3105 | cAgent.Position = m_pos; | 3066 | cAgent.Position = AbsolutePosition; |
3106 | cAgent.Velocity = m_velocity; | 3067 | cAgent.Velocity = m_velocity; |
3107 | cAgent.Center = m_CameraCenter; | 3068 | cAgent.Center = m_CameraCenter; |
3108 | // Don't copy the size; it is inferred from apearance parameters | 3069 | // Don't copy the size; it is inferred from apearance parameters |
@@ -3129,7 +3090,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3129 | 3090 | ||
3130 | cAgent.HeadRotation = m_headrotation; | 3091 | cAgent.HeadRotation = m_headrotation; |
3131 | cAgent.BodyRotation = m_bodyRot; | 3092 | cAgent.BodyRotation = m_bodyRot; |
3132 | cAgent.ControlFlags = m_AgentControlFlags; | 3093 | cAgent.ControlFlags = (uint)m_AgentControlFlags; |
3133 | 3094 | ||
3134 | if (m_scene.Permissions.IsGod(new UUID(cAgent.AgentID))) | 3095 | if (m_scene.Permissions.IsGod(new UUID(cAgent.AgentID))) |
3135 | cAgent.GodLevel = (byte)m_godlevel; | 3096 | cAgent.GodLevel = (byte)m_godlevel; |
@@ -3199,7 +3160,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3199 | 3160 | ||
3200 | public void CopyFrom(AgentData cAgent) | 3161 | public void CopyFrom(AgentData cAgent) |
3201 | { | 3162 | { |
3202 | m_rootRegionHandle= cAgent.RegionHandle; | 3163 | m_rootRegionHandle = cAgent.RegionHandle; |
3164 | |||
3203 | m_callbackURI = cAgent.CallbackURI; | 3165 | m_callbackURI = cAgent.CallbackURI; |
3204 | 3166 | ||
3205 | m_pos = cAgent.Position; | 3167 | m_pos = cAgent.Position; |
@@ -3217,7 +3179,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3217 | 3179 | ||
3218 | m_headrotation = cAgent.HeadRotation; | 3180 | m_headrotation = cAgent.HeadRotation; |
3219 | m_bodyRot = cAgent.BodyRotation; | 3181 | m_bodyRot = cAgent.BodyRotation; |
3220 | m_AgentControlFlags = cAgent.ControlFlags; | 3182 | m_AgentControlFlags = (AgentManager.ControlFlags)cAgent.ControlFlags; |
3221 | 3183 | ||
3222 | if (m_scene.Permissions.IsGod(new UUID(cAgent.AgentID))) | 3184 | if (m_scene.Permissions.IsGod(new UUID(cAgent.AgentID))) |
3223 | m_godlevel = cAgent.GodLevel; | 3185 | m_godlevel = cAgent.GodLevel; |
@@ -3291,47 +3253,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
3291 | /// </summary> | 3253 | /// </summary> |
3292 | public override void UpdateMovement() | 3254 | public override void UpdateMovement() |
3293 | { | 3255 | { |
3294 | lock (m_forcesList) | 3256 | if (m_forceToApply.HasValue) |
3295 | { | 3257 | { |
3296 | if (m_forcesList.Count > 0) | 3258 | Vector3 force = m_forceToApply.Value; |
3297 | { | ||
3298 | //we are only interested in the last velocity added to the list [Although they are called forces, they are actually velocities] | ||
3299 | NewForce force = m_forcesList[m_forcesList.Count - 1]; | ||
3300 | 3259 | ||
3301 | m_updateflag = true; | 3260 | m_updateflag = true; |
3302 | try | 3261 | // movementvector = force; |
3303 | { | 3262 | Velocity = force; |
3304 | movementvector.X = force.X; | ||
3305 | movementvector.Y = force.Y; | ||
3306 | movementvector.Z = force.Z; | ||
3307 | Velocity = movementvector; | ||
3308 | } | ||
3309 | catch (NullReferenceException) | ||
3310 | { | ||
3311 | // Under extreme load, this returns a NullReference Exception that we can ignore. | ||
3312 | // Ignoring this causes no movement to be sent to the physics engine... | ||
3313 | // which when the scene is moving at 1 frame every 10 seconds, it doesn't really matter! | ||
3314 | } | ||
3315 | 3263 | ||
3316 | m_forcesList.Clear(); | 3264 | m_forceToApply = null; |
3317 | } | ||
3318 | } | 3265 | } |
3319 | } | 3266 | } |
3320 | 3267 | ||
3321 | static ScenePresence() | ||
3322 | { | ||
3323 | Primitive.TextureEntry textu = AvatarAppearance.GetDefaultTexture(); | ||
3324 | DefaultTexture = textu.GetBytes(); | ||
3325 | |||
3326 | } | ||
3327 | |||
3328 | public class NewForce | ||
3329 | { | ||
3330 | public float X; | ||
3331 | public float Y; | ||
3332 | public float Z; | ||
3333 | } | ||
3334 | |||
3335 | public override void SetText(string text, Vector3 color, double alpha) | 3268 | public override void SetText(string text, Vector3 color, double alpha) |
3336 | { | 3269 | { |
3337 | throw new Exception("Can't set Text on avatar."); | 3270 | throw new Exception("Can't set Text on avatar."); |
@@ -3342,7 +3275,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3342 | /// </summary> | 3275 | /// </summary> |
3343 | public void AddToPhysicalScene(bool isFlying) | 3276 | public void AddToPhysicalScene(bool isFlying) |
3344 | { | 3277 | { |
3345 | |||
3346 | PhysicsScene scene = m_scene.PhysicsScene; | 3278 | PhysicsScene scene = m_scene.PhysicsScene; |
3347 | 3279 | ||
3348 | Vector3 pVec = AbsolutePosition; | 3280 | Vector3 pVec = AbsolutePosition; |
@@ -3388,15 +3320,48 @@ namespace OpenSim.Region.Framework.Scenes | |||
3388 | // as of this comment the interval is set in AddToPhysicalScene | 3320 | // as of this comment the interval is set in AddToPhysicalScene |
3389 | UpdateMovementAnimations(); | 3321 | UpdateMovementAnimations(); |
3390 | 3322 | ||
3323 | CollisionEventUpdate collisionData = (CollisionEventUpdate)e; | ||
3324 | Dictionary<uint, ContactPoint> coldata = collisionData.m_objCollisionList; | ||
3325 | |||
3326 | CollisionPlane = Vector4.UnitW; | ||
3327 | |||
3328 | if (coldata.Count != 0) | ||
3329 | { | ||
3330 | switch (m_movementAnimation) | ||
3331 | { | ||
3332 | case "STAND": | ||
3333 | case "WALK": | ||
3334 | case "RUN": | ||
3335 | case "CROUCH": | ||
3336 | case "CROUCHWALK": | ||
3337 | { | ||
3338 | ContactPoint lowest; | ||
3339 | lowest.SurfaceNormal = Vector3.Zero; | ||
3340 | lowest.Position = Vector3.Zero; | ||
3341 | lowest.Position.Z = Single.NaN; | ||
3342 | |||
3343 | foreach (ContactPoint contact in coldata.Values) | ||
3344 | { | ||
3345 | if (Single.IsNaN(lowest.Position.Z) || contact.Position.Z < lowest.Position.Z) | ||
3346 | { | ||
3347 | lowest = contact; | ||
3348 | } | ||
3349 | } | ||
3350 | |||
3351 | CollisionPlane = new Vector4(-lowest.SurfaceNormal, -Vector3.Dot(lowest.Position, lowest.SurfaceNormal)); | ||
3352 | } | ||
3353 | break; | ||
3354 | } | ||
3355 | } | ||
3356 | |||
3391 | if (m_invulnerable) | 3357 | if (m_invulnerable) |
3392 | return; | 3358 | return; |
3393 | CollisionEventUpdate collisionData = (CollisionEventUpdate)e; | 3359 | |
3394 | Dictionary<uint, float> coldata = collisionData.m_objCollisionList; | ||
3395 | float starthealth = Health; | 3360 | float starthealth = Health; |
3396 | uint killerObj = 0; | 3361 | uint killerObj = 0; |
3397 | foreach (uint localid in coldata.Keys) | 3362 | foreach (uint localid in coldata.Keys) |
3398 | { | 3363 | { |
3399 | if (coldata[localid] <= 0.10f || m_invulnerable) | 3364 | if (coldata[localid].PenetrationDepth <= 0.10f || m_invulnerable) |
3400 | continue; | 3365 | continue; |
3401 | //if (localid == 0) | 3366 | //if (localid == 0) |
3402 | //continue; | 3367 | //continue; |
@@ -3406,9 +3371,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
3406 | if (part != null && part.ParentGroup.Damage != -1.0f) | 3371 | if (part != null && part.ParentGroup.Damage != -1.0f) |
3407 | Health -= part.ParentGroup.Damage; | 3372 | Health -= part.ParentGroup.Damage; |
3408 | else | 3373 | else |
3409 | Health -= coldata[localid] * 5; | 3374 | Health -= coldata[localid].PenetrationDepth * 5.0f; |
3410 | 3375 | ||
3411 | if (Health <= 0) | 3376 | if (Health <= 0.0f) |
3412 | { | 3377 | { |
3413 | if (localid != 0) | 3378 | if (localid != 0) |
3414 | killerObj = localid; | 3379 | killerObj = localid; |
@@ -3471,11 +3436,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3471 | 3436 | ||
3472 | public ScenePresence() | 3437 | public ScenePresence() |
3473 | { | 3438 | { |
3474 | if (DefaultTexture == null) | ||
3475 | { | ||
3476 | Primitive.TextureEntry textu = AvatarAppearance.GetDefaultTexture(); | ||
3477 | DefaultTexture = textu.GetBytes(); | ||
3478 | } | ||
3479 | m_sendCourseLocationsMethod = SendCoarseLocationsDefault; | 3439 | m_sendCourseLocationsMethod = SendCoarseLocationsDefault; |
3480 | CreateSceneViewer(); | 3440 | CreateSceneViewer(); |
3481 | } | 3441 | } |
@@ -3632,19 +3592,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
3632 | IgnoredControls &= ~(ScriptControlled)controls; | 3592 | IgnoredControls &= ~(ScriptControlled)controls; |
3633 | if (scriptedcontrols.ContainsKey(Script_item_UUID)) | 3593 | if (scriptedcontrols.ContainsKey(Script_item_UUID)) |
3634 | scriptedcontrols.Remove(Script_item_UUID); | 3594 | scriptedcontrols.Remove(Script_item_UUID); |
3635 | |||
3636 | } | 3595 | } |
3637 | else | 3596 | else |
3638 | { | 3597 | { |
3639 | 3598 | scriptedcontrols[Script_item_UUID] = obj; | |
3640 | if (scriptedcontrols.ContainsKey(Script_item_UUID)) | ||
3641 | { | ||
3642 | scriptedcontrols[Script_item_UUID] = obj; | ||
3643 | } | ||
3644 | else | ||
3645 | { | ||
3646 | scriptedcontrols.Add(Script_item_UUID, obj); | ||
3647 | } | ||
3648 | } | 3599 | } |
3649 | } | 3600 | } |
3650 | ControllingClient.SendTakeControls(controls, pass_on == 1 ? true : false, true); | 3601 | ControllingClient.SendTakeControls(controls, pass_on == 1 ? true : false, true); |
@@ -3662,12 +3613,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
3662 | 3613 | ||
3663 | public void UnRegisterControlEventsToScript(uint Obj_localID, UUID Script_item_UUID) | 3614 | public void UnRegisterControlEventsToScript(uint Obj_localID, UUID Script_item_UUID) |
3664 | { | 3615 | { |
3616 | ScriptControllers takecontrols; | ||
3617 | |||
3665 | lock (scriptedcontrols) | 3618 | lock (scriptedcontrols) |
3666 | { | 3619 | { |
3667 | if (scriptedcontrols.ContainsKey(Script_item_UUID)) | 3620 | if (scriptedcontrols.TryGetValue(Script_item_UUID, out takecontrols)) |
3668 | { | 3621 | { |
3669 | ScriptControllers takecontrolls = scriptedcontrols[Script_item_UUID]; | 3622 | ScriptControlled sctc = takecontrols.eventControls; |
3670 | ScriptControlled sctc = takecontrolls.eventControls; | 3623 | |
3671 | ControllingClient.SendTakeControls((int)sctc, false, false); | 3624 | ControllingClient.SendTakeControls((int)sctc, false, false); |
3672 | ControllingClient.SendTakeControls((int)sctc, true, false); | 3625 | ControllingClient.SendTakeControls((int)sctc, true, false); |
3673 | 3626 | ||
@@ -3678,7 +3631,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3678 | IgnoredControls |= scData.ignoreControls; | 3631 | IgnoredControls |= scData.ignoreControls; |
3679 | } | 3632 | } |
3680 | } | 3633 | } |
3681 | |||
3682 | } | 3634 | } |
3683 | } | 3635 | } |
3684 | 3636 | ||
@@ -3745,9 +3697,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
3745 | { | 3697 | { |
3746 | lock (scriptedcontrols) | 3698 | lock (scriptedcontrols) |
3747 | { | 3699 | { |
3748 | foreach (UUID scriptUUID in scriptedcontrols.Keys) | 3700 | foreach (KeyValuePair<UUID, ScriptControllers> kvp in scriptedcontrols) |
3749 | { | 3701 | { |
3750 | ScriptControllers scriptControlData = scriptedcontrols[scriptUUID]; | 3702 | UUID scriptUUID = kvp.Key; |
3703 | ScriptControllers scriptControlData = kvp.Value; | ||
3704 | |||
3751 | ScriptControlled localHeld = allflags & scriptControlData.eventControls; // the flags interesting for us | 3705 | ScriptControlled localHeld = allflags & scriptControlData.eventControls; // the flags interesting for us |
3752 | ScriptControlled localLast = LastCommands & scriptControlData.eventControls; // the activated controls in the last cycle | 3706 | ScriptControlled localLast = LastCommands & scriptControlData.eventControls; // the activated controls in the last cycle |
3753 | ScriptControlled localChange = localHeld ^ localLast; // the changed bits | 3707 | ScriptControlled localChange = localHeld ^ localLast; // the changed bits |
@@ -3763,37 +3717,40 @@ namespace OpenSim.Region.Framework.Scenes | |||
3763 | LastCommands = allflags; | 3717 | LastCommands = allflags; |
3764 | } | 3718 | } |
3765 | 3719 | ||
3766 | internal static uint RemoveIgnoredControls(uint flags, ScriptControlled Ignored) | 3720 | internal static AgentManager.ControlFlags RemoveIgnoredControls(AgentManager.ControlFlags flags, ScriptControlled ignored) |
3767 | { | 3721 | { |
3768 | if (Ignored == ScriptControlled.CONTROL_ZERO) | 3722 | if (ignored == ScriptControlled.CONTROL_ZERO) |
3769 | return flags; | 3723 | return flags; |
3770 | if ((Ignored & ScriptControlled.CONTROL_BACK) != 0) | 3724 | |
3771 | flags &= ~((uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG | (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG); | 3725 | if ((ignored & ScriptControlled.CONTROL_BACK) != 0) |
3772 | if ((Ignored & ScriptControlled.CONTROL_FWD) != 0) | 3726 | flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG | AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG); |
3773 | flags &= ~((uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS | (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_POS); | 3727 | if ((ignored & ScriptControlled.CONTROL_FWD) != 0) |
3774 | if ((Ignored & ScriptControlled.CONTROL_DOWN) != 0) | 3728 | flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS | AgentManager.ControlFlags.AGENT_CONTROL_AT_POS); |
3775 | flags &= ~((uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG | (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG); | 3729 | if ((ignored & ScriptControlled.CONTROL_DOWN) != 0) |
3776 | if ((Ignored & ScriptControlled.CONTROL_UP) != 0) | 3730 | flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG | AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG); |
3777 | flags &= ~((uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_POS | (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_POS); | 3731 | if ((ignored & ScriptControlled.CONTROL_UP) != 0) |
3778 | if ((Ignored & ScriptControlled.CONTROL_LEFT) != 0) | 3732 | flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_POS | AgentManager.ControlFlags.AGENT_CONTROL_UP_POS); |
3779 | flags &= ~((uint)AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS | (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS); | 3733 | if ((ignored & ScriptControlled.CONTROL_LEFT) != 0) |
3780 | if ((Ignored & ScriptControlled.CONTROL_RIGHT) != 0) | 3734 | flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS | AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS); |
3781 | flags &= ~((uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG | (uint)AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG); | 3735 | if ((ignored & ScriptControlled.CONTROL_RIGHT) != 0) |
3782 | if ((Ignored & ScriptControlled.CONTROL_ROT_LEFT) != 0) | 3736 | flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG | AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG); |
3783 | flags &= ~((uint)AgentManager.ControlFlags.AGENT_CONTROL_YAW_NEG); | 3737 | if ((ignored & ScriptControlled.CONTROL_ROT_LEFT) != 0) |
3784 | if ((Ignored & ScriptControlled.CONTROL_ROT_RIGHT) != 0) | 3738 | flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_YAW_NEG); |
3785 | flags &= ~((uint)AgentManager.ControlFlags.AGENT_CONTROL_YAW_POS); | 3739 | if ((ignored & ScriptControlled.CONTROL_ROT_RIGHT) != 0) |
3786 | if ((Ignored & ScriptControlled.CONTROL_ML_LBUTTON) != 0) | 3740 | flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_YAW_POS); |
3787 | flags &= ~((uint)AgentManager.ControlFlags.AGENT_CONTROL_ML_LBUTTON_DOWN); | 3741 | if ((ignored & ScriptControlled.CONTROL_ML_LBUTTON) != 0) |
3788 | if ((Ignored & ScriptControlled.CONTROL_LBUTTON) != 0) | 3742 | flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_ML_LBUTTON_DOWN); |
3789 | flags &= ~((uint)AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_UP | (uint)AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_DOWN); | 3743 | if ((ignored & ScriptControlled.CONTROL_LBUTTON) != 0) |
3790 | //DIR_CONTROL_FLAG_FORWARD = AgentManager.ControlFlags.AGENT_CONTROL_AT_POS, | 3744 | flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_UP | AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_DOWN); |
3791 | //DIR_CONTROL_FLAG_BACK = AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG, | 3745 | |
3792 | //DIR_CONTROL_FLAG_LEFT = AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS, | 3746 | //DIR_CONTROL_FLAG_FORWARD = AgentManager.ControlFlags.AGENT_CONTROL_AT_POS, |
3793 | //DIR_CONTROL_FLAG_RIGHT = AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG, | 3747 | //DIR_CONTROL_FLAG_BACK = AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG, |
3794 | //DIR_CONTROL_FLAG_UP = AgentManager.ControlFlags.AGENT_CONTROL_UP_POS, | 3748 | //DIR_CONTROL_FLAG_LEFT = AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS, |
3795 | //DIR_CONTROL_FLAG_DOWN = AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG, | 3749 | //DIR_CONTROL_FLAG_RIGHT = AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG, |
3796 | //DIR_CONTROL_FLAG_DOWN_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG | 3750 | //DIR_CONTROL_FLAG_UP = AgentManager.ControlFlags.AGENT_CONTROL_UP_POS, |
3751 | //DIR_CONTROL_FLAG_DOWN = AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG, | ||
3752 | //DIR_CONTROL_FLAG_DOWN_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG | ||
3753 | |||
3797 | return flags; | 3754 | return flags; |
3798 | } | 3755 | } |
3799 | 3756 | ||
@@ -3950,7 +3907,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3950 | } | 3907 | } |
3951 | else | 3908 | else |
3952 | { | 3909 | { |
3953 | group = Scene.SceneGraph.GetGroupByPrim(data.localID); | 3910 | group = Scene.GetGroupByPrim(data.localID); |
3954 | if (group != null) | 3911 | if (group != null) |
3955 | return GetSOGUpdatePriority(group); | 3912 | return GetSOGUpdatePriority(group); |
3956 | } | 3913 | } |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs index 19c0fea..f495022 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs | |||
@@ -219,7 +219,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
219 | Assert.That(presence.IsChildAgent, Is.True, "Did not change to child agent after MakeChildAgent"); | 219 | Assert.That(presence.IsChildAgent, Is.True, "Did not change to child agent after MakeChildAgent"); |
220 | 220 | ||
221 | // Accepts 0 but rejects Constants.RegionSize | 221 | // Accepts 0 but rejects Constants.RegionSize |
222 | Vector3 pos = new Vector3(0,Constants.RegionSize-1,0); | 222 | Vector3 pos = new Vector3(0,unchecked(Constants.RegionSize-1),0); |
223 | presence.MakeRootAgent(pos,true); | 223 | presence.MakeRootAgent(pos,true); |
224 | Assert.That(presence.IsChildAgent, Is.False, "Did not go back to root agent"); | 224 | Assert.That(presence.IsChildAgent, Is.False, "Did not go back to root agent"); |
225 | Assert.That(presence.AbsolutePosition, Is.EqualTo(pos), "Position is not the same one entered"); | 225 | Assert.That(presence.AbsolutePosition, Is.EqualTo(pos), "Position is not the same one entered"); |
@@ -246,7 +246,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
246 | scene2.AddNewClient(testclient); | 246 | scene2.AddNewClient(testclient); |
247 | 247 | ||
248 | ScenePresence presence = scene.GetScenePresence(agent1); | 248 | ScenePresence presence = scene.GetScenePresence(agent1); |
249 | presence.MakeRootAgent(new Vector3(0,Constants.RegionSize-1,0), true); | 249 | presence.MakeRootAgent(new Vector3(0,unchecked(Constants.RegionSize-1),0), true); |
250 | 250 | ||
251 | ScenePresence presence2 = scene2.GetScenePresence(agent1); | 251 | ScenePresence presence2 = scene2.GetScenePresence(agent1); |
252 | 252 | ||
diff --git a/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs b/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs new file mode 100644 index 0000000..b68a044 --- /dev/null +++ b/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs | |||
@@ -0,0 +1,88 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System.Collections.Generic; | ||
29 | using System.Text; | ||
30 | using NUnit.Framework; | ||
31 | using NUnit.Framework.SyntaxHelpers; | ||
32 | using OpenMetaverse; | ||
33 | using OpenSim.Framework; | ||
34 | using OpenSim.Region.Framework.Scenes; | ||
35 | using OpenSim.Services.Interfaces; | ||
36 | using OpenSim.Tests.Common; | ||
37 | using OpenSim.Tests.Common.Setup; | ||
38 | using OpenSim.Tests.Common.Mock; | ||
39 | |||
40 | namespace OpenSim.Region.Framework.Scenes.Tests | ||
41 | { | ||
42 | [TestFixture] | ||
43 | public class UuidGathererTests | ||
44 | { | ||
45 | protected IAssetService m_assetService; | ||
46 | protected UuidGatherer m_uuidGatherer; | ||
47 | |||
48 | [SetUp] | ||
49 | public void Init() | ||
50 | { | ||
51 | m_assetService = new MockAssetService(); | ||
52 | m_uuidGatherer = new UuidGatherer(m_assetService); | ||
53 | } | ||
54 | |||
55 | [Test] | ||
56 | public void TestCorruptAsset() | ||
57 | { | ||
58 | TestHelper.InMethod(); | ||
59 | |||
60 | UUID corruptAssetUuid = UUID.Parse("00000000-0000-0000-0000-000000000666"); | ||
61 | AssetBase corruptAsset = AssetHelpers.CreateAsset(corruptAssetUuid, "CORRUPT ASSET"); | ||
62 | m_assetService.Store(corruptAsset); | ||
63 | |||
64 | IDictionary<UUID, int> foundAssetUuids = new Dictionary<UUID, int>(); | ||
65 | m_uuidGatherer.GatherAssetUuids(corruptAssetUuid, AssetType.Object, foundAssetUuids); | ||
66 | |||
67 | // We count the uuid as gathered even if the asset itself is corrupt. | ||
68 | Assert.That(foundAssetUuids.Count, Is.EqualTo(1)); | ||
69 | } | ||
70 | |||
71 | /// <summary> | ||
72 | /// Test requests made for non-existent assets while we're gathering | ||
73 | /// </summary> | ||
74 | [Test] | ||
75 | public void TestMissingAsset() | ||
76 | { | ||
77 | TestHelper.InMethod(); | ||
78 | |||
79 | UUID missingAssetUuid = UUID.Parse("00000000-0000-0000-0000-000000000666"); | ||
80 | IDictionary<UUID, int> foundAssetUuids = new Dictionary<UUID, int>(); | ||
81 | |||
82 | m_uuidGatherer.GatherAssetUuids(missingAssetUuid, AssetType.Object, foundAssetUuids); | ||
83 | |||
84 | // We count the uuid as gathered even if the asset itself is missing. | ||
85 | Assert.That(foundAssetUuids.Count, Is.EqualTo(1)); | ||
86 | } | ||
87 | } | ||
88 | } | ||
diff --git a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs index 525a93a..930af81 100644 --- a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs +++ b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs | |||
@@ -273,7 +273,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
273 | { | 273 | { |
274 | string xml = Utils.BytesToString(objectAsset.Data); | 274 | string xml = Utils.BytesToString(objectAsset.Data); |
275 | SceneObjectGroup sog = SceneObjectSerializer.FromOriginalXmlFormat(xml); | 275 | SceneObjectGroup sog = SceneObjectSerializer.FromOriginalXmlFormat(xml); |
276 | GatherAssetUuids(sog, assetUuids); | 276 | |
277 | if (null != sog) | ||
278 | GatherAssetUuids(sog, assetUuids); | ||
277 | } | 279 | } |
278 | } | 280 | } |
279 | } | 281 | } |
diff --git a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/IRCStackModule.cs b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/IRCStackModule.cs index 4c2a4b9..cfe1278 100644 --- a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/IRCStackModule.cs +++ b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/IRCStackModule.cs | |||
@@ -40,7 +40,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView | |||
40 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 40 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
41 | 41 | ||
42 | private IRCServer m_server; | 42 | private IRCServer m_server; |
43 | private Scene m_scene; | 43 | // private Scene m_scene; |
44 | 44 | ||
45 | #region Implementation of IRegionModule | 45 | #region Implementation of IRegionModule |
46 | 46 | ||
@@ -50,7 +50,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView | |||
50 | source.Configs["IRCd"].GetBoolean("Enabled",false)) | 50 | source.Configs["IRCd"].GetBoolean("Enabled",false)) |
51 | { | 51 | { |
52 | int portNo = source.Configs["IRCd"].GetInt("Port",6666); | 52 | int portNo = source.Configs["IRCd"].GetInt("Port",6666); |
53 | m_scene = scene; | 53 | // m_scene = scene; |
54 | m_server = new IRCServer(IPAddress.Parse("0.0.0.0"), portNo, scene); | 54 | m_server = new IRCServer(IPAddress.Parse("0.0.0.0"), portNo, scene); |
55 | m_server.OnNewIRCClient += m_server_OnNewIRCClient; | 55 | m_server.OnNewIRCClient += m_server_OnNewIRCClient; |
56 | } | 56 | } |
diff --git a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs index 4b0d01a..6c3e7eb 100644 --- a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs +++ b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs | |||
@@ -758,6 +758,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server | |||
758 | public event FriendActionDelegate OnApproveFriendRequest; | 758 | public event FriendActionDelegate OnApproveFriendRequest; |
759 | public event FriendActionDelegate OnDenyFriendRequest; | 759 | public event FriendActionDelegate OnDenyFriendRequest; |
760 | public event FriendshipTermination OnTerminateFriendship; | 760 | public event FriendshipTermination OnTerminateFriendship; |
761 | public event GrantUserFriendRights OnGrantUserRights; | ||
761 | public event MoneyTransferRequest OnMoneyTransferRequest; | 762 | public event MoneyTransferRequest OnMoneyTransferRequest; |
762 | public event EconomyDataRequest OnEconomyDataRequest; | 763 | public event EconomyDataRequest OnEconomyDataRequest; |
763 | public event MoneyBalanceRequest OnMoneyBalanceRequest; | 764 | public event MoneyBalanceRequest OnMoneyBalanceRequest; |
@@ -1055,7 +1056,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server | |||
1055 | 1056 | ||
1056 | } | 1057 | } |
1057 | 1058 | ||
1058 | public void SendInventoryFolderDetails(UUID ownerID, UUID folderID, List<InventoryItemBase> items, List<InventoryFolderBase> folders, bool fetchFolders, bool fetchItems) | 1059 | public void SendInventoryFolderDetails(UUID ownerID, UUID folderID, List<InventoryItemBase> items, List<InventoryFolderBase> folders, int version, bool fetchFolders, bool fetchItems) |
1059 | { | 1060 | { |
1060 | 1061 | ||
1061 | } | 1062 | } |
diff --git a/OpenSim/Region/OptionalModules/ContentManagementSystem/PointMetaEntity.cs b/OpenSim/Region/OptionalModules/ContentManagementSystem/PointMetaEntity.cs index fbe43d6..2c5093f 100644 --- a/OpenSim/Region/OptionalModules/ContentManagementSystem/PointMetaEntity.cs +++ b/OpenSim/Region/OptionalModules/ContentManagementSystem/PointMetaEntity.cs | |||
@@ -81,12 +81,11 @@ namespace OpenSim.Region.OptionalModules.ContentManagement | |||
81 | y.Scale = new Vector3(0.01f,0.01f,0.01f); | 81 | y.Scale = new Vector3(0.01f,0.01f,0.01f); |
82 | y.LastOwnerID = UUID.Zero; | 82 | y.LastOwnerID = UUID.Zero; |
83 | y.GroupPosition = groupPos; | 83 | y.GroupPosition = groupPos; |
84 | y.OffsetPosition = new Vector3(0, 0, 0); | 84 | y.OffsetPosition = Vector3.Zero; |
85 | y.RotationOffset = new Quaternion(0,0,0,0); | 85 | y.RotationOffset = Quaternion.Identity; |
86 | y.Velocity = new Vector3(0, 0, 0); | 86 | y.Velocity = Vector3.Zero; |
87 | y.RotationalVelocity = new Vector3(0, 0, 0); | 87 | y.AngularVelocity = Vector3.Zero; |
88 | y.AngularVelocity = new Vector3(0, 0, 0); | 88 | y.Acceleration = Vector3.Zero; |
89 | y.Acceleration = new Vector3(0, 0, 0); | ||
90 | 89 | ||
91 | y.Flags = 0; | 90 | y.Flags = 0; |
92 | y.TrimPermissions(); | 91 | y.TrimPermissions(); |
diff --git a/OpenSim/Region/OptionalModules/ContentManagementSystem/SceneObjectGroupDiff.cs b/OpenSim/Region/OptionalModules/ContentManagementSystem/SceneObjectGroupDiff.cs index e185351..a6afa5a 100644 --- a/OpenSim/Region/OptionalModules/ContentManagementSystem/SceneObjectGroupDiff.cs +++ b/OpenSim/Region/OptionalModules/ContentManagementSystem/SceneObjectGroupDiff.cs | |||
@@ -172,8 +172,6 @@ namespace OpenSim.Region.OptionalModules.ContentManagement | |||
172 | result |= Diff.ANGULARVELOCITY; | 172 | result |= Diff.ANGULARVELOCITY; |
173 | if (!AreVectorsEquivalent(first.OffsetPosition, second.OffsetPosition)) | 173 | if (!AreVectorsEquivalent(first.OffsetPosition, second.OffsetPosition)) |
174 | result |= Diff.OFFSETPOSITION; | 174 | result |= Diff.OFFSETPOSITION; |
175 | if (!AreVectorsEquivalent(first.RotationalVelocity, second.RotationalVelocity)) | ||
176 | result |= Diff.ROTATIONALVELOCITY; | ||
177 | if (!AreVectorsEquivalent(first.Scale, second.Scale)) | 175 | if (!AreVectorsEquivalent(first.Scale, second.Scale)) |
178 | result |= Diff.SCALE; | 176 | result |= Diff.SCALE; |
179 | if (!AreVectorsEquivalent(first.Velocity, second.Velocity)) | 177 | if (!AreVectorsEquivalent(first.Velocity, second.Velocity)) |
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Graphics.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Graphics.cs index 963cab5..8ea7ad3 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Graphics.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Graphics.cs | |||
@@ -49,11 +49,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | |||
49 | 49 | ||
50 | public UUID SaveBitmap(Bitmap data, bool lossless, bool temporary) | 50 | public UUID SaveBitmap(Bitmap data, bool lossless, bool temporary) |
51 | { | 51 | { |
52 | AssetBase asset = new AssetBase(); | 52 | AssetBase asset = new AssetBase(UUID.Random(), "MRMDynamicImage", (sbyte)AssetType.Texture); |
53 | asset.FullID = UUID.Random(); | ||
54 | asset.Data = OpenJPEG.EncodeFromImage(data, lossless); | 53 | asset.Data = OpenJPEG.EncodeFromImage(data, lossless); |
55 | asset.Name = "MRMDynamicImage"; | ||
56 | asset.Type = 0; | ||
57 | asset.Description = "MRM Image"; | 54 | asset.Description = "MRM Image"; |
58 | asset.Local = false; | 55 | asset.Local = false; |
59 | asset.Temporary = temporary; | 56 | asset.Temporary = temporary; |
diff --git a/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs b/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs new file mode 100644 index 0000000..44c9ada --- /dev/null +++ b/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs | |||
@@ -0,0 +1,105 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Reflection; | ||
30 | using Nini.Config; | ||
31 | using log4net; | ||
32 | using OpenSim.Framework; | ||
33 | using OpenSim.Region.Framework.Interfaces; | ||
34 | using OpenSim.Region.Framework.Scenes; | ||
35 | using Mono.Addins; | ||
36 | using OpenMetaverse; | ||
37 | |||
38 | namespace OpenSim.Region.OptionalModules.Scripting.ScriptModuleComms | ||
39 | { | ||
40 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "ScriptModuleCommsModule")] | ||
41 | class ScriptModuleCommsModule : INonSharedRegionModule, IScriptModuleComms | ||
42 | { | ||
43 | private static readonly ILog m_log = | ||
44 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
45 | |||
46 | private IScriptModule m_scriptModule = null; | ||
47 | |||
48 | public event ScriptCommand OnScriptCommand; | ||
49 | |||
50 | public void Initialise(IConfigSource config) | ||
51 | { | ||
52 | } | ||
53 | |||
54 | public void AddRegion(Scene scene) | ||
55 | { | ||
56 | scene.RegisterModuleInterface<IScriptModuleComms>(this); | ||
57 | } | ||
58 | |||
59 | public void RemoveRegion(Scene scene) | ||
60 | { | ||
61 | } | ||
62 | |||
63 | public void RegionLoaded(Scene scene) | ||
64 | { | ||
65 | m_scriptModule = scene.RequestModuleInterface<IScriptModule>(); | ||
66 | |||
67 | if (m_scriptModule != null) | ||
68 | m_log.Info("[MODULE COMMANDS]: Script engine found, module active"); | ||
69 | } | ||
70 | |||
71 | public string Name | ||
72 | { | ||
73 | get { return "ScriptModuleCommsModule"; } | ||
74 | } | ||
75 | |||
76 | public Type ReplaceableInterface | ||
77 | { | ||
78 | get { return null; } | ||
79 | } | ||
80 | |||
81 | public void Close() | ||
82 | { | ||
83 | } | ||
84 | |||
85 | public void RaiseEvent(UUID script, string id, string module, string command, string k) | ||
86 | { | ||
87 | ScriptCommand c = OnScriptCommand; | ||
88 | |||
89 | if (c == null) | ||
90 | return; | ||
91 | |||
92 | c(script, id, module, command, k); | ||
93 | } | ||
94 | |||
95 | public void DispatchReply(UUID script, int code, string text, string k) | ||
96 | { | ||
97 | if (m_scriptModule == null) | ||
98 | return; | ||
99 | |||
100 | Object[] args = new Object[] {-1, code, text, k}; | ||
101 | |||
102 | m_scriptModule.PostScriptEvent(script, "link_message", args); | ||
103 | } | ||
104 | } | ||
105 | } | ||
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs index f7cadaa..cf36d08 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs | |||
@@ -283,6 +283,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
283 | public event FriendActionDelegate OnApproveFriendRequest; | 283 | public event FriendActionDelegate OnApproveFriendRequest; |
284 | public event FriendActionDelegate OnDenyFriendRequest; | 284 | public event FriendActionDelegate OnDenyFriendRequest; |
285 | public event FriendshipTermination OnTerminateFriendship; | 285 | public event FriendshipTermination OnTerminateFriendship; |
286 | public event GrantUserFriendRights OnGrantUserRights; | ||
286 | 287 | ||
287 | public event EconomyDataRequest OnEconomyDataRequest; | 288 | public event EconomyDataRequest OnEconomyDataRequest; |
288 | public event MoneyBalanceRequest OnMoneyBalanceRequest; | 289 | public event MoneyBalanceRequest OnMoneyBalanceRequest; |
@@ -627,6 +628,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
627 | public virtual void SendInventoryFolderDetails(UUID ownerID, UUID folderID, | 628 | public virtual void SendInventoryFolderDetails(UUID ownerID, UUID folderID, |
628 | List<InventoryItemBase> items, | 629 | List<InventoryItemBase> items, |
629 | List<InventoryFolderBase> folders, | 630 | List<InventoryFolderBase> folders, |
631 | int version, | ||
630 | bool fetchFolders, | 632 | bool fetchFolders, |
631 | bool fetchItems) | 633 | bool fetchItems) |
632 | { | 634 | { |
diff --git a/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs b/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs index 0b3cee7..d5d146e 100644 --- a/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs +++ b/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs | |||
@@ -347,6 +347,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin | |||
347 | { | 347 | { |
348 | indexBase = mesh.getIndexListAsInt(); | 348 | indexBase = mesh.getIndexListAsInt(); |
349 | vertexBase = new Vector3[iVertexCount]; | 349 | vertexBase = new Vector3[iVertexCount]; |
350 | |||
350 | for (int i = 0; i < iVertexCount; i++) | 351 | for (int i = 0; i < iVertexCount; i++) |
351 | { | 352 | { |
352 | OpenMetaverse.Vector3 v = mesh.getVertexList()[i]; | 353 | OpenMetaverse.Vector3 v = mesh.getVertexList()[i]; |
@@ -355,6 +356,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin | |||
355 | else | 356 | else |
356 | vertexBase[i] = Vector3.Zero; | 357 | vertexBase[i] = Vector3.Zero; |
357 | } | 358 | } |
359 | |||
358 | for (int ix = 0; ix < iIndexCount; ix += 3) | 360 | for (int ix = 0; ix < iIndexCount; ix += 3) |
359 | { | 361 | { |
360 | int ia = indexBase[ix + 0]; | 362 | int ia = indexBase[ix + 0]; |
diff --git a/OpenSim/Region/Physics/Manager/PhysicsActor.cs b/OpenSim/Region/Physics/Manager/PhysicsActor.cs index ea4db70..8241e8f 100644 --- a/OpenSim/Region/Physics/Manager/PhysicsActor.cs +++ b/OpenSim/Region/Physics/Manager/PhysicsActor.cs | |||
@@ -52,6 +52,20 @@ namespace OpenSim.Region.Physics.Manager | |||
52 | , Absolute | 52 | , Absolute |
53 | } | 53 | } |
54 | 54 | ||
55 | public struct ContactPoint | ||
56 | { | ||
57 | public Vector3 Position; | ||
58 | public Vector3 SurfaceNormal; | ||
59 | public float PenetrationDepth; | ||
60 | |||
61 | public ContactPoint(Vector3 position, Vector3 surfaceNormal, float penetrationDepth) | ||
62 | { | ||
63 | Position = position; | ||
64 | SurfaceNormal = surfaceNormal; | ||
65 | PenetrationDepth = penetrationDepth; | ||
66 | } | ||
67 | } | ||
68 | |||
55 | public class CollisionEventUpdate : EventArgs | 69 | public class CollisionEventUpdate : EventArgs |
56 | { | 70 | { |
57 | // Raising the event on the object, so don't need to provide location.. further up the tree knows that info. | 71 | // Raising the event on the object, so don't need to provide location.. further up the tree knows that info. |
@@ -59,9 +73,9 @@ namespace OpenSim.Region.Physics.Manager | |||
59 | public int m_colliderType; | 73 | public int m_colliderType; |
60 | public int m_GenericStartEnd; | 74 | public int m_GenericStartEnd; |
61 | //public uint m_LocalID; | 75 | //public uint m_LocalID; |
62 | public Dictionary<uint,float> m_objCollisionList = new Dictionary<uint,float>(); | 76 | public Dictionary<uint, ContactPoint> m_objCollisionList = new Dictionary<uint, ContactPoint>(); |
63 | 77 | ||
64 | public CollisionEventUpdate(uint localID, int colliderType, int GenericStartEnd, Dictionary<uint, float> objCollisionList) | 78 | public CollisionEventUpdate(uint localID, int colliderType, int GenericStartEnd, Dictionary<uint, ContactPoint> objCollisionList) |
65 | { | 79 | { |
66 | m_colliderType = colliderType; | 80 | m_colliderType = colliderType; |
67 | m_GenericStartEnd = GenericStartEnd; | 81 | m_GenericStartEnd = GenericStartEnd; |
@@ -72,8 +86,7 @@ namespace OpenSim.Region.Physics.Manager | |||
72 | { | 86 | { |
73 | m_colliderType = (int) ActorTypes.Unknown; | 87 | m_colliderType = (int) ActorTypes.Unknown; |
74 | m_GenericStartEnd = 1; | 88 | m_GenericStartEnd = 1; |
75 | // m_objCollisionList = null; | 89 | m_objCollisionList = new Dictionary<uint, ContactPoint>(); |
76 | m_objCollisionList = new Dictionary<uint, float>(); | ||
77 | } | 90 | } |
78 | 91 | ||
79 | public int collidertype | 92 | public int collidertype |
@@ -88,16 +101,16 @@ namespace OpenSim.Region.Physics.Manager | |||
88 | set { m_GenericStartEnd = value; } | 101 | set { m_GenericStartEnd = value; } |
89 | } | 102 | } |
90 | 103 | ||
91 | public void addCollider(uint localID, float depth) | 104 | public void addCollider(uint localID, ContactPoint contact) |
92 | { | 105 | { |
93 | if (!m_objCollisionList.ContainsKey(localID)) | 106 | if (!m_objCollisionList.ContainsKey(localID)) |
94 | { | 107 | { |
95 | m_objCollisionList.Add(localID, depth); | 108 | m_objCollisionList.Add(localID, contact); |
96 | } | 109 | } |
97 | else | 110 | else |
98 | { | 111 | { |
99 | if (m_objCollisionList[localID] < depth) | 112 | if (m_objCollisionList[localID].PenetrationDepth < contact.PenetrationDepth) |
100 | m_objCollisionList[localID] = depth; | 113 | m_objCollisionList[localID] = contact; |
101 | } | 114 | } |
102 | } | 115 | } |
103 | } | 116 | } |
diff --git a/OpenSim/Region/Physics/Manager/PhysicsScene.cs b/OpenSim/Region/Physics/Manager/PhysicsScene.cs index bb0d18e..6d515e9 100644 --- a/OpenSim/Region/Physics/Manager/PhysicsScene.cs +++ b/OpenSim/Region/Physics/Manager/PhysicsScene.cs | |||
@@ -75,6 +75,11 @@ namespace OpenSim.Region.Physics.Manager | |||
75 | public abstract PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position, | 75 | public abstract PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position, |
76 | Vector3 size, Quaternion rotation, bool isPhysical); | 76 | Vector3 size, Quaternion rotation, bool isPhysical); |
77 | 77 | ||
78 | public virtual float TimeDilation | ||
79 | { | ||
80 | get { return 1.0f; } | ||
81 | } | ||
82 | |||
78 | public virtual bool SupportsNINJAJoints | 83 | public virtual bool SupportsNINJAJoints |
79 | { | 84 | { |
80 | get { return false; } | 85 | get { return false; } |
diff --git a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs index fbe1949..fded95e 100644 --- a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs +++ b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs | |||
@@ -284,9 +284,13 @@ namespace OpenSim.Region.Physics.Meshing | |||
284 | 284 | ||
285 | try | 285 | try |
286 | { | 286 | { |
287 | idata = CSJ2K.J2kImage.FromBytes(primShape.SculptData); | 287 | OpenMetaverse.Imaging.ManagedImage unusedData; |
288 | OpenMetaverse.Imaging.OpenJPEG.DecodeToImage(primShape.SculptData, out unusedData, out idata); | ||
289 | unusedData = null; | ||
288 | 290 | ||
289 | if (cacheSculptMaps) | 291 | //idata = CSJ2K.J2kImage.FromBytes(primShape.SculptData); |
292 | |||
293 | if (cacheSculptMaps && idata != null) | ||
290 | { | 294 | { |
291 | try { idata.Save(decodedSculptFileName, ImageFormat.MemoryBmp); } | 295 | try { idata.Save(decodedSculptFileName, ImageFormat.MemoryBmp); } |
292 | catch (Exception e) { m_log.Error("[SCULPT]: unable to cache sculpt map " + decodedSculptFileName + " " + e.Message); } | 296 | catch (Exception e) { m_log.Error("[SCULPT]: unable to cache sculpt map " + decodedSculptFileName + " " + e.Message); } |
@@ -299,12 +303,12 @@ namespace OpenSim.Region.Physics.Meshing | |||
299 | } | 303 | } |
300 | catch (IndexOutOfRangeException) | 304 | catch (IndexOutOfRangeException) |
301 | { | 305 | { |
302 | m_log.Error("[PHYSICS]: OpenJpeg was unable to decode this. Physics Proxy generation failed"); | 306 | m_log.Error("[PHYSICS]: OpenJpeg was unable to decode this. Physics Proxy generation failed"); |
303 | return null; | 307 | return null; |
304 | } | 308 | } |
305 | catch (Exception) | 309 | catch (Exception ex) |
306 | { | 310 | { |
307 | m_log.Error("[PHYSICS]: Unable to generate a Sculpty physics proxy. Sculpty texture decode failed!"); | 311 | m_log.Error("[PHYSICS]: Unable to generate a Sculpty physics proxy. Sculpty texture decode failed: " + ex.Message); |
308 | return null; | 312 | return null; |
309 | } | 313 | } |
310 | } | 314 | } |
diff --git a/OpenSim/Region/Physics/Meshing/PrimMesher.cs b/OpenSim/Region/Physics/Meshing/PrimMesher.cs index 47ce615..2a213c3 100644 --- a/OpenSim/Region/Physics/Meshing/PrimMesher.cs +++ b/OpenSim/Region/Physics/Meshing/PrimMesher.cs | |||
@@ -67,11 +67,6 @@ namespace PrimMesher | |||
67 | Normalize(); | 67 | Normalize(); |
68 | } | 68 | } |
69 | 69 | ||
70 | public Quat Identity() | ||
71 | { | ||
72 | return new Quat(0.0f, 0.0f, 0.0f, 1.0f); | ||
73 | } | ||
74 | |||
75 | public float Length() | 70 | public float Length() |
76 | { | 71 | { |
77 | return (float)Math.Sqrt(X * X + Y * Y + Z * Z + W * W); | 72 | return (float)Math.Sqrt(X * X + Y * Y + Z * Z + W * W); |
@@ -660,7 +655,7 @@ namespace PrimMesher | |||
660 | this.faceNumbers = new List<int>(); | 655 | this.faceNumbers = new List<int>(); |
661 | 656 | ||
662 | Coord center = new Coord(0.0f, 0.0f, 0.0f); | 657 | Coord center = new Coord(0.0f, 0.0f, 0.0f); |
663 | bool hasCenter = false; | 658 | //bool hasCenter = false; |
664 | 659 | ||
665 | List<Coord> hollowCoords = new List<Coord>(); | 660 | List<Coord> hollowCoords = new List<Coord>(); |
666 | List<Coord> hollowNormals = new List<Coord>(); | 661 | List<Coord> hollowNormals = new List<Coord>(); |
@@ -727,7 +722,7 @@ namespace PrimMesher | |||
727 | else if (!simpleFace) | 722 | else if (!simpleFace) |
728 | { | 723 | { |
729 | this.coords.Add(center); | 724 | this.coords.Add(center); |
730 | hasCenter = true; | 725 | //hasCenter = true; |
731 | if (this.calcVertexNormals) | 726 | if (this.calcVertexNormals) |
732 | this.vertexNormals.Add(new Coord(0.0f, 0.0f, 1.0f)); | 727 | this.vertexNormals.Add(new Coord(0.0f, 0.0f, 1.0f)); |
733 | this.us.Add(0.0f); | 728 | this.us.Add(0.0f); |
@@ -1353,7 +1348,7 @@ namespace PrimMesher | |||
1353 | float stepSize = twoPi / this.stepsPerRevolution; | 1348 | float stepSize = twoPi / this.stepsPerRevolution; |
1354 | 1349 | ||
1355 | int step = (int)(startAngle / stepSize); | 1350 | int step = (int)(startAngle / stepSize); |
1356 | int firstStep = step; | 1351 | // int firstStep = step; |
1357 | float angle = startAngle; | 1352 | float angle = startAngle; |
1358 | 1353 | ||
1359 | bool done = false; | 1354 | bool done = false; |
@@ -1541,7 +1536,7 @@ namespace PrimMesher | |||
1541 | } | 1536 | } |
1542 | 1537 | ||
1543 | /// <summary> | 1538 | /// <summary> |
1544 | /// Extrudes a profile along a straight line path. Used for prim types box, cylinder, and prism. | 1539 | /// Extrudes a profile along a path. |
1545 | /// </summary> | 1540 | /// </summary> |
1546 | public void Extrude(PathType pathType) | 1541 | public void Extrude(PathType pathType) |
1547 | { | 1542 | { |
@@ -1557,7 +1552,6 @@ namespace PrimMesher | |||
1557 | if (this.calcVertexNormals) | 1552 | if (this.calcVertexNormals) |
1558 | this.normals = new List<Coord>(); | 1553 | this.normals = new List<Coord>(); |
1559 | 1554 | ||
1560 | //int step = 0; | ||
1561 | int steps = 1; | 1555 | int steps = 1; |
1562 | 1556 | ||
1563 | float length = this.pathCutEnd - this.pathCutBegin; | 1557 | float length = this.pathCutEnd - this.pathCutBegin; |
@@ -1579,20 +1573,6 @@ namespace PrimMesher | |||
1579 | if (twistTotalAbs > 0.01f) | 1573 | if (twistTotalAbs > 0.01f) |
1580 | steps += (int)(twistTotalAbs * 3.66); // dahlia's magic number | 1574 | steps += (int)(twistTotalAbs * 3.66); // dahlia's magic number |
1581 | 1575 | ||
1582 | //float start = -0.5f; | ||
1583 | //float stepSize = length / (float)steps; | ||
1584 | //float percentOfPathMultiplier = stepSize; | ||
1585 | //float xProfileScale = 1.0f; | ||
1586 | //float yProfileScale = 1.0f; | ||
1587 | //float xOffset = 0.0f; | ||
1588 | //float yOffset = 0.0f; | ||
1589 | //float zOffset = start; | ||
1590 | //float xOffsetStepIncrement = this.topShearX / steps; | ||
1591 | //float yOffsetStepIncrement = this.topShearY / steps; | ||
1592 | |||
1593 | //float percentOfPath = this.pathCutBegin; | ||
1594 | //zOffset += percentOfPath; | ||
1595 | |||
1596 | float hollow = this.hollow; | 1576 | float hollow = this.hollow; |
1597 | 1577 | ||
1598 | // sanity checks | 1578 | // sanity checks |
@@ -1662,7 +1642,6 @@ namespace PrimMesher | |||
1662 | cut2Vert = hasHollow ? profile.numOuterVerts - 1 : profile.numOuterVerts; | 1642 | cut2Vert = hasHollow ? profile.numOuterVerts - 1 : profile.numOuterVerts; |
1663 | } | 1643 | } |
1664 | 1644 | ||
1665 | |||
1666 | if (initialProfileRot != 0.0f) | 1645 | if (initialProfileRot != 0.0f) |
1667 | { | 1646 | { |
1668 | profile.AddRot(new Quat(new Coord(0.0f, 0.0f, 1.0f), initialProfileRot)); | 1647 | profile.AddRot(new Quat(new Coord(0.0f, 0.0f, 1.0f), initialProfileRot)); |
@@ -1693,24 +1672,6 @@ namespace PrimMesher | |||
1693 | path.stepsPerRevolution = stepsPerRevolution; | 1672 | path.stepsPerRevolution = stepsPerRevolution; |
1694 | 1673 | ||
1695 | path.Create(pathType, steps); | 1674 | path.Create(pathType, steps); |
1696 | /* | ||
1697 | public int twistBegin = 0; | ||
1698 | public int twistEnd = 0; | ||
1699 | public float topShearX = 0.0f; | ||
1700 | public float topShearY = 0.0f; | ||
1701 | public float pathCutBegin = 0.0f; | ||
1702 | public float pathCutEnd = 1.0f; | ||
1703 | public float dimpleBegin = 0.0f; | ||
1704 | public float dimpleEnd = 1.0f; | ||
1705 | public float skew = 0.0f; | ||
1706 | public float holeSizeX = 1.0f; // called pathScaleX in pbs | ||
1707 | public float holeSizeY = 0.25f; | ||
1708 | public float taperX = 0.0f; | ||
1709 | public float taperY = 0.0f; | ||
1710 | public float radius = 0.0f; | ||
1711 | public float revolutions = 1.0f; | ||
1712 | public int stepsPerRevolution = 24; | ||
1713 | */ | ||
1714 | 1675 | ||
1715 | bool needEndFaces = false; | 1676 | bool needEndFaces = false; |
1716 | if (pathType == PathType.Circular) | 1677 | if (pathType == PathType.Circular) |
@@ -1777,7 +1738,7 @@ namespace PrimMesher | |||
1777 | // append this layer | 1738 | // append this layer |
1778 | 1739 | ||
1779 | int coordsLen = this.coords.Count; | 1740 | int coordsLen = this.coords.Count; |
1780 | int lastCoordsLen = coordsLen; | 1741 | // int lastCoordsLen = coordsLen; |
1781 | newLayer.AddValue2FaceVertexIndices(coordsLen); | 1742 | newLayer.AddValue2FaceVertexIndices(coordsLen); |
1782 | 1743 | ||
1783 | this.coords.AddRange(newLayer.coords); | 1744 | this.coords.AddRange(newLayer.coords); |
@@ -1796,7 +1757,6 @@ namespace PrimMesher | |||
1796 | int numVerts = newLayer.coords.Count; | 1757 | int numVerts = newLayer.coords.Count; |
1797 | Face newFace = new Face(); | 1758 | Face newFace = new Face(); |
1798 | 1759 | ||
1799 | //if (step > 0) | ||
1800 | if (nodeIndex > 0) | 1760 | if (nodeIndex > 0) |
1801 | { | 1761 | { |
1802 | int startVert = coordsLen + 1; | 1762 | int startVert = coordsLen + 1; |
@@ -1812,7 +1772,6 @@ namespace PrimMesher | |||
1812 | iNext = startVert; | 1772 | iNext = startVert; |
1813 | 1773 | ||
1814 | int whichVert = i - startVert; | 1774 | int whichVert = i - startVert; |
1815 | //int whichVert2 = i - lastCoordsLen; | ||
1816 | 1775 | ||
1817 | newFace.v1 = i; | 1776 | newFace.v1 = i; |
1818 | newFace.v2 = i - numVerts; | 1777 | newFace.v2 = i - numVerts; |
@@ -1982,809 +1941,27 @@ namespace PrimMesher | |||
1982 | 1941 | ||
1983 | 1942 | ||
1984 | /// <summary> | 1943 | /// <summary> |
1944 | /// DEPRICATED - use Extrude(PathType.Linear) instead | ||
1985 | /// Extrudes a profile along a straight line path. Used for prim types box, cylinder, and prism. | 1945 | /// Extrudes a profile along a straight line path. Used for prim types box, cylinder, and prism. |
1986 | /// </summary> | 1946 | /// </summary> |
1947 | /// | ||
1987 | public void ExtrudeLinear() | 1948 | public void ExtrudeLinear() |
1988 | { | 1949 | { |
1989 | this.coords = new List<Coord>(); | 1950 | this.Extrude(PathType.Linear); |
1990 | this.faces = new List<Face>(); | ||
1991 | |||
1992 | if (this.viewerMode) | ||
1993 | { | ||
1994 | this.viewerFaces = new List<ViewerFace>(); | ||
1995 | this.calcVertexNormals = true; | ||
1996 | } | ||
1997 | |||
1998 | if (this.calcVertexNormals) | ||
1999 | this.normals = new List<Coord>(); | ||
2000 | |||
2001 | int step = 0; | ||
2002 | int steps = 1; | ||
2003 | |||
2004 | float length = this.pathCutEnd - this.pathCutBegin; | ||
2005 | normalsProcessed = false; | ||
2006 | |||
2007 | if (this.viewerMode && this.sides == 3) | ||
2008 | { | ||
2009 | // prisms don't taper well so add some vertical resolution | ||
2010 | // other prims may benefit from this but just do prisms for now | ||
2011 | if (Math.Abs(this.taperX) > 0.01 || Math.Abs(this.taperY) > 0.01) | ||
2012 | steps = (int)(steps * 4.5 * length); | ||
2013 | } | ||
2014 | |||
2015 | |||
2016 | float twistBegin = this.twistBegin / 360.0f * twoPi; | ||
2017 | float twistEnd = this.twistEnd / 360.0f * twoPi; | ||
2018 | float twistTotal = twistEnd - twistBegin; | ||
2019 | float twistTotalAbs = Math.Abs(twistTotal); | ||
2020 | if (twistTotalAbs > 0.01f) | ||
2021 | steps += (int)(twistTotalAbs * 3.66); // dahlia's magic number | ||
2022 | |||
2023 | float start = -0.5f; | ||
2024 | float stepSize = length / (float)steps; | ||
2025 | float percentOfPathMultiplier = stepSize; | ||
2026 | float xProfileScale = 1.0f; | ||
2027 | float yProfileScale = 1.0f; | ||
2028 | float xOffset = 0.0f; | ||
2029 | float yOffset = 0.0f; | ||
2030 | float zOffset = start; | ||
2031 | float xOffsetStepIncrement = this.topShearX / steps; | ||
2032 | float yOffsetStepIncrement = this.topShearY / steps; | ||
2033 | |||
2034 | float percentOfPath = this.pathCutBegin; | ||
2035 | zOffset += percentOfPath; | ||
2036 | |||
2037 | float hollow = this.hollow; | ||
2038 | |||
2039 | // sanity checks | ||
2040 | float initialProfileRot = 0.0f; | ||
2041 | if (this.sides == 3) | ||
2042 | { | ||
2043 | if (this.hollowSides == 4) | ||
2044 | { | ||
2045 | if (hollow > 0.7f) | ||
2046 | hollow = 0.7f; | ||
2047 | hollow *= 0.707f; | ||
2048 | } | ||
2049 | else hollow *= 0.5f; | ||
2050 | } | ||
2051 | else if (this.sides == 4) | ||
2052 | { | ||
2053 | initialProfileRot = 1.25f * (float)Math.PI; | ||
2054 | if (this.hollowSides != 4) | ||
2055 | hollow *= 0.707f; | ||
2056 | } | ||
2057 | else if (this.sides == 24 && this.hollowSides == 4) | ||
2058 | hollow *= 1.414f; | ||
2059 | |||
2060 | Profile profile = new Profile(this.sides, this.profileStart, this.profileEnd, hollow, this.hollowSides, true, calcVertexNormals); | ||
2061 | this.errorMessage = profile.errorMessage; | ||
2062 | |||
2063 | this.numPrimFaces = profile.numPrimFaces; | ||
2064 | |||
2065 | int cut1Vert = -1; | ||
2066 | int cut2Vert = -1; | ||
2067 | if (hasProfileCut) | ||
2068 | { | ||
2069 | cut1Vert = hasHollow ? profile.coords.Count - 1 : 0; | ||
2070 | cut2Vert = hasHollow ? profile.numOuterVerts - 1 : profile.numOuterVerts; | ||
2071 | } | ||
2072 | |||
2073 | if (initialProfileRot != 0.0f) | ||
2074 | { | ||
2075 | profile.AddRot(new Quat(new Coord(0.0f, 0.0f, 1.0f), initialProfileRot)); | ||
2076 | if (viewerMode) | ||
2077 | profile.MakeFaceUVs(); | ||
2078 | } | ||
2079 | |||
2080 | Coord lastCutNormal1 = new Coord(); | ||
2081 | Coord lastCutNormal2 = new Coord(); | ||
2082 | float lastV = 1.0f; | ||
2083 | |||
2084 | bool done = false; | ||
2085 | while (!done) | ||
2086 | { | ||
2087 | Profile newLayer = profile.Copy(); | ||
2088 | |||
2089 | if (this.taperX == 0.0f) | ||
2090 | xProfileScale = 1.0f; | ||
2091 | else if (this.taperX > 0.0f) | ||
2092 | xProfileScale = 1.0f - percentOfPath * this.taperX; | ||
2093 | else xProfileScale = 1.0f + (1.0f - percentOfPath) * this.taperX; | ||
2094 | |||
2095 | if (this.taperY == 0.0f) | ||
2096 | yProfileScale = 1.0f; | ||
2097 | else if (this.taperY > 0.0f) | ||
2098 | yProfileScale = 1.0f - percentOfPath * this.taperY; | ||
2099 | else yProfileScale = 1.0f + (1.0f - percentOfPath) * this.taperY; | ||
2100 | |||
2101 | if (xProfileScale != 1.0f || yProfileScale != 1.0f) | ||
2102 | newLayer.Scale(xProfileScale, yProfileScale); | ||
2103 | |||
2104 | float twist = twistBegin + twistTotal * percentOfPath; | ||
2105 | if (twist != 0.0f) | ||
2106 | newLayer.AddRot(new Quat(new Coord(0.0f, 0.0f, 1.0f), twist)); | ||
2107 | |||
2108 | newLayer.AddPos(xOffset, yOffset, zOffset); | ||
2109 | |||
2110 | if (step == 0) | ||
2111 | { | ||
2112 | newLayer.FlipNormals(); | ||
2113 | |||
2114 | // add the top faces to the viewerFaces list here | ||
2115 | if (this.viewerMode) | ||
2116 | { | ||
2117 | Coord faceNormal = newLayer.faceNormal; | ||
2118 | ViewerFace newViewerFace = new ViewerFace(profile.bottomFaceNumber); | ||
2119 | int numFaces = newLayer.faces.Count; | ||
2120 | List<Face> faces = newLayer.faces; | ||
2121 | |||
2122 | for (int i = 0; i < numFaces; i++) | ||
2123 | { | ||
2124 | Face face = faces[i]; | ||
2125 | newViewerFace.v1 = newLayer.coords[face.v1]; | ||
2126 | newViewerFace.v2 = newLayer.coords[face.v2]; | ||
2127 | newViewerFace.v3 = newLayer.coords[face.v3]; | ||
2128 | |||
2129 | newViewerFace.coordIndex1 = face.v1; | ||
2130 | newViewerFace.coordIndex2 = face.v2; | ||
2131 | newViewerFace.coordIndex3 = face.v3; | ||
2132 | |||
2133 | newViewerFace.n1 = faceNormal; | ||
2134 | newViewerFace.n2 = faceNormal; | ||
2135 | newViewerFace.n3 = faceNormal; | ||
2136 | |||
2137 | newViewerFace.uv1 = newLayer.faceUVs[face.v1]; | ||
2138 | newViewerFace.uv2 = newLayer.faceUVs[face.v2]; | ||
2139 | newViewerFace.uv3 = newLayer.faceUVs[face.v3]; | ||
2140 | |||
2141 | this.viewerFaces.Add(newViewerFace); | ||
2142 | } | ||
2143 | } | ||
2144 | } | ||
2145 | |||
2146 | // append this layer | ||
2147 | |||
2148 | int coordsLen = this.coords.Count; | ||
2149 | int lastCoordsLen = coordsLen; | ||
2150 | newLayer.AddValue2FaceVertexIndices(coordsLen); | ||
2151 | |||
2152 | this.coords.AddRange(newLayer.coords); | ||
2153 | |||
2154 | if (this.calcVertexNormals) | ||
2155 | { | ||
2156 | newLayer.AddValue2FaceNormalIndices(this.normals.Count); | ||
2157 | this.normals.AddRange(newLayer.vertexNormals); | ||
2158 | } | ||
2159 | |||
2160 | if (percentOfPath < this.pathCutBegin + 0.01f || percentOfPath > this.pathCutEnd - 0.01f) | ||
2161 | this.faces.AddRange(newLayer.faces); | ||
2162 | |||
2163 | // fill faces between layers | ||
2164 | |||
2165 | int numVerts = newLayer.coords.Count; | ||
2166 | Face newFace = new Face(); | ||
2167 | |||
2168 | if (step > 0) | ||
2169 | { | ||
2170 | int startVert = coordsLen + 1; | ||
2171 | int endVert = this.coords.Count; | ||
2172 | |||
2173 | if (sides < 5 || this.hasProfileCut || hollow > 0.0f) | ||
2174 | startVert--; | ||
2175 | |||
2176 | for (int i = startVert; i < endVert; i++) | ||
2177 | { | ||
2178 | int iNext = i + 1; | ||
2179 | if (i == endVert - 1) | ||
2180 | iNext = startVert; | ||
2181 | |||
2182 | int whichVert = i - startVert; | ||
2183 | //int whichVert2 = i - lastCoordsLen; | ||
2184 | |||
2185 | newFace.v1 = i; | ||
2186 | newFace.v2 = i - numVerts; | ||
2187 | newFace.v3 = iNext - numVerts; | ||
2188 | this.faces.Add(newFace); | ||
2189 | |||
2190 | newFace.v2 = iNext - numVerts; | ||
2191 | newFace.v3 = iNext; | ||
2192 | this.faces.Add(newFace); | ||
2193 | |||
2194 | if (this.viewerMode) | ||
2195 | { | ||
2196 | // add the side faces to the list of viewerFaces here | ||
2197 | //int primFaceNum = 1; | ||
2198 | //if (whichVert >= sides) | ||
2199 | // primFaceNum = 2; | ||
2200 | int primFaceNum = profile.faceNumbers[whichVert]; | ||
2201 | |||
2202 | ViewerFace newViewerFace1 = new ViewerFace(primFaceNum); | ||
2203 | ViewerFace newViewerFace2 = new ViewerFace(primFaceNum); | ||
2204 | |||
2205 | float u1 = newLayer.us[whichVert]; | ||
2206 | float u2 = 1.0f; | ||
2207 | if (whichVert < newLayer.us.Count - 1) | ||
2208 | u2 = newLayer.us[whichVert + 1]; | ||
2209 | |||
2210 | if (whichVert == cut1Vert || whichVert == cut2Vert) | ||
2211 | { | ||
2212 | u1 = 0.0f; | ||
2213 | u2 = 1.0f; | ||
2214 | } | ||
2215 | else if (sides < 5) | ||
2216 | { // boxes and prisms have one texture face per side of the prim, so the U values have to be scaled | ||
2217 | // to reflect the entire texture width | ||
2218 | u1 *= sides; | ||
2219 | u2 *= sides; | ||
2220 | u2 -= (int)u1; | ||
2221 | u1 -= (int)u1; | ||
2222 | if (u2 < 0.1f) | ||
2223 | u2 = 1.0f; | ||
2224 | |||
2225 | //newViewerFace2.primFaceNumber = newViewerFace1.primFaceNumber = whichVert + 1; | ||
2226 | } | ||
2227 | |||
2228 | newViewerFace1.uv1.U = u1; | ||
2229 | newViewerFace1.uv2.U = u1; | ||
2230 | newViewerFace1.uv3.U = u2; | ||
2231 | |||
2232 | newViewerFace1.uv1.V = 1.0f - percentOfPath; | ||
2233 | newViewerFace1.uv2.V = lastV; | ||
2234 | newViewerFace1.uv3.V = lastV; | ||
2235 | |||
2236 | newViewerFace2.uv1.U = u1; | ||
2237 | newViewerFace2.uv2.U = u2; | ||
2238 | newViewerFace2.uv3.U = u2; | ||
2239 | |||
2240 | newViewerFace2.uv1.V = 1.0f - percentOfPath; | ||
2241 | newViewerFace2.uv2.V = lastV; | ||
2242 | newViewerFace2.uv3.V = 1.0f - percentOfPath; | ||
2243 | |||
2244 | newViewerFace1.v1 = this.coords[i]; | ||
2245 | newViewerFace1.v2 = this.coords[i - numVerts]; | ||
2246 | newViewerFace1.v3 = this.coords[iNext - numVerts]; | ||
2247 | |||
2248 | newViewerFace2.v1 = this.coords[i]; | ||
2249 | newViewerFace2.v2 = this.coords[iNext - numVerts]; | ||
2250 | newViewerFace2.v3 = this.coords[iNext]; | ||
2251 | |||
2252 | newViewerFace1.coordIndex1 = i; | ||
2253 | newViewerFace1.coordIndex2 = i - numVerts; | ||
2254 | newViewerFace1.coordIndex3 = iNext - numVerts; | ||
2255 | |||
2256 | newViewerFace2.coordIndex1 = i; | ||
2257 | newViewerFace2.coordIndex2 = iNext - numVerts; | ||
2258 | newViewerFace2.coordIndex3 = iNext; | ||
2259 | |||
2260 | // profile cut faces | ||
2261 | if (whichVert == cut1Vert) | ||
2262 | { | ||
2263 | newViewerFace1.n1 = newLayer.cutNormal1; | ||
2264 | newViewerFace1.n2 = newViewerFace1.n3 = lastCutNormal1; | ||
2265 | |||
2266 | newViewerFace2.n1 = newViewerFace2.n3 = newLayer.cutNormal1; | ||
2267 | newViewerFace2.n2 = lastCutNormal1; | ||
2268 | } | ||
2269 | else if (whichVert == cut2Vert) | ||
2270 | { | ||
2271 | newViewerFace1.n1 = newLayer.cutNormal2; | ||
2272 | newViewerFace1.n2 = newViewerFace1.n3 = lastCutNormal2; | ||
2273 | |||
2274 | newViewerFace2.n1 = newViewerFace2.n3 = newLayer.cutNormal2; | ||
2275 | newViewerFace2.n2 = lastCutNormal2; | ||
2276 | } | ||
2277 | |||
2278 | else // outer and hollow faces | ||
2279 | { | ||
2280 | if ((sides < 5 && whichVert < newLayer.numOuterVerts) || (hollowSides < 5 && whichVert >= newLayer.numOuterVerts)) | ||
2281 | { | ||
2282 | newViewerFace1.CalcSurfaceNormal(); | ||
2283 | newViewerFace2.CalcSurfaceNormal(); | ||
2284 | } | ||
2285 | else | ||
2286 | { | ||
2287 | newViewerFace1.n1 = this.normals[i]; | ||
2288 | newViewerFace1.n2 = this.normals[i - numVerts]; | ||
2289 | newViewerFace1.n3 = this.normals[iNext - numVerts]; | ||
2290 | |||
2291 | newViewerFace2.n1 = this.normals[i]; | ||
2292 | newViewerFace2.n2 = this.normals[iNext - numVerts]; | ||
2293 | newViewerFace2.n3 = this.normals[iNext]; | ||
2294 | } | ||
2295 | } | ||
2296 | |||
2297 | //newViewerFace2.primFaceNumber = newViewerFace1.primFaceNumber = newLayer.faceNumbers[whichVert]; | ||
2298 | |||
2299 | this.viewerFaces.Add(newViewerFace1); | ||
2300 | this.viewerFaces.Add(newViewerFace2); | ||
2301 | |||
2302 | } | ||
2303 | } | ||
2304 | } | ||
2305 | |||
2306 | lastCutNormal1 = newLayer.cutNormal1; | ||
2307 | lastCutNormal2 = newLayer.cutNormal2; | ||
2308 | lastV = 1.0f - percentOfPath; | ||
2309 | |||
2310 | // calc the step for the next iteration of the loop | ||
2311 | |||
2312 | if (step < steps) | ||
2313 | { | ||
2314 | step += 1; | ||
2315 | percentOfPath += percentOfPathMultiplier; | ||
2316 | xOffset += xOffsetStepIncrement; | ||
2317 | yOffset += yOffsetStepIncrement; | ||
2318 | zOffset += stepSize; | ||
2319 | if (percentOfPath > this.pathCutEnd) | ||
2320 | done = true; | ||
2321 | } | ||
2322 | else done = true; | ||
2323 | |||
2324 | if (done && viewerMode) | ||
2325 | { | ||
2326 | // add the top faces to the viewerFaces list here | ||
2327 | Coord faceNormal = newLayer.faceNormal; | ||
2328 | ViewerFace newViewerFace = new ViewerFace(); | ||
2329 | newViewerFace.primFaceNumber = 0; | ||
2330 | int numFaces = newLayer.faces.Count; | ||
2331 | List<Face> faces = newLayer.faces; | ||
2332 | |||
2333 | for (int i = 0; i < numFaces; i++) | ||
2334 | { | ||
2335 | Face face = faces[i]; | ||
2336 | newViewerFace.v1 = newLayer.coords[face.v1 - coordsLen]; | ||
2337 | newViewerFace.v2 = newLayer.coords[face.v2 - coordsLen]; | ||
2338 | newViewerFace.v3 = newLayer.coords[face.v3 - coordsLen]; | ||
2339 | |||
2340 | newViewerFace.coordIndex1 = face.v1 - coordsLen; | ||
2341 | newViewerFace.coordIndex2 = face.v2 - coordsLen; | ||
2342 | newViewerFace.coordIndex3 = face.v3 - coordsLen; | ||
2343 | |||
2344 | newViewerFace.n1 = faceNormal; | ||
2345 | newViewerFace.n2 = faceNormal; | ||
2346 | newViewerFace.n3 = faceNormal; | ||
2347 | |||
2348 | newViewerFace.uv1 = newLayer.faceUVs[face.v1 - coordsLen]; | ||
2349 | newViewerFace.uv2 = newLayer.faceUVs[face.v2 - coordsLen]; | ||
2350 | newViewerFace.uv3 = newLayer.faceUVs[face.v3 - coordsLen]; | ||
2351 | |||
2352 | this.viewerFaces.Add(newViewerFace); | ||
2353 | } | ||
2354 | } | ||
2355 | } | ||
2356 | } | 1951 | } |
2357 | 1952 | ||
2358 | 1953 | ||
2359 | /// <summary> | 1954 | /// <summary> |
1955 | /// DEPRICATED - use Extrude(PathType.Circular) instead | ||
2360 | /// Extrude a profile into a circular path prim mesh. Used for prim types torus, tube, and ring. | 1956 | /// Extrude a profile into a circular path prim mesh. Used for prim types torus, tube, and ring. |
2361 | /// </summary> | 1957 | /// </summary> |
1958 | /// | ||
2362 | public void ExtrudeCircular() | 1959 | public void ExtrudeCircular() |
2363 | { | 1960 | { |
2364 | this.coords = new List<Coord>(); | 1961 | this.Extrude(PathType.Circular); |
2365 | this.faces = new List<Face>(); | ||
2366 | |||
2367 | if (this.viewerMode) | ||
2368 | { | ||
2369 | this.viewerFaces = new List<ViewerFace>(); | ||
2370 | this.calcVertexNormals = true; | ||
2371 | } | ||
2372 | |||
2373 | if (this.calcVertexNormals) | ||
2374 | this.normals = new List<Coord>(); | ||
2375 | |||
2376 | int step = 0; | ||
2377 | int steps = 24; | ||
2378 | |||
2379 | normalsProcessed = false; | ||
2380 | |||
2381 | float twistBegin = this.twistBegin / 360.0f * twoPi; | ||
2382 | float twistEnd = this.twistEnd / 360.0f * twoPi; | ||
2383 | float twistTotal = twistEnd - twistBegin; | ||
2384 | |||
2385 | // if the profile has a lot of twist, add more layers otherwise the layers may overlap | ||
2386 | // and the resulting mesh may be quite inaccurate. This method is arbitrary and doesn't | ||
2387 | // accurately match the viewer | ||
2388 | float twistTotalAbs = Math.Abs(twistTotal); | ||
2389 | if (twistTotalAbs > 0.01f) | ||
2390 | { | ||
2391 | if (twistTotalAbs > Math.PI * 1.5f) | ||
2392 | steps *= 2; | ||
2393 | if (twistTotalAbs > Math.PI * 3.0f) | ||
2394 | steps *= 2; | ||
2395 | } | ||
2396 | |||
2397 | float yPathScale = this.holeSizeY * 0.5f; | ||
2398 | float pathLength = this.pathCutEnd - this.pathCutBegin; | ||
2399 | float totalSkew = this.skew * 2.0f * pathLength; | ||
2400 | float skewStart = this.pathCutBegin * 2.0f * this.skew - this.skew; | ||
2401 | float xOffsetTopShearXFactor = this.topShearX * (0.25f + 0.5f * (0.5f - this.holeSizeY)); | ||
2402 | float yShearCompensation = 1.0f + Math.Abs(this.topShearY) * 0.25f; | ||
2403 | |||
2404 | // It's not quite clear what pushY (Y top shear) does, but subtracting it from the start and end | ||
2405 | // angles appears to approximate it's effects on path cut. Likewise, adding it to the angle used | ||
2406 | // to calculate the sine for generating the path radius appears to approximate it's effects there | ||
2407 | // too, but there are some subtle differences in the radius which are noticeable as the prim size | ||
2408 | // increases and it may affect megaprims quite a bit. The effect of the Y top shear parameter on | ||
2409 | // the meshes generated with this technique appear nearly identical in shape to the same prims when | ||
2410 | // displayed by the viewer. | ||
2411 | |||
2412 | float startAngle = (twoPi * this.pathCutBegin * this.revolutions) - this.topShearY * 0.9f; | ||
2413 | float endAngle = (twoPi * this.pathCutEnd * this.revolutions) - this.topShearY * 0.9f; | ||
2414 | float stepSize = twoPi / this.stepsPerRevolution; | ||
2415 | |||
2416 | step = (int)(startAngle / stepSize); | ||
2417 | int firstStep = step; | ||
2418 | float angle = startAngle; | ||
2419 | float hollow = this.hollow; | ||
2420 | |||
2421 | // sanity checks | ||
2422 | float initialProfileRot = 0.0f; | ||
2423 | if (this.sides == 3) | ||
2424 | { | ||
2425 | initialProfileRot = (float)Math.PI; | ||
2426 | if (this.hollowSides == 4) | ||
2427 | { | ||
2428 | if (hollow > 0.7f) | ||
2429 | hollow = 0.7f; | ||
2430 | hollow *= 0.707f; | ||
2431 | } | ||
2432 | else hollow *= 0.5f; | ||
2433 | } | ||
2434 | else if (this.sides == 4) | ||
2435 | { | ||
2436 | initialProfileRot = 0.25f * (float)Math.PI; | ||
2437 | if (this.hollowSides != 4) | ||
2438 | hollow *= 0.707f; | ||
2439 | } | ||
2440 | else if (this.sides > 4) | ||
2441 | { | ||
2442 | initialProfileRot = (float)Math.PI; | ||
2443 | if (this.hollowSides == 4) | ||
2444 | { | ||
2445 | if (hollow > 0.7f) | ||
2446 | hollow = 0.7f; | ||
2447 | hollow /= 0.7f; | ||
2448 | } | ||
2449 | } | ||
2450 | |||
2451 | bool needEndFaces = false; | ||
2452 | if (this.pathCutBegin != 0.0f || this.pathCutEnd != 1.0f) | ||
2453 | needEndFaces = true; | ||
2454 | else if (this.taperX != 0.0f || this.taperY != 0.0f) | ||
2455 | needEndFaces = true; | ||
2456 | else if (this.skew != 0.0f) | ||
2457 | needEndFaces = true; | ||
2458 | else if (twistTotal != 0.0f) | ||
2459 | needEndFaces = true; | ||
2460 | else if (this.radius != 0.0f) | ||
2461 | needEndFaces = true; | ||
2462 | |||
2463 | Profile profile = new Profile(this.sides, this.profileStart, this.profileEnd, hollow, this.hollowSides, needEndFaces, calcVertexNormals); | ||
2464 | this.errorMessage = profile.errorMessage; | ||
2465 | |||
2466 | this.numPrimFaces = profile.numPrimFaces; | ||
2467 | |||
2468 | int cut1Vert = -1; | ||
2469 | int cut2Vert = -1; | ||
2470 | if (hasProfileCut) | ||
2471 | { | ||
2472 | cut1Vert = hasHollow ? profile.coords.Count - 1 : 0; | ||
2473 | cut2Vert = hasHollow ? profile.numOuterVerts - 1 : profile.numOuterVerts; | ||
2474 | } | ||
2475 | |||
2476 | if (initialProfileRot != 0.0f) | ||
2477 | { | ||
2478 | profile.AddRot(new Quat(new Coord(0.0f, 0.0f, 1.0f), initialProfileRot)); | ||
2479 | if (viewerMode) | ||
2480 | profile.MakeFaceUVs(); | ||
2481 | } | ||
2482 | |||
2483 | Coord lastCutNormal1 = new Coord(); | ||
2484 | Coord lastCutNormal2 = new Coord(); | ||
2485 | float lastV = 1.0f; | ||
2486 | |||
2487 | bool done = false; | ||
2488 | while (!done) // loop through the length of the path and add the layers | ||
2489 | { | ||
2490 | bool isEndLayer = false; | ||
2491 | if (angle <= startAngle + .01f || angle >= endAngle - .01f) | ||
2492 | isEndLayer = true; | ||
2493 | |||
2494 | Profile newLayer = profile.Copy(); | ||
2495 | |||
2496 | float xProfileScale = (1.0f - Math.Abs(this.skew)) * this.holeSizeX; | ||
2497 | float yProfileScale = this.holeSizeY; | ||
2498 | |||
2499 | float percentOfPath = angle / (twoPi * this.revolutions); | ||
2500 | float percentOfAngles = (angle - startAngle) / (endAngle - startAngle); | ||
2501 | |||
2502 | if (this.taperX > 0.01f) | ||
2503 | xProfileScale *= 1.0f - percentOfPath * this.taperX; | ||
2504 | else if (this.taperX < -0.01f) | ||
2505 | xProfileScale *= 1.0f + (1.0f - percentOfPath) * this.taperX; | ||
2506 | |||
2507 | if (this.taperY > 0.01f) | ||
2508 | yProfileScale *= 1.0f - percentOfPath * this.taperY; | ||
2509 | else if (this.taperY < -0.01f) | ||
2510 | yProfileScale *= 1.0f + (1.0f - percentOfPath) * this.taperY; | ||
2511 | |||
2512 | if (xProfileScale != 1.0f || yProfileScale != 1.0f) | ||
2513 | newLayer.Scale(xProfileScale, yProfileScale); | ||
2514 | |||
2515 | float radiusScale = 1.0f; | ||
2516 | if (this.radius > 0.001f) | ||
2517 | radiusScale = 1.0f - this.radius * percentOfPath; | ||
2518 | else if (this.radius < 0.001f) | ||
2519 | radiusScale = 1.0f + this.radius * (1.0f - percentOfPath); | ||
2520 | |||
2521 | float twist = twistBegin + twistTotal * percentOfPath; | ||
2522 | |||
2523 | float xOffset = 0.5f * (skewStart + totalSkew * percentOfAngles); | ||
2524 | xOffset += (float)Math.Sin(angle) * xOffsetTopShearXFactor; | ||
2525 | |||
2526 | float yOffset = yShearCompensation * (float)Math.Cos(angle) * (0.5f - yPathScale) * radiusScale; | ||
2527 | |||
2528 | float zOffset = (float)Math.Sin(angle + this.topShearY) * (0.5f - yPathScale) * radiusScale; | ||
2529 | |||
2530 | // next apply twist rotation to the profile layer | ||
2531 | if (twistTotal != 0.0f || twistBegin != 0.0f) | ||
2532 | newLayer.AddRot(new Quat(new Coord(0.0f, 0.0f, 1.0f), twist)); | ||
2533 | |||
2534 | // now orient the rotation of the profile layer relative to it's position on the path | ||
2535 | // adding taperY to the angle used to generate the quat appears to approximate the viewer | ||
2536 | newLayer.AddRot(new Quat(new Coord(1.0f, 0.0f, 0.0f), angle + this.topShearY)); | ||
2537 | newLayer.AddPos(xOffset, yOffset, zOffset); | ||
2538 | |||
2539 | if (isEndLayer && angle <= startAngle + .01f) | ||
2540 | { | ||
2541 | newLayer.FlipNormals(); | ||
2542 | |||
2543 | // add the top faces to the viewerFaces list here | ||
2544 | if (this.viewerMode && needEndFaces) | ||
2545 | { | ||
2546 | Coord faceNormal = newLayer.faceNormal; | ||
2547 | ViewerFace newViewerFace = new ViewerFace(); | ||
2548 | newViewerFace.primFaceNumber = 0; | ||
2549 | foreach (Face face in newLayer.faces) | ||
2550 | { | ||
2551 | newViewerFace.v1 = newLayer.coords[face.v1]; | ||
2552 | newViewerFace.v2 = newLayer.coords[face.v2]; | ||
2553 | newViewerFace.v3 = newLayer.coords[face.v3]; | ||
2554 | |||
2555 | newViewerFace.coordIndex1 = face.v1; | ||
2556 | newViewerFace.coordIndex2 = face.v2; | ||
2557 | newViewerFace.coordIndex3 = face.v3; | ||
2558 | |||
2559 | newViewerFace.n1 = faceNormal; | ||
2560 | newViewerFace.n2 = faceNormal; | ||
2561 | newViewerFace.n3 = faceNormal; | ||
2562 | |||
2563 | newViewerFace.uv1 = newLayer.faceUVs[face.v1]; | ||
2564 | newViewerFace.uv2 = newLayer.faceUVs[face.v2]; | ||
2565 | newViewerFace.uv3 = newLayer.faceUVs[face.v3]; | ||
2566 | |||
2567 | this.viewerFaces.Add(newViewerFace); | ||
2568 | } | ||
2569 | } | ||
2570 | } | ||
2571 | |||
2572 | // append the layer and fill in the sides | ||
2573 | |||
2574 | int coordsLen = this.coords.Count; | ||
2575 | newLayer.AddValue2FaceVertexIndices(coordsLen); | ||
2576 | |||
2577 | this.coords.AddRange(newLayer.coords); | ||
2578 | |||
2579 | if (this.calcVertexNormals) | ||
2580 | { | ||
2581 | newLayer.AddValue2FaceNormalIndices(this.normals.Count); | ||
2582 | this.normals.AddRange(newLayer.vertexNormals); | ||
2583 | } | ||
2584 | |||
2585 | if (isEndLayer) | ||
2586 | this.faces.AddRange(newLayer.faces); | ||
2587 | |||
2588 | // fill faces between layers | ||
2589 | |||
2590 | int numVerts = newLayer.coords.Count; | ||
2591 | Face newFace = new Face(); | ||
2592 | if (step > firstStep) | ||
2593 | { | ||
2594 | int startVert = coordsLen + 1; | ||
2595 | int endVert = this.coords.Count; | ||
2596 | |||
2597 | if (sides < 5 || this.hasProfileCut || hollow > 0.0f) | ||
2598 | startVert--; | ||
2599 | |||
2600 | for (int i = startVert; i < endVert; i++) | ||
2601 | { | ||
2602 | int iNext = i + 1; | ||
2603 | if (i == endVert - 1) | ||
2604 | iNext = startVert; | ||
2605 | |||
2606 | int whichVert = i - startVert; | ||
2607 | |||
2608 | newFace.v1 = i; | ||
2609 | newFace.v2 = i - numVerts; | ||
2610 | newFace.v3 = iNext - numVerts; | ||
2611 | this.faces.Add(newFace); | ||
2612 | |||
2613 | newFace.v2 = iNext - numVerts; | ||
2614 | newFace.v3 = iNext; | ||
2615 | this.faces.Add(newFace); | ||
2616 | |||
2617 | if (this.viewerMode) | ||
2618 | { | ||
2619 | int primFaceNumber = profile.faceNumbers[whichVert]; | ||
2620 | if (!needEndFaces) | ||
2621 | primFaceNumber -= 1; | ||
2622 | |||
2623 | // add the side faces to the list of viewerFaces here | ||
2624 | ViewerFace newViewerFace1 = new ViewerFace(primFaceNumber); | ||
2625 | ViewerFace newViewerFace2 = new ViewerFace(primFaceNumber); | ||
2626 | float u1 = newLayer.us[whichVert]; | ||
2627 | float u2 = 1.0f; | ||
2628 | if (whichVert < newLayer.us.Count - 1) | ||
2629 | u2 = newLayer.us[whichVert + 1]; | ||
2630 | |||
2631 | if (whichVert == cut1Vert || whichVert == cut2Vert) | ||
2632 | { | ||
2633 | u1 = 0.0f; | ||
2634 | u2 = 1.0f; | ||
2635 | } | ||
2636 | else if (sides < 5) | ||
2637 | { // boxes and prisms have one texture face per side of the prim, so the U values have to be scaled | ||
2638 | // to reflect the entire texture width | ||
2639 | u1 *= sides; | ||
2640 | u2 *= sides; | ||
2641 | u2 -= (int)u1; | ||
2642 | u1 -= (int)u1; | ||
2643 | if (u2 < 0.1f) | ||
2644 | u2 = 1.0f; | ||
2645 | |||
2646 | //newViewerFace2.primFaceNumber = newViewerFace1.primFaceNumber = whichVert + 1; | ||
2647 | } | ||
2648 | |||
2649 | newViewerFace1.uv1.U = u1; | ||
2650 | newViewerFace1.uv2.U = u1; | ||
2651 | newViewerFace1.uv3.U = u2; | ||
2652 | |||
2653 | newViewerFace1.uv1.V = 1.0f - percentOfPath; | ||
2654 | newViewerFace1.uv2.V = lastV; | ||
2655 | newViewerFace1.uv3.V = lastV; | ||
2656 | |||
2657 | newViewerFace2.uv1.U = u1; | ||
2658 | newViewerFace2.uv2.U = u2; | ||
2659 | newViewerFace2.uv3.U = u2; | ||
2660 | |||
2661 | newViewerFace2.uv1.V = 1.0f - percentOfPath; | ||
2662 | newViewerFace2.uv2.V = lastV; | ||
2663 | newViewerFace2.uv3.V = 1.0f - percentOfPath; | ||
2664 | |||
2665 | newViewerFace1.v1 = this.coords[i]; | ||
2666 | newViewerFace1.v2 = this.coords[i - numVerts]; | ||
2667 | newViewerFace1.v3 = this.coords[iNext - numVerts]; | ||
2668 | |||
2669 | newViewerFace2.v1 = this.coords[i]; | ||
2670 | newViewerFace2.v2 = this.coords[iNext - numVerts]; | ||
2671 | newViewerFace2.v3 = this.coords[iNext]; | ||
2672 | |||
2673 | newViewerFace1.coordIndex1 = i; | ||
2674 | newViewerFace1.coordIndex2 = i - numVerts; | ||
2675 | newViewerFace1.coordIndex3 = iNext - numVerts; | ||
2676 | |||
2677 | newViewerFace2.coordIndex1 = i; | ||
2678 | newViewerFace2.coordIndex2 = iNext - numVerts; | ||
2679 | newViewerFace2.coordIndex3 = iNext; | ||
2680 | |||
2681 | // profile cut faces | ||
2682 | if (whichVert == cut1Vert) | ||
2683 | { | ||
2684 | newViewerFace1.n1 = newLayer.cutNormal1; | ||
2685 | newViewerFace1.n2 = newViewerFace1.n3 = lastCutNormal1; | ||
2686 | |||
2687 | newViewerFace2.n1 = newViewerFace2.n3 = newLayer.cutNormal1; | ||
2688 | newViewerFace2.n2 = lastCutNormal1; | ||
2689 | } | ||
2690 | else if (whichVert == cut2Vert) | ||
2691 | { | ||
2692 | newViewerFace1.n1 = newLayer.cutNormal2; | ||
2693 | newViewerFace1.n2 = newViewerFace1.n3 = lastCutNormal2; | ||
2694 | |||
2695 | newViewerFace2.n1 = newViewerFace2.n3 = newLayer.cutNormal2; | ||
2696 | newViewerFace2.n2 = lastCutNormal2; | ||
2697 | } | ||
2698 | else // periphery faces | ||
2699 | { | ||
2700 | if (sides < 5 && whichVert < newLayer.numOuterVerts) | ||
2701 | { | ||
2702 | newViewerFace1.n1 = this.normals[i]; | ||
2703 | newViewerFace1.n2 = this.normals[i - numVerts]; | ||
2704 | newViewerFace1.n3 = this.normals[i - numVerts]; | ||
2705 | |||
2706 | newViewerFace2.n1 = this.normals[i]; | ||
2707 | newViewerFace2.n2 = this.normals[i - numVerts]; | ||
2708 | newViewerFace2.n3 = this.normals[i]; | ||
2709 | } | ||
2710 | else if (hollowSides < 5 && whichVert >= newLayer.numOuterVerts) | ||
2711 | { | ||
2712 | newViewerFace1.n1 = this.normals[iNext]; | ||
2713 | newViewerFace1.n2 = this.normals[iNext - numVerts]; | ||
2714 | newViewerFace1.n3 = this.normals[iNext - numVerts]; | ||
2715 | |||
2716 | newViewerFace2.n1 = this.normals[iNext]; | ||
2717 | newViewerFace2.n2 = this.normals[iNext - numVerts]; | ||
2718 | newViewerFace2.n3 = this.normals[iNext]; | ||
2719 | } | ||
2720 | else | ||
2721 | { | ||
2722 | newViewerFace1.n1 = this.normals[i]; | ||
2723 | newViewerFace1.n2 = this.normals[i - numVerts]; | ||
2724 | newViewerFace1.n3 = this.normals[iNext - numVerts]; | ||
2725 | |||
2726 | newViewerFace2.n1 = this.normals[i]; | ||
2727 | newViewerFace2.n2 = this.normals[iNext - numVerts]; | ||
2728 | newViewerFace2.n3 = this.normals[iNext]; | ||
2729 | } | ||
2730 | } | ||
2731 | |||
2732 | //newViewerFace1.primFaceNumber = newViewerFace2.primFaceNumber = newLayer.faceNumbers[whichVert]; | ||
2733 | this.viewerFaces.Add(newViewerFace1); | ||
2734 | this.viewerFaces.Add(newViewerFace2); | ||
2735 | |||
2736 | } | ||
2737 | } | ||
2738 | } | ||
2739 | |||
2740 | lastCutNormal1 = newLayer.cutNormal1; | ||
2741 | lastCutNormal2 = newLayer.cutNormal2; | ||
2742 | lastV = 1.0f - percentOfPath; | ||
2743 | |||
2744 | // calculate terms for next iteration | ||
2745 | // calculate the angle for the next iteration of the loop | ||
2746 | |||
2747 | if (angle >= endAngle - 0.01) | ||
2748 | done = true; | ||
2749 | else | ||
2750 | { | ||
2751 | step += 1; | ||
2752 | angle = stepSize * step; | ||
2753 | if (angle > endAngle) | ||
2754 | angle = endAngle; | ||
2755 | } | ||
2756 | |||
2757 | if (done && viewerMode && needEndFaces) | ||
2758 | { | ||
2759 | // add the bottom faces to the viewerFaces list here | ||
2760 | Coord faceNormal = newLayer.faceNormal; | ||
2761 | ViewerFace newViewerFace = new ViewerFace(); | ||
2762 | //newViewerFace.primFaceNumber = newLayer.bottomFaceNumber + 1; | ||
2763 | newViewerFace.primFaceNumber = newLayer.bottomFaceNumber; | ||
2764 | foreach (Face face in newLayer.faces) | ||
2765 | { | ||
2766 | newViewerFace.v1 = newLayer.coords[face.v1 - coordsLen]; | ||
2767 | newViewerFace.v2 = newLayer.coords[face.v2 - coordsLen]; | ||
2768 | newViewerFace.v3 = newLayer.coords[face.v3 - coordsLen]; | ||
2769 | |||
2770 | newViewerFace.coordIndex1 = face.v1 - coordsLen; | ||
2771 | newViewerFace.coordIndex2 = face.v2 - coordsLen; | ||
2772 | newViewerFace.coordIndex3 = face.v3 - coordsLen; | ||
2773 | |||
2774 | newViewerFace.n1 = faceNormal; | ||
2775 | newViewerFace.n2 = faceNormal; | ||
2776 | newViewerFace.n3 = faceNormal; | ||
2777 | |||
2778 | newViewerFace.uv1 = newLayer.faceUVs[face.v1 - coordsLen]; | ||
2779 | newViewerFace.uv2 = newLayer.faceUVs[face.v2 - coordsLen]; | ||
2780 | newViewerFace.uv3 = newLayer.faceUVs[face.v3 - coordsLen]; | ||
2781 | |||
2782 | this.viewerFaces.Add(newViewerFace); | ||
2783 | } | ||
2784 | } | ||
2785 | } | ||
2786 | } | 1962 | } |
2787 | 1963 | ||
1964 | |||
2788 | private Coord SurfaceNormal(Coord c1, Coord c2, Coord c3) | 1965 | private Coord SurfaceNormal(Coord c1, Coord c2, Coord c3) |
2789 | { | 1966 | { |
2790 | Coord edge1 = new Coord(c2.X - c1.X, c2.Y - c1.Y, c2.Z - c1.Z); | 1967 | Coord edge1 = new Coord(c2.X - c1.X, c2.Y - c1.Y, c2.Z - c1.Z); |
diff --git a/OpenSim/Region/Physics/Meshing/SculptMesh.cs b/OpenSim/Region/Physics/Meshing/SculptMesh.cs index f1dd586..4dc6e2e 100644 --- a/OpenSim/Region/Physics/Meshing/SculptMesh.cs +++ b/OpenSim/Region/Physics/Meshing/SculptMesh.cs | |||
@@ -25,12 +25,18 @@ | |||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | // to build without references to System.Drawing, comment this out | ||
29 | #define SYSTEM_DRAWING | ||
30 | |||
28 | using System; | 31 | using System; |
29 | using System.Collections.Generic; | 32 | using System.Collections.Generic; |
30 | using System.Text; | 33 | using System.Text; |
31 | using System.IO; | 34 | using System.IO; |
35 | |||
36 | #if SYSTEM_DRAWING | ||
32 | using System.Drawing; | 37 | using System.Drawing; |
33 | using System.Drawing.Imaging; | 38 | using System.Drawing.Imaging; |
39 | #endif | ||
34 | 40 | ||
35 | namespace PrimMesher | 41 | namespace PrimMesher |
36 | { | 42 | { |
@@ -46,6 +52,7 @@ namespace PrimMesher | |||
46 | 52 | ||
47 | public enum SculptType { sphere = 1, torus = 2, plane = 3, cylinder = 4 }; | 53 | public enum SculptType { sphere = 1, torus = 2, plane = 3, cylinder = 4 }; |
48 | 54 | ||
55 | #if SYSTEM_DRAWING | ||
49 | // private Bitmap ScaleImage(Bitmap srcImage, float scale) | 56 | // private Bitmap ScaleImage(Bitmap srcImage, float scale) |
50 | // { | 57 | // { |
51 | // int sourceWidth = srcImage.Width; | 58 | // int sourceWidth = srcImage.Width; |
@@ -83,6 +90,7 @@ namespace PrimMesher | |||
83 | // return scaledImage; | 90 | // return scaledImage; |
84 | // } | 91 | // } |
85 | 92 | ||
93 | |||
86 | public SculptMesh SculptMeshFromFile(string fileName, SculptType sculptType, int lod, bool viewerMode) | 94 | public SculptMesh SculptMeshFromFile(string fileName, SculptType sculptType, int lod, bool viewerMode) |
87 | { | 95 | { |
88 | Bitmap bitmap = (Bitmap)Bitmap.FromFile(fileName); | 96 | Bitmap bitmap = (Bitmap)Bitmap.FromFile(fileName); |
@@ -97,6 +105,7 @@ namespace PrimMesher | |||
97 | _SculptMesh(bitmap, (SculptType)sculptType, lod, viewerMode != 0, mirror != 0, invert != 0); | 105 | _SculptMesh(bitmap, (SculptType)sculptType, lod, viewerMode != 0, mirror != 0, invert != 0); |
98 | bitmap.Dispose(); | 106 | bitmap.Dispose(); |
99 | } | 107 | } |
108 | #endif | ||
100 | 109 | ||
101 | /// <summary> | 110 | /// <summary> |
102 | /// ** Experimental ** May disappear from future versions ** not recommeneded for use in applications | 111 | /// ** Experimental ** May disappear from future versions ** not recommeneded for use in applications |
@@ -201,6 +210,7 @@ namespace PrimMesher | |||
201 | calcVertexNormals(SculptType.plane, numXElements, numYElements); | 210 | calcVertexNormals(SculptType.plane, numXElements, numYElements); |
202 | } | 211 | } |
203 | 212 | ||
213 | #if SYSTEM_DRAWING | ||
204 | public SculptMesh(Bitmap sculptBitmap, SculptType sculptType, int lod, bool viewerMode) | 214 | public SculptMesh(Bitmap sculptBitmap, SculptType sculptType, int lod, bool viewerMode) |
205 | { | 215 | { |
206 | _SculptMesh(sculptBitmap, sculptType, lod, viewerMode, false, false); | 216 | _SculptMesh(sculptBitmap, sculptType, lod, viewerMode, false, false); |
@@ -210,9 +220,16 @@ namespace PrimMesher | |||
210 | { | 220 | { |
211 | _SculptMesh(sculptBitmap, sculptType, lod, viewerMode, mirror, invert); | 221 | _SculptMesh(sculptBitmap, sculptType, lod, viewerMode, mirror, invert); |
212 | } | 222 | } |
223 | #endif | ||
224 | |||
225 | public SculptMesh(List<List<Coord>> rows, SculptType sculptType, bool viewerMode, bool mirror, bool invert) | ||
226 | { | ||
227 | _SculptMesh(rows, sculptType, viewerMode, mirror, invert); | ||
228 | } | ||
213 | 229 | ||
230 | #if SYSTEM_DRAWING | ||
214 | /// <summary> | 231 | /// <summary> |
215 | /// converts a bitmap to a list lists of coords, while scaling the image. | 232 | /// converts a bitmap to a list of lists of coords, while scaling the image. |
216 | /// the scaling is done in floating point so as to allow for reduced vertex position | 233 | /// the scaling is done in floating point so as to allow for reduced vertex position |
217 | /// quantization as the position will be averaged between pixel values. this routine will | 234 | /// quantization as the position will be averaged between pixel values. this routine will |
218 | /// likely fail if the bitmap width and height are not powers of 2. | 235 | /// likely fail if the bitmap width and height are not powers of 2. |
@@ -267,6 +284,7 @@ namespace PrimMesher | |||
267 | return rows; | 284 | return rows; |
268 | } | 285 | } |
269 | 286 | ||
287 | |||
270 | void _SculptMesh(Bitmap sculptBitmap, SculptType sculptType, int lod, bool viewerMode, bool mirror, bool invert) | 288 | void _SculptMesh(Bitmap sculptBitmap, SculptType sculptType, int lod, bool viewerMode, bool mirror, bool invert) |
271 | { | 289 | { |
272 | coords = new List<Coord>(); | 290 | coords = new List<Coord>(); |
@@ -285,12 +303,27 @@ namespace PrimMesher | |||
285 | int scale = (int)(1.0f / sourceScaleFactor); | 303 | int scale = (int)(1.0f / sourceScaleFactor); |
286 | if (scale < 1) scale = 1; | 304 | if (scale < 1) scale = 1; |
287 | 305 | ||
288 | List<List<Coord>> rows = bitmap2Coords(sculptBitmap, scale, mirror); | 306 | _SculptMesh(bitmap2Coords(sculptBitmap, scale, mirror), sculptType, viewerMode, mirror, invert); |
307 | } | ||
308 | #endif | ||
309 | |||
310 | |||
311 | void _SculptMesh(List<List<Coord>> rows, SculptType sculptType, bool viewerMode, bool mirror, bool invert) | ||
312 | { | ||
313 | coords = new List<Coord>(); | ||
314 | faces = new List<Face>(); | ||
315 | normals = new List<Coord>(); | ||
316 | uvs = new List<UVCoord>(); | ||
317 | |||
318 | sculptType = (SculptType)(((int)sculptType) & 0x07); | ||
319 | |||
320 | if (mirror) | ||
321 | if (sculptType == SculptType.plane) | ||
322 | invert = !invert; | ||
289 | 323 | ||
290 | viewerFaces = new List<ViewerFace>(); | 324 | viewerFaces = new List<ViewerFace>(); |
291 | 325 | ||
292 | int width = sculptBitmap.Width / scale; | 326 | int width = rows[0].Count; |
293 | // int height = sculptBitmap.Height / scale; | ||
294 | 327 | ||
295 | int p1, p2, p3, p4; | 328 | int p1, p2, p3, p4; |
296 | 329 | ||
diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs index e344f97..905d3ba 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs | |||
@@ -1231,11 +1231,11 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1231 | m_requestedUpdateFrequency = 0; | 1231 | m_requestedUpdateFrequency = 0; |
1232 | m_eventsubscription = 0; | 1232 | m_eventsubscription = 0; |
1233 | } | 1233 | } |
1234 | public void AddCollisionEvent(uint CollidedWith, float depth) | 1234 | public void AddCollisionEvent(uint CollidedWith, ContactPoint contact) |
1235 | { | 1235 | { |
1236 | if (m_eventsubscription > 0) | 1236 | if (m_eventsubscription > 0) |
1237 | { | 1237 | { |
1238 | CollisionEventsThisFrame.addCollider(CollidedWith, depth); | 1238 | CollisionEventsThisFrame.addCollider(CollidedWith, contact); |
1239 | } | 1239 | } |
1240 | } | 1240 | } |
1241 | 1241 | ||
diff --git a/OpenSim/Region/Physics/OdePlugin/ODEDynamics.cs b/OpenSim/Region/Physics/OdePlugin/ODEDynamics.cs index 345112d..1842eb4 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODEDynamics.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODEDynamics.cs | |||
@@ -130,7 +130,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
130 | 130 | ||
131 | //Hover and Buoyancy properties | 131 | //Hover and Buoyancy properties |
132 | private float m_VhoverHeight = 0f; | 132 | private float m_VhoverHeight = 0f; |
133 | private float m_VhoverEfficiency = 0f; | 133 | // private float m_VhoverEfficiency = 0f; |
134 | private float m_VhoverTimescale = 0f; | 134 | private float m_VhoverTimescale = 0f; |
135 | private float m_VhoverTargetHeight = -1.0f; // if <0 then no hover, else its the current target height | 135 | private float m_VhoverTargetHeight = -1.0f; // if <0 then no hover, else its the current target height |
136 | private float m_VehicleBuoyancy = 0f; // Set by VEHICLE_BUOYANCY, for a vehicle. | 136 | private float m_VehicleBuoyancy = 0f; // Set by VEHICLE_BUOYANCY, for a vehicle. |
@@ -183,11 +183,11 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
183 | if (pValue > 1f) pValue = 1f; | 183 | if (pValue > 1f) pValue = 1f; |
184 | m_VehicleBuoyancy = pValue; | 184 | m_VehicleBuoyancy = pValue; |
185 | break; | 185 | break; |
186 | case Vehicle.HOVER_EFFICIENCY: | 186 | // case Vehicle.HOVER_EFFICIENCY: |
187 | if (pValue < 0f) pValue = 0f; | 187 | // if (pValue < 0f) pValue = 0f; |
188 | if (pValue > 1f) pValue = 1f; | 188 | // if (pValue > 1f) pValue = 1f; |
189 | m_VhoverEfficiency = pValue; | 189 | // m_VhoverEfficiency = pValue; |
190 | break; | 190 | // break; |
191 | case Vehicle.HOVER_HEIGHT: | 191 | case Vehicle.HOVER_HEIGHT: |
192 | m_VhoverHeight = pValue; | 192 | m_VhoverHeight = pValue; |
193 | break; | 193 | break; |
@@ -304,7 +304,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
304 | m_angularMotorTimescale = 1000; | 304 | m_angularMotorTimescale = 1000; |
305 | m_angularMotorDecayTimescale = 120; | 305 | m_angularMotorDecayTimescale = 120; |
306 | m_VhoverHeight = 0; | 306 | m_VhoverHeight = 0; |
307 | m_VhoverEfficiency = 1; | 307 | // m_VhoverEfficiency = 1; |
308 | m_VhoverTimescale = 10; | 308 | m_VhoverTimescale = 10; |
309 | m_VehicleBuoyancy = 0; | 309 | m_VehicleBuoyancy = 0; |
310 | // m_linearDeflectionEfficiency = 1; | 310 | // m_linearDeflectionEfficiency = 1; |
@@ -330,7 +330,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
330 | m_angularMotorTimescale = 1; | 330 | m_angularMotorTimescale = 1; |
331 | m_angularMotorDecayTimescale = 0.8f; | 331 | m_angularMotorDecayTimescale = 0.8f; |
332 | m_VhoverHeight = 0; | 332 | m_VhoverHeight = 0; |
333 | m_VhoverEfficiency = 0; | 333 | // m_VhoverEfficiency = 0; |
334 | m_VhoverTimescale = 1000; | 334 | m_VhoverTimescale = 1000; |
335 | m_VehicleBuoyancy = 0; | 335 | m_VehicleBuoyancy = 0; |
336 | // // m_linearDeflectionEfficiency = 1; | 336 | // // m_linearDeflectionEfficiency = 1; |
@@ -357,7 +357,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
357 | m_angularMotorTimescale = 4; | 357 | m_angularMotorTimescale = 4; |
358 | m_angularMotorDecayTimescale = 4; | 358 | m_angularMotorDecayTimescale = 4; |
359 | m_VhoverHeight = 0; | 359 | m_VhoverHeight = 0; |
360 | m_VhoverEfficiency = 0.5f; | 360 | // m_VhoverEfficiency = 0.5f; |
361 | m_VhoverTimescale = 2; | 361 | m_VhoverTimescale = 2; |
362 | m_VehicleBuoyancy = 1; | 362 | m_VehicleBuoyancy = 1; |
363 | // m_linearDeflectionEfficiency = 0.5f; | 363 | // m_linearDeflectionEfficiency = 0.5f; |
@@ -385,7 +385,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
385 | m_angularMotorTimescale = 4; | 385 | m_angularMotorTimescale = 4; |
386 | m_angularMotorDecayTimescale = 4; | 386 | m_angularMotorDecayTimescale = 4; |
387 | m_VhoverHeight = 0; | 387 | m_VhoverHeight = 0; |
388 | m_VhoverEfficiency = 0.5f; | 388 | // m_VhoverEfficiency = 0.5f; |
389 | m_VhoverTimescale = 1000; | 389 | m_VhoverTimescale = 1000; |
390 | m_VehicleBuoyancy = 0; | 390 | m_VehicleBuoyancy = 0; |
391 | // m_linearDeflectionEfficiency = 0.5f; | 391 | // m_linearDeflectionEfficiency = 0.5f; |
@@ -412,7 +412,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
412 | m_angularMotorTimescale = 6; | 412 | m_angularMotorTimescale = 6; |
413 | m_angularMotorDecayTimescale = 10; | 413 | m_angularMotorDecayTimescale = 10; |
414 | m_VhoverHeight = 5; | 414 | m_VhoverHeight = 5; |
415 | m_VhoverEfficiency = 0.8f; | 415 | // m_VhoverEfficiency = 0.8f; |
416 | m_VhoverTimescale = 10; | 416 | m_VhoverTimescale = 10; |
417 | m_VehicleBuoyancy = 1; | 417 | m_VehicleBuoyancy = 1; |
418 | // m_linearDeflectionEfficiency = 0; | 418 | // m_linearDeflectionEfficiency = 0; |
diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs index 62c5c81..b963d65 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs | |||
@@ -3030,11 +3030,11 @@ if(frcount == 0) Console.WriteLine("mass= " + m_mass + " servo= " + RLAservo + | |||
3030 | m_eventsubscription = 0; | 3030 | m_eventsubscription = 0; |
3031 | } | 3031 | } |
3032 | 3032 | ||
3033 | public void AddCollisionEvent(uint CollidedWith, float depth) | 3033 | public void AddCollisionEvent(uint CollidedWith, ContactPoint contact) |
3034 | { | 3034 | { |
3035 | if (CollisionEventsThisFrame == null) | 3035 | if (CollisionEventsThisFrame == null) |
3036 | CollisionEventsThisFrame = new CollisionEventUpdate(); | 3036 | CollisionEventsThisFrame = new CollisionEventUpdate(); |
3037 | CollisionEventsThisFrame.addCollider(CollidedWith,depth); | 3037 | CollisionEventsThisFrame.addCollider(CollidedWith, contact); |
3038 | } | 3038 | } |
3039 | 3039 | ||
3040 | public void SendCollisions() | 3040 | public void SendCollisions() |
diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs index 2f42646..981cf43 100644 --- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs +++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs | |||
@@ -159,6 +159,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
159 | 159 | ||
160 | private float ODE_STEPSIZE = 0.020f; | 160 | private float ODE_STEPSIZE = 0.020f; |
161 | private float metersInSpace = 29.9f; | 161 | private float metersInSpace = 29.9f; |
162 | private float m_timeDilation = 1.0f; | ||
162 | 163 | ||
163 | public float gravityx = 0f; | 164 | public float gravityx = 0f; |
164 | public float gravityy = 0f; | 165 | public float gravityy = 0f; |
@@ -177,8 +178,8 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
177 | //private int m_returncollisions = 10; | 178 | //private int m_returncollisions = 10; |
178 | 179 | ||
179 | private readonly IntPtr contactgroup; | 180 | private readonly IntPtr contactgroup; |
180 | internal IntPtr LandGeom; | ||
181 | 181 | ||
182 | internal IntPtr LandGeom; | ||
182 | internal IntPtr WaterGeom; | 183 | internal IntPtr WaterGeom; |
183 | 184 | ||
184 | private float nmTerrainContactFriction = 255.0f; | 185 | private float nmTerrainContactFriction = 255.0f; |
@@ -250,7 +251,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
250 | private bool m_NINJA_physics_joints_enabled = false; | 251 | private bool m_NINJA_physics_joints_enabled = false; |
251 | //private Dictionary<String, IntPtr> jointpart_name_map = new Dictionary<String,IntPtr>(); | 252 | //private Dictionary<String, IntPtr> jointpart_name_map = new Dictionary<String,IntPtr>(); |
252 | private readonly Dictionary<String, List<PhysicsJoint>> joints_connecting_actor = new Dictionary<String, List<PhysicsJoint>>(); | 253 | private readonly Dictionary<String, List<PhysicsJoint>> joints_connecting_actor = new Dictionary<String, List<PhysicsJoint>>(); |
253 | private d.ContactGeom[] contacts = new d.ContactGeom[80]; | 254 | private d.ContactGeom[] contacts; |
254 | private readonly List<PhysicsJoint> requestedJointsToBeCreated = new List<PhysicsJoint>(); // lock only briefly. accessed by external code (to request new joints) and by OdeScene.Simulate() to move those joints into pending/active | 255 | private readonly List<PhysicsJoint> requestedJointsToBeCreated = new List<PhysicsJoint>(); // lock only briefly. accessed by external code (to request new joints) and by OdeScene.Simulate() to move those joints into pending/active |
255 | private readonly List<PhysicsJoint> pendingJoints = new List<PhysicsJoint>(); // can lock for longer. accessed only by OdeScene. | 256 | private readonly List<PhysicsJoint> pendingJoints = new List<PhysicsJoint>(); // can lock for longer. accessed only by OdeScene. |
256 | private readonly List<PhysicsJoint> activeJoints = new List<PhysicsJoint>(); // can lock for longer. accessed only by OdeScene. | 257 | private readonly List<PhysicsJoint> activeJoints = new List<PhysicsJoint>(); // can lock for longer. accessed only by OdeScene. |
@@ -396,6 +397,8 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
396 | avStandupTensor = 550000f; | 397 | avStandupTensor = 550000f; |
397 | } | 398 | } |
398 | 399 | ||
400 | int contactsPerCollision = 80; | ||
401 | |||
399 | if (m_config != null) | 402 | if (m_config != null) |
400 | { | 403 | { |
401 | IConfig physicsconfig = m_config.Configs["ODEPhysicsSettings"]; | 404 | IConfig physicsconfig = m_config.Configs["ODEPhysicsSettings"]; |
@@ -436,7 +439,9 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
436 | avMovementDivisorWalk = physicsconfig.GetFloat("av_movement_divisor_walk", 1.3f); | 439 | avMovementDivisorWalk = physicsconfig.GetFloat("av_movement_divisor_walk", 1.3f); |
437 | avMovementDivisorRun = physicsconfig.GetFloat("av_movement_divisor_run", 0.8f); | 440 | avMovementDivisorRun = physicsconfig.GetFloat("av_movement_divisor_run", 0.8f); |
438 | avCapRadius = physicsconfig.GetFloat("av_capsule_radius", 0.37f); | 441 | avCapRadius = physicsconfig.GetFloat("av_capsule_radius", 0.37f); |
439 | avCapsuleTilted = physicsconfig.GetBoolean("av_capsule_tilted", true); | 442 | avCapsuleTilted = physicsconfig.GetBoolean("av_capsule_tilted", false); |
443 | |||
444 | contactsPerCollision = physicsconfig.GetInt("contacts_per_collision", 80); | ||
440 | 445 | ||
441 | geomContactPointsStartthrottle = physicsconfig.GetInt("geom_contactpoints_start_throttling", 3); | 446 | geomContactPointsStartthrottle = physicsconfig.GetInt("geom_contactpoints_start_throttling", 3); |
442 | geomUpdatesPerThrottledUpdate = physicsconfig.GetInt("geom_updates_before_throttled_update", 15); | 447 | geomUpdatesPerThrottledUpdate = physicsconfig.GetInt("geom_updates_before_throttled_update", 15); |
@@ -475,10 +480,11 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
475 | 480 | ||
476 | m_NINJA_physics_joints_enabled = physicsconfig.GetBoolean("use_NINJA_physics_joints", false); | 481 | m_NINJA_physics_joints_enabled = physicsconfig.GetBoolean("use_NINJA_physics_joints", false); |
477 | minimumGroundFlightOffset = physicsconfig.GetFloat("minimum_ground_flight_offset", 3f); | 482 | minimumGroundFlightOffset = physicsconfig.GetFloat("minimum_ground_flight_offset", 3f); |
478 | |||
479 | } | 483 | } |
480 | } | 484 | } |
481 | 485 | ||
486 | contacts = new d.ContactGeom[contactsPerCollision]; | ||
487 | |||
482 | staticPrimspace = new IntPtr[(int)(300 / metersInSpace), (int)(300 / metersInSpace)]; | 488 | staticPrimspace = new IntPtr[(int)(300 / metersInSpace), (int)(300 / metersInSpace)]; |
483 | 489 | ||
484 | // Centeral contact friction and bounce | 490 | // Centeral contact friction and bounce |
@@ -771,7 +777,9 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
771 | 777 | ||
772 | lock (contacts) | 778 | lock (contacts) |
773 | { | 779 | { |
774 | count = d.Collide(g1, g2, contacts.GetLength(0), contacts, d.ContactGeom.SizeOf); | 780 | count = d.Collide(g1, g2, contacts.Length, contacts, d.ContactGeom.SizeOf); |
781 | if (count > contacts.Length) | ||
782 | m_log.Error("[PHYSICS]: Got " + count + " contacts when we asked for a maximum of " + contacts.Length); | ||
775 | } | 783 | } |
776 | } | 784 | } |
777 | catch (SEHException) | 785 | catch (SEHException) |
@@ -799,7 +807,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
799 | p2 = PANull; | 807 | p2 = PANull; |
800 | } | 808 | } |
801 | 809 | ||
802 | float max_collision_depth = 0f; | 810 | ContactPoint maxDepthContact = new ContactPoint(); |
803 | if (p1.CollisionScore + count >= float.MaxValue) | 811 | if (p1.CollisionScore + count >= float.MaxValue) |
804 | p1.CollisionScore = 0; | 812 | p1.CollisionScore = 0; |
805 | p1.CollisionScore += count; | 813 | p1.CollisionScore += count; |
@@ -810,9 +818,17 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
810 | 818 | ||
811 | for (int i = 0; i < count; i++) | 819 | for (int i = 0; i < count; i++) |
812 | { | 820 | { |
821 | d.ContactGeom curContact = contacts[i]; | ||
813 | 822 | ||
823 | if (curContact.depth > maxDepthContact.PenetrationDepth) | ||
824 | { | ||
825 | maxDepthContact = new ContactPoint( | ||
826 | new Vector3(curContact.pos.X, curContact.pos.Y, curContact.pos.Z), | ||
827 | new Vector3(curContact.normal.X, curContact.normal.Y, curContact.normal.Z), | ||
828 | curContact.depth | ||
829 | ); | ||
830 | } | ||
814 | 831 | ||
815 | max_collision_depth = (contacts[i].depth > max_collision_depth) ? contacts[i].depth : max_collision_depth; | ||
816 | //m_log.Warn("[CCOUNT]: " + count); | 832 | //m_log.Warn("[CCOUNT]: " + count); |
817 | IntPtr joint; | 833 | IntPtr joint; |
818 | // If we're colliding with terrain, use 'TerrainContact' instead of contact. | 834 | // If we're colliding with terrain, use 'TerrainContact' instead of contact. |
@@ -829,7 +845,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
829 | p2.CollidingObj = true; | 845 | p2.CollidingObj = true; |
830 | break; | 846 | break; |
831 | case (int)ActorTypes.Prim: | 847 | case (int)ActorTypes.Prim: |
832 | if (p2.Velocity.X > 0 || p2.Velocity.Y > 0 || p2.Velocity.Z > 0) | 848 | if (p2.Velocity.LengthSquared() > 0.0f) |
833 | p2.CollidingObj = true; | 849 | p2.CollidingObj = true; |
834 | break; | 850 | break; |
835 | case (int)ActorTypes.Unknown: | 851 | case (int)ActorTypes.Unknown: |
@@ -845,14 +861,14 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
845 | #region InterPenetration Handling - Unintended physics explosions | 861 | #region InterPenetration Handling - Unintended physics explosions |
846 | # region disabled code1 | 862 | # region disabled code1 |
847 | 863 | ||
848 | if (contacts[i].depth >= 0.08f) | 864 | if (curContact.depth >= 0.08f) |
849 | { | 865 | { |
850 | //This is disabled at the moment only because it needs more tweaking | 866 | //This is disabled at the moment only because it needs more tweaking |
851 | //It will eventually be uncommented | 867 | //It will eventually be uncommented |
852 | /* | 868 | /* |
853 | if (contacts[i].depth >= 1.00f) | 869 | if (contact.depth >= 1.00f) |
854 | { | 870 | { |
855 | //m_log.Debug("[PHYSICS]: " + contacts[i].depth.ToString()); | 871 | //m_log.Debug("[PHYSICS]: " + contact.depth.ToString()); |
856 | } | 872 | } |
857 | 873 | ||
858 | //If you interpenetrate a prim with an agent | 874 | //If you interpenetrate a prim with an agent |
@@ -862,37 +878,37 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
862 | p2.PhysicsActorType == (int) ActorTypes.Prim)) | 878 | p2.PhysicsActorType == (int) ActorTypes.Prim)) |
863 | { | 879 | { |
864 | 880 | ||
865 | //contacts[i].depth = contacts[i].depth * 4.15f; | 881 | //contact.depth = contact.depth * 4.15f; |
866 | /* | 882 | /* |
867 | if (p2.PhysicsActorType == (int) ActorTypes.Agent) | 883 | if (p2.PhysicsActorType == (int) ActorTypes.Agent) |
868 | { | 884 | { |
869 | p2.CollidingObj = true; | 885 | p2.CollidingObj = true; |
870 | contacts[i].depth = 0.003f; | 886 | contact.depth = 0.003f; |
871 | p2.Velocity = p2.Velocity + new PhysicsVector(0, 0, 2.5f); | 887 | p2.Velocity = p2.Velocity + new PhysicsVector(0, 0, 2.5f); |
872 | OdeCharacter character = (OdeCharacter) p2; | 888 | OdeCharacter character = (OdeCharacter) p2; |
873 | character.SetPidStatus(true); | 889 | character.SetPidStatus(true); |
874 | contacts[i].pos = new d.Vector3(contacts[i].pos.X + (p1.Size.X / 2), contacts[i].pos.Y + (p1.Size.Y / 2), contacts[i].pos.Z + (p1.Size.Z / 2)); | 890 | contact.pos = new d.Vector3(contact.pos.X + (p1.Size.X / 2), contact.pos.Y + (p1.Size.Y / 2), contact.pos.Z + (p1.Size.Z / 2)); |
875 | 891 | ||
876 | } | 892 | } |
877 | else | 893 | else |
878 | { | 894 | { |
879 | 895 | ||
880 | //contacts[i].depth = 0.0000000f; | 896 | //contact.depth = 0.0000000f; |
881 | } | 897 | } |
882 | if (p1.PhysicsActorType == (int) ActorTypes.Agent) | 898 | if (p1.PhysicsActorType == (int) ActorTypes.Agent) |
883 | { | 899 | { |
884 | 900 | ||
885 | p1.CollidingObj = true; | 901 | p1.CollidingObj = true; |
886 | contacts[i].depth = 0.003f; | 902 | contact.depth = 0.003f; |
887 | p1.Velocity = p1.Velocity + new PhysicsVector(0, 0, 2.5f); | 903 | p1.Velocity = p1.Velocity + new PhysicsVector(0, 0, 2.5f); |
888 | contacts[i].pos = new d.Vector3(contacts[i].pos.X + (p2.Size.X / 2), contacts[i].pos.Y + (p2.Size.Y / 2), contacts[i].pos.Z + (p2.Size.Z / 2)); | 904 | contact.pos = new d.Vector3(contact.pos.X + (p2.Size.X / 2), contact.pos.Y + (p2.Size.Y / 2), contact.pos.Z + (p2.Size.Z / 2)); |
889 | OdeCharacter character = (OdeCharacter)p1; | 905 | OdeCharacter character = (OdeCharacter)p1; |
890 | character.SetPidStatus(true); | 906 | character.SetPidStatus(true); |
891 | } | 907 | } |
892 | else | 908 | else |
893 | { | 909 | { |
894 | 910 | ||
895 | //contacts[i].depth = 0.0000000f; | 911 | //contact.depth = 0.0000000f; |
896 | } | 912 | } |
897 | 913 | ||
898 | 914 | ||
@@ -917,7 +933,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
917 | //AddPhysicsActorTaint(p2); | 933 | //AddPhysicsActorTaint(p2); |
918 | //} | 934 | //} |
919 | 935 | ||
920 | //if (contacts[i].depth >= 0.25f) | 936 | //if (contact.depth >= 0.25f) |
921 | //{ | 937 | //{ |
922 | // Don't collide, one or both prim will expld. | 938 | // Don't collide, one or both prim will expld. |
923 | 939 | ||
@@ -935,21 +951,21 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
935 | //AddPhysicsActorTaint(p2); | 951 | //AddPhysicsActorTaint(p2); |
936 | //} | 952 | //} |
937 | 953 | ||
938 | //contacts[i].depth = contacts[i].depth / 8f; | 954 | //contact.depth = contact.depth / 8f; |
939 | //contacts[i].normal = new d.Vector3(0, 0, 1); | 955 | //contact.normal = new d.Vector3(0, 0, 1); |
940 | //} | 956 | //} |
941 | //if (op1.m_disabled || op2.m_disabled) | 957 | //if (op1.m_disabled || op2.m_disabled) |
942 | //{ | 958 | //{ |
943 | //Manually disabled objects stay disabled | 959 | //Manually disabled objects stay disabled |
944 | //contacts[i].depth = 0f; | 960 | //contact.depth = 0f; |
945 | //} | 961 | //} |
946 | #endregion | 962 | #endregion |
947 | } | 963 | } |
948 | */ | 964 | */ |
949 | #endregion | 965 | #endregion |
950 | if (contacts[i].depth >= 1.00f) | 966 | if (curContact.depth >= 1.00f) |
951 | { | 967 | { |
952 | //m_log.Info("[P]: " + contacts[i].depth.ToString()); | 968 | //m_log.Info("[P]: " + contact.depth.ToString()); |
953 | if ((p2.PhysicsActorType == (int) ActorTypes.Agent && | 969 | if ((p2.PhysicsActorType == (int) ActorTypes.Agent && |
954 | p1.PhysicsActorType == (int) ActorTypes.Unknown) || | 970 | p1.PhysicsActorType == (int) ActorTypes.Unknown) || |
955 | (p1.PhysicsActorType == (int) ActorTypes.Agent && | 971 | (p1.PhysicsActorType == (int) ActorTypes.Agent && |
@@ -962,12 +978,12 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
962 | OdeCharacter character = (OdeCharacter) p2; | 978 | OdeCharacter character = (OdeCharacter) p2; |
963 | 979 | ||
964 | //p2.CollidingObj = true; | 980 | //p2.CollidingObj = true; |
965 | contacts[i].depth = 0.00000003f; | 981 | curContact.depth = 0.00000003f; |
966 | p2.Velocity = p2.Velocity + new Vector3(0f, 0f, 0.5f); | 982 | p2.Velocity = p2.Velocity + new Vector3(0f, 0f, 0.5f); |
967 | contacts[i].pos = | 983 | curContact.pos = |
968 | new d.Vector3(contacts[i].pos.X + (p1.Size.X/2), | 984 | new d.Vector3(curContact.pos.X + (p1.Size.X/2), |
969 | contacts[i].pos.Y + (p1.Size.Y/2), | 985 | curContact.pos.Y + (p1.Size.Y/2), |
970 | contacts[i].pos.Z + (p1.Size.Z/2)); | 986 | curContact.pos.Z + (p1.Size.Z/2)); |
971 | character.SetPidStatus(true); | 987 | character.SetPidStatus(true); |
972 | } | 988 | } |
973 | } | 989 | } |
@@ -980,12 +996,12 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
980 | OdeCharacter character = (OdeCharacter) p1; | 996 | OdeCharacter character = (OdeCharacter) p1; |
981 | 997 | ||
982 | //p2.CollidingObj = true; | 998 | //p2.CollidingObj = true; |
983 | contacts[i].depth = 0.00000003f; | 999 | curContact.depth = 0.00000003f; |
984 | p1.Velocity = p1.Velocity + new Vector3(0f, 0f, 0.5f); | 1000 | p1.Velocity = p1.Velocity + new Vector3(0f, 0f, 0.5f); |
985 | contacts[i].pos = | 1001 | curContact.pos = |
986 | new d.Vector3(contacts[i].pos.X + (p1.Size.X/2), | 1002 | new d.Vector3(curContact.pos.X + (p1.Size.X/2), |
987 | contacts[i].pos.Y + (p1.Size.Y/2), | 1003 | curContact.pos.Y + (p1.Size.Y/2), |
988 | contacts[i].pos.Z + (p1.Size.Z/2)); | 1004 | curContact.pos.Z + (p1.Size.Z/2)); |
989 | character.SetPidStatus(true); | 1005 | character.SetPidStatus(true); |
990 | } | 1006 | } |
991 | } | 1007 | } |
@@ -1007,16 +1023,15 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1007 | if (!skipThisContact && (p2 is OdePrim) && (((OdePrim)p2).m_isVolumeDetect)) | 1023 | if (!skipThisContact && (p2 is OdePrim) && (((OdePrim)p2).m_isVolumeDetect)) |
1008 | skipThisContact = true; // No collision on volume detect prims | 1024 | skipThisContact = true; // No collision on volume detect prims |
1009 | 1025 | ||
1010 | if (!skipThisContact && contacts[i].depth < 0f) | 1026 | if (!skipThisContact && curContact.depth < 0f) |
1011 | skipThisContact = true; | 1027 | skipThisContact = true; |
1012 | 1028 | ||
1013 | if (!skipThisContact && checkDupe(contacts[i], p2.PhysicsActorType)) | 1029 | if (!skipThisContact && checkDupe(curContact, p2.PhysicsActorType)) |
1014 | skipThisContact = true; | 1030 | skipThisContact = true; |
1015 | 1031 | ||
1016 | int maxContactsbeforedeath = 4000; | 1032 | const int maxContactsbeforedeath = 4000; |
1017 | joint = IntPtr.Zero; | 1033 | joint = IntPtr.Zero; |
1018 | 1034 | ||
1019 | |||
1020 | if (!skipThisContact) | 1035 | if (!skipThisContact) |
1021 | { | 1036 | { |
1022 | // If we're colliding against terrain | 1037 | // If we're colliding against terrain |
@@ -1027,8 +1042,8 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1027 | (Math.Abs(p2.Velocity.X) > 0.01f || Math.Abs(p2.Velocity.Y) > 0.01f)) | 1042 | (Math.Abs(p2.Velocity.X) > 0.01f || Math.Abs(p2.Velocity.Y) > 0.01f)) |
1028 | { | 1043 | { |
1029 | // Use the movement terrain contact | 1044 | // Use the movement terrain contact |
1030 | AvatarMovementTerrainContact.geom = contacts[i]; | 1045 | AvatarMovementTerrainContact.geom = curContact; |
1031 | _perloopContact.Add(contacts[i]); | 1046 | _perloopContact.Add(curContact); |
1032 | if (m_global_contactcount < maxContactsbeforedeath) | 1047 | if (m_global_contactcount < maxContactsbeforedeath) |
1033 | { | 1048 | { |
1034 | joint = d.JointCreateContact(world, contactgroup, ref AvatarMovementTerrainContact); | 1049 | joint = d.JointCreateContact(world, contactgroup, ref AvatarMovementTerrainContact); |
@@ -1040,8 +1055,8 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1040 | if (p2.PhysicsActorType == (int)ActorTypes.Agent) | 1055 | if (p2.PhysicsActorType == (int)ActorTypes.Agent) |
1041 | { | 1056 | { |
1042 | // Use the non moving terrain contact | 1057 | // Use the non moving terrain contact |
1043 | TerrainContact.geom = contacts[i]; | 1058 | TerrainContact.geom = curContact; |
1044 | _perloopContact.Add(contacts[i]); | 1059 | _perloopContact.Add(curContact); |
1045 | if (m_global_contactcount < maxContactsbeforedeath) | 1060 | if (m_global_contactcount < maxContactsbeforedeath) |
1046 | { | 1061 | { |
1047 | joint = d.JointCreateContact(world, contactgroup, ref TerrainContact); | 1062 | joint = d.JointCreateContact(world, contactgroup, ref TerrainContact); |
@@ -1066,8 +1081,8 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1066 | material = ((OdePrim)p2).m_material; | 1081 | material = ((OdePrim)p2).m_material; |
1067 | 1082 | ||
1068 | //m_log.DebugFormat("Material: {0}", material); | 1083 | //m_log.DebugFormat("Material: {0}", material); |
1069 | m_materialContacts[material, movintYN].geom = contacts[i]; | 1084 | m_materialContacts[material, movintYN].geom = curContact; |
1070 | _perloopContact.Add(contacts[i]); | 1085 | _perloopContact.Add(curContact); |
1071 | 1086 | ||
1072 | if (m_global_contactcount < maxContactsbeforedeath) | 1087 | if (m_global_contactcount < maxContactsbeforedeath) |
1073 | { | 1088 | { |
@@ -1092,8 +1107,8 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1092 | if (p2 is OdePrim) | 1107 | if (p2 is OdePrim) |
1093 | material = ((OdePrim)p2).m_material; | 1108 | material = ((OdePrim)p2).m_material; |
1094 | //m_log.DebugFormat("Material: {0}", material); | 1109 | //m_log.DebugFormat("Material: {0}", material); |
1095 | m_materialContacts[material, movintYN].geom = contacts[i]; | 1110 | m_materialContacts[material, movintYN].geom = curContact; |
1096 | _perloopContact.Add(contacts[i]); | 1111 | _perloopContact.Add(curContact); |
1097 | 1112 | ||
1098 | if (m_global_contactcount < maxContactsbeforedeath) | 1113 | if (m_global_contactcount < maxContactsbeforedeath) |
1099 | { | 1114 | { |
@@ -1121,20 +1136,20 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1121 | */ | 1136 | */ |
1122 | //WaterContact.surface.soft_cfm = 0.0000f; | 1137 | //WaterContact.surface.soft_cfm = 0.0000f; |
1123 | //WaterContact.surface.soft_erp = 0.00000f; | 1138 | //WaterContact.surface.soft_erp = 0.00000f; |
1124 | if (contacts[i].depth > 0.1f) | 1139 | if (curContact.depth > 0.1f) |
1125 | { | 1140 | { |
1126 | contacts[i].depth *= 52; | 1141 | curContact.depth *= 52; |
1127 | //contacts[i].normal = new d.Vector3(0, 0, 1); | 1142 | //contact.normal = new d.Vector3(0, 0, 1); |
1128 | //contacts[i].pos = new d.Vector3(0, 0, contacts[i].pos.Z - 5f); | 1143 | //contact.pos = new d.Vector3(0, 0, contact.pos.Z - 5f); |
1129 | } | 1144 | } |
1130 | WaterContact.geom = contacts[i]; | 1145 | WaterContact.geom = curContact; |
1131 | _perloopContact.Add(contacts[i]); | 1146 | _perloopContact.Add(curContact); |
1132 | if (m_global_contactcount < maxContactsbeforedeath) | 1147 | if (m_global_contactcount < maxContactsbeforedeath) |
1133 | { | 1148 | { |
1134 | joint = d.JointCreateContact(world, contactgroup, ref WaterContact); | 1149 | joint = d.JointCreateContact(world, contactgroup, ref WaterContact); |
1135 | m_global_contactcount++; | 1150 | m_global_contactcount++; |
1136 | } | 1151 | } |
1137 | //m_log.Info("[PHYSICS]: Prim Water Contact" + contacts[i].depth); | 1152 | //m_log.Info("[PHYSICS]: Prim Water Contact" + contact.depth); |
1138 | } | 1153 | } |
1139 | else | 1154 | else |
1140 | { | 1155 | { |
@@ -1145,8 +1160,8 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1145 | if ((Math.Abs(p2.Velocity.X) > 0.01f || Math.Abs(p2.Velocity.Y) > 0.01f)) | 1160 | if ((Math.Abs(p2.Velocity.X) > 0.01f || Math.Abs(p2.Velocity.Y) > 0.01f)) |
1146 | { | 1161 | { |
1147 | // Use the Movement prim contact | 1162 | // Use the Movement prim contact |
1148 | AvatarMovementprimContact.geom = contacts[i]; | 1163 | AvatarMovementprimContact.geom = curContact; |
1149 | _perloopContact.Add(contacts[i]); | 1164 | _perloopContact.Add(curContact); |
1150 | if (m_global_contactcount < maxContactsbeforedeath) | 1165 | if (m_global_contactcount < maxContactsbeforedeath) |
1151 | { | 1166 | { |
1152 | joint = d.JointCreateContact(world, contactgroup, ref AvatarMovementprimContact); | 1167 | joint = d.JointCreateContact(world, contactgroup, ref AvatarMovementprimContact); |
@@ -1156,8 +1171,8 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1156 | else | 1171 | else |
1157 | { | 1172 | { |
1158 | // Use the non movement contact | 1173 | // Use the non movement contact |
1159 | contact.geom = contacts[i]; | 1174 | contact.geom = curContact; |
1160 | _perloopContact.Add(contacts[i]); | 1175 | _perloopContact.Add(curContact); |
1161 | 1176 | ||
1162 | if (m_global_contactcount < maxContactsbeforedeath) | 1177 | if (m_global_contactcount < maxContactsbeforedeath) |
1163 | { | 1178 | { |
@@ -1175,8 +1190,8 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1175 | material = ((OdePrim)p2).m_material; | 1190 | material = ((OdePrim)p2).m_material; |
1176 | 1191 | ||
1177 | //m_log.DebugFormat("Material: {0}", material); | 1192 | //m_log.DebugFormat("Material: {0}", material); |
1178 | m_materialContacts[material, 0].geom = contacts[i]; | 1193 | m_materialContacts[material, 0].geom = curContact; |
1179 | _perloopContact.Add(contacts[i]); | 1194 | _perloopContact.Add(curContact); |
1180 | 1195 | ||
1181 | if (m_global_contactcount < maxContactsbeforedeath) | 1196 | if (m_global_contactcount < maxContactsbeforedeath) |
1182 | { | 1197 | { |
@@ -1194,7 +1209,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1194 | } | 1209 | } |
1195 | 1210 | ||
1196 | } | 1211 | } |
1197 | collision_accounting_events(p1, p2, max_collision_depth); | 1212 | collision_accounting_events(p1, p2, maxDepthContact); |
1198 | if (count > geomContactPointsStartthrottle) | 1213 | if (count > geomContactPointsStartthrottle) |
1199 | { | 1214 | { |
1200 | // If there are more then 3 contact points, it's likely | 1215 | // If there are more then 3 contact points, it's likely |
@@ -1278,7 +1293,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1278 | return result; | 1293 | return result; |
1279 | } | 1294 | } |
1280 | 1295 | ||
1281 | private void collision_accounting_events(PhysicsActor p1, PhysicsActor p2, float collisiondepth) | 1296 | private void collision_accounting_events(PhysicsActor p1, PhysicsActor p2, ContactPoint contact) |
1282 | { | 1297 | { |
1283 | // obj1LocalID = 0; | 1298 | // obj1LocalID = 0; |
1284 | //returncollisions = false; | 1299 | //returncollisions = false; |
@@ -1299,7 +1314,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1299 | case ActorTypes.Agent: | 1314 | case ActorTypes.Agent: |
1300 | cc1 = (OdeCharacter)p1; | 1315 | cc1 = (OdeCharacter)p1; |
1301 | obj2LocalID = cc1.m_localID; | 1316 | obj2LocalID = cc1.m_localID; |
1302 | cc1.AddCollisionEvent(cc2.m_localID, collisiondepth); | 1317 | cc1.AddCollisionEvent(cc2.m_localID, contact); |
1303 | //ctype = (int)CollisionCategories.Character; | 1318 | //ctype = (int)CollisionCategories.Character; |
1304 | 1319 | ||
1305 | //if (cc1.CollidingObj) | 1320 | //if (cc1.CollidingObj) |
@@ -1314,7 +1329,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1314 | { | 1329 | { |
1315 | cp1 = (OdePrim) p1; | 1330 | cp1 = (OdePrim) p1; |
1316 | obj2LocalID = cp1.m_localID; | 1331 | obj2LocalID = cp1.m_localID; |
1317 | cp1.AddCollisionEvent(cc2.m_localID, collisiondepth); | 1332 | cp1.AddCollisionEvent(cc2.m_localID, contact); |
1318 | } | 1333 | } |
1319 | //ctype = (int)CollisionCategories.Geom; | 1334 | //ctype = (int)CollisionCategories.Geom; |
1320 | 1335 | ||
@@ -1334,7 +1349,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1334 | break; | 1349 | break; |
1335 | } | 1350 | } |
1336 | 1351 | ||
1337 | cc2.AddCollisionEvent(obj2LocalID, collisiondepth); | 1352 | cc2.AddCollisionEvent(obj2LocalID, contact); |
1338 | break; | 1353 | break; |
1339 | case ActorTypes.Prim: | 1354 | case ActorTypes.Prim: |
1340 | 1355 | ||
@@ -1350,7 +1365,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1350 | { | 1365 | { |
1351 | cc1 = (OdeCharacter) p1; | 1366 | cc1 = (OdeCharacter) p1; |
1352 | obj2LocalID = cc1.m_localID; | 1367 | obj2LocalID = cc1.m_localID; |
1353 | cc1.AddCollisionEvent(cp2.m_localID, collisiondepth); | 1368 | cc1.AddCollisionEvent(cp2.m_localID, contact); |
1354 | //ctype = (int)CollisionCategories.Character; | 1369 | //ctype = (int)CollisionCategories.Character; |
1355 | 1370 | ||
1356 | //if (cc1.CollidingObj) | 1371 | //if (cc1.CollidingObj) |
@@ -1366,7 +1381,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1366 | { | 1381 | { |
1367 | cp1 = (OdePrim) p1; | 1382 | cp1 = (OdePrim) p1; |
1368 | obj2LocalID = cp1.m_localID; | 1383 | obj2LocalID = cp1.m_localID; |
1369 | cp1.AddCollisionEvent(cp2.m_localID, collisiondepth); | 1384 | cp1.AddCollisionEvent(cp2.m_localID, contact); |
1370 | //ctype = (int)CollisionCategories.Geom; | 1385 | //ctype = (int)CollisionCategories.Geom; |
1371 | 1386 | ||
1372 | //if (cp1.CollidingObj) | 1387 | //if (cp1.CollidingObj) |
@@ -1387,7 +1402,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1387 | break; | 1402 | break; |
1388 | } | 1403 | } |
1389 | 1404 | ||
1390 | cp2.AddCollisionEvent(obj2LocalID, collisiondepth); | 1405 | cp2.AddCollisionEvent(obj2LocalID, contact); |
1391 | } | 1406 | } |
1392 | break; | 1407 | break; |
1393 | } | 1408 | } |
@@ -1750,6 +1765,11 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1750 | return result; | 1765 | return result; |
1751 | } | 1766 | } |
1752 | 1767 | ||
1768 | public override float TimeDilation | ||
1769 | { | ||
1770 | get { return m_timeDilation; } | ||
1771 | } | ||
1772 | |||
1753 | public override bool SupportsNINJAJoints | 1773 | public override bool SupportsNINJAJoints |
1754 | { | 1774 | { |
1755 | get { return m_NINJA_physics_joints_enabled; } | 1775 | get { return m_NINJA_physics_joints_enabled; } |
@@ -2657,8 +2677,10 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2657 | 2677 | ||
2658 | // Figure out the Frames Per Second we're going at. | 2678 | // Figure out the Frames Per Second we're going at. |
2659 | //(step_time == 0.004f, there's 250 of those per second. Times the step time/step size | 2679 | //(step_time == 0.004f, there's 250 of those per second. Times the step time/step size |
2660 | 2680 | ||
2661 | fps = (step_time/ODE_STEPSIZE) * 1000; | 2681 | fps = (step_time / ODE_STEPSIZE) * 1000; |
2682 | // HACK: Using a time dilation of 1.0 to debug rubberbanding issues | ||
2683 | //m_timeDilation = Math.Min((step_time / ODE_STEPSIZE) / (0.09375f / ODE_STEPSIZE), 1.0f); | ||
2662 | 2684 | ||
2663 | step_time = 0.09375f; | 2685 | step_time = 0.09375f; |
2664 | 2686 | ||
@@ -3519,7 +3541,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
3519 | public override void UnCombine(PhysicsScene pScene) | 3541 | public override void UnCombine(PhysicsScene pScene) |
3520 | { | 3542 | { |
3521 | IntPtr localGround = IntPtr.Zero; | 3543 | IntPtr localGround = IntPtr.Zero; |
3522 | float[] localHeightfield; | 3544 | // float[] localHeightfield; |
3523 | bool proceed = false; | 3545 | bool proceed = false; |
3524 | List<IntPtr> geomDestroyList = new List<IntPtr>(); | 3546 | List<IntPtr> geomDestroyList = new List<IntPtr>(); |
3525 | 3547 | ||
@@ -3531,7 +3553,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
3531 | { | 3553 | { |
3532 | if (geom == localGround) | 3554 | if (geom == localGround) |
3533 | { | 3555 | { |
3534 | localHeightfield = TerrainHeightFieldHeights[geom]; | 3556 | // localHeightfield = TerrainHeightFieldHeights[geom]; |
3535 | proceed = true; | 3557 | proceed = true; |
3536 | } | 3558 | } |
3537 | else | 3559 | else |
@@ -3553,7 +3575,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
3553 | // memory corruption | 3575 | // memory corruption |
3554 | if (TerrainHeightFieldHeights.ContainsKey(g)) | 3576 | if (TerrainHeightFieldHeights.ContainsKey(g)) |
3555 | { | 3577 | { |
3556 | float[] removingHeightField = TerrainHeightFieldHeights[g]; | 3578 | // float[] removingHeightField = TerrainHeightFieldHeights[g]; |
3557 | TerrainHeightFieldHeights.Remove(g); | 3579 | TerrainHeightFieldHeights.Remove(g); |
3558 | 3580 | ||
3559 | if (RegionTerrain.ContainsKey(g)) | 3581 | if (RegionTerrain.ContainsKey(g)) |
diff --git a/OpenSim/Region/CoreModules/World/Land/RegionCombinerClientEventForwarder.cs b/OpenSim/Region/RegionCombinerModule/RegionCombinerClientEventForwarder.cs index 70d6de3..721d396 100644 --- a/OpenSim/Region/CoreModules/World/Land/RegionCombinerClientEventForwarder.cs +++ b/OpenSim/Region/RegionCombinerModule/RegionCombinerClientEventForwarder.cs | |||
@@ -30,7 +30,7 @@ using System.Collections.Generic; | |||
30 | using OpenMetaverse; | 30 | using OpenMetaverse; |
31 | using OpenSim.Region.Framework.Scenes; | 31 | using OpenSim.Region.Framework.Scenes; |
32 | 32 | ||
33 | namespace OpenSim.Region.CoreModules.World.Land | 33 | namespace OpenSim.Region.RegionCombinerModule |
34 | { | 34 | { |
35 | public class RegionCombinerClientEventForwarder | 35 | public class RegionCombinerClientEventForwarder |
36 | { | 36 | { |
diff --git a/OpenSim/Region/CoreModules/World/Land/RegionCombinerIndividualEventForwarder.cs b/OpenSim/Region/RegionCombinerModule/RegionCombinerIndividualEventForwarder.cs index 2cbaf96..9d41c9c 100644 --- a/OpenSim/Region/CoreModules/World/Land/RegionCombinerIndividualEventForwarder.cs +++ b/OpenSim/Region/RegionCombinerModule/RegionCombinerIndividualEventForwarder.cs | |||
@@ -30,7 +30,7 @@ using OpenMetaverse; | |||
30 | using OpenSim.Framework; | 30 | using OpenSim.Framework; |
31 | using OpenSim.Region.Framework.Scenes; | 31 | using OpenSim.Region.Framework.Scenes; |
32 | 32 | ||
33 | namespace OpenSim.Region.CoreModules.World.Land | 33 | namespace OpenSim.Region.RegionCombinerModule |
34 | { | 34 | { |
35 | public class RegionCombinerIndividualEventForwarder | 35 | public class RegionCombinerIndividualEventForwarder |
36 | { | 36 | { |
diff --git a/OpenSim/Region/CoreModules/World/Land/RegionCombinerLargeLandChannel.cs b/OpenSim/Region/RegionCombinerModule/RegionCombinerLargeLandChannel.cs index 7df836c..146ec66 100644 --- a/OpenSim/Region/CoreModules/World/Land/RegionCombinerLargeLandChannel.cs +++ b/OpenSim/Region/RegionCombinerModule/RegionCombinerLargeLandChannel.cs | |||
@@ -30,8 +30,9 @@ using System.Collections.Generic; | |||
30 | using OpenMetaverse; | 30 | using OpenMetaverse; |
31 | using OpenSim.Framework; | 31 | using OpenSim.Framework; |
32 | using OpenSim.Region.Framework.Interfaces; | 32 | using OpenSim.Region.Framework.Interfaces; |
33 | using OpenSim.Region.CoreModules.World.Land; | ||
33 | 34 | ||
34 | namespace OpenSim.Region.CoreModules.World.Land | 35 | namespace OpenSim.Region.RegionCombinerModule |
35 | { | 36 | { |
36 | public class RegionCombinerLargeLandChannel : ILandChannel | 37 | public class RegionCombinerLargeLandChannel : ILandChannel |
37 | { | 38 | { |
diff --git a/OpenSim/Region/CoreModules/World/Land/RegionCombinerModule.cs b/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs index d8c5ed9..7ec1d4b 100644 --- a/OpenSim/Region/CoreModules/World/Land/RegionCombinerModule.cs +++ b/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs | |||
@@ -36,9 +36,15 @@ using OpenSim.Framework.Client; | |||
36 | using OpenSim.Region.Framework.Interfaces; | 36 | using OpenSim.Region.Framework.Interfaces; |
37 | using OpenSim.Region.Framework.Scenes; | 37 | using OpenSim.Region.Framework.Scenes; |
38 | using OpenSim.Framework.Console; | 38 | using OpenSim.Framework.Console; |
39 | using OpenSim.Region.Physics.Manager; | ||
40 | using Mono.Addins; | ||
39 | 41 | ||
40 | namespace OpenSim.Region.CoreModules.World.Land | 42 | [assembly: Addin("RegionCombinerModule", "0.1")] |
43 | [assembly: AddinDependency("OpenSim", "0.5")] | ||
44 | namespace OpenSim.Region.RegionCombinerModule | ||
41 | { | 45 | { |
46 | |||
47 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] | ||
42 | public class RegionCombinerModule : ISharedRegionModule | 48 | public class RegionCombinerModule : ISharedRegionModule |
43 | { | 49 | { |
44 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 50 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
@@ -299,76 +305,13 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
299 | //xxy | 305 | //xxy |
300 | //xxx | 306 | //xxx |
301 | 307 | ||
308 | |||
302 | if ((((int)conn.X * (int)Constants.RegionSize) + conn.XEnd | 309 | if ((((int)conn.X * (int)Constants.RegionSize) + conn.XEnd |
303 | >= (regionConnections.X * (int)Constants.RegionSize)) | 310 | >= (regionConnections.X * (int)Constants.RegionSize)) |
304 | && (((int)conn.Y * (int)Constants.RegionSize) | 311 | && (((int)conn.Y * (int)Constants.RegionSize) |
305 | >= (regionConnections.Y * (int)Constants.RegionSize))) | 312 | >= (regionConnections.Y * (int)Constants.RegionSize))) |
306 | { | 313 | { |
307 | Vector3 offset = Vector3.Zero; | 314 | connectedYN = DoWorkForOneRegionOverPlusXY(conn, regionConnections, scene); |
308 | offset.X = (((regionConnections.X * (int)Constants.RegionSize)) - | ||
309 | ((conn.X * (int)Constants.RegionSize))); | ||
310 | offset.Y = (((regionConnections.Y * (int)Constants.RegionSize)) - | ||
311 | ((conn.Y * (int)Constants.RegionSize))); | ||
312 | |||
313 | Vector3 extents = Vector3.Zero; | ||
314 | extents.Y = conn.YEnd; | ||
315 | extents.X = conn.XEnd + regionConnections.XEnd; | ||
316 | |||
317 | conn.UpdateExtents(extents); | ||
318 | |||
319 | m_log.DebugFormat("Scene: {0} to the west of Scene{1} Offset: {2}. Extents:{3}", | ||
320 | conn.RegionScene.RegionInfo.RegionName, | ||
321 | regionConnections.RegionScene.RegionInfo.RegionName, offset, extents); | ||
322 | |||
323 | scene.BordersLocked = true; | ||
324 | conn.RegionScene.BordersLocked = true; | ||
325 | |||
326 | RegionData ConnectedRegion = new RegionData(); | ||
327 | ConnectedRegion.Offset = offset; | ||
328 | ConnectedRegion.RegionId = scene.RegionInfo.originRegionID; | ||
329 | ConnectedRegion.RegionScene = scene; | ||
330 | conn.ConnectedRegions.Add(ConnectedRegion); | ||
331 | |||
332 | // Inform root region Physics about the extents of this region | ||
333 | conn.RegionScene.PhysicsScene.Combine(null, Vector3.Zero, extents); | ||
334 | |||
335 | // Inform Child region that it needs to forward it's terrain to the root region | ||
336 | scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset, Vector3.Zero); | ||
337 | |||
338 | // Extend the borders as appropriate | ||
339 | lock (conn.RegionScene.EastBorders) | ||
340 | conn.RegionScene.EastBorders[0].BorderLine.Z += (int)Constants.RegionSize; | ||
341 | |||
342 | lock (conn.RegionScene.NorthBorders) | ||
343 | conn.RegionScene.NorthBorders[0].BorderLine.Y += (int)Constants.RegionSize; | ||
344 | |||
345 | lock (conn.RegionScene.SouthBorders) | ||
346 | conn.RegionScene.SouthBorders[0].BorderLine.Y += (int)Constants.RegionSize; | ||
347 | |||
348 | lock (scene.WestBorders) | ||
349 | { | ||
350 | |||
351 | |||
352 | scene.WestBorders[0].BorderLine.Z = (int)((scene.RegionInfo.RegionLocX - conn.RegionScene.RegionInfo.RegionLocX) * (int)Constants.RegionSize); //auto teleport West | ||
353 | |||
354 | // Trigger auto teleport to root region | ||
355 | scene.WestBorders[0].TriggerRegionX = conn.RegionScene.RegionInfo.RegionLocX; | ||
356 | scene.WestBorders[0].TriggerRegionY = conn.RegionScene.RegionInfo.RegionLocY; | ||
357 | } | ||
358 | |||
359 | // Reset Terrain.. since terrain loads before we get here, we need to load | ||
360 | // it again so it loads in the root region | ||
361 | |||
362 | scene.PhysicsScene.SetTerrain(scene.Heightmap.GetFloatsSerialised()); | ||
363 | |||
364 | // Unlock borders | ||
365 | conn.RegionScene.BordersLocked = false; | ||
366 | scene.BordersLocked = false; | ||
367 | |||
368 | // Create a client event forwarder and add this region's events to the root region. | ||
369 | if (conn.ClientEventForwarder != null) | ||
370 | conn.ClientEventForwarder.AddSceneToEventForwarding(scene); | ||
371 | connectedYN = true; | ||
372 | break; | 315 | break; |
373 | } | 316 | } |
374 | 317 | ||
@@ -381,57 +324,8 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
381 | && (((int)conn.Y * (int)Constants.RegionSize) + conn.YEnd | 324 | && (((int)conn.Y * (int)Constants.RegionSize) + conn.YEnd |
382 | >= (regionConnections.Y * (int)Constants.RegionSize))) | 325 | >= (regionConnections.Y * (int)Constants.RegionSize))) |
383 | { | 326 | { |
384 | Vector3 offset = Vector3.Zero; | 327 | connectedYN = DoWorkForOneRegionOverXPlusY(conn, regionConnections, scene); |
385 | offset.X = (((regionConnections.X * (int)Constants.RegionSize)) - | 328 | break; |
386 | ((conn.X * (int)Constants.RegionSize))); | ||
387 | offset.Y = (((regionConnections.Y * (int)Constants.RegionSize)) - | ||
388 | ((conn.Y * (int)Constants.RegionSize))); | ||
389 | |||
390 | Vector3 extents = Vector3.Zero; | ||
391 | extents.Y = regionConnections.YEnd + conn.YEnd; | ||
392 | extents.X = conn.XEnd; | ||
393 | conn.UpdateExtents(extents); | ||
394 | |||
395 | scene.BordersLocked = true; | ||
396 | conn.RegionScene.BordersLocked = true; | ||
397 | |||
398 | RegionData ConnectedRegion = new RegionData(); | ||
399 | ConnectedRegion.Offset = offset; | ||
400 | ConnectedRegion.RegionId = scene.RegionInfo.originRegionID; | ||
401 | ConnectedRegion.RegionScene = scene; | ||
402 | conn.ConnectedRegions.Add(ConnectedRegion); | ||
403 | |||
404 | m_log.DebugFormat("Scene: {0} to the northeast of Scene{1} Offset: {2}. Extents:{3}", | ||
405 | conn.RegionScene.RegionInfo.RegionName, | ||
406 | regionConnections.RegionScene.RegionInfo.RegionName, offset, extents); | ||
407 | |||
408 | conn.RegionScene.PhysicsScene.Combine(null, Vector3.Zero, extents); | ||
409 | scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset, Vector3.Zero); | ||
410 | |||
411 | lock (conn.RegionScene.NorthBorders) | ||
412 | conn.RegionScene.NorthBorders[0].BorderLine.Z += (int)Constants.RegionSize; | ||
413 | lock (conn.RegionScene.EastBorders) | ||
414 | conn.RegionScene.EastBorders[0].BorderLine.Y += (int)Constants.RegionSize; | ||
415 | lock (conn.RegionScene.WestBorders) | ||
416 | conn.RegionScene.WestBorders[0].BorderLine.Y += (int)Constants.RegionSize; | ||
417 | lock (scene.SouthBorders) | ||
418 | { | ||
419 | scene.SouthBorders[0].BorderLine.Z = (int)((scene.RegionInfo.RegionLocY - conn.RegionScene.RegionInfo.RegionLocY) * (int)Constants.RegionSize); //auto teleport south | ||
420 | scene.SouthBorders[0].TriggerRegionX = conn.RegionScene.RegionInfo.RegionLocX; | ||
421 | scene.SouthBorders[0].TriggerRegionY = conn.RegionScene.RegionInfo.RegionLocY; | ||
422 | } | ||
423 | |||
424 | // Reset Terrain.. since terrain normally loads first. | ||
425 | //conn.RegionScene.PhysicsScene.SetTerrain(conn.RegionScene.Heightmap.GetFloatsSerialised()); | ||
426 | scene.PhysicsScene.SetTerrain(scene.Heightmap.GetFloatsSerialised()); | ||
427 | //conn.RegionScene.PhysicsScene.SetTerrain(conn.RegionScene.Heightmap.GetFloatsSerialised()); | ||
428 | |||
429 | scene.BordersLocked = false; | ||
430 | conn.RegionScene.BordersLocked = false; | ||
431 | if (conn.ClientEventForwarder != null) | ||
432 | conn.ClientEventForwarder.AddSceneToEventForwarding(scene); | ||
433 | connectedYN = true; | ||
434 | break; | ||
435 | } | 329 | } |
436 | 330 | ||
437 | // If we're one region over +x +y | 331 | // If we're one region over +x +y |
@@ -443,140 +337,276 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
443 | && (((int)conn.Y * (int)Constants.RegionSize) + conn.YEnd | 337 | && (((int)conn.Y * (int)Constants.RegionSize) + conn.YEnd |
444 | >= (regionConnections.Y * (int)Constants.RegionSize))) | 338 | >= (regionConnections.Y * (int)Constants.RegionSize))) |
445 | { | 339 | { |
446 | Vector3 offset = Vector3.Zero; | 340 | connectedYN = DoWorkForOneRegionOverPlusXPlusY(conn, regionConnections, scene); |
447 | offset.X = (((regionConnections.X * (int)Constants.RegionSize)) - | 341 | break; |
448 | ((conn.X * (int)Constants.RegionSize))); | ||
449 | offset.Y = (((regionConnections.Y * (int)Constants.RegionSize)) - | ||
450 | ((conn.Y * (int)Constants.RegionSize))); | ||
451 | 342 | ||
452 | Vector3 extents = Vector3.Zero; | 343 | } |
453 | extents.Y = regionConnections.YEnd + conn.YEnd; | 344 | } |
454 | extents.X = regionConnections.XEnd + conn.XEnd; | ||
455 | conn.UpdateExtents(extents); | ||
456 | 345 | ||
457 | scene.BordersLocked = true; | 346 | // If !connectYN means that this region is a root region |
458 | conn.RegionScene.BordersLocked = true; | 347 | if (!connectedYN) |
348 | { | ||
349 | DoWorkForRootRegion(regionConnections, scene); | ||
459 | 350 | ||
460 | RegionData ConnectedRegion = new RegionData(); | 351 | } |
461 | ConnectedRegion.Offset = offset; | 352 | } |
462 | ConnectedRegion.RegionId = scene.RegionInfo.originRegionID; | 353 | // Set up infinite borders around the entire AABB of the combined ConnectedRegions |
463 | ConnectedRegion.RegionScene = scene; | 354 | AdjustLargeRegionBounds(); |
355 | } | ||
464 | 356 | ||
465 | conn.ConnectedRegions.Add(ConnectedRegion); | 357 | private bool DoWorkForOneRegionOverPlusXY(RegionConnections conn, RegionConnections regionConnections, Scene scene) |
358 | { | ||
359 | Vector3 offset = Vector3.Zero; | ||
360 | offset.X = (((regionConnections.X * (int)Constants.RegionSize)) - | ||
361 | ((conn.X * (int)Constants.RegionSize))); | ||
362 | offset.Y = (((regionConnections.Y * (int)Constants.RegionSize)) - | ||
363 | ((conn.Y * (int)Constants.RegionSize))); | ||
466 | 364 | ||
467 | m_log.DebugFormat("Scene: {0} to the NorthEast of Scene{1} Offset: {2}. Extents:{3}", | 365 | Vector3 extents = Vector3.Zero; |
468 | conn.RegionScene.RegionInfo.RegionName, | 366 | extents.Y = conn.YEnd; |
469 | regionConnections.RegionScene.RegionInfo.RegionName, offset, extents); | 367 | extents.X = conn.XEnd + regionConnections.XEnd; |
470 | 368 | ||
471 | conn.RegionScene.PhysicsScene.Combine(null, Vector3.Zero, extents); | 369 | conn.UpdateExtents(extents); |
472 | scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset, Vector3.Zero); | ||
473 | lock (conn.RegionScene.NorthBorders) | ||
474 | { | ||
475 | if (conn.RegionScene.NorthBorders.Count == 1)// && 2) | ||
476 | { | ||
477 | //compound border | ||
478 | // already locked above | ||
479 | conn.RegionScene.NorthBorders[0].BorderLine.Z += (int)Constants.RegionSize; | ||
480 | |||
481 | lock (conn.RegionScene.EastBorders) | ||
482 | conn.RegionScene.EastBorders[0].BorderLine.Y += (int)Constants.RegionSize; | ||
483 | lock (conn.RegionScene.WestBorders) | ||
484 | conn.RegionScene.WestBorders[0].BorderLine.Y += (int)Constants.RegionSize; | ||
485 | } | ||
486 | } | ||
487 | 370 | ||
488 | lock (scene.SouthBorders) | 371 | m_log.DebugFormat("Scene: {0} to the west of Scene{1} Offset: {2}. Extents:{3}", |
489 | { | 372 | conn.RegionScene.RegionInfo.RegionName, |
490 | scene.SouthBorders[0].BorderLine.Z = (int)((scene.RegionInfo.RegionLocY - conn.RegionScene.RegionInfo.RegionLocY) * (int)Constants.RegionSize); //auto teleport south | 373 | regionConnections.RegionScene.RegionInfo.RegionName, offset, extents); |
491 | scene.SouthBorders[0].TriggerRegionX = conn.RegionScene.RegionInfo.RegionLocX; | ||
492 | scene.SouthBorders[0].TriggerRegionY = conn.RegionScene.RegionInfo.RegionLocY; | ||
493 | } | ||
494 | 374 | ||
495 | lock (conn.RegionScene.EastBorders) | 375 | scene.BordersLocked = true; |
496 | { | 376 | conn.RegionScene.BordersLocked = true; |
497 | if (conn.RegionScene.EastBorders.Count == 1)// && conn.RegionScene.EastBorders.Count == 2) | ||
498 | { | ||
499 | 377 | ||
500 | conn.RegionScene.EastBorders[0].BorderLine.Z += (int)Constants.RegionSize; | 378 | RegionData ConnectedRegion = new RegionData(); |
501 | lock (conn.RegionScene.NorthBorders) | 379 | ConnectedRegion.Offset = offset; |
502 | conn.RegionScene.NorthBorders[0].BorderLine.Y += (int)Constants.RegionSize; | 380 | ConnectedRegion.RegionId = scene.RegionInfo.originRegionID; |
503 | lock (conn.RegionScene.SouthBorders) | 381 | ConnectedRegion.RegionScene = scene; |
504 | conn.RegionScene.SouthBorders[0].BorderLine.Y += (int)Constants.RegionSize; | 382 | conn.ConnectedRegions.Add(ConnectedRegion); |
505 | 383 | ||
384 | // Inform root region Physics about the extents of this region | ||
385 | conn.RegionScene.PhysicsScene.Combine(null, Vector3.Zero, extents); | ||
506 | 386 | ||
507 | } | 387 | // Inform Child region that it needs to forward it's terrain to the root region |
508 | } | 388 | scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset, Vector3.Zero); |
509 | 389 | ||
510 | lock (scene.WestBorders) | 390 | // Extend the borders as appropriate |
511 | { | 391 | lock (conn.RegionScene.EastBorders) |
512 | scene.WestBorders[0].BorderLine.Z = (int)((scene.RegionInfo.RegionLocX - conn.RegionScene.RegionInfo.RegionLocX) * (int)Constants.RegionSize); //auto teleport West | 392 | conn.RegionScene.EastBorders[0].BorderLine.Z += (int)Constants.RegionSize; |
513 | scene.WestBorders[0].TriggerRegionX = conn.RegionScene.RegionInfo.RegionLocX; | ||
514 | scene.WestBorders[0].TriggerRegionY = conn.RegionScene.RegionInfo.RegionLocY; | ||
515 | } | ||
516 | 393 | ||
517 | /* | 394 | lock (conn.RegionScene.NorthBorders) |
518 | else | 395 | conn.RegionScene.NorthBorders[0].BorderLine.Y += (int)Constants.RegionSize; |
519 | { | 396 | |
520 | conn.RegionScene.NorthBorders[0].BorderLine.Z += (int)Constants.RegionSize; | 397 | lock (conn.RegionScene.SouthBorders) |
521 | conn.RegionScene.EastBorders[0].BorderLine.Y += (int)Constants.RegionSize; | 398 | conn.RegionScene.SouthBorders[0].BorderLine.Y += (int)Constants.RegionSize; |
522 | conn.RegionScene.WestBorders[0].BorderLine.Y += (int)Constants.RegionSize; | ||
523 | scene.SouthBorders[0].BorderLine.Z += (int)Constants.RegionSize; //auto teleport south | ||
524 | } | ||
525 | */ | ||
526 | 399 | ||
400 | lock (scene.WestBorders) | ||
401 | { | ||
527 | 402 | ||
528 | // Reset Terrain.. since terrain normally loads first. | ||
529 | //conn.RegionScene.PhysicsScene.SetTerrain(conn.RegionScene.Heightmap.GetFloatsSerialised()); | ||
530 | scene.PhysicsScene.SetTerrain(scene.Heightmap.GetFloatsSerialised()); | ||
531 | //conn.RegionScene.PhysicsScene.SetTerrain(conn.RegionScene.Heightmap.GetFloatsSerialised()); | ||
532 | scene.BordersLocked = false; | ||
533 | conn.RegionScene.BordersLocked = false; | ||
534 | 403 | ||
535 | if (conn.ClientEventForwarder != null) | 404 | scene.WestBorders[0].BorderLine.Z = (int)((scene.RegionInfo.RegionLocX - conn.RegionScene.RegionInfo.RegionLocX) * (int)Constants.RegionSize); //auto teleport West |
536 | conn.ClientEventForwarder.AddSceneToEventForwarding(scene); | ||
537 | 405 | ||
538 | connectedYN = true; | 406 | // Trigger auto teleport to root region |
407 | scene.WestBorders[0].TriggerRegionX = conn.RegionScene.RegionInfo.RegionLocX; | ||
408 | scene.WestBorders[0].TriggerRegionY = conn.RegionScene.RegionInfo.RegionLocY; | ||
409 | } | ||
539 | 410 | ||
540 | //scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset,extents); | 411 | // Reset Terrain.. since terrain loads before we get here, we need to load |
412 | // it again so it loads in the root region | ||
541 | 413 | ||
542 | break; | 414 | scene.PhysicsScene.SetTerrain(scene.Heightmap.GetFloatsSerialised()); |
543 | } | 415 | |
416 | // Unlock borders | ||
417 | conn.RegionScene.BordersLocked = false; | ||
418 | scene.BordersLocked = false; | ||
419 | |||
420 | // Create a client event forwarder and add this region's events to the root region. | ||
421 | if (conn.ClientEventForwarder != null) | ||
422 | conn.ClientEventForwarder.AddSceneToEventForwarding(scene); | ||
423 | |||
424 | return true; | ||
425 | } | ||
426 | |||
427 | private bool DoWorkForOneRegionOverXPlusY(RegionConnections conn, RegionConnections regionConnections, Scene scene) | ||
428 | { | ||
429 | Vector3 offset = Vector3.Zero; | ||
430 | offset.X = (((regionConnections.X * (int)Constants.RegionSize)) - | ||
431 | ((conn.X * (int)Constants.RegionSize))); | ||
432 | offset.Y = (((regionConnections.Y * (int)Constants.RegionSize)) - | ||
433 | ((conn.Y * (int)Constants.RegionSize))); | ||
434 | |||
435 | Vector3 extents = Vector3.Zero; | ||
436 | extents.Y = regionConnections.YEnd + conn.YEnd; | ||
437 | extents.X = conn.XEnd; | ||
438 | conn.UpdateExtents(extents); | ||
439 | |||
440 | scene.BordersLocked = true; | ||
441 | conn.RegionScene.BordersLocked = true; | ||
442 | |||
443 | RegionData ConnectedRegion = new RegionData(); | ||
444 | ConnectedRegion.Offset = offset; | ||
445 | ConnectedRegion.RegionId = scene.RegionInfo.originRegionID; | ||
446 | ConnectedRegion.RegionScene = scene; | ||
447 | conn.ConnectedRegions.Add(ConnectedRegion); | ||
448 | |||
449 | m_log.DebugFormat("Scene: {0} to the northeast of Scene{1} Offset: {2}. Extents:{3}", | ||
450 | conn.RegionScene.RegionInfo.RegionName, | ||
451 | regionConnections.RegionScene.RegionInfo.RegionName, offset, extents); | ||
452 | |||
453 | conn.RegionScene.PhysicsScene.Combine(null, Vector3.Zero, extents); | ||
454 | scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset, Vector3.Zero); | ||
455 | |||
456 | lock (conn.RegionScene.NorthBorders) | ||
457 | conn.RegionScene.NorthBorders[0].BorderLine.Z += (int)Constants.RegionSize; | ||
458 | lock (conn.RegionScene.EastBorders) | ||
459 | conn.RegionScene.EastBorders[0].BorderLine.Y += (int)Constants.RegionSize; | ||
460 | lock (conn.RegionScene.WestBorders) | ||
461 | conn.RegionScene.WestBorders[0].BorderLine.Y += (int)Constants.RegionSize; | ||
462 | lock (scene.SouthBorders) | ||
463 | { | ||
464 | scene.SouthBorders[0].BorderLine.Z = (int)((scene.RegionInfo.RegionLocY - conn.RegionScene.RegionInfo.RegionLocY) * (int)Constants.RegionSize); //auto teleport south | ||
465 | scene.SouthBorders[0].TriggerRegionX = conn.RegionScene.RegionInfo.RegionLocX; | ||
466 | scene.SouthBorders[0].TriggerRegionY = conn.RegionScene.RegionInfo.RegionLocY; | ||
467 | } | ||
468 | |||
469 | // Reset Terrain.. since terrain normally loads first. | ||
470 | //conn.RegionScene.PhysicsScene.SetTerrain(conn.RegionScene.Heightmap.GetFloatsSerialised()); | ||
471 | scene.PhysicsScene.SetTerrain(scene.Heightmap.GetFloatsSerialised()); | ||
472 | //conn.RegionScene.PhysicsScene.SetTerrain(conn.RegionScene.Heightmap.GetFloatsSerialised()); | ||
473 | |||
474 | scene.BordersLocked = false; | ||
475 | conn.RegionScene.BordersLocked = false; | ||
476 | if (conn.ClientEventForwarder != null) | ||
477 | conn.ClientEventForwarder.AddSceneToEventForwarding(scene); | ||
478 | return true; | ||
479 | } | ||
480 | |||
481 | private bool DoWorkForOneRegionOverPlusXPlusY(RegionConnections conn, RegionConnections regionConnections, Scene scene) | ||
482 | { | ||
483 | Vector3 offset = Vector3.Zero; | ||
484 | offset.X = (((regionConnections.X * (int)Constants.RegionSize)) - | ||
485 | ((conn.X * (int)Constants.RegionSize))); | ||
486 | offset.Y = (((regionConnections.Y * (int)Constants.RegionSize)) - | ||
487 | ((conn.Y * (int)Constants.RegionSize))); | ||
488 | |||
489 | Vector3 extents = Vector3.Zero; | ||
490 | extents.Y = regionConnections.YEnd + conn.YEnd; | ||
491 | extents.X = regionConnections.XEnd + conn.XEnd; | ||
492 | conn.UpdateExtents(extents); | ||
493 | |||
494 | scene.BordersLocked = true; | ||
495 | conn.RegionScene.BordersLocked = true; | ||
496 | |||
497 | RegionData ConnectedRegion = new RegionData(); | ||
498 | ConnectedRegion.Offset = offset; | ||
499 | ConnectedRegion.RegionId = scene.RegionInfo.originRegionID; | ||
500 | ConnectedRegion.RegionScene = scene; | ||
501 | |||
502 | conn.ConnectedRegions.Add(ConnectedRegion); | ||
503 | |||
504 | m_log.DebugFormat("Scene: {0} to the NorthEast of Scene{1} Offset: {2}. Extents:{3}", | ||
505 | conn.RegionScene.RegionInfo.RegionName, | ||
506 | regionConnections.RegionScene.RegionInfo.RegionName, offset, extents); | ||
507 | |||
508 | conn.RegionScene.PhysicsScene.Combine(null, Vector3.Zero, extents); | ||
509 | scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset, Vector3.Zero); | ||
510 | lock (conn.RegionScene.NorthBorders) | ||
511 | { | ||
512 | if (conn.RegionScene.NorthBorders.Count == 1)// && 2) | ||
513 | { | ||
514 | //compound border | ||
515 | // already locked above | ||
516 | conn.RegionScene.NorthBorders[0].BorderLine.Z += (int)Constants.RegionSize; | ||
517 | |||
518 | lock (conn.RegionScene.EastBorders) | ||
519 | conn.RegionScene.EastBorders[0].BorderLine.Y += (int)Constants.RegionSize; | ||
520 | lock (conn.RegionScene.WestBorders) | ||
521 | conn.RegionScene.WestBorders[0].BorderLine.Y += (int)Constants.RegionSize; | ||
544 | } | 522 | } |
523 | } | ||
545 | 524 | ||
546 | // If !connectYN means that this region is a root region | 525 | lock (scene.SouthBorders) |
547 | if (!connectedYN) | 526 | { |
527 | scene.SouthBorders[0].BorderLine.Z = (int)((scene.RegionInfo.RegionLocY - conn.RegionScene.RegionInfo.RegionLocY) * (int)Constants.RegionSize); //auto teleport south | ||
528 | scene.SouthBorders[0].TriggerRegionX = conn.RegionScene.RegionInfo.RegionLocX; | ||
529 | scene.SouthBorders[0].TriggerRegionY = conn.RegionScene.RegionInfo.RegionLocY; | ||
530 | } | ||
531 | |||
532 | lock (conn.RegionScene.EastBorders) | ||
533 | { | ||
534 | if (conn.RegionScene.EastBorders.Count == 1)// && conn.RegionScene.EastBorders.Count == 2) | ||
548 | { | 535 | { |
549 | RegionData rdata = new RegionData(); | ||
550 | rdata.Offset = Vector3.Zero; | ||
551 | rdata.RegionId = scene.RegionInfo.originRegionID; | ||
552 | rdata.RegionScene = scene; | ||
553 | // save it's land channel | ||
554 | regionConnections.RegionLandChannel = scene.LandChannel; | ||
555 | |||
556 | // Substitue our landchannel | ||
557 | RegionCombinerLargeLandChannel lnd = new RegionCombinerLargeLandChannel(rdata, scene.LandChannel, | ||
558 | regionConnections.ConnectedRegions); | ||
559 | scene.LandChannel = lnd; | ||
560 | // Forward the permissions modules of each of the connected regions to the root region | ||
561 | lock (m_regions) | ||
562 | { | ||
563 | foreach (RegionData r in regionConnections.ConnectedRegions) | ||
564 | { | ||
565 | ForwardPermissionRequests(regionConnections, r.RegionScene); | ||
566 | } | ||
567 | } | ||
568 | // Create the root region's Client Event Forwarder | ||
569 | regionConnections.ClientEventForwarder = new RegionCombinerClientEventForwarder(regionConnections); | ||
570 | 536 | ||
571 | // Sets up the CoarseLocationUpdate forwarder for this root region | 537 | conn.RegionScene.EastBorders[0].BorderLine.Z += (int)Constants.RegionSize; |
572 | scene.EventManager.OnNewPresence += SetCourseLocationDelegate; | 538 | lock (conn.RegionScene.NorthBorders) |
539 | conn.RegionScene.NorthBorders[0].BorderLine.Y += (int)Constants.RegionSize; | ||
540 | lock (conn.RegionScene.SouthBorders) | ||
541 | conn.RegionScene.SouthBorders[0].BorderLine.Y += (int)Constants.RegionSize; | ||
542 | |||
573 | 543 | ||
574 | // Adds this root region to a dictionary of regions that are connectable | ||
575 | m_regions.Add(scene.RegionInfo.originRegionID, regionConnections); | ||
576 | } | 544 | } |
577 | } | 545 | } |
578 | // Set up infinite borders around the entire AABB of the combined ConnectedRegions | 546 | |
579 | AdjustLargeRegionBounds(); | 547 | lock (scene.WestBorders) |
548 | { | ||
549 | scene.WestBorders[0].BorderLine.Z = (int)((scene.RegionInfo.RegionLocX - conn.RegionScene.RegionInfo.RegionLocX) * (int)Constants.RegionSize); //auto teleport West | ||
550 | scene.WestBorders[0].TriggerRegionX = conn.RegionScene.RegionInfo.RegionLocX; | ||
551 | scene.WestBorders[0].TriggerRegionY = conn.RegionScene.RegionInfo.RegionLocY; | ||
552 | } | ||
553 | |||
554 | /* | ||
555 | else | ||
556 | { | ||
557 | conn.RegionScene.NorthBorders[0].BorderLine.Z += (int)Constants.RegionSize; | ||
558 | conn.RegionScene.EastBorders[0].BorderLine.Y += (int)Constants.RegionSize; | ||
559 | conn.RegionScene.WestBorders[0].BorderLine.Y += (int)Constants.RegionSize; | ||
560 | scene.SouthBorders[0].BorderLine.Z += (int)Constants.RegionSize; //auto teleport south | ||
561 | } | ||
562 | */ | ||
563 | |||
564 | |||
565 | // Reset Terrain.. since terrain normally loads first. | ||
566 | //conn.RegionScene.PhysicsScene.SetTerrain(conn.RegionScene.Heightmap.GetFloatsSerialised()); | ||
567 | scene.PhysicsScene.SetTerrain(scene.Heightmap.GetFloatsSerialised()); | ||
568 | //conn.RegionScene.PhysicsScene.SetTerrain(conn.RegionScene.Heightmap.GetFloatsSerialised()); | ||
569 | scene.BordersLocked = false; | ||
570 | conn.RegionScene.BordersLocked = false; | ||
571 | |||
572 | if (conn.ClientEventForwarder != null) | ||
573 | conn.ClientEventForwarder.AddSceneToEventForwarding(scene); | ||
574 | |||
575 | return true; | ||
576 | |||
577 | //scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset,extents); | ||
578 | |||
579 | } | ||
580 | |||
581 | private void DoWorkForRootRegion(RegionConnections regionConnections, Scene scene) | ||
582 | { | ||
583 | RegionData rdata = new RegionData(); | ||
584 | rdata.Offset = Vector3.Zero; | ||
585 | rdata.RegionId = scene.RegionInfo.originRegionID; | ||
586 | rdata.RegionScene = scene; | ||
587 | // save it's land channel | ||
588 | regionConnections.RegionLandChannel = scene.LandChannel; | ||
589 | |||
590 | // Substitue our landchannel | ||
591 | RegionCombinerLargeLandChannel lnd = new RegionCombinerLargeLandChannel(rdata, scene.LandChannel, | ||
592 | regionConnections.ConnectedRegions); | ||
593 | scene.LandChannel = lnd; | ||
594 | // Forward the permissions modules of each of the connected regions to the root region | ||
595 | lock (m_regions) | ||
596 | { | ||
597 | foreach (RegionData r in regionConnections.ConnectedRegions) | ||
598 | { | ||
599 | ForwardPermissionRequests(regionConnections, r.RegionScene); | ||
600 | } | ||
601 | } | ||
602 | // Create the root region's Client Event Forwarder | ||
603 | regionConnections.ClientEventForwarder = new RegionCombinerClientEventForwarder(regionConnections); | ||
604 | |||
605 | // Sets up the CoarseLocationUpdate forwarder for this root region | ||
606 | scene.EventManager.OnNewPresence += SetCourseLocationDelegate; | ||
607 | |||
608 | // Adds this root region to a dictionary of regions that are connectable | ||
609 | m_regions.Add(scene.RegionInfo.originRegionID, regionConnections); | ||
580 | } | 610 | } |
581 | 611 | ||
582 | private void SetCourseLocationDelegate(ScenePresence presence) | 612 | private void SetCourseLocationDelegate(ScenePresence presence) |
diff --git a/OpenSim/Region/CoreModules/World/Land/RegionCombinerPermissionModule.cs b/OpenSim/Region/RegionCombinerModule/RegionCombinerPermissionModule.cs index 76ca5e3..4d1af57 100644 --- a/OpenSim/Region/CoreModules/World/Land/RegionCombinerPermissionModule.cs +++ b/OpenSim/Region/RegionCombinerModule/RegionCombinerPermissionModule.cs | |||
@@ -32,7 +32,7 @@ using OpenSim.Framework; | |||
32 | using OpenSim.Region.Framework.Interfaces; | 32 | using OpenSim.Region.Framework.Interfaces; |
33 | using OpenSim.Region.Framework.Scenes; | 33 | using OpenSim.Region.Framework.Scenes; |
34 | 34 | ||
35 | namespace OpenSim.Region.CoreModules.World.Land | 35 | namespace OpenSim.Region.RegionCombinerModule |
36 | { | 36 | { |
37 | public class RegionCombinerPermissionModule | 37 | public class RegionCombinerPermissionModule |
38 | { | 38 | { |
diff --git a/OpenSim/Region/CoreModules/World/Land/RegionConnections.cs b/OpenSim/Region/RegionCombinerModule/RegionConnections.cs index 419ed74..3aa9f20 100644 --- a/OpenSim/Region/CoreModules/World/Land/RegionConnections.cs +++ b/OpenSim/Region/RegionCombinerModule/RegionConnections.cs | |||
@@ -31,7 +31,7 @@ using OpenMetaverse; | |||
31 | using OpenSim.Region.Framework.Interfaces; | 31 | using OpenSim.Region.Framework.Interfaces; |
32 | using OpenSim.Region.Framework.Scenes; | 32 | using OpenSim.Region.Framework.Scenes; |
33 | 33 | ||
34 | namespace OpenSim.Region.CoreModules.World.Land | 34 | namespace OpenSim.Region.RegionCombinerModule |
35 | { | 35 | { |
36 | public class RegionConnections | 36 | public class RegionConnections |
37 | { | 37 | { |
diff --git a/OpenSim/Region/CoreModules/World/Land/RegionCourseLocation.cs b/OpenSim/Region/RegionCombinerModule/RegionCourseLocation.cs index 175ca89..53a678f 100644 --- a/OpenSim/Region/CoreModules/World/Land/RegionCourseLocation.cs +++ b/OpenSim/Region/RegionCombinerModule/RegionCourseLocation.cs | |||
@@ -30,7 +30,7 @@ using System.Collections.Generic; | |||
30 | using OpenMetaverse; | 30 | using OpenMetaverse; |
31 | using OpenSim.Framework; | 31 | using OpenSim.Framework; |
32 | 32 | ||
33 | namespace OpenSim.Region.CoreModules.World.Land | 33 | namespace OpenSim.Region.RegionCombinerModule |
34 | { | 34 | { |
35 | 35 | ||
36 | struct RegionCourseLocationStruct | 36 | struct RegionCourseLocationStruct |
diff --git a/OpenSim/Region/CoreModules/World/Land/RegionData.cs b/OpenSim/Region/RegionCombinerModule/RegionData.cs index 3383527..bd0e398 100644 --- a/OpenSim/Region/CoreModules/World/Land/RegionData.cs +++ b/OpenSim/Region/RegionCombinerModule/RegionData.cs | |||
@@ -28,7 +28,7 @@ | |||
28 | using OpenMetaverse; | 28 | using OpenMetaverse; |
29 | using OpenSim.Region.Framework.Scenes; | 29 | using OpenSim.Region.Framework.Scenes; |
30 | 30 | ||
31 | namespace OpenSim.Region.CoreModules.World.Land | 31 | namespace OpenSim.Region.RegionCombinerModule |
32 | { | 32 | { |
33 | public class RegionData | 33 | public class RegionData |
34 | { | 34 | { |
diff --git a/OpenSim/Region/ScriptEngine/Interfaces/ICompiler.cs b/OpenSim/Region/ScriptEngine/Interfaces/ICompiler.cs index f8af902..e4ca635 100644 --- a/OpenSim/Region/ScriptEngine/Interfaces/ICompiler.cs +++ b/OpenSim/Region/ScriptEngine/Interfaces/ICompiler.cs | |||
@@ -34,9 +34,7 @@ namespace OpenSim.Region.ScriptEngine.Interfaces | |||
34 | { | 34 | { |
35 | public interface ICompiler | 35 | public interface ICompiler |
36 | { | 36 | { |
37 | object PerformScriptCompile(string source, string asset, UUID ownerID); | 37 | void PerformScriptCompile(string source, string asset, UUID ownerID, out string assembly, out Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> linemap); |
38 | string[] GetWarnings(); | 38 | string[] GetWarnings(); |
39 | Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> | ||
40 | LineMap(); | ||
41 | } | 39 | } |
42 | } | 40 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 0f01c36..fc17808 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -2163,7 +2163,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2163 | public LSL_Vector llGetOmega() | 2163 | public LSL_Vector llGetOmega() |
2164 | { | 2164 | { |
2165 | m_host.AddScriptLPS(1); | 2165 | m_host.AddScriptLPS(1); |
2166 | return new LSL_Vector(m_host.RotationalVelocity.X, m_host.RotationalVelocity.Y, m_host.RotationalVelocity.Z); | 2166 | return new LSL_Vector(m_host.AngularVelocity.X, m_host.AngularVelocity.Y, m_host.AngularVelocity.Z); |
2167 | } | 2167 | } |
2168 | 2168 | ||
2169 | public LSL_Float llGetTimeOfDay() | 2169 | public LSL_Float llGetTimeOfDay() |
@@ -3163,7 +3163,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3163 | public void llTargetOmega(LSL_Vector axis, double spinrate, double gain) | 3163 | public void llTargetOmega(LSL_Vector axis, double spinrate, double gain) |
3164 | { | 3164 | { |
3165 | m_host.AddScriptLPS(1); | 3165 | m_host.AddScriptLPS(1); |
3166 | m_host.RotationalVelocity = new Vector3((float)(axis.x * spinrate), (float)(axis.y * spinrate), (float)(axis.z * spinrate)); | ||
3167 | m_host.AngularVelocity = new Vector3((float)(axis.x * spinrate), (float)(axis.y * spinrate), (float)(axis.z * spinrate)); | 3166 | m_host.AngularVelocity = new Vector3((float)(axis.x * spinrate), (float)(axis.y * spinrate), (float)(axis.z * spinrate)); |
3168 | m_host.ScheduleTerseUpdate(); | 3167 | m_host.ScheduleTerseUpdate(); |
3169 | m_host.SendTerseUpdateToAllClients(); | 3168 | m_host.SendTerseUpdateToAllClients(); |
@@ -3821,7 +3820,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3821 | { | 3820 | { |
3822 | case 1: // DATA_ONLINE (0|1) | 3821 | case 1: // DATA_ONLINE (0|1) |
3823 | // TODO: implement fetching of this information | 3822 | // TODO: implement fetching of this information |
3824 | if (userProfile.CurrentAgent.AgentOnline) | 3823 | if (userProfile.CurrentAgent!=null && userProfile.CurrentAgent.AgentOnline) |
3825 | reply = "1"; | 3824 | reply = "1"; |
3826 | else | 3825 | else |
3827 | reply = "0"; | 3826 | reply = "0"; |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs new file mode 100644 index 0000000..d4facdd --- /dev/null +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs | |||
@@ -0,0 +1,134 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Reflection; | ||
30 | using System.Collections; | ||
31 | using System.Collections.Generic; | ||
32 | using System.Runtime.Remoting.Lifetime; | ||
33 | using OpenMetaverse; | ||
34 | using Nini.Config; | ||
35 | using OpenSim; | ||
36 | using OpenSim.Framework; | ||
37 | using OpenSim.Region.Framework.Interfaces; | ||
38 | using OpenSim.Region.Framework.Scenes; | ||
39 | using OpenSim.Region.ScriptEngine.Shared; | ||
40 | using OpenSim.Region.ScriptEngine.Shared.Api.Plugins; | ||
41 | using OpenSim.Region.ScriptEngine.Shared.ScriptBase; | ||
42 | using OpenSim.Region.ScriptEngine.Interfaces; | ||
43 | using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces; | ||
44 | |||
45 | using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat; | ||
46 | using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; | ||
47 | using LSL_Key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; | ||
48 | using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list; | ||
49 | using LSL_Rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion; | ||
50 | using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; | ||
51 | using LSL_Vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3; | ||
52 | |||
53 | namespace OpenSim.Region.ScriptEngine.Shared.Api | ||
54 | { | ||
55 | [Serializable] | ||
56 | public class MOD_Api : MarshalByRefObject, IMOD_Api, IScriptApi | ||
57 | { | ||
58 | internal IScriptEngine m_ScriptEngine; | ||
59 | internal SceneObjectPart m_host; | ||
60 | internal uint m_localID; | ||
61 | internal UUID m_itemID; | ||
62 | internal bool m_MODFunctionsEnabled = false; | ||
63 | internal IScriptModuleComms m_comms = null; | ||
64 | |||
65 | public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, uint localID, UUID itemID) | ||
66 | { | ||
67 | m_ScriptEngine = ScriptEngine; | ||
68 | m_host = host; | ||
69 | m_localID = localID; | ||
70 | m_itemID = itemID; | ||
71 | |||
72 | if (m_ScriptEngine.Config.GetBoolean("AllowMODFunctions", false)) | ||
73 | m_MODFunctionsEnabled = true; | ||
74 | |||
75 | m_comms = m_ScriptEngine.World.RequestModuleInterface<IScriptModuleComms>(); | ||
76 | if (m_comms == null) | ||
77 | m_MODFunctionsEnabled = false; | ||
78 | } | ||
79 | |||
80 | public override Object InitializeLifetimeService() | ||
81 | { | ||
82 | ILease lease = (ILease)base.InitializeLifetimeService(); | ||
83 | |||
84 | if (lease.CurrentState == LeaseState.Initial) | ||
85 | { | ||
86 | lease.InitialLeaseTime = TimeSpan.FromMinutes(0); | ||
87 | // lease.RenewOnCallTime = TimeSpan.FromSeconds(10.0); | ||
88 | // lease.SponsorshipTimeout = TimeSpan.FromMinutes(1.0); | ||
89 | } | ||
90 | return lease; | ||
91 | } | ||
92 | |||
93 | public Scene World | ||
94 | { | ||
95 | get { return m_ScriptEngine.World; } | ||
96 | } | ||
97 | |||
98 | internal void MODError(string msg) | ||
99 | { | ||
100 | throw new Exception("MOD Runtime Error: " + msg); | ||
101 | } | ||
102 | |||
103 | // | ||
104 | //Dumps an error message on the debug console. | ||
105 | // | ||
106 | |||
107 | internal void MODShoutError(string message) | ||
108 | { | ||
109 | if (message.Length > 1023) | ||
110 | message = message.Substring(0, 1023); | ||
111 | |||
112 | World.SimChat(Utils.StringToBytes(message), | ||
113 | ChatTypeEnum.Shout, ScriptBaseClass.DEBUG_CHANNEL, m_host.ParentGroup.RootPart.AbsolutePosition, m_host.Name, m_host.UUID, true); | ||
114 | |||
115 | IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); | ||
116 | wComm.DeliverMessage(ChatTypeEnum.Shout, ScriptBaseClass.DEBUG_CHANNEL, m_host.Name, m_host.UUID, message); | ||
117 | } | ||
118 | |||
119 | public string modSendCommand(string module, string command, string k) | ||
120 | { | ||
121 | if (!m_MODFunctionsEnabled) | ||
122 | { | ||
123 | MODShoutError("Module command functions not enabled"); | ||
124 | return UUID.Zero.ToString();; | ||
125 | } | ||
126 | |||
127 | UUID req = UUID.Random(); | ||
128 | |||
129 | m_comms.RaiseEvent(m_itemID, req.ToString(), module, command, k); | ||
130 | |||
131 | return req.ToString(); | ||
132 | } | ||
133 | } | ||
134 | } | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 52396b6..3ffcff0 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | |||
@@ -199,7 +199,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
199 | //Dumps an error message on the debug console. | 199 | //Dumps an error message on the debug console. |
200 | // | 200 | // |
201 | 201 | ||
202 | internal void OSSLShoutError(string message) | 202 | internal void OSSLShoutError(string message) |
203 | { | 203 | { |
204 | if (message.Length > 1023) | 204 | if (message.Length > 1023) |
205 | message = message.Substring(0, 1023); | 205 | message = message.Substring(0, 1023); |
@@ -384,7 +384,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
384 | m_host.AddScriptLPS(1); | 384 | m_host.AddScriptLPS(1); |
385 | if (World.Entities.ContainsKey(target)) | 385 | if (World.Entities.ContainsKey(target)) |
386 | { | 386 | { |
387 | World.Entities[target].Rotation = rotation; | 387 | EntityBase entity; |
388 | if (World.Entities.TryGetValue(target, out entity)) | ||
389 | { | ||
390 | if (entity is SceneObjectGroup) | ||
391 | ((SceneObjectGroup)entity).Rotation = rotation; | ||
392 | else if (entity is ScenePresence) | ||
393 | ((ScenePresence)entity).Rotation = rotation; | ||
394 | } | ||
388 | } | 395 | } |
389 | else | 396 | else |
390 | { | 397 | { |
@@ -1169,7 +1176,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1169 | 1176 | ||
1170 | land.SetMediaUrl(url); | 1177 | land.SetMediaUrl(url); |
1171 | } | 1178 | } |
1172 | 1179 | ||
1173 | public void osSetParcelSIPAddress(string SIPAddress) | 1180 | public void osSetParcelSIPAddress(string SIPAddress) |
1174 | { | 1181 | { |
1175 | // What actually is the difference to the LL function? | 1182 | // What actually is the difference to the LL function? |
@@ -1177,7 +1184,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1177 | CheckThreatLevel(ThreatLevel.VeryLow, "osSetParcelMediaURL"); | 1184 | CheckThreatLevel(ThreatLevel.VeryLow, "osSetParcelMediaURL"); |
1178 | 1185 | ||
1179 | m_host.AddScriptLPS(1); | 1186 | m_host.AddScriptLPS(1); |
1180 | 1187 | ||
1181 | 1188 | ||
1182 | ILandObject land | 1189 | ILandObject land |
1183 | = World.LandChannel.GetLandObject(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y); | 1190 | = World.LandChannel.GetLandObject(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y); |
@@ -1187,16 +1194,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1187 | OSSLError("osSetParcelSIPAddress: Sorry, you need to own the land to use this function"); | 1194 | OSSLError("osSetParcelSIPAddress: Sorry, you need to own the land to use this function"); |
1188 | return; | 1195 | return; |
1189 | } | 1196 | } |
1190 | 1197 | ||
1191 | // get the voice module | 1198 | // get the voice module |
1192 | IVoiceModule voiceModule = World.RequestModuleInterface<IVoiceModule>(); | 1199 | IVoiceModule voiceModule = World.RequestModuleInterface<IVoiceModule>(); |
1193 | 1200 | ||
1194 | if (voiceModule != null) | 1201 | if (voiceModule != null) |
1195 | voiceModule.setLandSIPAddress(SIPAddress,land.LandData.GlobalID); | 1202 | voiceModule.setLandSIPAddress(SIPAddress,land.LandData.GlobalID); |
1196 | else | 1203 | else |
1197 | OSSLError("osSetParcelSIPAddress: No voice module enabled for this land"); | 1204 | OSSLError("osSetParcelSIPAddress: No voice module enabled for this land"); |
1198 | 1205 | ||
1199 | 1206 | ||
1200 | } | 1207 | } |
1201 | 1208 | ||
1202 | public string osGetScriptEngineName() | 1209 | public string osGetScriptEngineName() |
@@ -1476,12 +1483,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1476 | m_host.AddScriptLPS(1); | 1483 | m_host.AddScriptLPS(1); |
1477 | 1484 | ||
1478 | // Create new asset | 1485 | // Create new asset |
1479 | AssetBase asset = new AssetBase(); | 1486 | AssetBase asset = new AssetBase(UUID.Random(), notecardName, (sbyte)AssetType.Notecard); |
1480 | asset.Name = notecardName; | ||
1481 | asset.Description = "Script Generated Notecard"; | 1487 | asset.Description = "Script Generated Notecard"; |
1482 | asset.Type = 7; | 1488 | string notecardData = String.Empty; |
1483 | asset.FullID = UUID.Random(); | ||
1484 | string notecardData = ""; | ||
1485 | 1489 | ||
1486 | for (int i = 0; i < contents.Length; i++) { | 1490 | for (int i = 0; i < contents.Length; i++) { |
1487 | notecardData += contents.GetLSLStringItem(i) + "\n"; | 1491 | notecardData += contents.GetLSLStringItem(i) + "\n"; |
@@ -1521,10 +1525,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1521 | } | 1525 | } |
1522 | 1526 | ||
1523 | 1527 | ||
1524 | /*Instead of using the LSL Dataserver event to pull notecard data, | 1528 | /*Instead of using the LSL Dataserver event to pull notecard data, |
1525 | this will simply read the requested line and return its data as a string. | 1529 | this will simply read the requested line and return its data as a string. |
1526 | 1530 | ||
1527 | Warning - due to the synchronous method this function uses to fetch assets, its use | 1531 | Warning - due to the synchronous method this function uses to fetch assets, its use |
1528 | may be dangerous and unreliable while running in grid mode. | 1532 | may be dangerous and unreliable while running in grid mode. |
1529 | */ | 1533 | */ |
1530 | public string osGetNotecardLine(string name, int line) | 1534 | public string osGetNotecardLine(string name, int line) |
@@ -1572,10 +1576,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1572 | 1576 | ||
1573 | } | 1577 | } |
1574 | 1578 | ||
1575 | /*Instead of using the LSL Dataserver event to pull notecard data line by line, | 1579 | /*Instead of using the LSL Dataserver event to pull notecard data line by line, |
1576 | this will simply read the entire notecard and return its data as a string. | 1580 | this will simply read the entire notecard and return its data as a string. |
1577 | 1581 | ||
1578 | Warning - due to the synchronous method this function uses to fetch assets, its use | 1582 | Warning - due to the synchronous method this function uses to fetch assets, its use |
1579 | may be dangerous and unreliable while running in grid mode. | 1583 | may be dangerous and unreliable while running in grid mode. |
1580 | */ | 1584 | */ |
1581 | 1585 | ||
@@ -1630,10 +1634,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1630 | 1634 | ||
1631 | } | 1635 | } |
1632 | 1636 | ||
1633 | /*Instead of using the LSL Dataserver event to pull notecard data, | 1637 | /*Instead of using the LSL Dataserver event to pull notecard data, |
1634 | this will simply read the number of note card lines and return this data as an integer. | 1638 | this will simply read the number of note card lines and return this data as an integer. |
1635 | 1639 | ||
1636 | Warning - due to the synchronous method this function uses to fetch assets, its use | 1640 | Warning - due to the synchronous method this function uses to fetch assets, its use |
1637 | may be dangerous and unreliable while running in grid mode. | 1641 | may be dangerous and unreliable while running in grid mode. |
1638 | */ | 1642 | */ |
1639 | 1643 | ||
@@ -1833,7 +1837,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1833 | 1837 | ||
1834 | return World.RegionInfo.RegionSettings.LoadedCreationID; | 1838 | return World.RegionInfo.RegionSettings.LoadedCreationID; |
1835 | } | 1839 | } |
1836 | 1840 | ||
1837 | // Threat level is 'Low' because certain users could possibly be tricked into | 1841 | // Threat level is 'Low' because certain users could possibly be tricked into |
1838 | // dropping an unverified script into one of their own objects, which could | 1842 | // dropping an unverified script into one of their own objects, which could |
1839 | // then gather the physical construction details of the object and transmit it | 1843 | // then gather the physical construction details of the object and transmit it |
@@ -1857,7 +1861,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1857 | public LSL_Key osNpcCreate(string firstname, string lastname, LSL_Vector position, LSL_Key cloneFrom) | 1861 | public LSL_Key osNpcCreate(string firstname, string lastname, LSL_Vector position, LSL_Key cloneFrom) |
1858 | { | 1862 | { |
1859 | CheckThreatLevel(ThreatLevel.High, "osNpcCreate"); | 1863 | CheckThreatLevel(ThreatLevel.High, "osNpcCreate"); |
1860 | //QueueUserWorkItem | 1864 | //QueueUserWorkItem |
1861 | 1865 | ||
1862 | INPCModule module = World.RequestModuleInterface<INPCModule>(); | 1866 | INPCModule module = World.RequestModuleInterface<INPCModule>(); |
1863 | if (module != null) | 1867 | if (module != null) |
@@ -1906,5 +1910,42 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1906 | module.DeleteNPC(new UUID(npc.m_string), World); | 1910 | module.DeleteNPC(new UUID(npc.m_string), World); |
1907 | } | 1911 | } |
1908 | } | 1912 | } |
1913 | |||
1914 | /// <summary> | ||
1915 | /// Get current region's map texture UUID | ||
1916 | /// </summary> | ||
1917 | /// <returns></returns> | ||
1918 | public LSL_Key osGetMapTexture() | ||
1919 | { | ||
1920 | CheckThreatLevel(ThreatLevel.None, "osGetMapTexture"); | ||
1921 | return m_ScriptEngine.World.RegionInfo.RegionSettings.TerrainImageID.ToString(); | ||
1922 | } | ||
1923 | |||
1924 | /// <summary> | ||
1925 | /// Get a region's map texture UUID by region UUID or name. | ||
1926 | /// </summary> | ||
1927 | /// <param name="regionName"></param> | ||
1928 | /// <returns></returns> | ||
1929 | public LSL_Key osGetRegionMapTexture(string regionName) | ||
1930 | { | ||
1931 | CheckThreatLevel(ThreatLevel.High, "osGetRegionMapTexture"); | ||
1932 | Scene scene = m_ScriptEngine.World; | ||
1933 | UUID key = UUID.Zero; | ||
1934 | GridRegion region; | ||
1935 | |||
1936 | //If string is a key, use it. Otherwise, try to locate region by name. | ||
1937 | if (UUID.TryParse(regionName, out key)) | ||
1938 | region = scene.GridService.GetRegionByUUID(UUID.Zero, key); | ||
1939 | else | ||
1940 | region = scene.GridService.GetRegionByName(UUID.Zero, regionName); | ||
1941 | |||
1942 | // If region was found, return the regions map texture key. | ||
1943 | if (region != null) | ||
1944 | key = region.TerrainImage; | ||
1945 | |||
1946 | ScriptSleep(1000); | ||
1947 | |||
1948 | return key.ToString(); | ||
1949 | } | ||
1909 | } | 1950 | } |
1910 | } | 1951 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IMOD_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IMOD_Api.cs new file mode 100644 index 0000000..e08eca5 --- /dev/null +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IMOD_Api.cs | |||
@@ -0,0 +1,46 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System.Collections; | ||
29 | using OpenSim.Region.ScriptEngine.Interfaces; | ||
30 | |||
31 | using key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; | ||
32 | using rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion; | ||
33 | using vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3; | ||
34 | using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list; | ||
35 | using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; | ||
36 | using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; | ||
37 | using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat; | ||
38 | |||
39 | namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | ||
40 | { | ||
41 | public interface IMOD_Api | ||
42 | { | ||
43 | //Module functions | ||
44 | string modSendCommand(string modules, string command, string k); | ||
45 | } | ||
46 | } | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index d8d3c31..2a403bf 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | |||
@@ -79,7 +79,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
79 | 79 | ||
80 | // Avatar Info Commands | 80 | // Avatar Info Commands |
81 | string osGetAgentIP(string agent); | 81 | string osGetAgentIP(string agent); |
82 | LSL_List osGetAgents(); | 82 | LSL_List osGetAgents(); |
83 | 83 | ||
84 | // Teleport commands | 84 | // Teleport commands |
85 | void osTeleportAgent(string agent, string regionName, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat); | 85 | void osTeleportAgent(string agent, string regionName, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat); |
@@ -127,7 +127,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
127 | string osGetScriptEngineName(); | 127 | string osGetScriptEngineName(); |
128 | string osGetSimulatorVersion(); | 128 | string osGetSimulatorVersion(); |
129 | Hashtable osParseJSON(string JSON); | 129 | Hashtable osParseJSON(string JSON); |
130 | 130 | ||
131 | void osMessageObject(key objectUUID,string message); | 131 | void osMessageObject(key objectUUID,string message); |
132 | 132 | ||
133 | void osMakeNotecard(string notecardName, LSL_Types.list contents); | 133 | void osMakeNotecard(string notecardName, LSL_Types.list contents); |
@@ -138,7 +138,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
138 | 138 | ||
139 | string osAvatarName2Key(string firstname, string lastname); | 139 | string osAvatarName2Key(string firstname, string lastname); |
140 | string osKey2Name(string id); | 140 | string osKey2Name(string id); |
141 | 141 | ||
142 | // Grid Info Functions | 142 | // Grid Info Functions |
143 | string osGetGridNick(); | 143 | string osGetGridNick(); |
144 | string osGetGridName(); | 144 | string osGetGridName(); |
@@ -151,7 +151,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
151 | string osLoadedCreationDate(); | 151 | string osLoadedCreationDate(); |
152 | string osLoadedCreationTime(); | 152 | string osLoadedCreationTime(); |
153 | string osLoadedCreationID(); | 153 | string osLoadedCreationID(); |
154 | 154 | ||
155 | LSL_List osGetLinkPrimitiveParams(int linknumber, LSL_List rules); | 155 | LSL_List osGetLinkPrimitiveParams(int linknumber, LSL_List rules); |
156 | 156 | ||
157 | 157 | ||
@@ -160,5 +160,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
160 | void osNpcSay(key npc, string message); | 160 | void osNpcSay(key npc, string message); |
161 | void osNpcRemove(key npc); | 161 | void osNpcRemove(key npc); |
162 | 162 | ||
163 | key osGetMapTexture(); | ||
164 | key osGetRegionMapTexture(string regionName); | ||
163 | } | 165 | } |
164 | } | 166 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/MOD_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/MOD_Stub.cs new file mode 100644 index 0000000..6525c76 --- /dev/null +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/MOD_Stub.cs | |||
@@ -0,0 +1,66 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Runtime.Remoting.Lifetime; | ||
30 | using System.Threading; | ||
31 | using System.Reflection; | ||
32 | using System.Collections; | ||
33 | using System.Collections.Generic; | ||
34 | using OpenSim.Framework; | ||
35 | using OpenSim.Region.Framework.Interfaces; | ||
36 | using OpenSim.Region.ScriptEngine.Interfaces; | ||
37 | using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces; | ||
38 | using integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; | ||
39 | using vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3; | ||
40 | using rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion; | ||
41 | using key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; | ||
42 | using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list; | ||
43 | using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; | ||
44 | using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat; | ||
45 | using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; | ||
46 | |||
47 | namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | ||
48 | { | ||
49 | public partial class ScriptBaseClass : MarshalByRefObject | ||
50 | { | ||
51 | public IMOD_Api m_MOD_Functions; | ||
52 | |||
53 | public void ApiTypeMOD(IScriptApi api) | ||
54 | { | ||
55 | if (!(api is IMOD_Api)) | ||
56 | return; | ||
57 | |||
58 | m_MOD_Functions = (IMOD_Api)api; | ||
59 | } | ||
60 | |||
61 | public string modSendCommand(string module, string command, string k) | ||
62 | { | ||
63 | return m_MOD_Functions.modSendCommand(module, command, k); | ||
64 | } | ||
65 | } | ||
66 | } | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs index 8dcb1f5..4928e90 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | |||
@@ -94,7 +94,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
94 | { | 94 | { |
95 | return m_OSSL_Functions.osWindActiveModelPluginName(); | 95 | return m_OSSL_Functions.osWindActiveModelPluginName(); |
96 | } | 96 | } |
97 | 97 | ||
98 | // Not yet plugged in as available OSSL functions, so commented out | 98 | // Not yet plugged in as available OSSL functions, so commented out |
99 | // void osWindParamSet(string plugin, string param, float value) | 99 | // void osWindParamSet(string plugin, string param, float value) |
100 | // { | 100 | // { |
@@ -138,14 +138,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
138 | public string osSetDynamicTextureURLBlendFace(string dynamicID, string contentType, string url, string extraParams, | 138 | public string osSetDynamicTextureURLBlendFace(string dynamicID, string contentType, string url, string extraParams, |
139 | bool blend, int disp, int timer, int alpha, int face) | 139 | bool blend, int disp, int timer, int alpha, int face) |
140 | { | 140 | { |
141 | return m_OSSL_Functions.osSetDynamicTextureURLBlendFace(dynamicID, contentType, url, extraParams, | 141 | return m_OSSL_Functions.osSetDynamicTextureURLBlendFace(dynamicID, contentType, url, extraParams, |
142 | blend, disp, timer, alpha, face); | 142 | blend, disp, timer, alpha, face); |
143 | } | 143 | } |
144 | 144 | ||
145 | public string osSetDynamicTextureDataBlendFace(string dynamicID, string contentType, string data, string extraParams, | 145 | public string osSetDynamicTextureDataBlendFace(string dynamicID, string contentType, string data, string extraParams, |
146 | bool blend, int disp, int timer, int alpha, int face) | 146 | bool blend, int disp, int timer, int alpha, int face) |
147 | { | 147 | { |
148 | return m_OSSL_Functions.osSetDynamicTextureDataBlendFace(dynamicID, contentType, data, extraParams, | 148 | return m_OSSL_Functions.osSetDynamicTextureDataBlendFace(dynamicID, contentType, data, extraParams, |
149 | blend, disp, timer, alpha, face); | 149 | blend, disp, timer, alpha, face); |
150 | } | 150 | } |
151 | 151 | ||
@@ -183,7 +183,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
183 | { | 183 | { |
184 | m_OSSL_Functions.osSetParcelMediaURL(url); | 184 | m_OSSL_Functions.osSetParcelMediaURL(url); |
185 | } | 185 | } |
186 | 186 | ||
187 | public void osSetParcelSIPAddress(string SIPAddress) | 187 | public void osSetParcelSIPAddress(string SIPAddress) |
188 | { | 188 | { |
189 | m_OSSL_Functions.osSetParcelSIPAddress(SIPAddress); | 189 | m_OSSL_Functions.osSetParcelSIPAddress(SIPAddress); |
@@ -211,7 +211,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
211 | m_OSSL_Functions.osTeleportAgent(agent, position, lookat); | 211 | m_OSSL_Functions.osTeleportAgent(agent, position, lookat); |
212 | } | 212 | } |
213 | 213 | ||
214 | // Avatar info functions | 214 | // Avatar info functions |
215 | public string osGetAgentIP(string agent) | 215 | public string osGetAgentIP(string agent) |
216 | { | 216 | { |
217 | return m_OSSL_Functions.osGetAgentIP(agent); | 217 | return m_OSSL_Functions.osGetAgentIP(agent); |
@@ -326,17 +326,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
326 | { | 326 | { |
327 | return m_OSSL_Functions.osGetScriptEngineName(); | 327 | return m_OSSL_Functions.osGetScriptEngineName(); |
328 | } | 328 | } |
329 | 329 | ||
330 | public string osGetSimulatorVersion() | 330 | public string osGetSimulatorVersion() |
331 | { | 331 | { |
332 | return m_OSSL_Functions.osGetSimulatorVersion(); | 332 | return m_OSSL_Functions.osGetSimulatorVersion(); |
333 | } | 333 | } |
334 | 334 | ||
335 | public Hashtable osParseJSON(string JSON) | 335 | public Hashtable osParseJSON(string JSON) |
336 | { | 336 | { |
337 | return m_OSSL_Functions.osParseJSON(JSON); | 337 | return m_OSSL_Functions.osParseJSON(JSON); |
338 | } | 338 | } |
339 | 339 | ||
340 | public void osMessageObject(key objectUUID,string message) | 340 | public void osMessageObject(key objectUUID,string message) |
341 | { | 341 | { |
342 | m_OSSL_Functions.osMessageObject(objectUUID,message); | 342 | m_OSSL_Functions.osMessageObject(objectUUID,message); |
@@ -412,7 +412,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
412 | { | 412 | { |
413 | return m_OSSL_Functions.osLoadedCreationID(); | 413 | return m_OSSL_Functions.osLoadedCreationID(); |
414 | } | 414 | } |
415 | 415 | ||
416 | public LSL_List osGetLinkPrimitiveParams(int linknumber, LSL_List rules) | 416 | public LSL_List osGetLinkPrimitiveParams(int linknumber, LSL_List rules) |
417 | { | 417 | { |
418 | return m_OSSL_Functions.osGetLinkPrimitiveParams(linknumber, rules); | 418 | return m_OSSL_Functions.osGetLinkPrimitiveParams(linknumber, rules); |
@@ -622,5 +622,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
622 | } | 622 | } |
623 | } | 623 | } |
624 | } | 624 | } |
625 | |||
626 | public key osGetMapTexture() | ||
627 | { | ||
628 | return m_OSSL_Functions.osGetMapTexture(); | ||
629 | } | ||
630 | |||
631 | public key osGetRegionMapTexture(string regionName) | ||
632 | { | ||
633 | return m_OSSL_Functions.osGetRegionMapTexture(regionName); | ||
634 | } | ||
625 | } | 635 | } |
626 | } | 636 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OpenSim.Region.ScriptEngine.Shared.Api.Runtime.mdp b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OpenSim.Region.ScriptEngine.Shared.Api.Runtime.mdp index feff86a..98bbc68 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OpenSim.Region.ScriptEngine.Shared.Api.Runtime.mdp +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OpenSim.Region.ScriptEngine.Shared.Api.Runtime.mdp | |||
@@ -20,6 +20,7 @@ | |||
20 | <File name="./Executor.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> | 20 | <File name="./Executor.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> |
21 | <File name="./LSL_Constants.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> | 21 | <File name="./LSL_Constants.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> |
22 | <File name="./LSL_Stub.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> | 22 | <File name="./LSL_Stub.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> |
23 | <File name="./MOD_Stub.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> | ||
23 | <File name="./OSSL_Stub.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> | 24 | <File name="./OSSL_Stub.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> |
24 | <File name="./ScriptBase.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> | 25 | <File name="./ScriptBase.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> |
25 | <File name="./ScriptSponsor.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> | 26 | <File name="./ScriptSponsor.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs index 917ca44..121159c 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs | |||
@@ -113,7 +113,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
113 | return; | 113 | return; |
114 | 114 | ||
115 | //ILease lease = (ILease)RemotingServices.GetLifetimeService(data as MarshalByRefObject); | 115 | //ILease lease = (ILease)RemotingServices.GetLifetimeService(data as MarshalByRefObject); |
116 | RemotingServices.GetLifetimeService(data as MarshalByRefObject); | 116 | //RemotingServices.GetLifetimeService(data as MarshalByRefObject); |
117 | // lease.Register(m_sponser); | 117 | // lease.Register(m_sponser); |
118 | 118 | ||
119 | MethodInfo mi = inits[api]; | 119 | MethodInfo mi = inits[api]; |
diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs index fe26429..3080c71 100644 --- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs +++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs | |||
@@ -74,7 +74,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
74 | private string FilePrefix; | 74 | private string FilePrefix; |
75 | private string ScriptEnginesPath = "ScriptEngines"; | 75 | private string ScriptEnginesPath = "ScriptEngines"; |
76 | // mapping between LSL and C# line/column numbers | 76 | // mapping between LSL and C# line/column numbers |
77 | private Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> m_positionMap; | ||
78 | private ICodeConverter LSL_Converter; | 77 | private ICodeConverter LSL_Converter; |
79 | 78 | ||
80 | private List<string> m_warnings = new List<string>(); | 79 | private List<string> m_warnings = new List<string>(); |
@@ -91,6 +90,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
91 | private static UInt64 scriptCompileCounter = 0; // And a counter | 90 | private static UInt64 scriptCompileCounter = 0; // And a counter |
92 | 91 | ||
93 | public IScriptEngine m_scriptEngine; | 92 | public IScriptEngine m_scriptEngine; |
93 | private Dictionary<string, Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>>> m_lineMaps = | ||
94 | new Dictionary<string, Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>>>(); | ||
95 | |||
94 | public Compiler(IScriptEngine scriptEngine) | 96 | public Compiler(IScriptEngine scriptEngine) |
95 | { | 97 | { |
96 | m_scriptEngine = scriptEngine; | 98 | m_scriptEngine = scriptEngine; |
@@ -172,8 +174,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
172 | else | 174 | else |
173 | { | 175 | { |
174 | #if DEBUG | 176 | #if DEBUG |
175 | // m_log.Debug("[Compiler]: " + | 177 | // m_log.Debug("[Compiler]: " + |
176 | // "Config OK. Default language \"" + defaultCompileLanguage + "\" specified in \"DefaultCompileLanguage\" is recognized as a valid language."); | 178 | // "Config OK. Default language \"" + defaultCompileLanguage + "\" specified in \"DefaultCompileLanguage\" is recognized as a valid language."); |
177 | #endif | 179 | #endif |
178 | // LANGUAGE IS IN ALLOW-LIST | 180 | // LANGUAGE IS IN ALLOW-LIST |
179 | DefaultCompileLanguage = LanguageMapping[defaultCompileLanguage]; | 181 | DefaultCompileLanguage = LanguageMapping[defaultCompileLanguage]; |
@@ -212,12 +214,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
212 | catch (Exception ex) | 214 | catch (Exception ex) |
213 | { | 215 | { |
214 | m_log.Error("[Compiler]: Exception trying to create ScriptEngine directory \"" + Path.Combine(ScriptEnginesPath, | 216 | m_log.Error("[Compiler]: Exception trying to create ScriptEngine directory \"" + Path.Combine(ScriptEnginesPath, |
215 | m_scriptEngine.World.RegionInfo.RegionID.ToString())+ "\": " + ex.ToString()); | 217 | m_scriptEngine.World.RegionInfo.RegionID.ToString()) + "\": " + ex.ToString()); |
216 | } | 218 | } |
217 | } | 219 | } |
218 | 220 | ||
219 | foreach (string file in Directory.GetFiles(Path.Combine(ScriptEnginesPath, | 221 | foreach (string file in Directory.GetFiles(Path.Combine(ScriptEnginesPath, |
220 | m_scriptEngine.World.RegionInfo.RegionID.ToString()),FilePrefix + "_compiled*")) | 222 | m_scriptEngine.World.RegionInfo.RegionID.ToString()), FilePrefix + "_compiled*")) |
221 | { | 223 | { |
222 | try | 224 | try |
223 | { | 225 | { |
@@ -271,16 +273,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
271 | /// </summary> | 273 | /// </summary> |
272 | /// <param name="Script">LSL script</param> | 274 | /// <param name="Script">LSL script</param> |
273 | /// <returns>Filename to .dll assembly</returns> | 275 | /// <returns>Filename to .dll assembly</returns> |
274 | public object PerformScriptCompile(string Script, string asset, UUID ownerUUID) | 276 | public void PerformScriptCompile(string Script, string asset, UUID ownerUUID, |
277 | out string assembly, out Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> linemap) | ||
275 | { | 278 | { |
276 | m_positionMap = null; | 279 | linemap = null; |
277 | m_warnings.Clear(); | 280 | m_warnings.Clear(); |
278 | 281 | ||
279 | string OutFile = Path.Combine(ScriptEnginesPath, Path.Combine( | 282 | assembly = Path.Combine(ScriptEnginesPath, Path.Combine( |
280 | m_scriptEngine.World.RegionInfo.RegionID.ToString(), | 283 | m_scriptEngine.World.RegionInfo.RegionID.ToString(), |
281 | FilePrefix + "_compiled_" + asset + ".dll")); | 284 | FilePrefix + "_compiled_" + asset + ".dll")); |
282 | // string OutFile = Path.Combine(ScriptEnginesPath, | ||
283 | // FilePrefix + "_compiled_" + asset + ".dll"); | ||
284 | 285 | ||
285 | if (!Directory.Exists(ScriptEnginesPath)) | 286 | if (!Directory.Exists(ScriptEnginesPath)) |
286 | { | 287 | { |
@@ -305,60 +306,63 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
305 | } | 306 | } |
306 | } | 307 | } |
307 | 308 | ||
308 | if (Script == String.Empty) | 309 | // Don't recompile if we already have it |
310 | // Performing 3 file exists tests for every script can still be slow | ||
311 | if (File.Exists(assembly) && File.Exists(assembly + ".text") && File.Exists(assembly + ".map")) | ||
309 | { | 312 | { |
310 | if (File.Exists(OutFile)) | 313 | // If we have already read this linemap file, then it will be in our dictionary. |
311 | return OutFile; | 314 | // Don't build another copy of the dictionary (saves memory) and certainly |
312 | 315 | // don't keep reading the same file from disk multiple times. | |
313 | throw new Exception("Cannot find script assembly and no script text present"); | 316 | if (!m_lineMaps.ContainsKey(assembly)) |
317 | m_lineMaps[assembly] = ReadMapFile(assembly + ".map"); | ||
318 | linemap = m_lineMaps[assembly]; | ||
319 | return; | ||
314 | } | 320 | } |
315 | 321 | ||
316 | // Don't recompile if we already have it | 322 | if (Script == String.Empty) |
317 | // | ||
318 | if (File.Exists(OutFile) && File.Exists(OutFile+".text") && File.Exists(OutFile+".map")) | ||
319 | { | 323 | { |
320 | ReadMapFile(OutFile+".map"); | 324 | throw new Exception("Cannot find script assembly and no script text present"); |
321 | return OutFile; | ||
322 | } | 325 | } |
323 | 326 | ||
324 | enumCompileType l = DefaultCompileLanguage; | 327 | enumCompileType language = DefaultCompileLanguage; |
325 | 328 | ||
326 | if (Script.StartsWith("//c#", true, CultureInfo.InvariantCulture)) | 329 | if (Script.StartsWith("//c#", true, CultureInfo.InvariantCulture)) |
327 | l = enumCompileType.cs; | 330 | language = enumCompileType.cs; |
328 | if (Script.StartsWith("//vb", true, CultureInfo.InvariantCulture)) | 331 | if (Script.StartsWith("//vb", true, CultureInfo.InvariantCulture)) |
329 | { | 332 | { |
330 | l = enumCompileType.vb; | 333 | language = enumCompileType.vb; |
331 | // We need to remove //vb, it won't compile with that | 334 | // We need to remove //vb, it won't compile with that |
332 | 335 | ||
333 | Script = Script.Substring(4, Script.Length - 4); | 336 | Script = Script.Substring(4, Script.Length - 4); |
334 | } | 337 | } |
335 | if (Script.StartsWith("//lsl", true, CultureInfo.InvariantCulture)) | 338 | if (Script.StartsWith("//lsl", true, CultureInfo.InvariantCulture)) |
336 | l = enumCompileType.lsl; | 339 | language = enumCompileType.lsl; |
337 | 340 | ||
338 | if (Script.StartsWith("//js", true, CultureInfo.InvariantCulture)) | 341 | if (Script.StartsWith("//js", true, CultureInfo.InvariantCulture)) |
339 | l = enumCompileType.js; | 342 | language = enumCompileType.js; |
340 | 343 | ||
341 | if (Script.StartsWith("//yp", true, CultureInfo.InvariantCulture)) | 344 | if (Script.StartsWith("//yp", true, CultureInfo.InvariantCulture)) |
342 | l = enumCompileType.yp; | 345 | language = enumCompileType.yp; |
343 | 346 | ||
344 | if (!AllowedCompilers.ContainsKey(l.ToString())) | 347 | if (!AllowedCompilers.ContainsKey(language.ToString())) |
345 | { | 348 | { |
346 | // Not allowed to compile to this language! | 349 | // Not allowed to compile to this language! |
347 | string errtext = String.Empty; | 350 | string errtext = String.Empty; |
348 | errtext += "The compiler for language \"" + l.ToString() + "\" is not in list of allowed compilers. Script will not be executed!"; | 351 | errtext += "The compiler for language \"" + language.ToString() + "\" is not in list of allowed compilers. Script will not be executed!"; |
349 | throw new Exception(errtext); | 352 | throw new Exception(errtext); |
350 | } | 353 | } |
351 | 354 | ||
352 | if (m_scriptEngine.World.Permissions.CanCompileScript(ownerUUID, (int)l) == false) { | 355 | if (m_scriptEngine.World.Permissions.CanCompileScript(ownerUUID, (int)language) == false) |
356 | { | ||
353 | // Not allowed to compile to this language! | 357 | // Not allowed to compile to this language! |
354 | string errtext = String.Empty; | 358 | string errtext = String.Empty; |
355 | errtext += ownerUUID + " is not in list of allowed users for this scripting language. Script will not be executed!"; | 359 | errtext += ownerUUID + " is not in list of allowed users for this scripting language. Script will not be executed!"; |
356 | throw new Exception(errtext); | 360 | throw new Exception(errtext); |
357 | } | 361 | } |
358 | 362 | ||
359 | string compileScript = Script; | 363 | string compileScript = Script; |
360 | 364 | ||
361 | if (l == enumCompileType.lsl) | 365 | if (language == enumCompileType.lsl) |
362 | { | 366 | { |
363 | // Its LSL, convert it to C# | 367 | // Its LSL, convert it to C# |
364 | LSL_Converter = (ICodeConverter)new CSCodeGenerator(); | 368 | LSL_Converter = (ICodeConverter)new CSCodeGenerator(); |
@@ -370,16 +374,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
370 | AddWarning(warning); | 374 | AddWarning(warning); |
371 | } | 375 | } |
372 | 376 | ||
373 | m_positionMap = ((CSCodeGenerator) LSL_Converter).PositionMap; | 377 | linemap = ((CSCodeGenerator)LSL_Converter).PositionMap; |
378 | // Write the linemap to a file and save it in our dictionary for next time. | ||
379 | m_lineMaps[assembly] = linemap; | ||
380 | WriteMapFile(assembly + ".map", linemap); | ||
374 | } | 381 | } |
375 | 382 | ||
376 | if (l == enumCompileType.yp) | 383 | if (language == enumCompileType.yp) |
377 | { | 384 | { |
378 | // Its YP, convert it to C# | 385 | // Its YP, convert it to C# |
379 | compileScript = YP_Converter.Convert(Script); | 386 | compileScript = YP_Converter.Convert(Script); |
380 | } | 387 | } |
381 | 388 | ||
382 | switch (l) | 389 | switch (language) |
383 | { | 390 | { |
384 | case enumCompileType.cs: | 391 | case enumCompileType.cs: |
385 | case enumCompileType.lsl: | 392 | case enumCompileType.lsl: |
@@ -396,7 +403,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
396 | break; | 403 | break; |
397 | } | 404 | } |
398 | 405 | ||
399 | return CompileFromDotNetText(compileScript, l, asset); | 406 | assembly = CompileFromDotNetText(compileScript, language, asset, assembly); |
407 | return; | ||
400 | } | 408 | } |
401 | 409 | ||
402 | public string[] GetWarnings() | 410 | public string[] GetWarnings() |
@@ -468,22 +476,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
468 | /// </summary> | 476 | /// </summary> |
469 | /// <param name="Script">CS script</param> | 477 | /// <param name="Script">CS script</param> |
470 | /// <returns>Filename to .dll assembly</returns> | 478 | /// <returns>Filename to .dll assembly</returns> |
471 | internal string CompileFromDotNetText(string Script, enumCompileType lang, string asset) | 479 | internal string CompileFromDotNetText(string Script, enumCompileType lang, string asset, string assembly) |
472 | { | 480 | { |
473 | string ext = "." + lang.ToString(); | 481 | string ext = "." + lang.ToString(); |
474 | 482 | ||
475 | // Output assembly name | 483 | // Output assembly name |
476 | scriptCompileCounter++; | 484 | scriptCompileCounter++; |
477 | string OutFile = Path.Combine(ScriptEnginesPath, Path.Combine( | ||
478 | m_scriptEngine.World.RegionInfo.RegionID.ToString(), | ||
479 | FilePrefix + "_compiled_" + asset + ".dll")); | ||
480 | try | 485 | try |
481 | { | 486 | { |
482 | File.Delete(OutFile); | 487 | File.Delete(assembly); |
483 | } | 488 | } |
484 | catch (Exception e) // NOTLEGIT - Should be just FileIOException | 489 | catch (Exception e) // NOTLEGIT - Should be just FileIOException |
485 | { | 490 | { |
486 | throw new Exception("Unable to delete old existing "+ | 491 | throw new Exception("Unable to delete old existing " + |
487 | "script-file before writing new. Compile aborted: " + | 492 | "script-file before writing new. Compile aborted: " + |
488 | e.ToString()); | 493 | e.ToString()); |
489 | } | 494 | } |
@@ -492,7 +497,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
492 | if (WriteScriptSourceToDebugFile) | 497 | if (WriteScriptSourceToDebugFile) |
493 | { | 498 | { |
494 | string srcFileName = FilePrefix + "_source_" + | 499 | string srcFileName = FilePrefix + "_source_" + |
495 | Path.GetFileNameWithoutExtension(OutFile) + ext; | 500 | Path.GetFileNameWithoutExtension(assembly) + ext; |
496 | try | 501 | try |
497 | { | 502 | { |
498 | File.WriteAllText(Path.Combine(Path.Combine( | 503 | File.WriteAllText(Path.Combine(Path.Combine( |
@@ -502,7 +507,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
502 | } | 507 | } |
503 | catch (Exception ex) //NOTLEGIT - Should be just FileIOException | 508 | catch (Exception ex) //NOTLEGIT - Should be just FileIOException |
504 | { | 509 | { |
505 | m_log.Error("[Compiler]: Exception while "+ | 510 | m_log.Error("[Compiler]: Exception while " + |
506 | "trying to write script source to file \"" + | 511 | "trying to write script source to file \"" + |
507 | srcFileName + "\": " + ex.ToString()); | 512 | srcFileName + "\": " + ex.ToString()); |
508 | } | 513 | } |
@@ -528,7 +533,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
528 | } | 533 | } |
529 | 534 | ||
530 | parameters.GenerateExecutable = false; | 535 | parameters.GenerateExecutable = false; |
531 | parameters.OutputAssembly = OutFile; | 536 | parameters.OutputAssembly = assembly; |
532 | parameters.IncludeDebugInformation = CompileWithDebugInformation; | 537 | parameters.IncludeDebugInformation = CompileWithDebugInformation; |
533 | //parameters.WarningLevel = 1; // Should be 4? | 538 | //parameters.WarningLevel = 1; // Should be 4? |
534 | parameters.TreatWarningsAsErrors = false; | 539 | parameters.TreatWarningsAsErrors = false; |
@@ -543,7 +548,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
543 | case enumCompileType.cs: | 548 | case enumCompileType.cs: |
544 | case enumCompileType.lsl: | 549 | case enumCompileType.lsl: |
545 | bool complete = false; | 550 | bool complete = false; |
546 | bool retried = false; | 551 | bool retried = false; |
547 | do | 552 | do |
548 | { | 553 | { |
549 | lock (CScodeProvider) | 554 | lock (CScodeProvider) |
@@ -584,7 +589,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
584 | parameters, Script); | 589 | parameters, Script); |
585 | break; | 590 | break; |
586 | default: | 591 | default: |
587 | throw new Exception("Compiler is not able to recongnize "+ | 592 | throw new Exception("Compiler is not able to recongnize " + |
588 | "language type \"" + lang.ToString() + "\""); | 593 | "language type \"" + lang.ToString() + "\""); |
589 | } | 594 | } |
590 | 595 | ||
@@ -609,7 +614,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
609 | 614 | ||
610 | if (severity == "Error") | 615 | if (severity == "Error") |
611 | { | 616 | { |
612 | lslPos = FindErrorPosition(CompErr.Line, CompErr.Column); | 617 | lslPos = FindErrorPosition(CompErr.Line, CompErr.Column, m_lineMaps[assembly]); |
613 | string text = CompErr.ErrorText; | 618 | string text = CompErr.ErrorText; |
614 | 619 | ||
615 | // Use LSL type names | 620 | // Use LSL type names |
@@ -635,14 +640,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
635 | // the compile may not be immediately apparent. Wait a | 640 | // the compile may not be immediately apparent. Wait a |
636 | // reasonable amount of time before giving up on it. | 641 | // reasonable amount of time before giving up on it. |
637 | 642 | ||
638 | if (!File.Exists(OutFile)) | 643 | if (!File.Exists(assembly)) |
639 | { | 644 | { |
640 | for (int i=0; i<20 && !File.Exists(OutFile); i++) | 645 | for (int i = 0; i < 20 && !File.Exists(assembly); i++) |
641 | { | 646 | { |
642 | System.Threading.Thread.Sleep(250); | 647 | System.Threading.Thread.Sleep(250); |
643 | } | 648 | } |
644 | // One final chance... | 649 | // One final chance... |
645 | if (!File.Exists(OutFile)) | 650 | if (!File.Exists(assembly)) |
646 | { | 651 | { |
647 | errtext = String.Empty; | 652 | errtext = String.Empty; |
648 | errtext += "No compile error. But not able to locate compiled file."; | 653 | errtext += "No compile error. But not able to locate compiled file."; |
@@ -650,15 +655,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
650 | } | 655 | } |
651 | } | 656 | } |
652 | 657 | ||
653 | // m_log.DebugFormat("[Compiler] Compiled new assembly "+ | 658 | // m_log.DebugFormat("[Compiler] Compiled new assembly "+ |
654 | // "for {0}", asset); | 659 | // "for {0}", asset); |
655 | 660 | ||
656 | // Because windows likes to perform exclusive locks, we simply | 661 | // Because windows likes to perform exclusive locks, we simply |
657 | // write out a textual representation of the file here | 662 | // write out a textual representation of the file here |
658 | // | 663 | // |
659 | // Read the binary file into a buffer | 664 | // Read the binary file into a buffer |
660 | // | 665 | // |
661 | FileInfo fi = new FileInfo(OutFile); | 666 | FileInfo fi = new FileInfo(assembly); |
662 | 667 | ||
663 | if (fi == null) | 668 | if (fi == null) |
664 | { | 669 | { |
@@ -671,7 +676,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
671 | 676 | ||
672 | try | 677 | try |
673 | { | 678 | { |
674 | FileStream fs = File.Open(OutFile, FileMode.Open, FileAccess.Read); | 679 | FileStream fs = File.Open(assembly, FileMode.Open, FileAccess.Read); |
675 | fs.Read(data, 0, data.Length); | 680 | fs.Read(data, 0, data.Length); |
676 | fs.Close(); | 681 | fs.Close(); |
677 | } | 682 | } |
@@ -690,40 +695,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
690 | 695 | ||
691 | Byte[] buf = enc.GetBytes(filetext); | 696 | Byte[] buf = enc.GetBytes(filetext); |
692 | 697 | ||
693 | FileStream sfs = File.Create(OutFile+".text"); | 698 | FileStream sfs = File.Create(assembly + ".text"); |
694 | sfs.Write(buf, 0, buf.Length); | 699 | sfs.Write(buf, 0, buf.Length); |
695 | sfs.Close(); | 700 | sfs.Close(); |
696 | 701 | ||
697 | string posmap = String.Empty; | 702 | return assembly; |
698 | if (m_positionMap != null) | ||
699 | { | ||
700 | foreach (KeyValuePair<KeyValuePair<int, int>, KeyValuePair<int, int>> kvp in m_positionMap) | ||
701 | { | ||
702 | KeyValuePair<int, int> k = kvp.Key; | ||
703 | KeyValuePair<int, int> v = kvp.Value; | ||
704 | posmap += String.Format("{0},{1},{2},{3}\n", | ||
705 | k.Key, k.Value, v.Key, v.Value); | ||
706 | } | ||
707 | } | ||
708 | |||
709 | buf = enc.GetBytes(posmap); | ||
710 | |||
711 | FileStream mfs = File.Create(OutFile+".map"); | ||
712 | mfs.Write(buf, 0, buf.Length); | ||
713 | mfs.Close(); | ||
714 | |||
715 | return OutFile; | ||
716 | } | ||
717 | |||
718 | public KeyValuePair<int, int> FindErrorPosition(int line, int col) | ||
719 | { | ||
720 | return FindErrorPosition(line, col, m_positionMap); | ||
721 | } | 703 | } |
722 | 704 | ||
723 | private class kvpSorter : IComparer<KeyValuePair<int,int>> | 705 | private class kvpSorter : IComparer<KeyValuePair<int, int>> |
724 | { | 706 | { |
725 | public int Compare(KeyValuePair<int,int> a, | 707 | public int Compare(KeyValuePair<int, int> a, |
726 | KeyValuePair<int,int> b) | 708 | KeyValuePair<int, int> b) |
727 | { | 709 | { |
728 | return a.Key.CompareTo(b.Key); | 710 | return a.Key.CompareTo(b.Key); |
729 | } | 711 | } |
@@ -742,8 +724,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
742 | out ret)) | 724 | out ret)) |
743 | return ret; | 725 | return ret; |
744 | 726 | ||
745 | List<KeyValuePair<int,int>> sorted = | 727 | List<KeyValuePair<int, int>> sorted = |
746 | new List<KeyValuePair<int,int>>(positionMap.Keys); | 728 | new List<KeyValuePair<int, int>>(positionMap.Keys); |
747 | 729 | ||
748 | sorted.Sort(new kvpSorter()); | 730 | sorted.Sort(new kvpSorter()); |
749 | 731 | ||
@@ -791,32 +773,37 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
791 | return message; | 773 | return message; |
792 | } | 774 | } |
793 | 775 | ||
794 | public Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> LineMap() | 776 | |
777 | private static void WriteMapFile(string filename, Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> linemap) | ||
795 | { | 778 | { |
796 | if (m_positionMap == null) | 779 | string mapstring = String.Empty; |
797 | return null; | 780 | foreach (KeyValuePair<KeyValuePair<int, int>, KeyValuePair<int, int>> kvp in linemap) |
798 | 781 | { | |
799 | Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> ret = | 782 | KeyValuePair<int, int> k = kvp.Key; |
800 | new Dictionary<KeyValuePair<int,int>, KeyValuePair<int, int>>(); | 783 | KeyValuePair<int, int> v = kvp.Value; |
801 | 784 | mapstring += String.Format("{0},{1},{2},{3}\n", k.Key, k.Value, v.Key, v.Value); | |
802 | foreach (KeyValuePair<int, int> kvp in m_positionMap.Keys) | 785 | } |
803 | ret.Add(kvp, m_positionMap[kvp]); | 786 | |
804 | 787 | System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding(); | |
805 | return ret; | 788 | Byte[] mapbytes = enc.GetBytes(mapstring); |
789 | FileStream mfs = File.Create(filename); | ||
790 | mfs.Write(mapbytes, 0, mapbytes.Length); | ||
791 | mfs.Close(); | ||
806 | } | 792 | } |
807 | 793 | ||
808 | private void ReadMapFile(string filename) | 794 | |
795 | private static Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> ReadMapFile(string filename) | ||
809 | { | 796 | { |
797 | Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> linemap; | ||
810 | try | 798 | try |
811 | { | 799 | { |
812 | StreamReader r = File.OpenText(filename); | 800 | StreamReader r = File.OpenText(filename); |
801 | linemap = new Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>>(); | ||
813 | 802 | ||
814 | m_positionMap = new Dictionary<KeyValuePair<int,int>, KeyValuePair<int, int>>(); | ||
815 | |||
816 | string line; | 803 | string line; |
817 | while ((line = r.ReadLine()) != null) | 804 | while ((line = r.ReadLine()) != null) |
818 | { | 805 | { |
819 | String[] parts = line.Split(new Char[] {','}); | 806 | String[] parts = line.Split(new Char[] { ',' }); |
820 | int kk = System.Convert.ToInt32(parts[0]); | 807 | int kk = System.Convert.ToInt32(parts[0]); |
821 | int kv = System.Convert.ToInt32(parts[1]); | 808 | int kv = System.Convert.ToInt32(parts[1]); |
822 | int vk = System.Convert.ToInt32(parts[2]); | 809 | int vk = System.Convert.ToInt32(parts[2]); |
@@ -825,12 +812,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
825 | KeyValuePair<int, int> k = new KeyValuePair<int, int>(kk, kv); | 812 | KeyValuePair<int, int> k = new KeyValuePair<int, int>(kk, kv); |
826 | KeyValuePair<int, int> v = new KeyValuePair<int, int>(vk, vv); | 813 | KeyValuePair<int, int> v = new KeyValuePair<int, int>(vk, vv); |
827 | 814 | ||
828 | m_positionMap[k] = v; | 815 | linemap[k] = v; |
829 | } | 816 | } |
830 | } | 817 | } |
831 | catch | 818 | catch |
832 | { | 819 | { |
820 | linemap = new Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>>(); | ||
833 | } | 821 | } |
822 | return linemap; | ||
834 | } | 823 | } |
835 | } | 824 | } |
836 | } | 825 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs index 2b858ec..549c038 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs | |||
@@ -74,27 +74,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
74 | private string m_PrimName; | 74 | private string m_PrimName; |
75 | private string m_ScriptName; | 75 | private string m_ScriptName; |
76 | private string m_Assembly; | 76 | private string m_Assembly; |
77 | private int m_StartParam = 0; | 77 | private int m_StartParam; |
78 | private string m_CurrentEvent = String.Empty; | 78 | private string m_CurrentEvent = String.Empty; |
79 | private bool m_InSelfDelete = false; | 79 | private bool m_InSelfDelete; |
80 | private int m_MaxScriptQueue; | 80 | private int m_MaxScriptQueue; |
81 | private bool m_SaveState = true; | 81 | private bool m_SaveState = true; |
82 | private bool m_ShuttingDown = false; | 82 | private bool m_ShuttingDown; |
83 | private int m_ControlEventsInQueue = 0; | 83 | private int m_ControlEventsInQueue; |
84 | private int m_LastControlLevel = 0; | 84 | private int m_LastControlLevel; |
85 | private bool m_CollisionInQueue = false; | 85 | private bool m_CollisionInQueue; |
86 | private TaskInventoryItem m_thisScriptTask; | 86 | private TaskInventoryItem m_thisScriptTask; |
87 | // The following is for setting a minimum delay between events | 87 | // The following is for setting a minimum delay between events |
88 | private double m_minEventDelay = 0; | 88 | private double m_minEventDelay; |
89 | private long m_eventDelayTicks = 0; | 89 | private long m_eventDelayTicks; |
90 | private long m_nextEventTimeTicks = 0; | 90 | private long m_nextEventTimeTicks; |
91 | private bool m_startOnInit = true; | 91 | private bool m_startOnInit = true; |
92 | private UUID m_AttachedAvatar = UUID.Zero; | 92 | private UUID m_AttachedAvatar; |
93 | private StateSource m_stateSource; | 93 | private StateSource m_stateSource; |
94 | private bool m_postOnRez; | 94 | private bool m_postOnRez; |
95 | private bool m_startedFromSavedState = false; | 95 | private bool m_startedFromSavedState; |
96 | private string m_CurrentState = String.Empty; | 96 | private UUID m_CurrentStateHash; |
97 | private UUID m_RegionID = UUID.Zero; | 97 | private UUID m_RegionID; |
98 | 98 | ||
99 | private Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> | 99 | private Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> |
100 | m_LineMap; | 100 | m_LineMap; |
@@ -252,16 +252,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
252 | { | 252 | { |
253 | m_Apis[api] = am.CreateApi(api); | 253 | m_Apis[api] = am.CreateApi(api); |
254 | m_Apis[api].Initialize(engine, part, m_LocalID, itemID); | 254 | m_Apis[api].Initialize(engine, part, m_LocalID, itemID); |
255 | } | 255 | } |
256 | |||
257 | try | ||
258 | { | ||
259 | if (dom != System.AppDomain.CurrentDomain) | ||
260 | m_Script = (IScript)dom.CreateInstanceAndUnwrap( | ||
261 | Path.GetFileNameWithoutExtension(assembly), | ||
262 | "SecondLife.Script"); | ||
263 | else | ||
264 | m_Script = (IScript)Assembly.Load( | ||
265 | Path.GetFileNameWithoutExtension(assembly)).CreateInstance( | ||
266 | "SecondLife.Script"); | ||
256 | 267 | ||
257 | try | ||
258 | { | ||
259 | m_Script = (IScript)dom.CreateInstanceAndUnwrap( | ||
260 | Path.GetFileNameWithoutExtension(assembly), | ||
261 | "SecondLife.Script"); | ||
262 | 268 | ||
263 | //ILease lease = (ILease)RemotingServices.GetLifetimeService(m_Script as ScriptBaseClass); | 269 | //ILease lease = (ILease)RemotingServices.GetLifetimeService(m_Script as ScriptBaseClass); |
264 | RemotingServices.GetLifetimeService(m_Script as ScriptBaseClass); | 270 | //RemotingServices.GetLifetimeService(m_Script as ScriptBaseClass); |
265 | // lease.Register(this); | 271 | // lease.Register(this); |
266 | } | 272 | } |
267 | catch (Exception) | 273 | catch (Exception) |
@@ -893,7 +899,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
893 | 899 | ||
894 | string xml = ScriptSerializer.Serialize(this); | 900 | string xml = ScriptSerializer.Serialize(this); |
895 | 901 | ||
896 | if (m_CurrentState != xml) | 902 | // Compare hash of the state we just just created with the state last written to disk |
903 | // If the state is different, update the disk file. | ||
904 | UUID hash = UUID.Parse(Utils.MD5String(xml)); | ||
905 | |||
906 | if(hash != m_CurrentStateHash) | ||
897 | { | 907 | { |
898 | try | 908 | try |
899 | { | 909 | { |
@@ -911,7 +921,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
911 | //{ | 921 | //{ |
912 | // throw new Exception("Completed persistence save, but no file was created"); | 922 | // throw new Exception("Completed persistence save, but no file was created"); |
913 | //} | 923 | //} |
914 | m_CurrentState = xml; | 924 | m_CurrentStateHash = hash; |
915 | } | 925 | } |
916 | } | 926 | } |
917 | 927 | ||
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index 7b19ce3..a60c0ba 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | |||
@@ -50,6 +50,8 @@ using OpenSim.Region.ScriptEngine.Shared.CodeTools; | |||
50 | using OpenSim.Region.ScriptEngine.Shared.Instance; | 50 | using OpenSim.Region.ScriptEngine.Shared.Instance; |
51 | using OpenSim.Region.ScriptEngine.Interfaces; | 51 | using OpenSim.Region.ScriptEngine.Interfaces; |
52 | 52 | ||
53 | using ScriptCompileQueue = OpenSim.Framework.LocklessQueue<object[]>; | ||
54 | |||
53 | namespace OpenSim.Region.ScriptEngine.XEngine | 55 | namespace OpenSim.Region.ScriptEngine.XEngine |
54 | { | 56 | { |
55 | public class XEngine : INonSharedRegionModule, IScriptModule, IScriptEngine | 57 | public class XEngine : INonSharedRegionModule, IScriptModule, IScriptEngine |
@@ -73,9 +75,11 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
73 | private bool m_InitialStartup = true; | 75 | private bool m_InitialStartup = true; |
74 | private int m_ScriptFailCount; // Number of script fails since compile queue was last empty | 76 | private int m_ScriptFailCount; // Number of script fails since compile queue was last empty |
75 | private string m_ScriptErrorMessage; | 77 | private string m_ScriptErrorMessage; |
78 | private Dictionary<string, string> m_uniqueScripts = new Dictionary<string, string>(); | ||
79 | private bool m_AppDomainLoading; | ||
76 | 80 | ||
77 | // disable warning: need to keep a reference to XEngine.EventManager | 81 | // disable warning: need to keep a reference to XEngine.EventManager |
78 | // alive to avoid it being garbage collected | 82 | // alive to avoid it being garbage collected |
79 | #pragma warning disable 414 | 83 | #pragma warning disable 414 |
80 | private EventManager m_EventManager; | 84 | private EventManager m_EventManager; |
81 | #pragma warning restore 414 | 85 | #pragma warning restore 414 |
@@ -114,7 +118,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
114 | private Dictionary<UUID, List<UUID> > m_DomainScripts = | 118 | private Dictionary<UUID, List<UUID> > m_DomainScripts = |
115 | new Dictionary<UUID, List<UUID> >(); | 119 | new Dictionary<UUID, List<UUID> >(); |
116 | 120 | ||
117 | private Queue m_CompileQueue = new Queue(100); | 121 | private ScriptCompileQueue m_CompileQueue = new ScriptCompileQueue(); |
118 | IWorkItemResult m_CurrentCompile = null; | 122 | IWorkItemResult m_CurrentCompile = null; |
119 | 123 | ||
120 | public string ScriptEngineName | 124 | public string ScriptEngineName |
@@ -201,6 +205,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
201 | m_MaxScriptQueue = m_ScriptConfig.GetInt("MaxScriptEventQueue",300); | 205 | m_MaxScriptQueue = m_ScriptConfig.GetInt("MaxScriptEventQueue",300); |
202 | m_StackSize = m_ScriptConfig.GetInt("ThreadStackSize", 262144); | 206 | m_StackSize = m_ScriptConfig.GetInt("ThreadStackSize", 262144); |
203 | m_SleepTime = m_ScriptConfig.GetInt("MaintenanceInterval", 10) * 1000; | 207 | m_SleepTime = m_ScriptConfig.GetInt("MaintenanceInterval", 10) * 1000; |
208 | m_AppDomainLoading = m_ScriptConfig.GetBoolean("AppDomainLoading", true); | ||
204 | 209 | ||
205 | m_EventLimit = m_ScriptConfig.GetInt("EventLimit", 30); | 210 | m_EventLimit = m_ScriptConfig.GetInt("EventLimit", 30); |
206 | m_KillTimedOutScripts = m_ScriptConfig.GetBoolean("KillTimedOutScripts", false); | 211 | m_KillTimedOutScripts = m_ScriptConfig.GetBoolean("KillTimedOutScripts", false); |
@@ -470,6 +475,12 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
470 | if (engine != ScriptEngineName) | 475 | if (engine != ScriptEngineName) |
471 | return; | 476 | return; |
472 | 477 | ||
478 | // If we've seen this exact script text before, use that reference instead | ||
479 | if (m_uniqueScripts.ContainsKey(script)) | ||
480 | script = m_uniqueScripts[script]; | ||
481 | else | ||
482 | m_uniqueScripts[script] = script; | ||
483 | |||
473 | Object[] parms = new Object[]{localID, itemID, script, startParam, postOnRez, (StateSource)stateSource}; | 484 | Object[] parms = new Object[]{localID, itemID, script, startParam, postOnRez, (StateSource)stateSource}; |
474 | 485 | ||
475 | if (stateSource == (int)StateSource.ScriptedRez) | 486 | if (stateSource == (int)StateSource.ScriptedRez) |
@@ -478,15 +489,19 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
478 | } | 489 | } |
479 | else | 490 | else |
480 | { | 491 | { |
481 | lock (m_CompileQueue) | 492 | m_CompileQueue.Enqueue(parms); |
482 | { | ||
483 | m_CompileQueue.Enqueue(parms); | ||
484 | 493 | ||
485 | if (m_CurrentCompile == null) | 494 | if (m_CurrentCompile == null) |
495 | { | ||
496 | // NOTE: Although we use a lockless queue, the lock here | ||
497 | // is required. It ensures that there are never two | ||
498 | // compile threads running, which, due to a race | ||
499 | // conndition, might otherwise happen | ||
500 | // | ||
501 | lock (m_CompileQueue) | ||
486 | { | 502 | { |
487 | m_CurrentCompile = m_ThreadPool.QueueWorkItem( | 503 | if (m_CurrentCompile == null) |
488 | new WorkItemCallback(this.DoOnRezScriptQueue), | 504 | m_CurrentCompile = m_ThreadPool.QueueWorkItem(DoOnRezScriptQueue, null); |
489 | new Object[0]); | ||
490 | } | 505 | } |
491 | } | 506 | } |
492 | } | 507 | } |
@@ -498,50 +513,38 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
498 | { | 513 | { |
499 | m_InitialStartup = false; | 514 | m_InitialStartup = false; |
500 | System.Threading.Thread.Sleep(15000); | 515 | System.Threading.Thread.Sleep(15000); |
501 | lock (m_CompileQueue) | ||
502 | { | ||
503 | if (m_CompileQueue.Count==0) | ||
504 | // No scripts on region, so won't get triggered later | ||
505 | // by the queue becoming empty so we trigger it here | ||
506 | m_Scene.EventManager.TriggerEmptyScriptCompileQueue(0, String.Empty); | ||
507 | } | ||
508 | } | ||
509 | 516 | ||
510 | Object o; | 517 | if (m_CompileQueue.Count == 0) |
511 | lock (m_CompileQueue) | ||
512 | { | ||
513 | o = m_CompileQueue.Dequeue(); | ||
514 | if (o == null) | ||
515 | { | 518 | { |
516 | m_CurrentCompile = null; | 519 | // No scripts on region, so won't get triggered later |
517 | return null; | 520 | // by the queue becoming empty so we trigger it here |
521 | m_Scene.EventManager.TriggerEmptyScriptCompileQueue(0, String.Empty); | ||
518 | } | 522 | } |
519 | } | 523 | } |
520 | 524 | ||
521 | DoOnRezScript(o); | 525 | object[] o; |
526 | while (m_CompileQueue.Dequeue(out o)) | ||
527 | DoOnRezScript(o); | ||
522 | 528 | ||
529 | // NOTE: Despite having a lockless queue, this lock is required | ||
530 | // to make sure there is never no compile thread while there | ||
531 | // are still scripts to compile. This could otherwise happen | ||
532 | // due to a race condition | ||
533 | // | ||
523 | lock (m_CompileQueue) | 534 | lock (m_CompileQueue) |
524 | { | 535 | { |
525 | if (m_CompileQueue.Count > 0) | 536 | m_CurrentCompile = null; |
526 | { | ||
527 | m_CurrentCompile = m_ThreadPool.QueueWorkItem( | ||
528 | new WorkItemCallback(this.DoOnRezScriptQueue), | ||
529 | new Object[0]); | ||
530 | } | ||
531 | else | ||
532 | { | ||
533 | m_CurrentCompile = null; | ||
534 | m_Scene.EventManager.TriggerEmptyScriptCompileQueue(m_ScriptFailCount, | ||
535 | m_ScriptErrorMessage); | ||
536 | m_ScriptFailCount = 0; | ||
537 | } | ||
538 | } | 537 | } |
538 | m_Scene.EventManager.TriggerEmptyScriptCompileQueue(m_ScriptFailCount, | ||
539 | m_ScriptErrorMessage); | ||
540 | m_ScriptFailCount = 0; | ||
541 | |||
539 | return null; | 542 | return null; |
540 | } | 543 | } |
541 | 544 | ||
542 | private bool DoOnRezScript(object parm) | 545 | private bool DoOnRezScript(object[] parms) |
543 | { | 546 | { |
544 | Object[] p = (Object[])parm; | 547 | Object[] p = parms; |
545 | uint localID = (uint)p[0]; | 548 | uint localID = (uint)p[0]; |
546 | UUID itemID = (UUID)p[1]; | 549 | UUID itemID = (UUID)p[1]; |
547 | string script =(string)p[2]; | 550 | string script =(string)p[2]; |
@@ -590,14 +593,12 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
590 | { | 593 | { |
591 | lock (m_AddingAssemblies) | 594 | lock (m_AddingAssemblies) |
592 | { | 595 | { |
593 | assembly = (string)m_Compiler.PerformScriptCompile(script, | 596 | m_Compiler.PerformScriptCompile(script, assetID.ToString(), item.OwnerID, out assembly, out linemap); |
594 | assetID.ToString(), item.OwnerID); | ||
595 | if (!m_AddingAssemblies.ContainsKey(assembly)) { | 597 | if (!m_AddingAssemblies.ContainsKey(assembly)) { |
596 | m_AddingAssemblies[assembly] = 1; | 598 | m_AddingAssemblies[assembly] = 1; |
597 | } else { | 599 | } else { |
598 | m_AddingAssemblies[assembly]++; | 600 | m_AddingAssemblies[assembly]++; |
599 | } | 601 | } |
600 | linemap = m_Compiler.LineMap(); | ||
601 | } | 602 | } |
602 | 603 | ||
603 | string[] warnings = m_Compiler.GetWarnings(); | 604 | string[] warnings = m_Compiler.GetWarnings(); |
@@ -696,19 +697,22 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
696 | Evidence baseEvidence = AppDomain.CurrentDomain.Evidence; | 697 | Evidence baseEvidence = AppDomain.CurrentDomain.Evidence; |
697 | Evidence evidence = new Evidence(baseEvidence); | 698 | Evidence evidence = new Evidence(baseEvidence); |
698 | 699 | ||
699 | AppDomain sandbox = | 700 | AppDomain sandbox; |
700 | AppDomain.CreateDomain( | 701 | if (m_AppDomainLoading) |
701 | m_Scene.RegionInfo.RegionID.ToString(), | 702 | sandbox = AppDomain.CreateDomain( |
702 | evidence, appSetup); | 703 | m_Scene.RegionInfo.RegionID.ToString(), |
703 | /* | 704 | evidence, appSetup); |
704 | PolicyLevel sandboxPolicy = PolicyLevel.CreateAppDomainLevel(); | 705 | else |
705 | AllMembershipCondition sandboxMembershipCondition = new AllMembershipCondition(); | 706 | sandbox = AppDomain.CurrentDomain; |
706 | PermissionSet sandboxPermissionSet = sandboxPolicy.GetNamedPermissionSet("Internet"); | 707 | |
707 | PolicyStatement sandboxPolicyStatement = new PolicyStatement(sandboxPermissionSet); | 708 | //PolicyLevel sandboxPolicy = PolicyLevel.CreateAppDomainLevel(); |
708 | CodeGroup sandboxCodeGroup = new UnionCodeGroup(sandboxMembershipCondition, sandboxPolicyStatement); | 709 | //AllMembershipCondition sandboxMembershipCondition = new AllMembershipCondition(); |
709 | sandboxPolicy.RootCodeGroup = sandboxCodeGroup; | 710 | //PermissionSet sandboxPermissionSet = sandboxPolicy.GetNamedPermissionSet("Internet"); |
710 | sandbox.SetAppDomainPolicy(sandboxPolicy); | 711 | //PolicyStatement sandboxPolicyStatement = new PolicyStatement(sandboxPermissionSet); |
711 | */ | 712 | //CodeGroup sandboxCodeGroup = new UnionCodeGroup(sandboxMembershipCondition, sandboxPolicyStatement); |
713 | //sandboxPolicy.RootCodeGroup = sandboxCodeGroup; | ||
714 | //sandbox.SetAppDomainPolicy(sandboxPolicy); | ||
715 | |||
712 | m_AppDomains[appDomain] = sandbox; | 716 | m_AppDomains[appDomain] = sandbox; |
713 | 717 | ||
714 | m_AppDomains[appDomain].AssemblyResolve += | 718 | m_AppDomains[appDomain].AssemblyResolve += |
@@ -905,9 +909,10 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
905 | AppDomain domain = m_AppDomains[id]; | 909 | AppDomain domain = m_AppDomains[id]; |
906 | m_AppDomains.Remove(id); | 910 | m_AppDomains.Remove(id); |
907 | 911 | ||
908 | AppDomain.Unload(domain); | 912 | if (domain != AppDomain.CurrentDomain) |
913 | AppDomain.Unload(domain); | ||
909 | domain = null; | 914 | domain = null; |
910 | // m_log.DebugFormat("[XEngine] Unloaded app domain {0}", id.ToString()); | 915 | // m_log.DebugFormat("[XEngine] Unloaded app domain {0}", id.ToString()); |
911 | } | 916 | } |
912 | } | 917 | } |
913 | 918 | ||
diff --git a/OpenSim/Services/Connectors/Asset/AssetServiceConnector.cs b/OpenSim/Services/Connectors/Asset/AssetServiceConnector.cs index ecda85a..8e311d7 100644 --- a/OpenSim/Services/Connectors/Asset/AssetServiceConnector.cs +++ b/OpenSim/Services/Connectors/Asset/AssetServiceConnector.cs | |||
@@ -243,7 +243,7 @@ namespace OpenSim.Services.Connectors | |||
243 | if (metadata == null) | 243 | if (metadata == null) |
244 | return false; | 244 | return false; |
245 | 245 | ||
246 | asset = new AssetBase(); | 246 | asset = new AssetBase(metadata.FullID, metadata.Name, metadata.Type); |
247 | asset.Metadata = metadata; | 247 | asset.Metadata = metadata; |
248 | } | 248 | } |
249 | asset.Data = data; | 249 | asset.Data = data; |
diff --git a/OpenSim/Services/Connectors/Authorization/AuthorizationServiceConnector.cs b/OpenSim/Services/Connectors/Authorization/AuthorizationServiceConnector.cs index 7926efb..c2ad9db 100644 --- a/OpenSim/Services/Connectors/Authorization/AuthorizationServiceConnector.cs +++ b/OpenSim/Services/Connectors/Authorization/AuthorizationServiceConnector.cs | |||
@@ -105,10 +105,14 @@ namespace OpenSim.Services.Connectors | |||
105 | catch (Exception e) | 105 | catch (Exception e) |
106 | { | 106 | { |
107 | m_log.WarnFormat("[AUTHORIZATION CONNECTOR]: Unable to send authorize {0} for region {1} error thrown during comms with remote server. Reason: {2}", userID, regionID, e.Message); | 107 | m_log.WarnFormat("[AUTHORIZATION CONNECTOR]: Unable to send authorize {0} for region {1} error thrown during comms with remote server. Reason: {2}", userID, regionID, e.Message); |
108 | message=""; | 108 | message = ""; |
109 | return m_ResponseOnFailure; | ||
110 | } | ||
111 | if (response == null) | ||
112 | { | ||
113 | message = "Null response"; | ||
109 | return m_ResponseOnFailure; | 114 | return m_ResponseOnFailure; |
110 | } | 115 | } |
111 | |||
112 | m_log.DebugFormat("[AUTHORIZATION CONNECTOR] response from remote service was {0}", response.Message); | 116 | m_log.DebugFormat("[AUTHORIZATION CONNECTOR] response from remote service was {0}", response.Message); |
113 | message = response.Message; | 117 | message = response.Message; |
114 | 118 | ||
diff --git a/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs b/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs index 3d7f112..2f33bab 100644 --- a/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs +++ b/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs | |||
@@ -140,12 +140,11 @@ namespace OpenSim.Services.Connectors.Grid | |||
140 | Bitmap m = new Bitmap(info.RegionID.ToString() + ".jpg"); | 140 | Bitmap m = new Bitmap(info.RegionID.ToString() + ".jpg"); |
141 | //m_log.Debug("Size: " + m.PhysicalDimension.Height + "-" + m.PhysicalDimension.Width); | 141 | //m_log.Debug("Size: " + m.PhysicalDimension.Height + "-" + m.PhysicalDimension.Width); |
142 | byte[] imageData = OpenJPEG.EncodeFromImage(m, true); | 142 | byte[] imageData = OpenJPEG.EncodeFromImage(m, true); |
143 | AssetBase ass = new AssetBase(UUID.Random(), "region " + info.RegionID.ToString()); | 143 | AssetBase ass = new AssetBase(UUID.Random(), "region " + info.RegionID.ToString(), (sbyte)AssetType.Texture); |
144 | 144 | ||
145 | // !!! for now | 145 | // !!! for now |
146 | //info.RegionSettings.TerrainImageID = ass.FullID; | 146 | //info.RegionSettings.TerrainImageID = ass.FullID; |
147 | 147 | ||
148 | ass.Type = (int)AssetType.Texture; | ||
149 | ass.Temporary = true; | 148 | ass.Temporary = true; |
150 | ass.Local = true; | 149 | ass.Local = true; |
151 | ass.Data = imageData; | 150 | ass.Data = imageData; |
diff --git a/OpenSim/Services/PresenceService/PresenceService.cs b/OpenSim/Services/PresenceService/PresenceService.cs index 6e59642..ba8eec8 100644 --- a/OpenSim/Services/PresenceService/PresenceService.cs +++ b/OpenSim/Services/PresenceService/PresenceService.cs | |||
@@ -41,9 +41,9 @@ namespace OpenSim.Services.PresenceService | |||
41 | { | 41 | { |
42 | public class PresenceService : PresenceServiceBase, IPresenceService | 42 | public class PresenceService : PresenceServiceBase, IPresenceService |
43 | { | 43 | { |
44 | private static readonly ILog m_log = | 44 | // private static readonly ILog m_log = |
45 | LogManager.GetLogger( | 45 | // LogManager.GetLogger( |
46 | MethodBase.GetCurrentMethod().DeclaringType); | 46 | // MethodBase.GetCurrentMethod().DeclaringType); |
47 | 47 | ||
48 | public PresenceService(IConfigSource config) | 48 | public PresenceService(IConfigSource config) |
49 | : base(config) | 49 | : base(config) |
diff --git a/OpenSim/TestSuite/PhysicsBot.cs b/OpenSim/TestSuite/PhysicsBot.cs index 9c9c1ea..fac4275 100644 --- a/OpenSim/TestSuite/PhysicsBot.cs +++ b/OpenSim/TestSuite/PhysicsBot.cs | |||
@@ -130,9 +130,9 @@ namespace OpenSim.TestSuite | |||
130 | public void startup() | 130 | public void startup() |
131 | { | 131 | { |
132 | client.Settings.LOGIN_SERVER = loginURI; | 132 | client.Settings.LOGIN_SERVER = loginURI; |
133 | client.Network.OnConnected += new NetworkManager.ConnectedCallback(this.Network_OnConnected); | 133 | client.Network.LoginProgress += this.Network_LoginProgress; |
134 | client.Network.OnSimConnected += new NetworkManager.SimConnectedCallback(this.Network_OnConnected); | 134 | client.Network.SimConnected += this.Network_SimConnected; |
135 | client.Network.OnDisconnected += new NetworkManager.DisconnectedCallback(this.Network_OnDisconnected); | 135 | client.Network.Disconnected += this.Network_OnDisconnected; |
136 | if (client.Network.Login(firstname, lastname, password, "pCampBot", "Your name")) | 136 | if (client.Network.Login(firstname, lastname, password, "pCampBot", "Your name")) |
137 | { | 137 | { |
138 | 138 | ||
@@ -155,19 +155,22 @@ namespace OpenSim.TestSuite | |||
155 | } | 155 | } |
156 | } | 156 | } |
157 | 157 | ||
158 | public void Network_OnConnected(object sender) | 158 | public void Network_LoginProgress(object sender, LoginProgressEventArgs args) |
159 | { | 159 | { |
160 | if (OnConnected != null) | 160 | if (args.Status == LoginStatus.Success) |
161 | { | 161 | { |
162 | OnConnected(this, EventType.CONNECTED); | 162 | if (OnConnected != null) |
163 | { | ||
164 | OnConnected(this, EventType.CONNECTED); | ||
165 | } | ||
163 | } | 166 | } |
164 | } | 167 | } |
165 | 168 | ||
166 | public void Simulator_Connected(object sender) | 169 | public void Network_SimConnected(object sender, SimConnectedEventArgs args) |
167 | { | 170 | { |
168 | } | 171 | } |
169 | 172 | ||
170 | public void Network_OnDisconnected(NetworkManager.DisconnectType reason, string message) | 173 | public void Network_OnDisconnected(object sender, DisconnectedEventArgs args) |
171 | { | 174 | { |
172 | if (OnDisconnected != null) | 175 | if (OnDisconnected != null) |
173 | { | 176 | { |
diff --git a/OpenSim/Tests/Common/Mock/TestAssetService.cs b/OpenSim/Tests/Common/Mock/MockAssetService.cs index 317ec06..cb38043 100644 --- a/OpenSim/Tests/Common/Mock/TestAssetService.cs +++ b/OpenSim/Tests/Common/Mock/MockAssetService.cs | |||
@@ -27,6 +27,8 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Reflection; | ||
31 | using log4net; | ||
30 | using OpenMetaverse; | 32 | using OpenMetaverse; |
31 | using OpenSim.Framework; | 33 | using OpenSim.Framework; |
32 | using OpenSim.Data; | 34 | using OpenSim.Data; |
@@ -35,16 +37,25 @@ using Nini.Config; | |||
35 | 37 | ||
36 | namespace OpenSim.Tests.Common.Mock | 38 | namespace OpenSim.Tests.Common.Mock |
37 | { | 39 | { |
38 | public class TestAssetService : IAssetService | 40 | public class MockAssetService : IAssetService |
39 | { | 41 | { |
42 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
43 | |||
40 | private readonly Dictionary<string, AssetBase> Assets = new Dictionary<string, AssetBase>(); | 44 | private readonly Dictionary<string, AssetBase> Assets = new Dictionary<string, AssetBase>(); |
41 | 45 | ||
42 | public TestAssetService(IConfigSource config) | 46 | public MockAssetService() {} |
43 | { | 47 | |
44 | } | 48 | /// <summary> |
49 | /// This constructor is required if the asset service is being created reflectively (which is the case in some | ||
50 | /// tests). | ||
51 | /// </summary> | ||
52 | /// <param name="config"></param> | ||
53 | public MockAssetService(IConfigSource config) {} | ||
45 | 54 | ||
46 | public AssetBase Get(string id) | 55 | public AssetBase Get(string id) |
47 | { | 56 | { |
57 | m_log.DebugFormat("[MOCK ASSET SERVICE]: Getting asset with id {0}", id); | ||
58 | |||
48 | AssetBase asset; | 59 | AssetBase asset; |
49 | if (Assets.ContainsKey(id)) | 60 | if (Assets.ContainsKey(id)) |
50 | asset = Assets[id]; | 61 | asset = Assets[id]; |
@@ -73,6 +84,8 @@ namespace OpenSim.Tests.Common.Mock | |||
73 | 84 | ||
74 | public string Store(AssetBase asset) | 85 | public string Store(AssetBase asset) |
75 | { | 86 | { |
87 | m_log.DebugFormat("[MOCK ASSET SERVICE]: Storing asset {0}", asset.ID); | ||
88 | |||
76 | Assets[asset.ID] = asset; | 89 | Assets[asset.ID] = asset; |
77 | 90 | ||
78 | return asset.ID; | 91 | return asset.ID; |
diff --git a/OpenSim/Tests/Common/Mock/TestInventoryService.cs b/OpenSim/Tests/Common/Mock/MockInventoryService.cs index 5a0ee7c..1ea4bc1 100644 --- a/OpenSim/Tests/Common/Mock/TestInventoryService.cs +++ b/OpenSim/Tests/Common/Mock/MockInventoryService.cs | |||
@@ -35,13 +35,13 @@ using Nini.Config; | |||
35 | 35 | ||
36 | namespace OpenSim.Tests.Common.Mock | 36 | namespace OpenSim.Tests.Common.Mock |
37 | { | 37 | { |
38 | public class TestInventoryService : IInventoryService | 38 | public class MockInventoryService : IInventoryService |
39 | { | 39 | { |
40 | public TestInventoryService() | 40 | public MockInventoryService() |
41 | { | 41 | { |
42 | } | 42 | } |
43 | 43 | ||
44 | public TestInventoryService(IConfigSource config) | 44 | public MockInventoryService(IConfigSource config) |
45 | { | 45 | { |
46 | } | 46 | } |
47 | 47 | ||
diff --git a/OpenSim/Tests/Common/Mock/MockUserService.cs b/OpenSim/Tests/Common/Mock/MockUserService.cs new file mode 100644 index 0000000..1e27fb7 --- /dev/null +++ b/OpenSim/Tests/Common/Mock/MockUserService.cs | |||
@@ -0,0 +1,123 @@ | |||
1 | |||
2 | using System; | ||
3 | using System.Collections.Generic; | ||
4 | using OpenMetaverse; | ||
5 | using OpenSim.Framework; | ||
6 | using OpenSim.Framework.Communications; | ||
7 | using OpenSim.Framework.Communications.Cache; | ||
8 | using OpenSim.Services.Interfaces; | ||
9 | |||
10 | namespace OpenSim.Tests.Common | ||
11 | { | ||
12 | public class MockUserService : IUserService | ||
13 | { | ||
14 | public void AddTemporaryUserProfile(UserProfileData userProfile) | ||
15 | { | ||
16 | throw new NotImplementedException(); | ||
17 | } | ||
18 | |||
19 | public UserProfileData GetUserProfile(string firstName, string lastName) | ||
20 | { | ||
21 | throw new NotImplementedException(); | ||
22 | } | ||
23 | |||
24 | public UserProfileData GetUserProfile(UUID userId) | ||
25 | { | ||
26 | throw new NotImplementedException(); | ||
27 | } | ||
28 | |||
29 | public UserProfileData GetUserProfile(Uri uri) | ||
30 | { | ||
31 | UserProfileData userProfile = new UserProfileData(); | ||
32 | |||
33 | // userProfile.ID = new UUID(Util.GetHashGuid(uri.ToString(), AssetCache.AssetInfo.Secret)); | ||
34 | |||
35 | return userProfile; | ||
36 | } | ||
37 | |||
38 | public Uri GetUserUri(UserProfileData userProfile) | ||
39 | { | ||
40 | throw new NotImplementedException(); | ||
41 | } | ||
42 | |||
43 | public UserAgentData GetAgentByUUID(UUID userId) | ||
44 | { | ||
45 | throw new NotImplementedException(); | ||
46 | } | ||
47 | |||
48 | public void ClearUserAgent(UUID avatarID) | ||
49 | { | ||
50 | throw new NotImplementedException(); | ||
51 | } | ||
52 | |||
53 | public List<AvatarPickerAvatar> GenerateAgentPickerRequestResponse(UUID QueryID, string Query) | ||
54 | { | ||
55 | throw new NotImplementedException(); | ||
56 | } | ||
57 | |||
58 | public UserProfileData SetupMasterUser(string firstName, string lastName) | ||
59 | { | ||
60 | throw new NotImplementedException(); | ||
61 | } | ||
62 | |||
63 | public UserProfileData SetupMasterUser(string firstName, string lastName, string password) | ||
64 | { | ||
65 | throw new NotImplementedException(); | ||
66 | } | ||
67 | |||
68 | public UserProfileData SetupMasterUser(UUID userId) | ||
69 | { | ||
70 | throw new NotImplementedException(); | ||
71 | } | ||
72 | |||
73 | public bool UpdateUserProfile(UserProfileData data) | ||
74 | { | ||
75 | throw new NotImplementedException(); | ||
76 | } | ||
77 | |||
78 | public void AddNewUserFriend(UUID friendlistowner, UUID friend, uint perms) | ||
79 | { | ||
80 | throw new NotImplementedException(); | ||
81 | } | ||
82 | |||
83 | public void RemoveUserFriend(UUID friendlistowner, UUID friend) | ||
84 | { | ||
85 | throw new NotImplementedException(); | ||
86 | } | ||
87 | |||
88 | public void UpdateUserFriendPerms(UUID friendlistowner, UUID friend, uint perms) | ||
89 | { | ||
90 | throw new NotImplementedException(); | ||
91 | } | ||
92 | |||
93 | public void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, Vector3 position, Vector3 lookat) | ||
94 | { | ||
95 | throw new NotImplementedException(); | ||
96 | } | ||
97 | |||
98 | public void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, float posx, float posy, float posz) | ||
99 | { | ||
100 | throw new NotImplementedException(); | ||
101 | } | ||
102 | |||
103 | public List<FriendListItem> GetUserFriendList(UUID friendlistowner) | ||
104 | { | ||
105 | throw new NotImplementedException(); | ||
106 | } | ||
107 | |||
108 | public bool VerifySession(UUID userID, UUID sessionID) | ||
109 | { | ||
110 | return true; | ||
111 | } | ||
112 | |||
113 | public void SetInventoryService(IInventoryService inv) | ||
114 | { | ||
115 | throw new NotImplementedException(); | ||
116 | } | ||
117 | |||
118 | public virtual bool AuthenticateUserByPassword(UUID userID, string password) | ||
119 | { | ||
120 | throw new NotImplementedException(); | ||
121 | } | ||
122 | } | ||
123 | } | ||
diff --git a/OpenSim/Tests/Common/Mock/TestClient.cs b/OpenSim/Tests/Common/Mock/TestClient.cs index 0f642b9..27025d9 100644 --- a/OpenSim/Tests/Common/Mock/TestClient.cs +++ b/OpenSim/Tests/Common/Mock/TestClient.cs | |||
@@ -191,6 +191,7 @@ namespace OpenSim.Tests.Common.Mock | |||
191 | public event FriendActionDelegate OnApproveFriendRequest; | 191 | public event FriendActionDelegate OnApproveFriendRequest; |
192 | public event FriendActionDelegate OnDenyFriendRequest; | 192 | public event FriendActionDelegate OnDenyFriendRequest; |
193 | public event FriendshipTermination OnTerminateFriendship; | 193 | public event FriendshipTermination OnTerminateFriendship; |
194 | public event GrantUserFriendRights OnGrantUserRights; | ||
194 | 195 | ||
195 | public event EconomyDataRequest OnEconomyDataRequest; | 196 | public event EconomyDataRequest OnEconomyDataRequest; |
196 | public event MoneyBalanceRequest OnMoneyBalanceRequest; | 197 | public event MoneyBalanceRequest OnMoneyBalanceRequest; |
@@ -631,6 +632,7 @@ namespace OpenSim.Tests.Common.Mock | |||
631 | public virtual void SendInventoryFolderDetails(UUID ownerID, UUID folderID, | 632 | public virtual void SendInventoryFolderDetails(UUID ownerID, UUID folderID, |
632 | List<InventoryItemBase> items, | 633 | List<InventoryItemBase> items, |
633 | List<InventoryFolderBase> folders, | 634 | List<InventoryFolderBase> folders, |
635 | int version, | ||
634 | bool fetchFolders, | 636 | bool fetchFolders, |
635 | bool fetchItems) | 637 | bool fetchItems) |
636 | { | 638 | { |
diff --git a/OpenSim/Tests/Common/Setup/AssetHelpers.cs b/OpenSim/Tests/Common/Setup/AssetHelpers.cs new file mode 100644 index 0000000..df69cd9 --- /dev/null +++ b/OpenSim/Tests/Common/Setup/AssetHelpers.cs | |||
@@ -0,0 +1,64 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System.Text; | ||
29 | using OpenMetaverse; | ||
30 | using OpenSim.Framework; | ||
31 | using OpenSim.Region.Framework.Scenes; | ||
32 | using OpenSim.Region.Framework.Scenes.Serialization; | ||
33 | |||
34 | namespace OpenSim.Tests.Common | ||
35 | { | ||
36 | public class AssetHelpers | ||
37 | { | ||
38 | /// <summary> | ||
39 | /// Create an asset from the given data | ||
40 | /// </summary> | ||
41 | /// <param name="assetUuid"></param> | ||
42 | /// <param name="data"></param> | ||
43 | /// <returns></returns> | ||
44 | public static AssetBase CreateAsset(UUID assetUuid, string data) | ||
45 | { | ||
46 | AssetBase asset = new AssetBase(assetUuid, assetUuid.ToString(), (sbyte)AssetType.Object); | ||
47 | asset.Data = Encoding.ASCII.GetBytes(data); | ||
48 | return asset; | ||
49 | } | ||
50 | |||
51 | /// <summary> | ||
52 | /// Create an asset from the given scene object | ||
53 | /// </summary> | ||
54 | /// <param name="assetUuid"></param> | ||
55 | /// <param name="sog"></param> | ||
56 | /// <returns></returns> | ||
57 | public static AssetBase CreateAsset(UUID assetUuid, SceneObjectGroup sog) | ||
58 | { | ||
59 | AssetBase asset = new AssetBase(assetUuid, assetUuid.ToString(), (sbyte)AssetType.Object); | ||
60 | asset.Data = Encoding.ASCII.GetBytes(SceneObjectSerializer.ToXml2Format(sog)); | ||
61 | return asset; | ||
62 | } | ||
63 | } | ||
64 | } | ||
diff --git a/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs b/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs index eab5422..8b18d07 100644 --- a/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs +++ b/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs | |||
@@ -219,7 +219,7 @@ namespace OpenSim.Tests.Common.Setup | |||
219 | if (real) | 219 | if (real) |
220 | config.Configs["AssetService"].Set("LocalServiceModule", "OpenSim.Services.AssetService.dll:AssetService"); | 220 | config.Configs["AssetService"].Set("LocalServiceModule", "OpenSim.Services.AssetService.dll:AssetService"); |
221 | else | 221 | else |
222 | config.Configs["AssetService"].Set("LocalServiceModule", "OpenSim.Tests.Common.dll:TestAssetService"); | 222 | config.Configs["AssetService"].Set("LocalServiceModule", "OpenSim.Tests.Common.dll:MockAssetService"); |
223 | config.Configs["AssetService"].Set("StorageProvider", "OpenSim.Tests.Common.dll"); | 223 | config.Configs["AssetService"].Set("StorageProvider", "OpenSim.Tests.Common.dll"); |
224 | assetService.Initialise(config); | 224 | assetService.Initialise(config); |
225 | assetService.AddRegion(testScene); | 225 | assetService.AddRegion(testScene); |
@@ -238,7 +238,7 @@ namespace OpenSim.Tests.Common.Setup | |||
238 | if (real) | 238 | if (real) |
239 | config.Configs["InventoryService"].Set("LocalServiceModule", "OpenSim.Services.InventoryService.dll:InventoryService"); | 239 | config.Configs["InventoryService"].Set("LocalServiceModule", "OpenSim.Services.InventoryService.dll:InventoryService"); |
240 | else | 240 | else |
241 | config.Configs["InventoryService"].Set("LocalServiceModule", "OpenSim.Tests.Common.dll:TestInventoryService"); | 241 | config.Configs["InventoryService"].Set("LocalServiceModule", "OpenSim.Tests.Common.dll:MockInventoryService"); |
242 | config.Configs["InventoryService"].Set("StorageProvider", "OpenSim.Tests.Common.dll"); | 242 | config.Configs["InventoryService"].Set("StorageProvider", "OpenSim.Tests.Common.dll"); |
243 | inventoryService.Initialise(config); | 243 | inventoryService.Initialise(config); |
244 | inventoryService.AddRegion(testScene); | 244 | inventoryService.AddRegion(testScene); |
diff --git a/OpenSim/Tests/Common/Setup/UserProfileTestUtils.cs b/OpenSim/Tests/Common/Setup/UserProfileTestUtils.cs index 3ca44a1..1b06a46 100644 --- a/OpenSim/Tests/Common/Setup/UserProfileTestUtils.cs +++ b/OpenSim/Tests/Common/Setup/UserProfileTestUtils.cs | |||
@@ -85,14 +85,34 @@ namespace OpenSim.Tests.Common.Setup | |||
85 | CommunicationsManager commsManager, string firstName, string lastName, | 85 | CommunicationsManager commsManager, string firstName, string lastName, |
86 | UUID userId, OnInventoryReceivedDelegate callback) | 86 | UUID userId, OnInventoryReceivedDelegate callback) |
87 | { | 87 | { |
88 | return CreateUserWithInventory(commsManager, firstName, lastName, "troll", userId, callback); | ||
89 | } | ||
90 | |||
91 | /// <summary> | ||
92 | /// Create a test user with a standard inventory | ||
93 | /// </summary> | ||
94 | /// <param name="commsManager"></param> | ||
95 | /// <param name="firstName">First name of user</param> | ||
96 | /// <param name="lastName">Last name of user</param> | ||
97 | /// <param name="password">Password</param> | ||
98 | /// <param name="userId">User ID</param> | ||
99 | /// <param name="callback"> | ||
100 | /// Callback to invoke when inventory has been loaded. This is required because | ||
101 | /// loading may be asynchronous, even on standalone | ||
102 | /// </param> | ||
103 | /// <returns></returns> | ||
104 | public static CachedUserInfo CreateUserWithInventory( | ||
105 | CommunicationsManager commsManager, string firstName, string lastName, string password, | ||
106 | UUID userId, OnInventoryReceivedDelegate callback) | ||
107 | { | ||
88 | LocalUserServices lus = (LocalUserServices)commsManager.UserService; | 108 | LocalUserServices lus = (LocalUserServices)commsManager.UserService; |
89 | lus.AddUser(firstName, lastName, "troll", "bill@bailey.com", 1000, 1000, userId); | 109 | lus.AddUser(firstName, lastName, password, "bill@bailey.com", 1000, 1000, userId); |
90 | 110 | ||
91 | CachedUserInfo userInfo = commsManager.UserProfileCacheService.GetUserDetails(userId); | 111 | CachedUserInfo userInfo = commsManager.UserProfileCacheService.GetUserDetails(userId); |
92 | userInfo.OnInventoryReceived += callback; | 112 | userInfo.OnInventoryReceived += callback; |
93 | userInfo.FetchInventory(); | 113 | userInfo.FetchInventory(); |
94 | 114 | ||
95 | return userInfo; | 115 | return userInfo; |
96 | } | 116 | } |
97 | } | 117 | } |
98 | } | 118 | } |
diff --git a/OpenSim/Tests/Common/TestHelper.cs b/OpenSim/Tests/Common/TestHelper.cs index 4abf2e3..9d53063 100644 --- a/OpenSim/Tests/Common/TestHelper.cs +++ b/OpenSim/Tests/Common/TestHelper.cs | |||
@@ -54,6 +54,7 @@ namespace OpenSim.Tests.Common | |||
54 | public static void InMethod() | 54 | public static void InMethod() |
55 | { | 55 | { |
56 | StackTrace stackTrace = new StackTrace(); | 56 | StackTrace stackTrace = new StackTrace(); |
57 | Console.WriteLine(); | ||
57 | Console.WriteLine("===> In Test Method : {0} <===", stackTrace.GetFrame(1).GetMethod().Name); | 58 | Console.WriteLine("===> In Test Method : {0} <===", stackTrace.GetFrame(1).GetMethod().Name); |
58 | } | 59 | } |
59 | } | 60 | } |
diff --git a/OpenSim/Tools/pCampBot/PhysicsBot.cs b/OpenSim/Tools/pCampBot/PhysicsBot.cs index 38986a2..5d4af31 100644 --- a/OpenSim/Tools/pCampBot/PhysicsBot.cs +++ b/OpenSim/Tools/pCampBot/PhysicsBot.cs | |||
@@ -151,9 +151,9 @@ namespace pCampBot | |||
151 | client.Throttle.Texture = 100000; | 151 | client.Throttle.Texture = 100000; |
152 | client.Throttle.Wind = 100000; | 152 | client.Throttle.Wind = 100000; |
153 | client.Throttle.Total = 400000; | 153 | client.Throttle.Total = 400000; |
154 | client.Network.OnConnected += new NetworkManager.ConnectedCallback(this.Network_OnConnected); | 154 | client.Network.LoginProgress += this.Network_LoginProgress; |
155 | client.Network.OnSimConnected += new NetworkManager.SimConnectedCallback(this.Network_OnConnected); | 155 | client.Network.SimConnected += this.Network_SimConnected; |
156 | client.Network.OnDisconnected += new NetworkManager.DisconnectedCallback(this.Network_OnDisconnected); | 156 | client.Network.Disconnected += this.Network_OnDisconnected; |
157 | client.Objects.ObjectUpdate += Objects_NewPrim; | 157 | client.Objects.ObjectUpdate += Objects_NewPrim; |
158 | //client.Assets.OnAssetReceived += Asset_ReceivedCallback; | 158 | //client.Assets.OnAssetReceived += Asset_ReceivedCallback; |
159 | if (client.Network.Login(firstname, lastname, password, "pCampBot", "Your name")) | 159 | if (client.Network.Login(firstname, lastname, password, "pCampBot", "Your name")) |
@@ -349,19 +349,22 @@ namespace pCampBot | |||
349 | return clothfolder; | 349 | return clothfolder; |
350 | } | 350 | } |
351 | 351 | ||
352 | public void Network_OnConnected(object sender) | 352 | public void Network_LoginProgress(object sender, LoginProgressEventArgs args) |
353 | { | 353 | { |
354 | if (OnConnected != null) | 354 | if (args.Status == LoginStatus.Success) |
355 | { | 355 | { |
356 | OnConnected(this, EventType.CONNECTED); | 356 | if (OnConnected != null) |
357 | { | ||
358 | OnConnected(this, EventType.CONNECTED); | ||
359 | } | ||
357 | } | 360 | } |
358 | } | 361 | } |
359 | 362 | ||
360 | public void Simulator_Connected(object sender) | 363 | public void Network_SimConnected(object sender, SimConnectedEventArgs args) |
361 | { | 364 | { |
362 | } | 365 | } |
363 | 366 | ||
364 | public void Network_OnDisconnected(NetworkManager.DisconnectType reason, string message) | 367 | public void Network_OnDisconnected(object sender, DisconnectedEventArgs args) |
365 | { | 368 | { |
366 | if (OnDisconnected != null) | 369 | if (OnDisconnected != null) |
367 | { | 370 | { |