* Updates the SQLite region database to support the same properties that the MySQL version does for the table, prims.

* If this causes any unit tests to fail, the tests need to be updated.
0.6.0-stable
Teravus Ovares 2008-09-18 17:47:29 +00:00
parent 584704edd3
commit e6f3181d3a
4 changed files with 201 additions and 2 deletions

View File

@ -0,0 +1,28 @@
BEGIN;
ALTER TABLE prims ADD COLUMN PayPrice INTEGER NOT NULL default 0;
ALTER TABLE prims ADD COLUMN PayButton1 INTEGER NOT NULL default 0;
ALTER TABLE prims ADD COLUMN PayButton2 INTEGER NOT NULL default 0;
ALTER TABLE prims ADD COLUMN PayButton3 INTEGER NOT NULL default 0;
ALTER TABLE prims ADD COLUMN PayButton4 INTEGER NOT NULL default 0;
ALTER TABLE prims ADD COLUMN LoopedSound varchar(36) NOT NULL default '00000000-0000-0000-0000-000000000000';
ALTER TABLE prims ADD COLUMN LoopedSoundGain float NOT NULL default 0;
ALTER TABLE prims ADD COLUMN TextureAnimation string;
ALTER TABLE prims ADD COLUMN ParticleSystem string;
ALTER TABLE prims ADD COLUMN OmegaX float NOT NULL default 0;
ALTER TABLE prims ADD COLUMN OmegaY float NOT NULL default 0;
ALTER TABLE prims ADD COLUMN OmegaZ float NOT NULL default 0;
ALTER TABLE prims ADD COLUMN CameraEyeOffsetX float NOT NULL default 0;
ALTER TABLE prims ADD COLUMN CameraEyeOffsetY float NOT NULL default 0;
ALTER TABLE prims ADD COLUMN CameraEyeOffsetZ float NOT NULL default 0;
ALTER TABLE prims ADD COLUMN CameraAtOffsetX float NOT NULL default 0;
ALTER TABLE prims ADD COLUMN CameraAtOffsetY float NOT NULL default 0;
ALTER TABLE prims ADD COLUMN CameraAtOffsetZ float NOT NULL default 0;
ALTER TABLE prims ADD COLUMN ForceMouselook string NOT NULL default 0;
ALTER TABLE prims ADD COLUMN ScriptAccessPin INTEGER NOT NULL default 0;
ALTER TABLE prims ADD COLUMN AllowedDrop INTEGER NOT NULL default 0;
ALTER TABLE prims ADD COLUMN DieAtEdge string NOT NULL default 0;
ALTER TABLE prims ADD COLUMN SalePrice INTEGER NOT NULL default 0;
ALTER TABLE prims ADD COLUMN SaleType string NOT NULL default 0;
COMMIT;

View File

@ -774,6 +774,39 @@ namespace OpenSim.Data.SQLite
createCol(prims, "SitTargetOrientY", typeof (Double));
createCol(prims, "SitTargetOrientZ", typeof (Double));
createCol(prims, "PayPrice", typeof(Int32));
createCol(prims, "PayButton1", typeof(Int32));
createCol(prims, "PayButton2", typeof(Int32));
createCol(prims, "PayButton3", typeof(Int32));
createCol(prims, "PayButton4", typeof(Int32));
createCol(prims, "LoopedSound", typeof(String));
createCol(prims, "LoopedSoundGain", typeof(Double));
createCol(prims, "TextureAnimation", typeof(String));
createCol(prims, "ParticleSystem", typeof(String));
createCol(prims, "OmegaX", typeof(Double));
createCol(prims, "OmegaY", typeof(Double));
createCol(prims, "OmegaZ", typeof(Double));
createCol(prims, "CameraEyeOffsetX", typeof(Double));
createCol(prims, "CameraEyeOffsetY", typeof(Double));
createCol(prims, "CameraEyeOffsetZ", typeof(Double));
createCol(prims, "CameraAtOffsetX", typeof(Double));
createCol(prims, "CameraAtOffsetY", typeof(Double));
createCol(prims, "CameraAtOffsetZ", typeof(Double));
createCol(prims, "ForceMouselook", typeof(Int16));
createCol(prims, "ScriptAccessPin", typeof(Int32));
createCol(prims, "AllowedDrop", typeof(Int16));
createCol(prims, "DieAtEdge", typeof(Int16));
createCol(prims, "SalePrice", typeof(Int32));
createCol(prims, "SaleType", typeof(Int16));
// click action
createCol(prims, "ClickAction", typeof (Byte));
@ -984,9 +1017,29 @@ namespace OpenSim.Data.SQLite
/// <returns></returns>
private SceneObjectPart buildPrim(DataRow row)
{
// Code commented. Uncomment to test the unit test inline.
// The unit test mentions this commented code for the purposes
// of debugging a unit test failure
// SceneObjectGroup sog = new SceneObjectGroup();
// SceneObjectPart sop = new SceneObjectPart();
// sop.LocalId = 1;
// sop.Name = "object1";
// sop.Description = "object1";
// sop.Text = "";
// sop.SitName = "";
// sop.TouchName = "";
// sop.UUID = UUID.Random();
// sop.Shape = PrimitiveBaseShape.Default;
// sog.AddPart(sop);
// sog.RootPart = sop;
// Add breakpoint in above line. Check sop fields.
// TODO: this doesn't work yet because something more
// interesting has to be done to actually get these values
// back out. Not enough time to figure it out yet.
SceneObjectPart prim = new SceneObjectPart();
prim.UUID = new UUID((String) row["UUID"]);
// explicit conversion of integers is required, which sort
@ -1093,6 +1146,52 @@ namespace OpenSim.Data.SQLite
prim.Color = Color.FromArgb(Convert.ToInt32(row["ColorR"]), Convert.ToInt32(row["ColorB"]), Convert.ToInt32(row["ColorG"]));
prim.ClickAction = Convert.ToByte(row["ClickAction"]);
prim.PayPrice[0] = Convert.ToInt32(row["PayPrice"]);
prim.PayPrice[1] = Convert.ToInt32(row["PayButton1"]);
prim.PayPrice[2] = Convert.ToInt32(row["PayButton2"]);
prim.PayPrice[3] = Convert.ToInt32(row["PayButton3"]);
prim.PayPrice[4] = Convert.ToInt32(row["PayButton4"]);
prim.Sound = new UUID(row["LoopedSound"].ToString());
prim.SoundGain = Convert.ToSingle(row["LoopedSoundGain"]);
prim.SoundFlags = 1; // If it's persisted at all, it's looped
if (!row.IsNull("TextureAnimation"))
prim.TextureAnimation = Convert.FromBase64String(row["TextureAnimation"].ToString());
if (!row.IsNull("ParticleSystem"))
prim.ParticleSystem = Convert.FromBase64String(row["ParticleSystem"].ToString());
prim.RotationalVelocity = new Vector3(
Convert.ToSingle(row["OmegaX"]),
Convert.ToSingle(row["OmegaY"]),
Convert.ToSingle(row["OmegaZ"])
);
prim.SetCameraEyeOffset(new Vector3(
Convert.ToSingle(row["CameraEyeOffsetX"]),
Convert.ToSingle(row["CameraEyeOffsetY"]),
Convert.ToSingle(row["CameraEyeOffsetZ"])
));
prim.SetCameraAtOffset(new Vector3(
Convert.ToSingle(row["CameraAtOffsetX"]),
Convert.ToSingle(row["CameraAtOffsetY"]),
Convert.ToSingle(row["CameraAtOffsetZ"])
));
if (Convert.ToInt16(row["ForceMouselook"]) != 0)
prim.SetForceMouselook(true);
prim.ScriptAccessPin = Convert.ToInt32(row["ScriptAccessPin"]);
if (Convert.ToInt16(row["AllowedDrop"]) != 0)
prim.AllowedDrop = true;
if (Convert.ToInt16(row["DieAtEdge"]) != 0)
prim.DIE_AT_EDGE = true;
prim.SalePrice = Convert.ToInt32(row["SalePrice"]);
prim.ObjectSaleType = Convert.ToByte(row["SaleType"]);
return prim;
}
@ -1383,6 +1482,59 @@ namespace OpenSim.Data.SQLite
row["ColorG"] = Convert.ToInt32(prim.Color.G);
row["ColorB"] = Convert.ToInt32(prim.Color.B);
row["ColorA"] = Convert.ToInt32(prim.Color.A);
row["PayPrice"] = prim.PayPrice[0];
row["PayButton1"] = prim.PayPrice[1];
row["PayButton2"] = prim.PayPrice[2];
row["PayButton3"] = prim.PayPrice[3];
row["PayButton4"] = prim.PayPrice[4];
row["TextureAnimation"] = Convert.ToBase64String(prim.TextureAnimation);
row["ParticleSystem"] = Convert.ToBase64String(prim.ParticleSystem);
row["OmegaX"] = prim.RotationalVelocity.X;
row["OmegaY"] = prim.RotationalVelocity.Y;
row["OmegaZ"] = prim.RotationalVelocity.Z;
row["CameraEyeOffsetX"] = prim.GetCameraEyeOffset().X;
row["CameraEyeOffsetY"] = prim.GetCameraEyeOffset().Y;
row["CameraEyeOffsetZ"] = prim.GetCameraEyeOffset().Z;
row["CameraAtOffsetX"] = prim.GetCameraAtOffset().X;
row["CameraAtOffsetY"] = prim.GetCameraAtOffset().Y;
row["CameraAtOffsetZ"] = prim.GetCameraAtOffset().Z;
if ((prim.SoundFlags & 1) != 0) // Looped
{
row["LoopedSound"] = prim.Sound.ToString();
row["LoopedSoundGain"] = prim.SoundGain;
}
else
{
row["LoopedSound"] = UUID.Zero.ToString();
row["LoopedSoundGain"] = 0.0f;
}
if (prim.GetForceMouselook())
row["ForceMouselook"] = 1;
else
row["ForceMouselook"] = 0;
row["ScriptAccessPin"] = prim.ScriptAccessPin;
if (prim.AllowedDrop)
row["AllowedDrop"] = 1;
else
row["AllowedDrop"] = 0;
if (prim.DIE_AT_EDGE)
row["DieAtEdge"] = 1;
else
row["DieAtEdge"] = 0;
row["SalePrice"] = prim.SalePrice;
row["SaleType"] = Convert.ToInt16(prim.ObjectSaleType);
// click action
row["ClickAction"] = prim.ClickAction;

View File

@ -205,6 +205,14 @@ namespace OpenSim.Data.Tests
// common failure case is people adding new fields that aren't
// initialized, but have non-null db constraints. We should
// honestly be passing more and more null things in here.
//
// Please note that in Sqlite.BuildPrim there is a commented out inline version
// of this so you can debug and step through the build process and check the fields
//
// Real World Value: Tests for situation where extending a SceneObjectGroup/SceneObjectPart
// causes the application to crash at the database layer because of null values
// in NOT NULL fields
//
private SceneObjectGroup NewSOG(string name)
{
SceneObjectGroup sog = new SceneObjectGroup();
@ -218,7 +226,8 @@ namespace OpenSim.Data.Tests
sop.UUID = UUID.Random();
sop.Shape = PrimitiveBaseShape.Default;
sog.AddPart(sop);
sog.RootPart = sop;
sog.RootPart = sop;
return sog;
}

View File

@ -211,6 +211,7 @@ namespace OpenSim.Region.Environment.Scenes
{
// It's not necessary to persist this
m_TextureAnimation = new byte[0];
m_particleSystem = new byte[0];
}
public SceneObjectPart(ulong regionHandle, SceneObjectGroup parent, UUID ownerID, uint localID,
@ -256,7 +257,13 @@ namespace OpenSim.Region.Environment.Scenes
Velocity = new Vector3(0, 0, 0);
AngularVelocity = new Vector3(0, 0, 0);
Acceleration = new Vector3(0, 0, 0);
m_TextureAnimation = new byte[0];
m_particleSystem = new byte[0];
// Prims currently only contain a single folder (Contents). From looking at the Second Life protocol,
// this appears to have the same UUID (!) as the prim. If this isn't the case, one can't drag items from
@ -304,6 +311,8 @@ namespace OpenSim.Region.Environment.Scenes
RotationOffset = rotation;
ObjectFlags = flags;
m_TextureAnimation = new byte[0];
m_particleSystem = new byte[0];
// Since we don't store script state, this is only a 'temporary' objectflag now
// If the object is scripted, the script will get loaded and this will be set again
ObjectFlags &= ~(uint)(PrimFlags.Scripted | PrimFlags.Touch);
@ -317,7 +326,8 @@ namespace OpenSim.Region.Environment.Scenes
protected SceneObjectPart(SerializationInfo info, StreamingContext context)
{
//System.Console.WriteLine("SceneObjectPart Deserialize BGN");
m_TextureAnimation = new byte[0];
m_particleSystem = new byte[0];
if (info == null)
{
throw new ArgumentNullException("info");