Mantis#1437. Patch one of four. Thank you kindly, Melanie for:

Corrects the XEngine's script startup semantics.
Completes llRequestAgentData
Implements llDetectedLink
Fixes a few minor issues
0.6.0-stable
Charles Krinke 2008-06-05 14:15:15 +00:00
parent e2d87b04e3
commit e3c14e9b24
6 changed files with 95 additions and 37 deletions

View File

@ -322,6 +322,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine.AsyncCommandPlugins
int idx;
for (idx = 0; idx < SensedObjects.Length; idx++)
{
detect[idx] = new XDetectParams();
detect[idx].Key=(LLUUID)(SensedObjects.Data[idx]);
}

View File

@ -59,8 +59,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine.AsyncCommandPlugins
public void SetTimerEvent(uint m_localID, LLUUID m_itemID, double sec)
{
Console.WriteLine("SetTimerEvent");
// Always remove first, in case this is a re-set
UnSetTimerEvents(m_localID, m_itemID);
if (sec == 0) // Disabling timer

View File

@ -79,8 +79,18 @@ namespace OpenSim.Region.ScriptEngine.XEngine
{
// Add to queue for all scripts in ObjectID object
XDetectParams[] det = new XDetectParams[1];
det[0] = new XDetectParams();
det[0].Key = remoteClient.AgentId;
SceneObjectPart part = myScriptEngine.World.GetSceneObjectPart(
localID);
if(part == null)
return;
det[0].LinkNum = 0;
if(part.ParentGroup.Children.Count > 0)
det[0].LinkNum = part.LinkNum + 1;
myScriptEngine.PostObjectEvent(localID, new XEventParams(
"touch_start", new Object[] { new LSL_Types.LSLInteger(1) },
det));
@ -91,11 +101,21 @@ namespace OpenSim.Region.ScriptEngine.XEngine
{
// Add to queue for all scripts in ObjectID object
XDetectParams[] det = new XDetectParams[1];
det[0] = new XDetectParams();
det[0].Key = remoteClient.AgentId;
det[0].OffsetPos = new LSL_Types.Vector3(offsetPos.X,
offsetPos.Y,
offsetPos.Z);
SceneObjectPart part = myScriptEngine.World.GetSceneObjectPart(
localID);
if(part == null)
return;
det[0].LinkNum = 0;
if(part.ParentGroup.Children.Count > 0)
det[0].LinkNum = part.LinkNum + 1;
myScriptEngine.PostObjectEvent(localID, new XEventParams(
"touch", new Object[] { new LSL_Types.LSLInteger(1) },
det));
@ -105,8 +125,18 @@ namespace OpenSim.Region.ScriptEngine.XEngine
{
// Add to queue for all scripts in ObjectID object
XDetectParams[] det = new XDetectParams[1];
det[0] = new XDetectParams();
det[0].Key = remoteClient.AgentId;
SceneObjectPart part = myScriptEngine.World.GetSceneObjectPart(
localID);
if(part == null)
return;
det[0].LinkNum = 0;
if(part.ParentGroup.Children.Count > 0)
det[0].LinkNum = part.LinkNum + 1;
myScriptEngine.PostObjectEvent(localID, new XEventParams(
"touch_end", new Object[] { new LSL_Types.LSLInteger(1) },
det));
@ -137,6 +167,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
{
// Add to queue for all scripts in ObjectID object
XDetectParams[] det = new XDetectParams[1];
det[0] = new XDetectParams();
det[0].Key = remoteClient.AgentId;
myScriptEngine.PostObjectEvent(localID, new XEventParams(
@ -150,6 +181,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
{
// Add to queue for all scripts in ObjectID object
XDetectParams[] det = new XDetectParams[1];
det[0] = new XDetectParams();
det[0].Key = remoteClient.AgentId;
myScriptEngine.PostObjectEvent(localID, new XEventParams(
@ -162,6 +194,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
{
// Add to queue for all scripts in ObjectID object
XDetectParams[] det = new XDetectParams[1];
det[0] = new XDetectParams();
det[0].Key = remoteClient.AgentId;
myScriptEngine.PostObjectEvent(localID, new XEventParams(

View File

@ -524,7 +524,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
{
m_host.AddScriptLPS(1);
LLUUID sensedUUID = m_ScriptEngine.GetDetectID(m_itemID, number);
if (sensedUUID != null)
if (sensedUUID != LLUUID.Zero)
return resolveName(sensedUUID);
return String.Empty;
}
@ -537,7 +537,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
public EntityBase entityDetectedKey(int number)
{
LLUUID sensedUUID = m_ScriptEngine.GetDetectID(m_itemID, number);
if (sensedUUID != null)
if (sensedUUID != LLUUID.Zero)
{
EntityBase SensedObject = null;
lock (World.Entities)
@ -636,6 +636,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
{
m_host.AddScriptLPS(1);
XDetectParams parms = m_ScriptEngine.GetDetectParams(m_itemID, number);
if(parms == null)
return new LSL_Types.Vector3(0, 0, 0);
return parms.OffsetPos;
}
@ -660,8 +662,11 @@ namespace OpenSim.Region.ScriptEngine.XEngine
public LSL_Types.LSLInteger llDetectedLinkNumber(int number)
{
m_host.AddScriptLPS(1);
NotImplemented("llDetectedLinkNumber");
return 0;
XDetectParams parms = m_ScriptEngine.GetDetectParams(m_itemID, number);
if(parms == null)
return new LSL_Types.LSLInteger(0);
return new LSL_Types.LSLInteger(parms.LinkNum);
}
public void llDie()
@ -1920,8 +1925,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
msg.fromAgentSession = new Guid(friendTransactionID.ToString());// fromAgentSession.UUID;
msg.toAgentID = new Guid(user); // toAgentID.UUID;
msg.imSessionID = new Guid(friendTransactionID.ToString()); // This is the item we're mucking with here
Console.WriteLine("[Scripting IM]: From:" + msg.fromAgentID.ToString() + " To: " + msg.toAgentID.ToString() + " Session:" + msg.imSessionID.ToString() + " Message:" + message);
Console.WriteLine("[Scripting IM]: Filling Session: " + msg.imSessionID.ToString());
// Console.WriteLine("[Scripting IM]: From:" + msg.fromAgentID.ToString() + " To: " + msg.toAgentID.ToString() + " Session:" + msg.imSessionID.ToString() + " Message:" + message);
// Console.WriteLine("[Scripting IM]: Filling Session: " + msg.imSessionID.ToString());
msg.timestamp = (uint)Util.UnixTimeSinceEpoch();// timestamp;
//if (client != null)
//{
@ -2513,15 +2518,21 @@ namespace OpenSim.Region.ScriptEngine.XEngine
UserProfileData userProfile =
World.CommsManager.UserService.GetUserProfile(id);
UserAgentData userAgent =
World.CommsManager.UserService.GetAgentByUUID(id);
if(userProfile == null || userAgent == null)
return LLUUID.Zero.ToString();
string reply = String.Empty;
switch (data)
{
case 1: // DATA_ONLINE (0|1)
// TODO: implement fetching of this information
// if (userProfile.CurrentAgent.AgentOnline)
// reply = "1";
// else
if (userProfile.CurrentAgent.AgentOnline)
reply = "1";
else
reply = "0";
break;
case 2: // DATA_NAME (First Last)
@ -2672,8 +2683,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine
case (int)BuiltIn_Commands_BaseClass.LINK_SET:
Console.WriteLine("LINK_SET");
foreach (SceneObjectPart partInst in m_host.ParentGroup.GetParts())
{
@ -6280,7 +6289,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
System.Text.ASCIIEncoding enc =
new System.Text.ASCIIEncoding();
string data = enc.GetString(a.Data);
Console.WriteLine(data);
//Console.WriteLine(data);
NotecardCache.Cache(id, data);
m_ScriptEngine.m_ASYNCLSLCommandManager.
m_Dataserver.DataserverReply(id.ToString(),
@ -6316,7 +6325,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
System.Text.ASCIIEncoding enc =
new System.Text.ASCIIEncoding();
string data = enc.GetString(a.Data);
Console.WriteLine(data);
//Console.WriteLine(data);
NotecardCache.Cache(id, data);
m_ScriptEngine.m_ASYNCLSLCommandManager.
m_Dataserver.DataserverReply(id.ToString(),

View File

@ -81,10 +81,13 @@ namespace OpenSim.Region.ScriptEngine.XEngine.Script
public Dictionary<string, object> GetVars()
{
m_Fields.Clear();
Dictionary<string, object> vars = new Dictionary<string, object>();
if(m_Fields == null)
return vars;
m_Fields.Clear();
Type t = GetType();
FieldInfo[] fields = t.GetFields(BindingFlags.NonPublic |

View File

@ -280,9 +280,10 @@ namespace OpenSim.Region.ScriptEngine.XEngine
//
public void OnRezScript(uint localID, LLUUID itemID, string script)
{
m_ThreadPool.QueueWorkItem(new WorkItemCallback(
this.DoOnRezScript), new Object[]
{ localID, itemID, script});
// m_ThreadPool.QueueWorkItem(new WorkItemCallback(
// this.DoOnRezScript), new Object[]
// { localID, itemID, script});
DoOnRezScript(new Object[] { localID, itemID, script});
}
private object DoOnRezScript(object parm)
@ -346,15 +347,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine
{
// Create the object record
if (!m_PrimObjects.ContainsKey(localID))
m_PrimObjects[localID] = new List<LLUUID>();
if (!m_PrimObjects[localID].Contains(itemID))
m_PrimObjects[localID].Add(itemID);
if (!m_Assemblies.ContainsKey(assetID))
m_Assemblies[assetID] = assembly;
if ((!m_Scripts.ContainsKey(itemID)) ||
(m_Scripts[itemID].AssetID != assetID))
{
@ -402,6 +394,15 @@ namespace OpenSim.Region.ScriptEngine.XEngine
m_Scripts[itemID] = instance;
}
if(!m_PrimObjects.ContainsKey(localID))
m_PrimObjects[localID] = new List<LLUUID>();
if(!m_PrimObjects[localID].Contains(itemID))
m_PrimObjects[localID].Add(itemID);
if(!m_Assemblies.ContainsKey(assetID))
m_Assemblies[assetID] = assembly;
}
return true;
}
@ -653,7 +654,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
XScriptInstance instance = GetInstance(itemID);
if (instance != null)
return instance.GetDetectParams(idx);
return new XDetectParams();
return null;
}
public LLUUID GetDetectID(LLUUID itemID, int idx)
@ -665,10 +666,11 @@ namespace OpenSim.Region.ScriptEngine.XEngine
}
}
public struct XDetectParams
public class XDetectParams
{
public LLUUID Key;
public LSL_Types.Vector3 OffsetPos;
public int LinkNum;
}
public class XEventParams
@ -886,6 +888,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
{
if (m_CurrentResult == null)
m_CurrentResult = m_Engine.QueueEventHandler(this);
else
m_Engine.Log.Error("[XEngine] Tried to start a script that was already queued");
}
}
}
@ -923,12 +927,22 @@ namespace OpenSim.Region.ScriptEngine.XEngine
lock (m_EventQueue)
{
if (m_CurrentResult != null)
m_CurrentResult.Abort();
else
return true;
result = m_CurrentResult;
}
if(result == null)
return true;
if(SmartThreadPool.WaitAll(new IWorkItemResult[] {result}, new TimeSpan((long)10000000), false))
{
lock(m_EventQueue)
{
m_CurrentResult = null;
}
return true;
}
m_Engine.Log.Error("[XEngine] Failed to reliably stop script");
return true;
}
@ -1109,7 +1123,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
public XDetectParams GetDetectParams(int idx)
{
if (idx < 0 || idx >= m_DetectParams.Length)
return new XDetectParams();
return null;
return m_DetectParams[idx];
}
@ -1307,7 +1321,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
LLUUID.TryParse(det.InnerText,
out uuid);
XDetectParams d;
XDetectParams d = new XDetectParams();
d.Key = uuid;
d.OffsetPos = v;