From 3dc2010da6412941bfbcdb29007b12a8f37b7bef Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Mon, 29 Jun 2009 15:05:12 +0000 Subject: [PATCH] From: Chris Yeoh Attached is a patch that changes the oar file saving of creation date/time to an integer instead of a string. I did this after justincc emailed me saying there is a problem with internationalisation doing it the old way and I said I'd fix it. Its been tested with MySQL and I've made the changes for MSSQL but that hasn't been well tested. --- OpenSim/Data/MSSQL/MSSQLRegionData.cs | 19 ++++---------- .../Data/MSSQL/Resources/023_RegionStore.sql | 7 ++++++ OpenSim/Data/MySQL/MySQLRegionData.cs | 17 +++---------- .../Data/MySQL/Resources/031_RegionStore.sql | 7 ++++++ OpenSim/Framework/RegionSettings.cs | 25 +++++++++++++------ .../Transfer/InventoryTransferModule.cs | 5 ++++ .../World/Archiver/ArchiveReadRequest.cs | 15 ++++------- .../Archiver/ArchiveWriteRequestExecution.cs | 6 ++--- .../Framework/Scenes/Scene.Inventory.cs | 4 +++ .../Shared/Api/Implementation/LSL_Api.cs | 1 + 10 files changed, 59 insertions(+), 47 deletions(-) create mode 100644 OpenSim/Data/MSSQL/Resources/023_RegionStore.sql create mode 100644 OpenSim/Data/MySQL/Resources/031_RegionStore.sql diff --git a/OpenSim/Data/MSSQL/MSSQLRegionData.cs b/OpenSim/Data/MSSQL/MSSQLRegionData.cs index 293282e29c..1aaf2a5c7c 100644 --- a/OpenSim/Data/MSSQL/MSSQLRegionData.cs +++ b/OpenSim/Data/MSSQL/MSSQLRegionData.cs @@ -723,7 +723,7 @@ VALUES ,[elevation_1_ne] = @elevation_1_ne ,[elevation_2_ne] = @elevation_2_ne ,[elevation_1_se] = @elevation_1_se ,[elevation_2_se] = @elevation_2_se ,[elevation_1_sw] = @elevation_1_sw ,[elevation_2_sw] = @elevation_2_sw ,[water_height] = @water_height ,[terrain_raise_limit] = @terrain_raise_limit ,[terrain_lower_limit] = @terrain_lower_limit ,[use_estate_sun] = @use_estate_sun ,[fixed_sun] = @fixed_sun ,[sun_position] = @sun_position -,[covenant] = @covenant , [sunvectorx] = @sunvectorx, [sunvectory] = @sunvectory, [sunvectorz] = @sunvectorz, [Sandbox] = @Sandbox, [loaded_creation_date] = @loaded_creation_date, [loaded_creation_time] = @loaded_creation_time, [loaded_creation_id] = @loaded_creation_id +,[covenant] = @covenant , [sunvectorx] = @sunvectorx, [sunvectory] = @sunvectory, [sunvectorz] = @sunvectorz, [Sandbox] = @Sandbox, [loaded_creation_datetime] = @loaded_creation_datetime, [loaded_creation_id] = @loaded_creation_id WHERE [regionUUID] = @regionUUID"; using (AutoClosingSqlCommand cmd = _Database.Query(sql)) @@ -777,14 +777,14 @@ VALUES [block_show_in_search],[agent_limit],[object_bonus],[maturity],[disable_scripts],[disable_collisions],[disable_physics], [terrain_texture_1],[terrain_texture_2],[terrain_texture_3],[terrain_texture_4],[elevation_1_nw],[elevation_2_nw],[elevation_1_ne], [elevation_2_ne],[elevation_1_se],[elevation_2_se],[elevation_1_sw],[elevation_2_sw],[water_height],[terrain_raise_limit], - [terrain_lower_limit],[use_estate_sun],[fixed_sun],[sun_position],[covenant],[sunvectorx], [sunvectory], [sunvectorz],[Sandbox], [loaded_creation_date], [loaded_creation_time], [loaded_creation_id] + [terrain_lower_limit],[use_estate_sun],[fixed_sun],[sun_position],[covenant],[sunvectorx], [sunvectory], [sunvectorz],[Sandbox], [loaded_creation_datetime], [loaded_creation_id] ) VALUES (@regionUUID,@block_terraform,@block_fly,@allow_damage,@restrict_pushing,@allow_land_resell,@allow_land_join_divide, @block_show_in_search,@agent_limit,@object_bonus,@maturity,@disable_scripts,@disable_collisions,@disable_physics, @terrain_texture_1,@terrain_texture_2,@terrain_texture_3,@terrain_texture_4,@elevation_1_nw,@elevation_2_nw,@elevation_1_ne, @elevation_2_ne,@elevation_1_se,@elevation_2_se,@elevation_1_sw,@elevation_2_sw,@water_height,@terrain_raise_limit, - @terrain_lower_limit,@use_estate_sun,@fixed_sun,@sun_position,@covenant,@sunvectorx,@sunvectory, @sunvectorz, @Sandbox, @loaded_creation_date, @loaded_creation_time, @loaded_creation_id)"; + @terrain_lower_limit,@use_estate_sun,@fixed_sun,@sun_position,@covenant,@sunvectorx,@sunvectory, @sunvectorz, @Sandbox, @loaded_creation_datetime, @loaded_creation_id)"; using (AutoClosingSqlCommand cmd = _Database.Query(sql)) { @@ -845,15 +845,7 @@ VALUES ); newSettings.Covenant = new UUID((Guid)row["covenant"]); - if (row["loaded_creation_date"] is DBNull) - newSettings.LoadedCreationDate = ""; - else - newSettings.LoadedCreationDate = (String)row["loaded_creation_date"]; - - if (row["loaded_creation_time"] is DBNull) - newSettings.LoadedCreationTime = ""; - else - newSettings.LoadedCreationTime = (String)row["loaded_creation_time"]; + newSettings.LoadedCreationDateTime = Convert.ToInt32(row["loaded_creation_datetime"]); if (row["loaded_creation_id"] is DBNull) newSettings.LoadedCreationID = ""; @@ -1257,8 +1249,7 @@ VALUES parameters.Add(_Database.CreateParameter("sunvectory", settings.SunVector.Y)); parameters.Add(_Database.CreateParameter("sunvectorz", settings.SunVector.Z)); parameters.Add(_Database.CreateParameter("covenant", settings.Covenant)); - parameters.Add(_Database.CreateParameter("LoadedCreationDate", settings.LoadedCreationDate)); - parameters.Add(_Database.CreateParameter("LoadedCreationTime", settings.LoadedCreationTime)); + parameters.Add(_Database.CreateParameter("LoadedCreationDateTime", settings.LoadedCreationDateTime)); parameters.Add(_Database.CreateParameter("LoadedCreationID", settings.LoadedCreationID)); return parameters.ToArray(); diff --git a/OpenSim/Data/MSSQL/Resources/023_RegionStore.sql b/OpenSim/Data/MSSQL/Resources/023_RegionStore.sql new file mode 100644 index 0000000000..61b08f1b38 --- /dev/null +++ b/OpenSim/Data/MSSQL/Resources/023_RegionStore.sql @@ -0,0 +1,7 @@ +BEGIN TRANSACTION + +ALTER TABLE regionsettings DROP COLUMN loaded_creation_date; +ALTER TABLE regionsettings DROP COLUMN loaded_creation_time; +ALTER TABLE regionsettings ADD COLUMN loaded_creation_datetime int unsigned NOT NULL default 0; + +COMMIT diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index 72c089ea0c..a72ae45530 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -741,7 +741,7 @@ namespace OpenSim.Data.MySQL "terrain_raise_limit, terrain_lower_limit, " + "use_estate_sun, fixed_sun, sun_position, " + "covenant, Sandbox, sunvectorx, sunvectory, " + - "sunvectorz, loaded_creation_date, loaded_creation_time, " + + "sunvectorz, loaded_creation_datetime, " + "loaded_creation_id) values ( ?RegionUUID, ?BlockTerraform, " + "?BlockFly, ?AllowDamage, ?RestrictPushing, " + "?AllowLandResell, ?AllowLandJoinDivide, " + @@ -756,7 +756,7 @@ namespace OpenSim.Data.MySQL "?TerrainLowerLimit, ?UseEstateSun, ?FixedSun, " + "?SunPosition, ?Covenant, ?Sandbox, " + "?SunVectorX, ?SunVectorY, ?SunVectorZ, " + - "?LoadedCreationDate, ?LoadedCreationTime, ?LoadedCreationID)"; + "?LoadedCreationDateTime, ?LoadedCreationID)"; FillRegionSettingsCommand(cmd, rs); @@ -1042,15 +1042,7 @@ namespace OpenSim.Data.MySQL newSettings.SunPosition = Convert.ToDouble(row["sun_position"]); newSettings.Covenant = new UUID((String) row["covenant"]); - if (row["loaded_creation_date"] is DBNull) - newSettings.LoadedCreationDate = ""; - else - newSettings.LoadedCreationDate = (String) row["loaded_creation_date"]; - - if (row["loaded_creation_time"] is DBNull) - newSettings.LoadedCreationTime = ""; - else - newSettings.LoadedCreationTime = (String) row["loaded_creation_time"]; + newSettings.LoadedCreationDateTime = Convert.ToInt32(row["loaded_creation_datetime"]); if (row["loaded_creation_id"] is DBNull) newSettings.LoadedCreationID = ""; @@ -1375,8 +1367,7 @@ namespace OpenSim.Data.MySQL cmd.Parameters.AddWithValue("FixedSun", settings.FixedSun); cmd.Parameters.AddWithValue("SunPosition", settings.SunPosition); cmd.Parameters.AddWithValue("Covenant", settings.Covenant.ToString()); - cmd.Parameters.AddWithValue("LoadedCreationDate", settings.LoadedCreationDate); - cmd.Parameters.AddWithValue("LoadedCreationTime", settings.LoadedCreationTime); + cmd.Parameters.AddWithValue("LoadedCreationDateTime", settings.LoadedCreationDate); cmd.Parameters.AddWithValue("LoadedCreationID", settings.LoadedCreationID); } diff --git a/OpenSim/Data/MySQL/Resources/031_RegionStore.sql b/OpenSim/Data/MySQL/Resources/031_RegionStore.sql new file mode 100644 index 0000000000..d069296039 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/031_RegionStore.sql @@ -0,0 +1,7 @@ +BEGIN; + +ALTER TABLE regionsettings DROP COLUMN loaded_creation_date; +ALTER TABLE regionsettings DROP COLUMN loaded_creation_time; +ALTER TABLE regionsettings ADD COLUMN loaded_creation_datetime int unsigned NOT NULL default 0; + +COMMIT; diff --git a/OpenSim/Framework/RegionSettings.cs b/OpenSim/Framework/RegionSettings.cs index c05cc1076a..8d1212bbbc 100644 --- a/OpenSim/Framework/RegionSettings.cs +++ b/OpenSim/Framework/RegionSettings.cs @@ -561,20 +561,31 @@ namespace OpenSim.Framework set { m_Covenant = value; } } - private String m_LoadedCreationDate; + private int m_LoadedCreationDateTime; + public int LoadedCreationDateTime + { + get { return m_LoadedCreationDateTime; } + set { m_LoadedCreationDateTime = value; } + } public String LoadedCreationDate { - get { return m_LoadedCreationDate; } - set { m_LoadedCreationDate = value; } + get + { + TimeSpan ts = new TimeSpan(0, 0, LoadedCreationDateTime); + DateTime stamp = new DateTime(1970, 1, 1) + ts; + return stamp.ToLongDateString(); + } } - private String m_LoadedCreationTime; - public String LoadedCreationTime { - get { return m_LoadedCreationTime; } - set { m_LoadedCreationTime = value; } + get + { + TimeSpan ts = new TimeSpan(0, 0, LoadedCreationDateTime); + DateTime stamp = new DateTime(1970, 1, 1) + ts; + return stamp.ToLongTimeString(); + } } private String m_LoadedCreationID; diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs index d862c06f33..811d4ccd31 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs @@ -128,11 +128,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer private void OnInstantMessage(IClientAPI client, GridInstantMessage im) { + m_log.InfoFormat("OnInstantMessage {0}", im.dialog); Scene scene = FindClientScene(client.AgentId); if (scene == null) // Something seriously wrong here. return; + + if (im.dialog == (byte) InstantMessageDialog.InventoryOffered) { //m_log.DebugFormat("Asset type {0}", ((AssetType)im.binaryBucket[0])); @@ -177,6 +180,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer { // First byte of the array is probably the item type // Next 16 bytes are the UUID + m_log.Info("OnInstantMessage - giving item"); UUID itemID = new UUID(im.binaryBucket, 1); @@ -382,6 +386,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer { // Check if this is ours to handle // + m_log.Info("OnFridInstantMessage"); if (msg.dialog != (byte) InstantMessageDialog.InventoryOffered) return; diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs index 5c596a1ed3..150798b733 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs @@ -504,24 +504,19 @@ namespace OpenSim.Region.CoreModules.World.Archiver RegionSettings currentRegionSettings = m_scene.RegionInfo.RegionSettings; // Loaded metadata will empty if no information exists in the archive - currentRegionSettings.LoadedCreationDate = ""; - currentRegionSettings.LoadedCreationTime = ""; + currentRegionSettings.LoadedCreationDateTime = 0; currentRegionSettings.LoadedCreationID = ""; while (xtr.Read()) { if (xtr.NodeType == XmlNodeType.Element) { - if (xtr.Name.ToString() == "date") + if (xtr.Name.ToString() == "datetime") { - // Disable date & time for now until load problem in - // http://opensimulator.org/mantis/view.php?id=3741 (note 0012120 by WWWench) is resolved - //currentRegionSettings.LoadedCreationDate = xtr.ReadElementContentAsString(); + int value; + if (Int32.TryParse(xtr.ReadElementContentAsString(), out value)) + currentRegionSettings.LoadedCreationDateTime = value; } - else if (xtr.Name.ToString() == "time") - { - //currentRegionSettings.LoadedCreationTime = xtr.ReadElementContentAsString(); - } else if (xtr.Name.ToString() == "id") { currentRegionSettings.LoadedCreationID = xtr.ReadElementContentAsString(); diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestExecution.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestExecution.cs index ac5d0678ac..a62c5b3ce2 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestExecution.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestExecution.cs @@ -152,12 +152,12 @@ namespace OpenSim.Region.CoreModules.World.Archiver xtw.WriteStartDocument(); xtw.WriteStartElement("archive"); xtw.WriteAttributeString("major_version", "0"); - xtw.WriteAttributeString("minor_version", "2"); + xtw.WriteAttributeString("minor_version", "3"); xtw.WriteStartElement("creation_info"); DateTime now = DateTime.UtcNow; - xtw.WriteElementString("date", now.ToLongDateString()); - xtw.WriteElementString("time", now.ToLongTimeString()); + TimeSpan t = now - new DateTime(1970, 1, 1); + xtw.WriteElementString("datetime", ((int)t.TotalSeconds).ToString()); xtw.WriteElementString("id", UUID.Random().ToString()); xtw.WriteEndElement(); xtw.WriteEndElement(); diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 2fc37914ec..f65f834764 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -448,6 +448,8 @@ namespace OpenSim.Region.Framework.Scenes // Retrieve the item from the sender CachedUserInfo senderUserInfo = CommsManager.UserProfileCacheService.GetUserDetails(senderId); + Console.WriteLine("Scene.Inventory.cs: GiveInventoryItem"); + if (senderUserInfo == null) { m_log.ErrorFormat( @@ -1064,6 +1066,7 @@ namespace OpenSim.Region.Framework.Scenes private InventoryItemBase CreateAgentInventoryItemFromTask(UUID destAgent, SceneObjectPart part, UUID itemId) { + Console.WriteLine("CreateAgentInventoryItemFromTask"); TaskInventoryItem taskItem = part.Inventory.GetInventoryItem(itemId); if (null == taskItem) @@ -1133,6 +1136,7 @@ namespace OpenSim.Region.Framework.Scenes /// public InventoryItemBase MoveTaskInventoryItem(IClientAPI remoteClient, UUID folderId, SceneObjectPart part, UUID itemId) { + m_log.Info("Adding task inventory"); InventoryItemBase agentItem = CreateAgentInventoryItemFromTask(remoteClient.AgentId, part, itemId); if (agentItem == null) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 7be7e230c9..5552078760 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -3657,6 +3657,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api byte[] objBytes = objId.GetBytes(); Array.Copy(objBytes, 0, bucket, 1, 16); + Console.WriteLine("Giving inventory"); GridInstantMessage msg = new GridInstantMessage(World, m_host.UUID, m_host.Name+", an object owned by "+ resolveName(m_host.OwnerID)+",", destId,