From c89db49f3cd3bbd60577eb5a1787ccf8dea930e3 Mon Sep 17 00:00:00 2001
From: MW
Date: Sun, 19 Aug 2007 13:35:20 +0000
Subject: Sqlite datastore should now save the textures and extraparams data
(used by sculpties) correctly. [Really need to add a ExtraParams field to the
sqlite database though, but for now I have combined their data so that we
don't lose backward compatibility, know a couple of people have been using
the datastore already]. Now have a rough day/night cycle (the movement of the
sun needs to be made smoother but for now it is better than we had I think).
Added dalien's patch (issue 294) for saving and loading prims to a xml file
(think he will be modifying these to be import/export functions and maybe
writing a xml datastore for backups). Some preliminary work on task inventory
(ie object's/prim's inventory). Added place holder data for AvatarProperties
(ie a avatar's profile). Should we store this sort of data on the user server
or have another server for it (a normal webserver should work). Added a few
more method to IClientAPI. Sure there is something I'm forgeting.
---
.../Environment/Scenes/Scene.PacketHandlers.cs | 21 ++++-
OpenSim/Region/Environment/Scenes/Scene.cs | 92 ++++++++++++++++++-
.../Region/Environment/Scenes/SceneObjectGroup.cs | 24 +++--
.../Region/Environment/Scenes/SceneObjectPart.cs | 101 +++++++++++++++++++--
OpenSim/Region/Environment/Scenes/ScenePresence.cs | 3 +-
5 files changed, 221 insertions(+), 20 deletions(-)
(limited to 'OpenSim/Region/Environment/Scenes')
diff --git a/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs
index f0f73b0..6b8ddc6 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs
@@ -472,7 +472,7 @@ namespace OpenSim.Region.Environment.Scenes
hasPrim = ((SceneObjectGroup)ent).HasChildPrim(primLocalID);
if (hasPrim != false)
{
- ((SceneObjectGroup)ent).GetPartInventory(remoteClient, primLocalID);
+ ((SceneObjectGroup)ent).GetPartInventoryFileName(remoteClient, primLocalID);
break;
}
}
@@ -758,6 +758,25 @@ namespace OpenSim.Region.Environment.Scenes
}
///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public void RequestXfer(IClientAPI remoteClient, ulong xferID, string fileName)
+ {
+ /*
+ foreach (EntityBase ent in Entities.Values)
+ {
+ if (ent is SceneObjectGroup)
+ {
+ ((SceneObjectGroup)ent).RequestInventoryFile(remoteClient, ((SceneObjectGroup)ent).LocalId, xferID);
+ break;
+ }
+ }*/
+ }
+
+ ///
/// temporary method to test out creating new inventory items
///
///
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs
index 01e58c7..85479a7 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.cs
@@ -29,6 +29,8 @@ using System;
using System.Collections.Generic;
using System.Threading;
using System.Timers;
+using System.IO;
+using System.Xml;
using libsecondlife;
using OpenSim.Framework;
using OpenSim.Framework.Communications;
@@ -65,6 +67,10 @@ namespace OpenSim.Region.Environment.Scenes
private int storageCount;
private int terrainCheckCount;
private int landPrimCheckCount;
+
+ private int m_timePhase = 24;
+ private int m_timeUpdateCount;
+
private Mutex updateLock;
protected StorageManager storageManager;
@@ -123,6 +129,11 @@ namespace OpenSim.Region.Environment.Scenes
get { return Prims; }
}
+ public int TimePhase
+ {
+ get { return this.m_timePhase; }
+ }
+
#endregion
#region Constructors
@@ -301,6 +312,26 @@ namespace OpenSim.Region.Environment.Scenes
landPrimCheckCount = 0;
}
}
+
+ m_timeUpdateCount++;
+ if (m_timeUpdateCount > 600)
+ {
+ List Avatars = this.RequestAvatarList();
+ foreach (ScenePresence avatar in Avatars)
+ {
+ if (!avatar.childAgent)
+ {
+ //Console.WriteLine("sending time update " + timePhase + " from region " + m_regionHandle + " to avatar " + avatar.Firstname);
+ avatar.ControllingClient.SendViewerTime(m_timePhase);
+ }
+ }
+ m_timeUpdateCount = 0;
+ m_timePhase++;
+ if (m_timePhase > 94)
+ {
+ m_timePhase = 0;
+ }
+ }
}
catch (NotImplementedException)
{
@@ -538,7 +569,7 @@ namespace OpenSim.Region.Environment.Scenes
public void AddEntity(SceneObjectGroup sceneObject)
{
- if(!Entities.ContainsKey(sceneObject.UUID))
+ if (!Entities.ContainsKey(sceneObject.UUID))
{
Entities.Add(sceneObject.UUID, sceneObject);
}
@@ -563,6 +594,52 @@ namespace OpenSim.Region.Environment.Scenes
prim.OnPrimCountTainted += m_LandManager.setPrimsTainted;
}
+ public void LoadPrimsFromXml(string fileName)
+ {
+ XmlDocument doc = new XmlDocument();
+ XmlNode rootNode;
+ int primCount = 0;
+ if (File.Exists(fileName))
+ {
+ XmlTextReader reader = new XmlTextReader(fileName);
+ reader.WhitespaceHandling = WhitespaceHandling.None;
+ doc.Load(reader);
+ reader.Close();
+ rootNode = doc.FirstChild;
+ foreach (XmlNode aPrimNode in rootNode.ChildNodes)
+ {
+ SceneObjectGroup obj = new SceneObjectGroup(this,
+ this.m_regionHandle, aPrimNode.OuterXml);
+ AddEntity(obj);
+ primCount++;
+ }
+ }
+ else
+ {
+ throw new Exception("Could not open file " + fileName + " for reading");
+ }
+ }
+
+ public void SavePrimsToXml(string fileName)
+ {
+ FileStream file = new FileStream(fileName, FileMode.Create);
+ StreamWriter stream = new StreamWriter(file);
+ int primCount = 0;
+ stream.WriteLine("\n");
+ foreach (EntityBase ent in Entities.Values)
+ {
+ if (ent is SceneObjectGroup)
+ {
+ stream.WriteLine(((SceneObjectGroup)ent).ToXmlString());
+ primCount++;
+ }
+ }
+ stream.WriteLine("\n");
+ stream.Close();
+ file.Close();
+ }
+
+
#endregion
#region Add/Remove Avatar Methods
@@ -632,6 +709,7 @@ namespace OpenSim.Region.Environment.Scenes
client.OnFetchInventory += commsManager.UserProfiles.HandleFetchInventory;
client.OnAssetUploadRequest += commsManager.TransactionsManager.HandleUDPUploadRequest;
client.OnXferReceive += commsManager.TransactionsManager.HandleXfer;
+ // client.OnRequestXfer += RequestXfer;
client.OnGrabObject += ProcessObjectGrab;
}
@@ -950,7 +1028,7 @@ namespace OpenSim.Region.Environment.Scenes
AgentCircuitData agent = remoteClient.RequestClientInfo();
agent.BaseFolder = LLUUID.Zero;
agent.InventoryFolder = LLUUID.Zero;
-// agent.startpos = new LLVector3(128, 128, 70);
+ // agent.startpos = new LLVector3(128, 128, 70);
agent.startpos = position;
agent.child = true;
commsManager.InterRegion.InformRegionOfChildAgent(regionHandle, agent);
@@ -1121,7 +1199,15 @@ namespace OpenSim.Region.Environment.Scenes
item.assetID = asset.FullID;
userInfo.UpdateItem(remoteClient.AgentId, item);
- // remoteClient.SendInventoryItemUpdate(item);
+ // remoteClient.SendInventoryItemUpdate(item);
+ if (item.invType == 7)
+ {
+ //do we want to know about updated note cards?
+ }
+ else if (item.invType == 10)
+ {
+ // do we want to know about updated scripts
+ }
return (asset.FullID);
}
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
index 421a981..1e6cd8f 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
@@ -212,7 +212,6 @@ namespace OpenSim.Region.Environment.Scenes
public string ToXmlString()
{
StringWriter sw = new StringWriter();
- //StreamWriter st = new StreamWriter("testxml.txt");
XmlTextWriter writer = new XmlTextWriter(sw);
writer.WriteStartElement(String.Empty, "SceneObjectGroup", String.Empty);
writer.WriteStartElement(String.Empty, "RootPart", String.Empty);
@@ -231,11 +230,7 @@ namespace OpenSim.Region.Environment.Scenes
writer.WriteEndElement();
writer.WriteEndElement();
writer.Close();
- // System.Console.WriteLine("prim: " + sw.ToString());
return sw.ToString();
- // st.Close();
- // return "";
-
}
#region Copying
@@ -557,12 +552,26 @@ namespace OpenSim.Region.Environment.Scenes
///
///
///
- public void GetPartInventory(IClientAPI remoteClient, uint localID)
+ public void GetPartInventoryFileName(IClientAPI remoteClient, uint localID)
{
SceneObjectPart part = this.GetChildPrim(localID);
if (part != null)
{
- part.GetInventory(remoteClient, localID);
+ part.GetInventoryFileName(remoteClient, localID);
+ }
+ }
+
+ ///
+ ///
+ ///
+ ///
+ ///
+ public void RequestInventoryFile(IClientAPI remoteClient, uint localID, ulong xferID)
+ {
+ SceneObjectPart part = this.GetChildPrim(localID);
+ if (part != null)
+ {
+ part.RequestInventoryFile(remoteClient, xferID);
}
}
@@ -636,6 +645,7 @@ namespace OpenSim.Region.Environment.Scenes
public void UpdateGroupPosition(LLVector3 pos)
{
this.AbsolutePosition = pos;
+
}
///
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
index 1cfe9c8..c8a7515 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
@@ -31,7 +31,7 @@ namespace OpenSim.Region.Environment.Scenes
public uint GroupMask = FULL_MASK_PERMISSIONS;
public uint EveryoneMask = FULL_MASK_PERMISSIONS;
public uint BaseMask = FULL_MASK_PERMISSIONS;
-
+
protected byte[] m_particleSystem = new byte[0];
protected SceneObjectGroup m_parentGroup;
@@ -47,7 +47,7 @@ namespace OpenSim.Region.Environment.Scenes
public LLUUID UUID
{
get { return m_uuid; }
- set { m_uuid = value ; }
+ set { m_uuid = value; }
}
protected uint m_localID;
@@ -64,7 +64,7 @@ namespace OpenSim.Region.Environment.Scenes
set { m_name = value; }
}
- protected LLObject.ObjectFlags m_flags = (LLObject.ObjectFlags)32 + 65536 + 131072 + 256 + 4 + 8 + 2048 + 524288 + 268435456 + 128;
+ protected LLObject.ObjectFlags m_flags = (LLObject.ObjectFlags)32 + 65536 + 131072 + 256 + 4 + 8 + 268435456 + 128;
public uint ObjectFlags
{
get { return (uint)m_flags; }
@@ -221,7 +221,6 @@ namespace OpenSim.Region.Environment.Scenes
this.AngularVelocity = new LLVector3(0, 0, 0);
this.Acceleration = new LLVector3(0, 0, 0);
-
//temporary code just so the m_flags field doesn't give a compiler warning
if (m_flags == LLObject.ObjectFlags.AllowInventoryDrop)
@@ -233,6 +232,7 @@ namespace OpenSim.Region.Environment.Scenes
///
/// Re/create a SceneObjectPart (prim)
+ /// currently not used, and maybe won't be
///
///
///
@@ -396,13 +396,59 @@ namespace OpenSim.Region.Environment.Scenes
#endregion
#region Inventory
- public void GetInventory(IClientAPI client, uint localID)
+ ///
+ ///
+ ///
+ ///
+ ///
+ public void GetInventoryFileName(IClientAPI client, uint localID)
{
if (localID == this.m_localID)
{
+ // client.SendTaskInventory(this.m_uuid, 0, Helpers.StringToField("primInventory"));
client.SendTaskInventory(this.m_uuid, 0, new byte[0]);
}
}
+
+ ///
+ ///
+ ///
+ ///
+ ///
+ public void RequestInventoryFile(IClientAPI client, ulong xferID)
+ {
+ // a test item
+ InventoryStringBuilder invString = new InventoryStringBuilder();
+ invString.AddItemStart();
+ invString.AddNameValueLine("item_id", LLUUID.Random().ToStringHyphenated());
+ invString.AddNameValueLine("parent_id", this.UUID.ToStringHyphenated());
+
+ invString.AddPermissionsStart();
+ invString.AddNameValueLine("base_mask", "0x7FFFFFFF");
+ invString.AddNameValueLine("owner_mask", "0x7FFFFFFF");
+ invString.AddNameValueLine("group_mask", "0x7FFFFFFF");
+ invString.AddNameValueLine("everyone_mask", "0x7FFFFFFF");
+ invString.AddNameValueLine("next_owner_mask", "0x7FFFFFFF");
+ invString.AddNameValueLine("creator_id", client.AgentId.ToStringHyphenated());
+ invString.AddNameValueLine("owner_id", client.AgentId.ToStringHyphenated());
+ invString.AddNameValueLine("last_owner_id", LLUUID.Zero.ToStringHyphenated());
+ invString.AddNameValueLine("group_id", LLUUID.Zero.ToStringHyphenated());
+ invString.AddSectionEnd();
+
+ invString.AddNameValueLine("asset_id", "00000000-0000-0000-9999-000000000002");
+ invString.AddNameValueLine("type", "texture");
+ invString.AddNameValueLine("inv_type" , "texture");
+ invString.AddNameValueLine("flags", "0x00");
+ invString.AddNameValueLine("name", "Test inventory" + "|");
+ invString.AddNameValueLine("desc", "test description" + "|");
+ invString.AddNameValueLine("creation_date", "10000");
+ invString.AddSectionEnd();
+
+ byte[] fileInv = Helpers.StringToField(invString.BuildString);
+ byte[] data = new byte[fileInv.Length + 4];
+ Array.Copy(fileInv, 0,data , 4, fileInv.Length);
+ client.SendXferPacket(xferID, 0 + 0x80000000, data);
+ }
#endregion
#region ExtraParams
@@ -422,7 +468,7 @@ namespace OpenSim.Region.Environment.Scenes
Array.Copy(data, 0, this.m_shape.ExtraParams, i, data.Length);
this.ScheduleFullUpdate();
-
+
}
#endregion
@@ -497,7 +543,7 @@ namespace OpenSim.Region.Environment.Scenes
///
public void SendFullUpdate(IClientAPI remoteClient)
{
- m_parentGroup.SendPartFullUpdate( remoteClient, this );
+ m_parentGroup.SendPartFullUpdate(remoteClient, this);
}
///
@@ -580,7 +626,46 @@ namespace OpenSim.Region.Environment.Scenes
public void SetText(string text, Vector3 color, double alpha)
{
- Text = text;
+ Text = text;
+ }
+
+ public class InventoryStringBuilder
+ {
+ public string BuildString = "";
+
+ public InventoryStringBuilder()
+ {
+
+ }
+
+ public void AddItemStart()
+ {
+ BuildString += "\tinv_item\t0\n";
+ BuildString += "\t{\n";
+ }
+
+ public void AddPermissionsStart()
+ {
+ BuildString += "\tpermissions 0\n";
+ BuildString += "\t{\n";
+ }
+
+ public void AddSectionEnd()
+ {
+ BuildString += "\t}\n";
+ }
+
+ public void AddLine(string addLine)
+ {
+ BuildString += addLine;
+ }
+
+ public void AddNameValueLine(string name, string value)
+ {
+ BuildString += "\t\t";
+ BuildString += name + "\t";
+ BuildString += value + "\n";
+ }
}
}
}
diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs
index 7dcb760..0393a2a 100644
--- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs
@@ -59,7 +59,7 @@ namespace OpenSim.Region.Environment.Scenes
private ulong m_regionHandle;
- public bool childAgent = false;
+ public bool childAgent = true;
public bool IsRestrictedToRegion = false;
private bool newForce = false;
@@ -495,6 +495,7 @@ namespace OpenSim.Region.Environment.Scenes
this.SendArrearanceToAllOtherAgents();
this.m_scene.SendAllSceneObjectsToClient(this.ControllingClient);
+ this.ControllingClient.SendViewerTime(this.m_scene.TimePhase);
}
///
--
cgit v1.1