refactor: Eliminate local id parameter from api initialize.

This is always available from m_host.LocalId
0.7.3-extended
Justin Clark-Casey (justincc) 2012-05-08 23:20:27 +01:00
parent 796334c5ff
commit 8c1e549c12
10 changed files with 36 additions and 46 deletions

View File

@ -42,8 +42,7 @@ namespace OpenSim.Region.ScriptEngine.Interfaces
/// proper runtime assembly at load time. /// proper runtime assembly at load time.
/// <param name='engine'>/param> /// <param name='engine'>/param>
/// <param name='part'></param> /// <param name='part'></param>
/// <param name='localID'></param>
/// <param name='item'></param> /// <param name='item'></param>
void Initialize(IScriptEngine engine, SceneObjectPart part, uint localID, TaskInventoryItem item); void Initialize(IScriptEngine engine, SceneObjectPart part, TaskInventoryItem item);
} }
} }

View File

@ -84,7 +84,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
protected IScriptEngine m_ScriptEngine; protected IScriptEngine m_ScriptEngine;
protected SceneObjectPart m_host; protected SceneObjectPart m_host;
protected uint m_localID;
/// <summary> /// <summary>
/// The item that hosts this script /// The item that hosts this script
@ -108,11 +107,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
protected Dictionary<UUID, UserInfoCacheEntry> m_userInfoCache = protected Dictionary<UUID, UserInfoCacheEntry> m_userInfoCache =
new Dictionary<UUID, UserInfoCacheEntry>(); new Dictionary<UUID, UserInfoCacheEntry>();
public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, uint localID, TaskInventoryItem item) public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, TaskInventoryItem item)
{ {
m_ScriptEngine = ScriptEngine; m_ScriptEngine = ScriptEngine;
m_host = host; m_host = host;
m_localID = localID;
m_item = item; m_item = item;
m_ScriptDelayFactor = m_ScriptDelayFactor =
@ -841,7 +839,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
UUID.TryParse(ID, out keyID); UUID.TryParse(ID, out keyID);
IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>();
if (wComm != null) 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 else
return -1; return -1;
} }
@ -868,7 +866,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
UUID keyID = UUID.Zero; UUID keyID = UUID.Zero;
UUID.TryParse(id, out keyID); 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) public void llSensorRepeat(string name, string id, int type, double range, double arc, double rate)
@ -877,13 +875,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
UUID keyID = UUID.Zero; UUID keyID = UUID.Zero;
UUID.TryParse(id, out keyID); 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() public void llSensorRemove()
{ {
m_host.AddScriptLPS(1); 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) public string resolveName(UUID objecUUID)
@ -2870,7 +2868,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
sec = m_MinTimerInterval; sec = m_MinTimerInterval;
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
// Setting timer repeat // 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) public virtual void llSleep(double sec)
@ -2909,7 +2907,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{ {
if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0) 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);
} }
} }
} }
@ -2930,7 +2928,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0) if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0)
{ {
// Unregister controls from Presence // Unregister controls from Presence
presence.UnRegisterControlEventsToScript(m_localID, m_item.ItemID); presence.UnRegisterControlEventsToScript(m_host.LocalId, m_item.ItemID);
// Remove Take Control permission. // Remove Take Control permission.
m_item.PermsMask &= ~ScriptBaseClass.PERMISSION_TAKE_CONTROLS; m_item.PermsMask &= ~ScriptBaseClass.PERMISSION_TAKE_CONTROLS;
} }
@ -4047,7 +4045,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
UUID rq = UUID.Random(); UUID rq = UUID.Random();
UUID tid = AsyncCommands. UUID tid = AsyncCommands.
DataserverPlugin.RegisterRequest(m_localID, DataserverPlugin.RegisterRequest(m_host.LocalId,
m_item.ItemID, rq.ToString()); m_item.ItemID, rq.ToString());
AsyncCommands. AsyncCommands.
@ -4068,7 +4066,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (item.Type == 3 && item.Name == name) if (item.Type == 3 && item.Name == name)
{ {
UUID tid = AsyncCommands. UUID tid = AsyncCommands.
DataserverPlugin.RegisterRequest(m_localID, DataserverPlugin.RegisterRequest(m_host.LocalId,
m_item.ItemID, item.AssetID.ToString()); m_item.ItemID, item.AssetID.ToString());
Vector3 region = new Vector3( Vector3 region = new Vector3(
@ -6533,7 +6531,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
IXMLRPC xmlrpcMod = m_ScriptEngine.World.RequestModuleInterface<IXMLRPC>(); IXMLRPC xmlrpcMod = m_ScriptEngine.World.RequestModuleInterface<IXMLRPC>();
if (xmlrpcMod.IsEnabled()) 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<IXmlRpcRouter>(); IXmlRpcRouter xmlRpcRouter = m_ScriptEngine.World.RequestModuleInterface<IXmlRpcRouter>();
if (xmlRpcRouter != null) if (xmlRpcRouter != null)
{ {
@ -6563,7 +6561,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
IXMLRPC xmlrpcMod = m_ScriptEngine.World.RequestModuleInterface<IXMLRPC>(); IXMLRPC xmlrpcMod = m_ScriptEngine.World.RequestModuleInterface<IXMLRPC>();
ScriptSleep(3000); 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) public void llRemoteDataReply(string channel, string message_id, string sdata, int idata)
@ -9051,7 +9049,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
UUID rq = UUID.Random(); UUID rq = UUID.Random();
UUID tid = AsyncCommands. UUID tid = AsyncCommands.
DataserverPlugin.RegisterRequest(m_localID, m_item.ItemID, rq.ToString()); DataserverPlugin.RegisterRequest(m_host.LocalId, m_item.ItemID, rq.ToString());
AsyncCommands. AsyncCommands.
DataserverPlugin.DataserverReply(rq.ToString(), reply); DataserverPlugin.DataserverReply(rq.ToString(), reply);
@ -9950,8 +9948,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
} }
} }
UUID reqID = httpScriptMod. UUID reqID
StartHttpRequest(m_localID, m_item.ItemID, url, param, httpHeaders, body); = httpScriptMod.StartHttpRequest(m_host.LocalId, m_item.ItemID, url, param, httpHeaders, body);
if (reqID != UUID.Zero) if (reqID != UUID.Zero)
return reqID.ToString(); return reqID.ToString();
@ -10304,7 +10302,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
} }
// was: UUID tid = tid = AsyncCommands. // 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)) if (NotecardCache.IsCached(assetID))
{ {
@ -10366,7 +10364,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
} }
// was: UUID tid = tid = AsyncCommands. // 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)) if (NotecardCache.IsCached(assetID))
{ {
@ -10452,7 +10450,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{ {
UUID rq = UUID.Random(); 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))); AsyncCommands.DataserverPlugin.DataserverReply(rq.ToString(), Name2Username(llKey2Name(id)));
@ -10468,7 +10466,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{ {
UUID rq = UUID.Random(); 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)); AsyncCommands.DataserverPlugin.DataserverReply(rq.ToString(), llKey2Name(id));

View File

@ -58,15 +58,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{ {
internal IScriptEngine m_ScriptEngine; internal IScriptEngine m_ScriptEngine;
internal SceneObjectPart m_host; internal SceneObjectPart m_host;
internal uint m_localID;
internal bool m_LSFunctionsEnabled = false; internal bool m_LSFunctionsEnabled = false;
internal IScriptModuleComms m_comms = null; 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_ScriptEngine = ScriptEngine;
m_host = host; m_host = host;
m_localID = localID;
if (m_ScriptEngine.Config.GetBoolean("AllowLightShareFunctions", false)) if (m_ScriptEngine.Config.GetBoolean("AllowLightShareFunctions", false))
m_LSFunctionsEnabled = true; m_LSFunctionsEnabled = true;

View File

@ -57,16 +57,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{ {
internal IScriptEngine m_ScriptEngine; internal IScriptEngine m_ScriptEngine;
internal SceneObjectPart m_host; internal SceneObjectPart m_host;
internal uint m_localID;
internal TaskInventoryItem m_item; internal TaskInventoryItem m_item;
internal bool m_MODFunctionsEnabled = false; internal bool m_MODFunctionsEnabled = false;
internal IScriptModuleComms m_comms = null; 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_ScriptEngine = ScriptEngine;
m_host = host; m_host = host;
m_localID = localID;
m_item = item; m_item = item;
if (m_ScriptEngine.Config.GetBoolean("AllowMODFunctions", false)) if (m_ScriptEngine.Config.GetBoolean("AllowMODFunctions", false))

View File

@ -133,7 +133,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
internal IScriptEngine m_ScriptEngine; 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 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 SceneObjectPart m_host;
internal uint m_localID;
internal TaskInventoryItem m_item; internal TaskInventoryItem m_item;
internal bool m_OSFunctionsEnabled = false; internal bool m_OSFunctionsEnabled = false;
internal ThreatLevel m_MaxThreatLevel = ThreatLevel.VeryLow; internal ThreatLevel m_MaxThreatLevel = ThreatLevel.VeryLow;
@ -141,11 +140,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
internal float m_ScriptDistanceFactor = 1.0f; internal float m_ScriptDistanceFactor = 1.0f;
internal Dictionary<string, FunctionPerms > m_FunctionPerms = new Dictionary<string, FunctionPerms >(); internal Dictionary<string, FunctionPerms > m_FunctionPerms = new Dictionary<string, FunctionPerms >();
public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, uint localID, TaskInventoryItem item) public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, TaskInventoryItem item)
{ {
m_ScriptEngine = ScriptEngine; m_ScriptEngine = ScriptEngine;
m_host = host; m_host = host;
m_localID = localID;
m_item = item; m_item = item;
if (m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false)) if (m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false))

View File

@ -232,7 +232,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
foreach (string api in am.GetApis()) foreach (string api in am.GetApis())
{ {
m_Apis[api] = am.CreateApi(api); m_Apis[api] = am.CreateApi(api);
m_Apis[api].Initialize(engine, part, LocalID, ScriptTask); m_Apis[api].Initialize(engine, part, ScriptTask);
} }
try try

View File

@ -88,11 +88,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
// Create an object embedded inside the first // Create an object embedded inside the first
UUID itemId = TestHelpers.ParseTail(0x20); 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(); 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 // Create a second object
SceneObjectGroup so2 = SceneHelpers.CreateSceneObject(1, userId, "so2", 0x100); 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); SceneObjectGroup so1 = SceneHelpers.CreateSceneObject(1, user1Id, "so1", 0x10);
m_scene.AddSceneObject(so1); m_scene.AddSceneObject(so1);
LSL_Api api = new LSL_Api(); 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 // Create an object embedded inside the first
UUID itemId = TestHelpers.ParseTail(0x20); UUID itemId = TestHelpers.ParseTail(0x20);
@ -135,7 +134,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
SceneObjectGroup so2 = SceneHelpers.CreateSceneObject(1, user2Id, "so2", 0x100); SceneObjectGroup so2 = SceneHelpers.CreateSceneObject(1, user2Id, "so2", 0x100);
m_scene.AddSceneObject(so2); m_scene.AddSceneObject(so2);
LSL_Api api2 = new LSL_Api(); 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. *** // *** Firstly, we test where llAllowInventoryDrop() has not been called. ***
api.llGiveInventory(so2.UUID.ToString(), inventoryItemName); api.llGiveInventory(so2.UUID.ToString(), inventoryItemName);

View File

@ -66,7 +66,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
engine.AddRegion(scene); engine.AddRegion(scene);
m_lslApi = new LSL_Api(); m_lslApi = new LSL_Api();
m_lslApi.Initialize(engine, part, part.LocalId, null); m_lslApi.Initialize(engine, part, null);
} }
[Test] [Test]

View File

@ -95,7 +95,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
m_scene.AddSceneObject(so); m_scene.AddSceneObject(so);
OSSL_Api osslApi = new OSSL_Api(); OSSL_Api osslApi = new OSSL_Api();
osslApi.Initialize(m_engine, part, part.LocalId, null); osslApi.Initialize(m_engine, part, null);
string notecardName = "appearanceNc"; string notecardName = "appearanceNc";
osslApi.osOwnerSaveAppearance(notecardName); osslApi.osOwnerSaveAppearance(notecardName);
@ -130,7 +130,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
m_scene.AddSceneObject(so); m_scene.AddSceneObject(so);
OSSL_Api osslApi = new OSSL_Api(); OSSL_Api osslApi = new OSSL_Api();
osslApi.Initialize(m_engine, part, part.LocalId, null); osslApi.Initialize(m_engine, part, null);
string notecardName = "appearanceNc"; string notecardName = "appearanceNc";
osslApi.osOwnerSaveAppearance(notecardName); osslApi.osOwnerSaveAppearance(notecardName);
@ -161,7 +161,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
m_scene.AddSceneObject(so); m_scene.AddSceneObject(so);
OSSL_Api osslApi = new OSSL_Api(); OSSL_Api osslApi = new OSSL_Api();
osslApi.Initialize(m_engine, part, part.LocalId, null); osslApi.Initialize(m_engine, part, null);
string notecardName = "appearanceNc"; string notecardName = "appearanceNc";
@ -202,7 +202,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
m_scene.AddSceneObject(so); m_scene.AddSceneObject(so);
OSSL_Api osslApi = new OSSL_Api(); OSSL_Api osslApi = new OSSL_Api();
osslApi.Initialize(m_engine, part, part.LocalId, null); osslApi.Initialize(m_engine, part, null);
string notecardName = "appearanceNc"; string notecardName = "appearanceNc";

View File

@ -104,10 +104,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
m_scene.AddSceneObject(otherSo); m_scene.AddSceneObject(otherSo);
OSSL_Api osslApi = new OSSL_Api(); 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(); OSSL_Api otherOsslApi = new OSSL_Api();
otherOsslApi.Initialize(m_engine, otherPart, otherPart.LocalId, null); otherOsslApi.Initialize(m_engine, otherPart, null);
string notecardName = "appearanceNc"; string notecardName = "appearanceNc";
osslApi.osOwnerSaveAppearance(notecardName); osslApi.osOwnerSaveAppearance(notecardName);
@ -151,7 +151,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
m_scene.AddSceneObject(so); m_scene.AddSceneObject(so);
OSSL_Api osslApi = new OSSL_Api(); OSSL_Api osslApi = new OSSL_Api();
osslApi.Initialize(m_engine, part, part.LocalId, null); osslApi.Initialize(m_engine, part, null);
string notecardName = "appearanceNc"; string notecardName = "appearanceNc";
osslApi.osOwnerSaveAppearance(notecardName); osslApi.osOwnerSaveAppearance(notecardName);