From 9c1f7995820d9d480450774575ac469ff5113b0d Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 22 May 2011 21:01:31 +0200 Subject: Implement llGodLikeRezObject and llGetUsedMemory --- .../Shared/Api/Implementation/LSL_Api.cs | 56 ++++++++++++++++++++-- .../ScriptEngine/Shared/Api/Interface/ILSL_Api.cs | 1 + .../ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs | 5 ++ 3 files changed, 59 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 64eb6d0..c87f8ba 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -46,6 +46,7 @@ using OpenSim.Region.CoreModules.World.Land; using OpenSim.Region.CoreModules.World.Terrain; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; +using OpenSim.Region.Framework.Scenes.Serialization; using OpenSim.Region.Framework.Scenes.Animation; using OpenSim.Region.Physics.Manager; using OpenSim.Region.ScriptEngine.Shared; @@ -11010,11 +11011,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } - public virtual void llGetUsedMemory() + public virtual LSL_Integer llGetUsedMemory() { m_host.AddScriptLPS(1); NotImplemented("llGetUsedMemory"); - + return 0; } public void llRegionSayTo( LSL_Key target, LSL_Integer channel, LSL_String msg ) @@ -11045,7 +11046,56 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llGodLikeRezObject(string inventory, LSL_Vector pos) { m_host.AddScriptLPS(1); - NotImplemented("llGodLikeRezObject"); + + if (!World.Permissions.IsGod(m_host.OwnerID)) + NotImplemented("llGodLikeRezObject"); + + AssetBase rezAsset = World.AssetService.Get(inventory); + if (rezAsset == null) + { + llSay(0, "Asset not found"); + return; + } + + SceneObjectGroup group = null; + + try + { + string xmlData = Utils.BytesToString(rezAsset.Data); + group = SceneObjectSerializer.FromOriginalXmlFormat(xmlData); + } + catch + { + llSay(0, "Asset not found"); + return; + } + + if (group == null) + { + llSay(0, "Asset not found"); + return; + } + + group.RootPart.AttachPoint = group.RootPart.Shape.State; + group.RootPart.AttachOffset = group.AbsolutePosition; + + group.ResetIDs(); + + Vector3 llpos = new Vector3((float)pos.x, (float)pos.y, (float)pos.z); + World.AddNewSceneObject(group, true, llpos, Quaternion.Identity, Vector3.Zero); + group.CreateScriptInstances(0, true, World.DefaultScriptEngine, 3); + group.ScheduleGroupForFullUpdate(); + + // objects rezzed with this method are die_at_edge by default. + group.RootPart.SetDieAtEdge(true); + + group.ResumeScripts(); + + m_ScriptEngine.PostObjectEvent(m_host.LocalId, new EventParams( + "object_rez", new Object[] { + new LSL_String( + group.RootPart.UUID.ToString()) }, + new DetectParams[0])); } #endregion diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs index 0ae2388..ce13d6b 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs @@ -121,6 +121,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces LSL_Float llGetEnergy(); LSL_Vector llGetForce(); LSL_Integer llGetFreeMemory(); + LSL_Integer llGetUsedMemory(); LSL_Integer llGetFreeURLs(); LSL_Vector llGetGeometricCenter(); LSL_Float llGetGMTclock(); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs index 63cac9a..7d7e54e 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs @@ -461,6 +461,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase return m_LSL_Functions.llGetFreeMemory(); } + public LSL_Integer llGetUsedMemory() + { + return m_LSL_Functions.llGetUsedMemory(); + } + public LSL_Integer llGetFreeURLs() { return m_LSL_Functions.llGetFreeURLs(); -- cgit v1.1