From a3e1e6dd611a179eb2d894a45ae45ef278ae2e85 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Mon, 16 Aug 2010 21:57:08 +0100 Subject: [PATCH] Implement dynamic attribute persistence on mysql and mssql mssql is untested --- OpenSim/Data/MSSQL/MSSQLSimulationData.cs | 23 ++++++++++++++----- .../MSSQL/Resources/RegionStore.migrations | 9 ++++++++ OpenSim/Data/MySQL/MySQLSimulationData.cs | 16 +++++++++++-- .../MySQL/Resources/RegionStore.migrations | 9 ++++++++ 4 files changed, 49 insertions(+), 8 deletions(-) diff --git a/OpenSim/Data/MSSQL/MSSQLSimulationData.cs b/OpenSim/Data/MSSQL/MSSQLSimulationData.cs index 17f42e1f0b..e9497389c8 100644 --- a/OpenSim/Data/MSSQL/MSSQLSimulationData.cs +++ b/OpenSim/Data/MSSQL/MSSQLSimulationData.cs @@ -351,7 +351,7 @@ IF EXISTS (SELECT UUID FROM prims WHERE UUID = @UUID) ScriptAccessPin = @ScriptAccessPin, AllowedDrop = @AllowedDrop, DieAtEdge = @DieAtEdge, SalePrice = @SalePrice, SaleType = @SaleType, ColorR = @ColorR, ColorG = @ColorG, ColorB = @ColorB, ColorA = @ColorA, ParticleSystem = @ParticleSystem, ClickAction = @ClickAction, Material = @Material, CollisionSound = @CollisionSound, CollisionSoundVolume = @CollisionSoundVolume, PassTouches = @PassTouches, - LinkNumber = @LinkNumber, MediaURL = @MediaURL + LinkNumber = @LinkNumber, MediaURL = @MediaURL, DynAttrs = @DynAttrs WHERE UUID = @UUID END ELSE @@ -366,7 +366,7 @@ ELSE PayPrice, PayButton1, PayButton2, PayButton3, PayButton4, LoopedSound, LoopedSoundGain, TextureAnimation, OmegaX, OmegaY, OmegaZ, CameraEyeOffsetX, CameraEyeOffsetY, CameraEyeOffsetZ, CameraAtOffsetX, CameraAtOffsetY, CameraAtOffsetZ, ForceMouselook, ScriptAccessPin, AllowedDrop, DieAtEdge, SalePrice, SaleType, ColorR, ColorG, ColorB, ColorA, - ParticleSystem, ClickAction, Material, CollisionSound, CollisionSoundVolume, PassTouches, LinkNumber, MediaURL + ParticleSystem, ClickAction, Material, CollisionSound, CollisionSoundVolume, PassTouches, LinkNumber, MediaURL, DynAttrs ) VALUES ( @UUID, @CreationDate, @Name, @Text, @Description, @SitName, @TouchName, @ObjectFlags, @OwnerMask, @NextOwnerMask, @GroupMask, @EveryoneMask, @BaseMask, @PositionX, @PositionY, @PositionZ, @GroupPositionX, @GroupPositionY, @GroupPositionZ, @VelocityX, @@ -376,7 +376,7 @@ ELSE @PayPrice, @PayButton1, @PayButton2, @PayButton3, @PayButton4, @LoopedSound, @LoopedSoundGain, @TextureAnimation, @OmegaX, @OmegaY, @OmegaZ, @CameraEyeOffsetX, @CameraEyeOffsetY, @CameraEyeOffsetZ, @CameraAtOffsetX, @CameraAtOffsetY, @CameraAtOffsetZ, @ForceMouselook, @ScriptAccessPin, @AllowedDrop, @DieAtEdge, @SalePrice, @SaleType, @ColorR, @ColorG, @ColorB, @ColorA, - @ParticleSystem, @ClickAction, @Material, @CollisionSound, @CollisionSoundVolume, @PassTouches, @LinkNumber, @MediaURL + @ParticleSystem, @ClickAction, @Material, @CollisionSound, @CollisionSoundVolume, @PassTouches, @LinkNumber, @MediaURL, @DynAttrs ) END"; @@ -409,7 +409,7 @@ IF EXISTS (SELECT UUID FROM primshapes WHERE UUID = @UUID) PathSkew = @PathSkew, PathCurve = @PathCurve, PathRadiusOffset = @PathRadiusOffset, PathRevolutions = @PathRevolutions, PathTaperX = @PathTaperX, PathTaperY = @PathTaperY, PathTwist = @PathTwist, PathTwistBegin = @PathTwistBegin, ProfileBegin = @ProfileBegin, ProfileEnd = @ProfileEnd, ProfileCurve = @ProfileCurve, ProfileHollow = @ProfileHollow, - Texture = @Texture, ExtraParams = @ExtraParams, State = @State, Media = @Media + Texture = @Texture, ExtraParams = @ExtraParams, State = @State, Media = @Media, DynAttrs = @DynAttrs WHERE UUID = @UUID END ELSE @@ -418,11 +418,11 @@ ELSE primshapes ( UUID, Shape, ScaleX, ScaleY, ScaleZ, PCode, PathBegin, PathEnd, PathScaleX, PathScaleY, PathShearX, PathShearY, PathSkew, PathCurve, PathRadiusOffset, PathRevolutions, PathTaperX, PathTaperY, PathTwist, PathTwistBegin, ProfileBegin, - ProfileEnd, ProfileCurve, ProfileHollow, Texture, ExtraParams, State, Media + ProfileEnd, ProfileCurve, ProfileHollow, Texture, ExtraParams, State, Media, DynAttrs ) VALUES ( @UUID, @Shape, @ScaleX, @ScaleY, @ScaleZ, @PCode, @PathBegin, @PathEnd, @PathScaleX, @PathScaleY, @PathShearX, @PathShearY, @PathSkew, @PathCurve, @PathRadiusOffset, @PathRevolutions, @PathTaperX, @PathTaperY, @PathTwist, @PathTwistBegin, @ProfileBegin, - @ProfileEnd, @ProfileCurve, @ProfileHollow, @Texture, @ExtraParams, @State, @Media + @ProfileEnd, @ProfileCurve, @ProfileHollow, @Texture, @ExtraParams, @State, @Media, @DynAttrs ) END"; @@ -1691,6 +1691,11 @@ VALUES if (!(primRow["MediaURL"] is System.DBNull)) prim.MediaUrl = (string)primRow["MediaURL"]; + + if (!(primRow["DynAttrs"] is System.DBNull)) + prim.DynAttrs = DynAttrsOSDMap.FromXml((string)primRow["DynAttrs"]); + else + prim.DynAttrs = new DynAttrsOSDMap(); return prim; } @@ -1749,6 +1754,10 @@ VALUES baseShape.Media = PrimitiveBaseShape.MediaList.FromXml((string)shapeRow["Media"]); } + if (!(shapeRow["DynAttrs"] is System.DBNull)) + baseShape.DynAttrs = DynAttrsOSDMap.FromXml((string)shapeRow["DynAttrs"]); + else + baseShape.DynAttrs = new DynAttrsOSDMap(); return baseShape; } @@ -2086,6 +2095,7 @@ VALUES parameters.Add(_Database.CreateParameter("PassTouches", 0)); parameters.Add(_Database.CreateParameter("LinkNumber", prim.LinkNum)); parameters.Add(_Database.CreateParameter("MediaURL", prim.MediaUrl)); + parameters.Add(_Database.CreateParameter("DynAttrs", prim.DynAttrs.ToXml())); return parameters.ToArray(); } @@ -2143,6 +2153,7 @@ VALUES parameters.Add(_Database.CreateParameter("Media", s.Media.ToXml())); } + parameters.Add(_Database.CreateParameter("DynAttrs", s.DynAttrs.ToXml())); return parameters.ToArray(); } diff --git a/OpenSim/Data/MSSQL/Resources/RegionStore.migrations b/OpenSim/Data/MSSQL/Resources/RegionStore.migrations index 350e548a0a..5e88e36eb4 100644 --- a/OpenSim/Data/MSSQL/Resources/RegionStore.migrations +++ b/OpenSim/Data/MSSQL/Resources/RegionStore.migrations @@ -1148,3 +1148,12 @@ CREATE TABLE [dbo].[regionenvironment]( ) ON [PRIMARY] COMMIT + +:VERSION 38 #---------------- Dynamic attributes + +BEGIN TRANSACTION + +ALTER TABLE prims ADD COLUMN DynAttrs TEXT; +ALTER TABLE primshapes ADD COLUMN DynAttrs TEXT; + +COMMIT diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs index d56278354c..b7f39fba6f 100644 --- a/OpenSim/Data/MySQL/MySQLSimulationData.cs +++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs @@ -202,7 +202,7 @@ namespace OpenSim.Data.MySQL "?SaleType, ?ColorR, ?ColorG, " + "?ColorB, ?ColorA, ?ParticleSystem, " + "?ClickAction, ?Material, ?CollisionSound, " + - "?CollisionSoundVolume, ?PassTouches, ?LinkNumber, ?MediaURL)"; + "?CollisionSoundVolume, ?PassTouches, ?LinkNumber, ?MediaURL, ?DynAttrs)"; FillPrimCommand(cmd, prim, obj.UUID, regionUUID); @@ -230,7 +230,7 @@ namespace OpenSim.Data.MySQL "?PathTwistBegin, ?ProfileBegin, " + "?ProfileEnd, ?ProfileCurve, " + "?ProfileHollow, ?Texture, ?ExtraParams, " + - "?State, ?Media)"; + "?State, ?Media, ?DynAttrs)"; FillShapeCommand(cmd, prim); @@ -1291,6 +1291,11 @@ namespace OpenSim.Data.MySQL if (!(row["MediaURL"] is System.DBNull)) prim.MediaUrl = (string)row["MediaURL"]; + + if (!(row["DynAttrs"] is System.DBNull)) + prim.DynAttrs = DynAttrsOSDMap.FromXml((string)row["DynAttrs"]); + else + prim.DynAttrs = new DynAttrsOSDMap(); return prim; } @@ -1637,6 +1642,7 @@ namespace OpenSim.Data.MySQL cmd.Parameters.AddWithValue("LinkNumber", prim.LinkNum); cmd.Parameters.AddWithValue("MediaURL", prim.MediaUrl); + cmd.Parameters.AddWithValue("DynAttrs", prim.DynAttrs.ToXml()); } /// @@ -1829,6 +1835,11 @@ namespace OpenSim.Data.MySQL if (!(row["Media"] is System.DBNull)) s.Media = PrimitiveBaseShape.MediaList.FromXml((string)row["Media"]); + + if (!(row["DynAttrs"] is System.DBNull)) + s.DynAttrs = DynAttrsOSDMap.FromXml((string)row["DynAttrs"]); + else + s.DynAttrs = new DynAttrsOSDMap(); return s; } @@ -1873,6 +1884,7 @@ namespace OpenSim.Data.MySQL cmd.Parameters.AddWithValue("ExtraParams", s.ExtraParams); cmd.Parameters.AddWithValue("State", s.State); cmd.Parameters.AddWithValue("Media", null == s.Media ? null : s.Media.ToXml()); + cmd.Parameters.AddWithValue("DynAttrs", s.DynAttrs.ToXml()); } public void StorePrimInventory(UUID primID, ICollection items) diff --git a/OpenSim/Data/MySQL/Resources/RegionStore.migrations b/OpenSim/Data/MySQL/Resources/RegionStore.migrations index 5b59779050..1a38836ef1 100644 --- a/OpenSim/Data/MySQL/Resources/RegionStore.migrations +++ b/OpenSim/Data/MySQL/Resources/RegionStore.migrations @@ -902,3 +902,12 @@ BEGIN; CREATE TABLE `regionextra` (`RegionID` char(36) not null, `Name` varchar(32) not null, `value` text, primary key(`RegionID`, `Name`)); COMMIT; + +:VERSION 46 #---------------- Dynamic attributes + +BEGIN; + +ALTER TABLE prims ADD COLUMN DynAttrs TEXT; +ALTER TABLE primshapes ADD COLUMN DynAttrs TEXT; + +COMMIT;