Implement proper persistence of the following prim properties:

Floating text, Rotation, Texture animation, Particle System
This will make "Eye Candy" scripts work without modification in
XEngine. The use of the CHANGED_REGION_RESTART hack is no longer
needed. Implemented in MySQL only, hovertext also in SQLite.
0.6.0-stable
Melanie Thielker 2008-09-08 02:40:20 +00:00
parent 4822e79759
commit 490ac0be00
14 changed files with 102 additions and 15 deletions

View File

@ -31,6 +31,7 @@ using System.Data;
using System.IO; using System.IO;
using System.Reflection; using System.Reflection;
using System.Threading; using System.Threading;
using System.Drawing;
using OpenMetaverse; using OpenMetaverse;
using log4net; using log4net;
using MySql.Data.MySqlClient; using MySql.Data.MySqlClient;
@ -858,6 +859,10 @@ namespace OpenSim.Data.MySQL
createCol(prims, "SceneGroupID", typeof (String)); createCol(prims, "SceneGroupID", typeof (String));
// various text fields // various text fields
createCol(prims, "Text", typeof (String)); createCol(prims, "Text", typeof (String));
createCol(prims, "ColorR", typeof (Int32));
createCol(prims, "ColorG", typeof (Int32));
createCol(prims, "ColorB", typeof (Int32));
createCol(prims, "ColorA", typeof (Int32));
createCol(prims, "Description", typeof (String)); createCol(prims, "Description", typeof (String));
createCol(prims, "SitName", typeof (String)); createCol(prims, "SitName", typeof (String));
createCol(prims, "TouchName", typeof (String)); createCol(prims, "TouchName", typeof (String));
@ -912,6 +917,7 @@ namespace OpenSim.Data.MySQL
createCol(prims, "LoopedSound", typeof(String)); createCol(prims, "LoopedSound", typeof(String));
createCol(prims, "LoopedSoundGain", typeof(Double)); createCol(prims, "LoopedSoundGain", typeof(Double));
createCol(prims, "TextureAnimation", typeof(Byte[])); createCol(prims, "TextureAnimation", typeof(Byte[]));
createCol(prims, "ParticleSystem", typeof(Byte[]));
createCol(prims, "OmegaX", typeof (Double)); createCol(prims, "OmegaX", typeof (Double));
createCol(prims, "OmegaY", typeof (Double)); createCol(prims, "OmegaY", typeof (Double));
@ -1109,6 +1115,10 @@ namespace OpenSim.Data.MySQL
prim.Name = (String) row["Name"]; prim.Name = (String) row["Name"];
// various text fields // various text fields
prim.Text = (String) row["Text"]; prim.Text = (String) row["Text"];
prim.Color = Color.FromArgb(Convert.ToInt32(row["ColorA"]),
Convert.ToInt32(row["ColorR"]),
Convert.ToInt32(row["ColorG"]),
Convert.ToInt32(row["ColorB"]));
prim.Description = (String) row["Description"]; prim.Description = (String) row["Description"];
prim.SitName = (String) row["SitName"]; prim.SitName = (String) row["SitName"];
prim.TouchName = (String) row["TouchName"]; prim.TouchName = (String) row["TouchName"];
@ -1180,6 +1190,8 @@ namespace OpenSim.Data.MySQL
if (!row.IsNull("TextureAnimation")) if (!row.IsNull("TextureAnimation"))
prim.TextureAnimation = (Byte[])row["TextureAnimation"]; prim.TextureAnimation = (Byte[])row["TextureAnimation"];
if (!row.IsNull("ParticleSystem"))
prim.ParticleSystem = (Byte[])row["ParticleSystem"];
prim.RotationalVelocity = new Vector3( prim.RotationalVelocity = new Vector3(
Convert.ToSingle(row["OmegaX"]), Convert.ToSingle(row["OmegaX"]),
@ -1187,9 +1199,6 @@ namespace OpenSim.Data.MySQL
Convert.ToSingle(row["OmegaZ"]) Convert.ToSingle(row["OmegaZ"])
); );
// TODO: Rotation
// OmegaX, OmegaY, OmegaZ
prim.SetCameraEyeOffset(new Vector3( prim.SetCameraEyeOffset(new Vector3(
Convert.ToSingle(row["CameraEyeOffsetX"]), Convert.ToSingle(row["CameraEyeOffsetX"]),
Convert.ToSingle(row["CameraEyeOffsetY"]), Convert.ToSingle(row["CameraEyeOffsetY"]),
@ -1419,6 +1428,10 @@ namespace OpenSim.Data.MySQL
// the UUID of the root part for this SceneObjectGroup // the UUID of the root part for this SceneObjectGroup
// various text fields // various text fields
row["Text"] = prim.Text; row["Text"] = prim.Text;
row["ColorR"] = prim.Color.R;
row["ColorG"] = prim.Color.G;
row["ColorB"] = prim.Color.B;
row["ColorA"] = prim.Color.A;
row["Description"] = prim.Description; row["Description"] = prim.Description;
row["SitName"] = prim.SitName; row["SitName"] = prim.SitName;
row["TouchName"] = prim.TouchName; row["TouchName"] = prim.TouchName;
@ -1485,6 +1498,7 @@ namespace OpenSim.Data.MySQL
} }
row["TextureAnimation"] = prim.TextureAnimation; row["TextureAnimation"] = prim.TextureAnimation;
row["ParticleSystem"] = prim.ParticleSystem;
row["OmegaX"] = prim.RotationalVelocity.X; row["OmegaX"] = prim.RotationalVelocity.X;
row["OmegaY"] = prim.RotationalVelocity.Y; row["OmegaY"] = prim.RotationalVelocity.Y;

View File

@ -0,0 +1,9 @@
BEGIN;
ALTER TABLE prims ADD COLUMN ColorR integer not null default 0;
ALTER TABLE prims ADD COLUMN ColorG integer not null default 0;
ALTER TABLE prims ADD COLUMN ColorB integer not null default 0;
ALTER TABLE prims ADD COLUMN ColorA integer not null default 0;
ALTER TABLE prims ADD COLUMN ParticleSystem blob;
COMMIT;

View File

@ -0,0 +1,8 @@
BEGIN;
ALTER TABLE prims ADD COLUMN ColorR integer not null default 0;
ALTER TABLE prims ADD COLUMN ColorG integer not null default 0;
ALTER TABLE prims ADD COLUMN ColorB integer not null default 0;
ALTER TABLE prims ADD COLUMN ColorA integer not null default 0;
COMMIT;

View File

@ -31,6 +31,7 @@ using System.Data;
using System.IO; using System.IO;
using System.Reflection; using System.Reflection;
using System.Threading; using System.Threading;
using System.Drawing;
using OpenMetaverse; using OpenMetaverse;
using log4net; using log4net;
using Mono.Data.SqliteClient; using Mono.Data.SqliteClient;
@ -666,6 +667,10 @@ namespace OpenSim.Data.SQLite
createCol(prims, "SceneGroupID", typeof (String)); createCol(prims, "SceneGroupID", typeof (String));
// various text fields // various text fields
createCol(prims, "Text", typeof (String)); createCol(prims, "Text", typeof (String));
createCol(prims, "ColorR", typeof (Int32));
createCol(prims, "ColorG", typeof (Int32));
createCol(prims, "ColorB", typeof (Int32));
createCol(prims, "ColorA", typeof (Int32));
createCol(prims, "Description", typeof (String)); createCol(prims, "Description", typeof (String));
createCol(prims, "SitName", typeof (String)); createCol(prims, "SitName", typeof (String));
createCol(prims, "TouchName", typeof (String)); createCol(prims, "TouchName", typeof (String));
@ -890,6 +895,10 @@ namespace OpenSim.Data.SQLite
prim.Name = (String) row["Name"]; prim.Name = (String) row["Name"];
// various text fields // various text fields
prim.Text = (String) row["Text"]; prim.Text = (String) row["Text"];
prim.Color = Color.FromArgb(Convert.ToInt32(row["ColorA"]),
Convert.ToInt32(row["ColorR"]),
Convert.ToInt32(row["ColorG"]),
Convert.ToInt32(row["ColorB"]));
prim.Description = (String) row["Description"]; prim.Description = (String) row["Description"];
prim.SitName = (String) row["SitName"]; prim.SitName = (String) row["SitName"];
prim.TouchName = (String) row["TouchName"]; prim.TouchName = (String) row["TouchName"];

View File

@ -111,6 +111,10 @@ namespace OpenSim.Framework
{ {
PacketType type = GetType(bytes); PacketType type = GetType(bytes);
int z;
for (z = 0 ; z < zeroBuffer.Length ; z++)
zeroBuffer[z] = (byte)0;
int i = 0; int i = 0;
Packet packet = GetPacket(type); Packet packet = GetPacket(type);
packet.FromBytes(bytes, ref i, ref packetEnd, zeroBuffer); packet.FromBytes(bytes, ref i, ref packetEnd, zeroBuffer);

View File

@ -213,6 +213,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP
if (ok) if (ok)
{ {
// Make sure we are getting zeroes when running off the
// end of grab / degrab packets from old clients
//
int z;
for (z = numBytes ; z < RecvBuffer.Length ; z++)
RecvBuffer[z] = (byte)0;
epProxy = epSender; epProxy = epSender;
if (proxyPortOffset != 0) if (proxyPortOffset != 0)
{ {

View File

@ -1131,6 +1131,10 @@ namespace OpenSim.Region.Environment.Scenes
Name, UUID, m_scene.RegionInfo.RegionName); Name, UUID, m_scene.RegionInfo.RegionName);
SceneObjectGroup backup_group = Copy(OwnerID, GroupID, false); SceneObjectGroup backup_group = Copy(OwnerID, GroupID, false);
backup_group.RootPart.Velocity = RootPart.Velocity;
backup_group.RootPart.Acceleration = RootPart.Acceleration;
backup_group.RootPart.AngularVelocity = RootPart.AngularVelocity;
backup_group.RootPart.ParticleSystem = RootPart.ParticleSystem;
datastore.StoreObject(backup_group, m_scene.RegionInfo.RegionID); datastore.StoreObject(backup_group, m_scene.RegionInfo.RegionID);
HasGroupChanged = false; HasGroupChanged = false;

View File

@ -433,6 +433,13 @@ namespace OpenSim.Region.Environment.Scenes
set { m_TextureAnimation = value; } set { m_TextureAnimation = value; }
} }
[XmlIgnore]
public Byte[] ParticleSystem
{
get { return m_particleSystem; }
set { m_particleSystem = value; }
}
public Vector3 GroupPosition public Vector3 GroupPosition
{ {
get get
@ -1212,9 +1219,9 @@ namespace OpenSim.Region.Environment.Scenes
dupe.GroupPosition = GroupPosition; dupe.GroupPosition = GroupPosition;
dupe.OffsetPosition = OffsetPosition; dupe.OffsetPosition = OffsetPosition;
dupe.RotationOffset = RotationOffset; dupe.RotationOffset = RotationOffset;
dupe.Velocity = Vector3.Zero; dupe.Velocity = new Vector3(0, 0, 0);
dupe.Acceleration = Vector3.Zero; dupe.Acceleration = new Vector3(0, 0, 0);
dupe.AngularVelocity = Vector3.Zero; dupe.AngularVelocity = new Vector3(0, 0, 0);
dupe.ObjectFlags = ObjectFlags; dupe.ObjectFlags = ObjectFlags;
dupe._ownershipCost = _ownershipCost; dupe._ownershipCost = _ownershipCost;

View File

@ -53,6 +53,7 @@ namespace OpenSim.Region.ScriptEngine.Interfaces
public interface IScriptInstance public interface IScriptInstance
{ {
bool Running { get; set; } bool Running { get; set; }
bool ShuttingDown { get; set; }
string State { get; set; } string State { get; set; }
IScriptEngine Engine { get; } IScriptEngine Engine { get; }
UUID AppDomain { get; set; } UUID AppDomain { get; set; }

View File

@ -2173,7 +2173,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams(
"object_rez", new Object[] { "object_rez", new Object[] {
new LSL_Types.LSLString( new LSL_Types.LSLString(
new_group.RootPart.ToString()) }, new_group.RootPart.UUID.ToString()) },
new DetectParams[0])); new DetectParams[0]));
float groupmass = new_group.GetMass(); float groupmass = new_group.GetMass();
@ -2542,6 +2542,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
m_host.AngularVelocity = new Vector3((float)(axis.x * spinrate), (float)(axis.y * spinrate), (float)(axis.z * spinrate)); m_host.AngularVelocity = new Vector3((float)(axis.x * spinrate), (float)(axis.y * spinrate), (float)(axis.z * spinrate));
m_host.ScheduleTerseUpdate(); m_host.ScheduleTerseUpdate();
m_host.SendTerseUpdateToAllClients(); m_host.SendTerseUpdateToAllClients();
m_host.ParentGroup.HasGroupChanged = true;
} }
public LSL_Types.LSLInteger llGetStartParameter() public LSL_Types.LSLInteger llGetStartParameter()
@ -3009,6 +3010,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
Vector3 av3 = new Vector3((float)color.x, (float)color.y, (float)color.z); Vector3 av3 = new Vector3((float)color.x, (float)color.y, (float)color.z);
m_host.SetText(text, av3, alpha); m_host.SetText(text, av3, alpha);
m_host.ParentGroup.HasGroupChanged = true;
} }
public double llWater(LSL_Types.Vector3 offset) public double llWater(LSL_Types.Vector3 offset)
@ -4396,6 +4398,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
m_host.AddTextureAnimation(pTexAnim); m_host.AddTextureAnimation(pTexAnim);
m_host.SendFullUpdateToAllClients(); m_host.SendFullUpdateToAllClients();
m_host.ParentGroup.HasGroupChanged = true;
} }
public void llTriggerSoundLimited(string sound, double volume, LSL_Types.Vector3 top_north_east, public void llTriggerSoundLimited(string sound, double volume, LSL_Types.Vector3 top_north_east,
@ -4713,6 +4716,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (rules.Length == 0) if (rules.Length == 0)
{ {
m_host.RemoveParticleSystem(); m_host.RemoveParticleSystem();
m_host.ParentGroup.HasGroupChanged = true;
} }
else else
{ {
@ -4857,6 +4861,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
prules.CRC = 1; prules.CRC = 1;
m_host.AddNewParticleSystem(prules); m_host.AddNewParticleSystem(prules);
m_host.ParentGroup.HasGroupChanged = true;
} }
m_host.SendFullUpdateToAllClients(); m_host.SendFullUpdateToAllClients();
} }
@ -7260,10 +7265,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return; return;
} }
m_host.ParentGroup.RootPart.PayPrice[0]=price; m_host.ParentGroup.RootPart.PayPrice[0]=price;
m_host.ParentGroup.RootPart.PayPrice[1]=(int)quick_pay_buttons.Data[0];
m_host.ParentGroup.RootPart.PayPrice[2]=(int)quick_pay_buttons.Data[1]; m_host.ParentGroup.RootPart.PayPrice[1]=(LSL_Types.LSLInteger)quick_pay_buttons.Data[0];
m_host.ParentGroup.RootPart.PayPrice[3]=(int)quick_pay_buttons.Data[2]; m_host.ParentGroup.RootPart.PayPrice[2]=(LSL_Types.LSLInteger)quick_pay_buttons.Data[1];
m_host.ParentGroup.RootPart.PayPrice[4]=(int)quick_pay_buttons.Data[3]; m_host.ParentGroup.RootPart.PayPrice[3]=(LSL_Types.LSLInteger)quick_pay_buttons.Data[2];
m_host.ParentGroup.RootPart.PayPrice[4]=(LSL_Types.LSLInteger)quick_pay_buttons.Data[3];
m_host.ParentGroup.HasGroupChanged = true;
} }
public LSL_Types.Vector3 llGetCameraPos() public LSL_Types.Vector3 llGetCameraPos()

View File

@ -260,7 +260,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
public const int CHANGED_REGION_RESTART = 256; public const int CHANGED_REGION_RESTART = 256;
public const int TYPE_INVALID = 0; public const int TYPE_INVALID = 0;
public const int TYPE_INTEGER = 1; public const int TYPE_INTEGER = 1;
public const int TYPE_double = 2; public const int TYPE_FLOAT = 2;
public const int TYPE_STRING = 3; public const int TYPE_STRING = 3;
public const int TYPE_KEY = 4; public const int TYPE_KEY = 4;
public const int TYPE_VECTOR = 5; public const int TYPE_VECTOR = 5;

View File

@ -74,6 +74,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
private bool m_InSelfDelete = false; private bool m_InSelfDelete = false;
private int m_MaxScriptQueue; private int m_MaxScriptQueue;
private bool m_SaveState = true; private bool m_SaveState = true;
private bool m_ShuttingDown = false;
private Dictionary<string,IScriptApi> m_Apis = new Dictionary<string,IScriptApi>(); private Dictionary<string,IScriptApi> m_Apis = new Dictionary<string,IScriptApi>();
@ -88,6 +89,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
set { m_RunEvents = value; } set { m_RunEvents = value; }
} }
public bool ShuttingDown
{
get { return m_ShuttingDown; }
set { m_ShuttingDown = value; }
}
public string State public string State
{ {
get { return m_State; } get { return m_State; }
@ -248,7 +255,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
m_Engine.Log.DebugFormat("[Script] Successfully retrieved state for script {0}.{1}", m_PrimName, m_ScriptName); m_Engine.Log.DebugFormat("[Script] Successfully retrieved state for script {0}.{1}", m_PrimName, m_ScriptName);
if (m_RunEvents) if (m_RunEvents && (!m_ShuttingDown))
{ {
m_RunEvents = false; m_RunEvents = false;
Start(); Start();
@ -517,7 +524,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
{ {
lock (m_EventQueue) lock (m_EventQueue)
{ {
if ((m_EventQueue.Count > 0) && m_RunEvents) if ((m_EventQueue.Count > 0) && m_RunEvents && (!m_ShuttingDown))
{ {
m_CurrentResult=m_Engine.QueueEventHandler(this); m_CurrentResult=m_Engine.QueueEventHandler(this);
} }
@ -564,7 +571,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
lock (m_EventQueue) lock (m_EventQueue)
{ {
if ((m_EventQueue.Count > 0) && m_RunEvents) if ((m_EventQueue.Count > 0) && m_RunEvents && (!m_ShuttingDown))
{ {
m_CurrentResult = m_Engine.QueueEventHandler(this); m_CurrentResult = m_Engine.QueueEventHandler(this);
} }

View File

@ -856,7 +856,15 @@ namespace OpenSim.Region.ScriptEngine.XEngine
foreach (IScriptInstance i in instances) foreach (IScriptInstance i in instances)
{ {
// Stop the script, even forcibly if needed. Then flag
// it as shutting down and restore the previous run state
// for serialization, so the scripts don't come back
// dead after region restart
//
bool prevRunning = i.Running;
i.Stop(50); i.Stop(50);
i.ShuttingDown = true;
i.Running = prevRunning;
} }
DoBackup(new Object[] {0}); DoBackup(new Object[] {0});

View File

@ -1315,6 +1315,7 @@
<Reference name="System" localCopy="false"/> <Reference name="System" localCopy="false"/>
<Reference name="System.Xml"/> <Reference name="System.Xml"/>
<Reference name="System.Data"/> <Reference name="System.Data"/>
<Reference name="System.Drawing"/>
<Reference name="OpenSim.Framework"/> <Reference name="OpenSim.Framework"/>
<Reference name="OpenSim.Data"/> <Reference name="OpenSim.Data"/>
<Reference name="OpenSim.Data.MapperFactory"/> <Reference name="OpenSim.Data.MapperFactory"/>
@ -1385,6 +1386,7 @@
<Reference name="System.Data"/> <Reference name="System.Data"/>
<Reference name="System.Data.SQLite.dll"/> <Reference name="System.Data.SQLite.dll"/>
<Reference name="OpenSim.Data"/> <Reference name="OpenSim.Data"/>
<Reference name="System.Drawing"/>
<Reference name="OpenSim.Framework"/> <Reference name="OpenSim.Framework"/>
<Reference name="OpenSim.Framework.Console"/> <Reference name="OpenSim.Framework.Console"/>
<Reference name="OpenSim.Region.Environment"/> <Reference name="OpenSim.Region.Environment"/>