From 6406d5a5b9c1c4ef261254e7d4446603b496d1fd Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 8 May 2012 23:20:27 +0100 Subject: refactor: Eliminate local id parameter from api initialize. This is always available from m_host.LocalId --- .../Region/ScriptEngine/Interfaces/IScriptApi.cs | 3 +- .../Shared/Api/Implementation/LSL_Api.cs | 40 ++++++++++------------ .../Shared/Api/Implementation/LS_Api.cs | 4 +-- .../Shared/Api/Implementation/MOD_Api.cs | 4 +-- .../Shared/Api/Implementation/OSSL_Api.cs | 4 +-- .../ScriptEngine/Shared/Instance/ScriptInstance.cs | 2 +- .../Shared/Tests/LSL_ApiInventoryTests.cs | 9 +++-- .../ScriptEngine/Shared/Tests/LSL_ApiTest.cs | 2 +- .../Shared/Tests/OSSL_ApiAppearanceTest.cs | 8 ++--- .../ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs | 6 ++-- 10 files changed, 36 insertions(+), 46 deletions(-) (limited to 'OpenSim/Region/ScriptEngine') diff --git a/OpenSim/Region/ScriptEngine/Interfaces/IScriptApi.cs b/OpenSim/Region/ScriptEngine/Interfaces/IScriptApi.cs index cced522..2027ca6 100644 --- a/OpenSim/Region/ScriptEngine/Interfaces/IScriptApi.cs +++ b/OpenSim/Region/ScriptEngine/Interfaces/IScriptApi.cs @@ -42,8 +42,7 @@ namespace OpenSim.Region.ScriptEngine.Interfaces /// proper runtime assembly at load time. /// /param> /// - /// /// - void Initialize(IScriptEngine engine, SceneObjectPart part, uint localID, TaskInventoryItem item); + void Initialize(IScriptEngine engine, SceneObjectPart part, TaskInventoryItem item); } } \ No newline at end of file diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index e8e4dab..afd943b 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -84,7 +84,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); protected IScriptEngine m_ScriptEngine; protected SceneObjectPart m_host; - protected uint m_localID; /// /// The item that hosts this script @@ -108,11 +107,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api protected Dictionary m_userInfoCache = new Dictionary(); - public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, uint localID, TaskInventoryItem item) + public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, TaskInventoryItem item) { m_ScriptEngine = ScriptEngine; m_host = host; - m_localID = localID; m_item = item; m_ScriptDelayFactor = @@ -843,7 +841,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api UUID.TryParse(ID, out keyID); IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface(); if (wComm != null) - return wComm.Listen(m_localID, m_item.ItemID, m_host.UUID, channelID, name, keyID, msg); + return wComm.Listen(m_host.LocalId, m_item.ItemID, m_host.UUID, channelID, name, keyID, msg); else return -1; } @@ -870,7 +868,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api UUID keyID = UUID.Zero; UUID.TryParse(id, out keyID); - AsyncCommands.SensorRepeatPlugin.SenseOnce(m_localID, m_item.ItemID, name, keyID, type, range, arc, m_host); + AsyncCommands.SensorRepeatPlugin.SenseOnce(m_host.LocalId, m_item.ItemID, name, keyID, type, range, arc, m_host); } public void llSensorRepeat(string name, string id, int type, double range, double arc, double rate) @@ -879,13 +877,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api UUID keyID = UUID.Zero; UUID.TryParse(id, out keyID); - AsyncCommands.SensorRepeatPlugin.SetSenseRepeatEvent(m_localID, m_item.ItemID, name, keyID, type, range, arc, rate, m_host); + AsyncCommands.SensorRepeatPlugin.SetSenseRepeatEvent(m_host.LocalId, m_item.ItemID, name, keyID, type, range, arc, rate, m_host); } public void llSensorRemove() { m_host.AddScriptLPS(1); - AsyncCommands.SensorRepeatPlugin.UnSetSenseRepeaterEvents(m_localID, m_item.ItemID); + AsyncCommands.SensorRepeatPlugin.UnSetSenseRepeaterEvents(m_host.LocalId, m_item.ItemID); } public string resolveName(UUID objecUUID) @@ -2874,7 +2872,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api sec = m_MinTimerInterval; m_host.AddScriptLPS(1); // Setting timer repeat - AsyncCommands.TimerPlugin.SetTimerEvent(m_localID, m_item.ItemID, sec); + AsyncCommands.TimerPlugin.SetTimerEvent(m_host.LocalId, m_item.ItemID, sec); } public virtual void llSleep(double sec) @@ -2937,7 +2935,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0) { - presence.RegisterControlEventsToScript(controls, accept, pass_on, m_localID, m_item.ItemID); + presence.RegisterControlEventsToScript(controls, accept, pass_on, m_host.LocalId, m_item.ItemID); } } } @@ -2958,7 +2956,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0) { // Unregister controls from Presence - presence.UnRegisterControlEventsToScript(m_localID, m_item.ItemID); + presence.UnRegisterControlEventsToScript(m_host.LocalId, m_item.ItemID); // Remove Take Control permission. m_item.PermsMask &= ~ScriptBaseClass.PERMISSION_TAKE_CONTROLS; } @@ -4089,7 +4087,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api UUID rq = UUID.Random(); UUID tid = AsyncCommands. - DataserverPlugin.RegisterRequest(m_localID, + DataserverPlugin.RegisterRequest(m_host.LocalId, m_item.ItemID, rq.ToString()); AsyncCommands. @@ -4110,7 +4108,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (item.Type == 3 && item.Name == name) { UUID tid = AsyncCommands. - DataserverPlugin.RegisterRequest(m_localID, + DataserverPlugin.RegisterRequest(m_host.LocalId, m_item.ItemID, item.AssetID.ToString()); Vector3 region = new Vector3( @@ -6564,7 +6562,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api IXMLRPC xmlrpcMod = m_ScriptEngine.World.RequestModuleInterface(); if (xmlrpcMod.IsEnabled()) { - UUID channelID = xmlrpcMod.OpenXMLRPCChannel(m_localID, m_item.ItemID, UUID.Zero); + UUID channelID = xmlrpcMod.OpenXMLRPCChannel(m_host.LocalId, m_item.ItemID, UUID.Zero); IXmlRpcRouter xmlRpcRouter = m_ScriptEngine.World.RequestModuleInterface(); if (xmlRpcRouter != null) { @@ -6594,7 +6592,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_host.AddScriptLPS(1); IXMLRPC xmlrpcMod = m_ScriptEngine.World.RequestModuleInterface(); ScriptSleep(3000); - return (xmlrpcMod.SendRemoteData(m_localID, m_item.ItemID, channel, dest, idata, sdata)).ToString(); + return (xmlrpcMod.SendRemoteData(m_host.LocalId, m_item.ItemID, channel, dest, idata, sdata)).ToString(); } public void llRemoteDataReply(string channel, string message_id, string sdata, int idata) @@ -9083,7 +9081,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api UUID rq = UUID.Random(); UUID tid = AsyncCommands. - DataserverPlugin.RegisterRequest(m_localID, m_item.ItemID, rq.ToString()); + DataserverPlugin.RegisterRequest(m_host.LocalId, m_item.ItemID, rq.ToString()); AsyncCommands. DataserverPlugin.DataserverReply(rq.ToString(), reply); @@ -9982,8 +9980,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } } - UUID reqID = httpScriptMod. - StartHttpRequest(m_localID, m_item.ItemID, url, param, httpHeaders, body); + UUID reqID + = httpScriptMod.StartHttpRequest(m_host.LocalId, m_item.ItemID, url, param, httpHeaders, body); if (reqID != UUID.Zero) return reqID.ToString(); @@ -10413,7 +10411,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } // was: UUID tid = tid = AsyncCommands. - UUID tid = AsyncCommands.DataserverPlugin.RegisterRequest(m_localID, m_item.ItemID, assetID.ToString()); + UUID tid = AsyncCommands.DataserverPlugin.RegisterRequest(m_host.LocalId, m_item.ItemID, assetID.ToString()); if (NotecardCache.IsCached(assetID)) { @@ -10475,7 +10473,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } // was: UUID tid = tid = AsyncCommands. - UUID tid = AsyncCommands.DataserverPlugin.RegisterRequest(m_localID, m_item.ItemID, assetID.ToString()); + UUID tid = AsyncCommands.DataserverPlugin.RegisterRequest(m_host.LocalId, m_item.ItemID, assetID.ToString()); if (NotecardCache.IsCached(assetID)) { @@ -10561,7 +10559,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { UUID rq = UUID.Random(); - AsyncCommands.DataserverPlugin.RegisterRequest(m_localID, m_item.ItemID, rq.ToString()); + AsyncCommands.DataserverPlugin.RegisterRequest(m_host.LocalId, m_item.ItemID, rq.ToString()); AsyncCommands.DataserverPlugin.DataserverReply(rq.ToString(), Name2Username(llKey2Name(id))); @@ -10577,7 +10575,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { UUID rq = UUID.Random(); - AsyncCommands.DataserverPlugin.RegisterRequest(m_localID, m_item.ItemID, rq.ToString()); + AsyncCommands.DataserverPlugin.RegisterRequest(m_host.LocalId, m_item.ItemID, rq.ToString()); AsyncCommands.DataserverPlugin.DataserverReply(rq.ToString(), llKey2Name(id)); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs index cd47d96..795de80 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs @@ -58,15 +58,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { internal IScriptEngine m_ScriptEngine; internal SceneObjectPart m_host; - internal uint m_localID; internal bool m_LSFunctionsEnabled = false; internal IScriptModuleComms m_comms = null; - public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, uint localID, TaskInventoryItem item) + public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, TaskInventoryItem item) { m_ScriptEngine = ScriptEngine; m_host = host; - m_localID = localID; if (m_ScriptEngine.Config.GetBoolean("AllowLightShareFunctions", false)) m_LSFunctionsEnabled = true; diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs index a578b50..4bd3dff 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs @@ -57,16 +57,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { internal IScriptEngine m_ScriptEngine; internal SceneObjectPart m_host; - internal uint m_localID; internal TaskInventoryItem m_item; internal bool m_MODFunctionsEnabled = false; internal IScriptModuleComms m_comms = null; - public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, uint localID, TaskInventoryItem item) + public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, TaskInventoryItem item) { m_ScriptEngine = ScriptEngine; m_host = host; - m_localID = localID; m_item = item; if (m_ScriptEngine.Config.GetBoolean("AllowMODFunctions", false)) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 9b2022a..ad1a358 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -133,7 +133,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api internal IScriptEngine m_ScriptEngine; internal ILSL_Api m_LSL_Api = null; // get a reference to the LSL API so we can call methods housed there internal SceneObjectPart m_host; - internal uint m_localID; internal TaskInventoryItem m_item; internal bool m_OSFunctionsEnabled = false; internal ThreatLevel m_MaxThreatLevel = ThreatLevel.VeryLow; @@ -141,11 +140,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api internal float m_ScriptDistanceFactor = 1.0f; internal Dictionary m_FunctionPerms = new Dictionary(); - public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, uint localID, TaskInventoryItem item) + public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, TaskInventoryItem item) { m_ScriptEngine = ScriptEngine; m_host = host; - m_localID = localID; m_item = item; if (m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false)) diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs index dd47393..329e361 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs @@ -232,7 +232,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance foreach (string api in am.GetApis()) { m_Apis[api] = am.CreateApi(api); - m_Apis[api].Initialize(engine, part, LocalID, ScriptTask); + m_Apis[api].Initialize(engine, part, ScriptTask); } try diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiInventoryTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiInventoryTests.cs index f480e1d..c73e22f 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiInventoryTests.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiInventoryTests.cs @@ -88,11 +88,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests // Create an object embedded inside the first UUID itemId = TestHelpers.ParseTail(0x20); - TaskInventoryItem item - = TaskInventoryHelpers.AddSceneObject(m_scene, so1.RootPart, inventoryItemName, itemId, userId); + TaskInventoryHelpers.AddSceneObject(m_scene, so1.RootPart, inventoryItemName, itemId, userId); LSL_Api api = new LSL_Api(); - api.Initialize(m_engine, so1.RootPart, so1.RootPart.LocalId, null); + api.Initialize(m_engine, so1.RootPart, null); // Create a second object SceneObjectGroup so2 = SceneHelpers.CreateSceneObject(1, userId, "so2", 0x100); @@ -125,7 +124,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests SceneObjectGroup so1 = SceneHelpers.CreateSceneObject(1, user1Id, "so1", 0x10); m_scene.AddSceneObject(so1); LSL_Api api = new LSL_Api(); - api.Initialize(m_engine, so1.RootPart, so1.RootPart.LocalId, null); + api.Initialize(m_engine, so1.RootPart, null); // Create an object embedded inside the first UUID itemId = TestHelpers.ParseTail(0x20); @@ -135,7 +134,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests SceneObjectGroup so2 = SceneHelpers.CreateSceneObject(1, user2Id, "so2", 0x100); m_scene.AddSceneObject(so2); LSL_Api api2 = new LSL_Api(); - api2.Initialize(m_engine, so2.RootPart, so2.RootPart.LocalId, null); + api2.Initialize(m_engine, so2.RootPart, null); // *** Firstly, we test where llAllowInventoryDrop() has not been called. *** api.llGiveInventory(so2.UUID.ToString(), inventoryItemName); diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs index bba6c56..f96a156 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs @@ -66,7 +66,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests engine.AddRegion(scene); m_lslApi = new LSL_Api(); - m_lslApi.Initialize(engine, part, part.LocalId, null); + m_lslApi.Initialize(engine, part, null); } [Test] diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs index dff8f6e..3965734 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs @@ -95,7 +95,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests m_scene.AddSceneObject(so); OSSL_Api osslApi = new OSSL_Api(); - osslApi.Initialize(m_engine, part, part.LocalId, null); + osslApi.Initialize(m_engine, part, null); string notecardName = "appearanceNc"; osslApi.osOwnerSaveAppearance(notecardName); @@ -130,7 +130,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests m_scene.AddSceneObject(so); OSSL_Api osslApi = new OSSL_Api(); - osslApi.Initialize(m_engine, part, part.LocalId, null); + osslApi.Initialize(m_engine, part, null); string notecardName = "appearanceNc"; osslApi.osOwnerSaveAppearance(notecardName); @@ -161,7 +161,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests m_scene.AddSceneObject(so); OSSL_Api osslApi = new OSSL_Api(); - osslApi.Initialize(m_engine, part, part.LocalId, null); + osslApi.Initialize(m_engine, part, null); string notecardName = "appearanceNc"; @@ -202,7 +202,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests m_scene.AddSceneObject(so); OSSL_Api osslApi = new OSSL_Api(); - osslApi.Initialize(m_engine, part, part.LocalId, null); + osslApi.Initialize(m_engine, part, null); string notecardName = "appearanceNc"; diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs index 80ac52c..0ccd889 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs @@ -104,10 +104,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests m_scene.AddSceneObject(otherSo); OSSL_Api osslApi = new OSSL_Api(); - osslApi.Initialize(m_engine, part, part.LocalId, null); + osslApi.Initialize(m_engine, part, null); OSSL_Api otherOsslApi = new OSSL_Api(); - otherOsslApi.Initialize(m_engine, otherPart, otherPart.LocalId, null); + otherOsslApi.Initialize(m_engine, otherPart, null); string notecardName = "appearanceNc"; osslApi.osOwnerSaveAppearance(notecardName); @@ -151,7 +151,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests m_scene.AddSceneObject(so); OSSL_Api osslApi = new OSSL_Api(); - osslApi.Initialize(m_engine, part, part.LocalId, null); + osslApi.Initialize(m_engine, part, null); string notecardName = "appearanceNc"; osslApi.osOwnerSaveAppearance(notecardName); -- cgit v1.1