Persistent prim inventory phase 5. Restart scripts contained in persisted prims on region start.

No user functionality exposed yet - no ini switch to enable persistence or restore.  A bit more initial work to do.
afrisby
Justin Clarke Casey 2008-01-07 02:12:06 +00:00
parent f43e75762a
commit 3e75dede1b
9 changed files with 111 additions and 29 deletions

View File

@ -426,7 +426,7 @@ namespace OpenSim
UDPServer udpServer;
Scene scene = SetupScene(regionInfo, out udpServer, m_permissions);
MainLog.Instance.Verbose("MODULES", "Loading Region's Modules");
MainLog.Instance.Verbose("MODULES", "Loading Region's modules");
m_moduleLoader.PickupModules(scene, ".");
//m_moduleLoader.PickupModules(scene, "ScriptEngines");
@ -434,14 +434,15 @@ namespace OpenSim
MainLog.Instance.Verbose("MODULES", "Loading scripting engine modules");
m_moduleLoader.LoadRegionModules(Path.Combine("ScriptEngines", m_scriptEngine), scene);
m_moduleLoader.InitialiseSharedModules(scene);
scene.SetModuleInterfaces();
//Server side object editing permissions checking
scene.PermissionsMngr.BypassPermissions = !m_permissions;
// We need to do this after we've initialized the scripting engines.
scene.StartScripts();
m_sceneManager.Add(scene);
m_udpServers.Add(udpServer);

View File

@ -36,7 +36,12 @@ namespace OpenSim.Region.Environment.Scenes
{
protected List<EntityBase> m_children;
public Scene m_scene;
protected Scene m_scene;
public Scene Scene
{
get { return m_scene; }
}
public LLUUID m_uuid;

View File

@ -37,6 +37,19 @@ namespace OpenSim.Region.Environment.Scenes
{
public partial class Scene
{
/// <summary>
/// Start all the scripts in the scene which should be started.
/// </summary>
public void StartScripts()
{
MainLog.Instance.Verbose("PRIMINVENTORY", "Starting scripts in scene");
foreach (SceneObjectGroup group in Entities.Values)
{
group.StartScripts();
}
}
//split these method into this partial as a lot of these (hopefully) are only temporary and won't be needed once Caps is more complete
// or at least some of they can be moved somewhere else

View File

@ -890,11 +890,12 @@ namespace OpenSim.Region.Environment.Scenes
public virtual void LoadPrimsFromStorage(bool m_permissions)
{
MainLog.Instance.Verbose("SCENE", "Loading objects from datastore");
List<SceneObjectGroup> PrimsFromDB = m_storageManager.DataStore.LoadObjects(m_regInfo.RegionID);
foreach (SceneObjectGroup prim in PrimsFromDB)
foreach (SceneObjectGroup group in PrimsFromDB)
{
AddEntityFromStorage(prim);
SceneObjectPart rootPart = prim.GetChildPart(prim.UUID);
AddEntityFromStorage(group);
SceneObjectPart rootPart = group.GetChildPart(group.UUID);
rootPart.ApplySanePermissions();
bool UsePhysics = (((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Physics) > 0) && m_physicalPrim);
@ -909,6 +910,7 @@ namespace OpenSim.Region.Environment.Scenes
rootPart.RotationOffset.Y, rootPart.RotationOffset.Z), UsePhysics);
rootPart.DoPhysicsPropertyUpdate(UsePhysics, true);
}
MainLog.Instance.Verbose("SCENE", "Loaded " + PrimsFromDB.Count.ToString() + " SceneObject(s)");
}

View File

@ -54,7 +54,6 @@ namespace OpenSim.Region.Environment.Scenes
protected ulong m_regionHandle;
protected string m_regionName;
protected RegionInfo m_regInfo;
protected RegionStatus m_regStatus;
public TerrainEngine Terrain;
@ -68,6 +67,7 @@ namespace OpenSim.Region.Environment.Scenes
protected string m_datastore;
private uint m_nextLocalId = 8880000;
private AssetCache m_assetCache;
public AssetCache AssetCache
@ -76,6 +76,8 @@ namespace OpenSim.Region.Environment.Scenes
set { m_assetCache = value; }
}
protected RegionStatus m_regStatus;
public RegionStatus Region_Status
{
get { return m_regStatus; }

View File

@ -38,6 +38,17 @@ namespace OpenSim.Region.Environment.Scenes
{
public partial class SceneObjectGroup : EntityBase
{
/// <summary>
/// Start the scripts contained in all the prims in this group.
/// </summary>
public void StartScripts()
{
foreach (SceneObjectPart part in m_parts.Values)
{
part.StartScripts();
}
}
/// <summary>
///
/// </summary>

View File

@ -33,6 +33,7 @@ using System.Xml.Serialization;
using libsecondlife;
using OpenSim.Framework;
using OpenSim.Framework.Console;
using OpenSim.Region.Environment.Interfaces;
using OpenSim.Region.Environment.Scenes.Scripting;
@ -80,6 +81,53 @@ namespace OpenSim.Region.Environment.Scenes
get { return m_inventorySerial; }
}
/// <summary>
/// Start all the scripts contained in this prim's inventory
/// </summary>
public void StartScripts()
{
foreach (TaskInventoryItem item in m_taskInventory.Values)
{
if ("lsltext" == item.type)
{
StartScript(item);
}
}
}
/// <summary>
/// Start a script in this prim
/// </summary>
/// <param name="item"></param>
/// <returns>true if script asset was found, false if it wasn't</returns>
public bool StartScript(TaskInventoryItem item)
{
// MainLog.Instance.Verbose(
// "PRIMINVENTORY",
// "Starting script {0}, {1} in prim {2}, {3}",
// item.name, item.item_id, Name, UUID);
AssetBase rezAsset = m_parentGroup.Scene.AssetCache.GetAsset(item.asset_id, false);
if (rezAsset != null)
{
string script = Helpers.FieldToUTF8String(rezAsset.Data);
m_parentGroup.Scene.EventManager.TriggerRezScript(LocalID, item.item_id, script);
return true;
}
else
{
MainLog.Instance.Error(
"PRIMINVENTORY",
"Couldn't start script {0}, {1} since asset ID {2} could not be found",
item.name, item.item_id, item.asset_id);
}
return false;
}
/// <summary>
/// Add an item to this prim's inventory.
/// </summary>

View File

@ -172,10 +172,10 @@ namespace OpenSim.Region.Environment.Scenes
{
try
{
//lock (m_parentGroup.m_scene.SyncRoot)
//lock (m_parentGroup.Scene.SyncRoot)
//{
PhysActor.Position = new PhysicsVector(value.X, value.Y, value.Z);
m_parentGroup.m_scene.PhysicsScene.AddPhysicsActorTaint(PhysActor);
m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor);
//}
}
catch (Exception e)
@ -225,10 +225,10 @@ namespace OpenSim.Region.Environment.Scenes
{
try
{
//lock (m_scene.SyncRoot)
//lock (Scene.SyncRoot)
//{
PhysActor.Orientation = new Quaternion(value.W, value.X, value.Y, value.Z);
m_parentGroup.m_scene.PhysicsScene.AddPhysicsActorTaint(PhysActor);
m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor);
//}
}
catch (Exception ex)
@ -554,7 +554,7 @@ namespace OpenSim.Region.Environment.Scenes
if (usePhysics)
{
PhysActor = m_parentGroup.m_scene.PhysicsScene.AddPrimShape(
PhysActor = m_parentGroup.Scene.PhysicsScene.AddPrimShape(
Name,
Shape,
new PhysicsVector(AbsolutePosition.X, AbsolutePosition.Y,
@ -1044,7 +1044,7 @@ namespace OpenSim.Region.Environment.Scenes
{
i += 46;
//IsLocked = (data[i++] != 0) ? true : false;
usePhysics = ((data[i++] != 0) && m_parentGroup.m_scene.m_physicalPrim) ? true : false;
usePhysics = ((data[i++] != 0) && m_parentGroup.Scene.m_physicalPrim) ? true : false;
//System.Console.WriteLine("U" + packet.ToBytes().Length.ToString());
IsTemporary = (data[i++] != 0) ? true : false;
IsPhantom = (data[i++] != 0) ? true : false;
@ -1079,8 +1079,8 @@ namespace OpenSim.Region.Environment.Scenes
AddFlag(LLObject.ObjectFlags.Phantom);
if (PhysActor != null)
{
m_parentGroup.m_scene.PhysicsScene.RemovePrim(PhysActor);
/// that's not wholesome. Had to make m_scene public
m_parentGroup.Scene.PhysicsScene.RemovePrim(PhysActor);
/// that's not wholesome. Had to make Scene public
PhysActor = null;
}
}
@ -1089,7 +1089,7 @@ namespace OpenSim.Region.Environment.Scenes
RemFlag(LLObject.ObjectFlags.Phantom);
if (PhysActor == null)
{
PhysActor = m_parentGroup.m_scene.PhysicsScene.AddPrimShape(
PhysActor = m_parentGroup.Scene.PhysicsScene.AddPrimShape(
Name,
Shape,
new PhysicsVector(AbsolutePosition.X, AbsolutePosition.Y,
@ -1127,7 +1127,7 @@ namespace OpenSim.Region.Environment.Scenes
if (PhysActor.IsPhysical)
{
if (!isNew)
ParentGroup.m_scene.RemovePhysicalPrim(1);
ParentGroup.Scene.RemovePhysicalPrim(1);
PhysActor.OnRequestTerseUpdate -= PhysicsRequestingTerseUpdate;
PhysActor.OnOutOfBounds -= PhysicsOutOfBounds;
@ -1135,14 +1135,14 @@ namespace OpenSim.Region.Environment.Scenes
PhysActor.IsPhysical = UsePhysics;
// If we're not what we're supposed to be in the physics scene, recreate ourselves.
//m_parentGroup.m_scene.PhysicsScene.RemovePrim(PhysActor);
/// that's not wholesome. Had to make m_scene public
//m_parentGroup.Scene.PhysicsScene.RemovePrim(PhysActor);
/// that's not wholesome. Had to make Scene public
//PhysActor = null;
if ((ObjectFlags & (uint) LLObject.ObjectFlags.Phantom) == 0)
{
//PhysActor = m_parentGroup.m_scene.PhysicsScene.AddPrimShape(
//PhysActor = m_parentGroup.Scene.PhysicsScene.AddPrimShape(
//Name,
//Shape,
//new PhysicsVector(AbsolutePosition.X, AbsolutePosition.Y,
@ -1152,14 +1152,14 @@ namespace OpenSim.Region.Environment.Scenes
//RotationOffset.Y, RotationOffset.Z), UsePhysics);
if (UsePhysics)
{
ParentGroup.m_scene.AddPhysicalPrim(1);
ParentGroup.Scene.AddPhysicalPrim(1);
PhysActor.OnRequestTerseUpdate += PhysicsRequestingTerseUpdate;
PhysActor.OnOutOfBounds += PhysicsOutOfBounds;
}
}
}
m_parentGroup.m_scene.PhysicsScene.AddPhysicsActorTaint(PhysActor);
m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor);
}
}
@ -1517,7 +1517,7 @@ namespace OpenSim.Region.Environment.Scenes
MainLog.Instance.Verbose("PHYSICS", "Physical Object went out of bounds.");
RemFlag(LLObject.ObjectFlags.Physics);
DoPhysicsPropertyUpdate(false, true);
m_parentGroup.m_scene.PhysicsScene.AddPhysicsActorTaint(PhysActor);
m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor);
}
public virtual void OnGrab(LLVector3 offsetPos, IClientAPI remoteClient)

View File

@ -243,7 +243,7 @@ namespace OpenSim.DataStore.MonoSqlite
/// Load persisted objects from region storage.
/// </summary>
/// <param name="regionUUID"></param>
/// <returns></returns>
/// <returns>List of loaded groups</returns>
public List<SceneObjectGroup> LoadObjects(LLUUID regionUUID)
{
Dictionary<LLUUID, SceneObjectGroup> createdObjects = new Dictionary<LLUUID, SceneObjectGroup>();