add LSL_Integer osGetLinkNumber(LSL_String name). uses a cache for the string to linknumber map, cache invalidations may still be missing :(

httptests
UbitUmarov 2017-04-04 19:27:45 +01:00
parent ca250e0b0b
commit e237e1b2fa
4 changed files with 77 additions and 0 deletions

View File

@ -1985,6 +1985,7 @@ namespace OpenSim.Region.Framework.Scenes
{
newRoot.TriggerScriptChangedEvent(Changed.LINK);
newRoot.ParentGroup.HasGroupChanged = true;
newRoot.ParentGroup.InvalidatePartsLinkMaps();
newRoot.ParentGroup.ScheduleGroupForFullUpdate();
}
}
@ -2001,6 +2002,7 @@ namespace OpenSim.Region.Framework.Scenes
// from the database. They will be rewritten immediately,
// minus the rows for the unlinked child prims.
m_parentScene.SimulationDataService.RemoveObject(g.UUID, m_parentScene.RegionInfo.RegionID);
g.InvalidatePartsLinkMaps();
g.TriggerScriptChangedEvent(Changed.LINK);
g.HasGroupChanged = true; // Persist
g.ScheduleGroupForFullUpdate();

View File

@ -2004,6 +2004,7 @@ namespace OpenSim.Region.Framework.Scenes
if (part.LinkNum == 2)
RootPart.LinkNum = 1;
InvalidatePartsLinkMaps();
}
/// <summary>
@ -2560,6 +2561,7 @@ namespace OpenSim.Region.Framework.Scenes
dupe.ScheduleGroupForFullUpdate();
}
dupe.InvalidatePartsLinkMaps();
m_dupeInProgress = false;
return dupe;
}
@ -3321,6 +3323,7 @@ namespace OpenSim.Region.Framework.Scenes
ResetChildPrimPhysicsPositions();
InvalidBoundsRadius();
InvalidatePartsLinkMaps();
if (m_rootPart.PhysActor != null)
m_rootPart.PhysActor.Building = false;
@ -3477,6 +3480,7 @@ namespace OpenSim.Region.Framework.Scenes
objectGroup.HasGroupChangedDueToDelink = true;
InvalidBoundsRadius();
InvalidatePartsLinkMaps();
objectGroup.AggregatePerms();
if (sendEvents)
@ -5333,6 +5337,63 @@ namespace OpenSim.Region.Framework.Scenes
m_PlaySoundSlavePrims.Clear();
m_LoopSoundMasterPrim = null;
m_targets.Clear();
m_partsNameToLinkMap.Clear();
}
Dictionary<string,int> m_partsNameToLinkMap = new Dictionary<string, int>();
// this scales bad but so does GetLinkNumPart
public int GetLinkNumber(string name)
{
if(String.IsNullOrEmpty(name) || name == "Object")
return -1;
lock(m_partsNameToLinkMap)
{
if(m_partsNameToLinkMap.Count == 0)
{
SceneObjectPart[] parts = m_parts.GetArray();
for (int i = 0; i < parts.Length; i++)
{
string s = parts[i].Name;
if(String.IsNullOrEmpty(s) || s == "Object" || s == "Primitive")
continue;
if(m_partsNameToLinkMap.ContainsKey(s))
{
int ol = parts[i].LinkNum;
if(ol < m_partsNameToLinkMap[s])
m_partsNameToLinkMap[s] = ol;
}
else
m_partsNameToLinkMap[s] = parts[i].LinkNum;
}
}
if(m_partsNameToLinkMap.ContainsKey(name))
return m_partsNameToLinkMap[name];
}
if(m_sittingAvatars.Count > 0)
{
int j = m_parts.Count;
if(j > 1)
j++;
ScenePresence[] avs = m_sittingAvatars.ToArray();
for (int i = 0; i < avs.Length; i++, j++)
{
if (avs[i].Name == name)
return j;
}
}
return -1;
}
public void InvalidatePartsLinkMaps()
{
lock(m_partsNameToLinkMap)
m_partsNameToLinkMap.Clear();
}
#endregion

View File

@ -4663,5 +4663,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
sog.TeleportObject(myid, targetPos, rotation, flags);
// a delay here may break vehicles
}
public LSL_Integer osGetLinkNumber(LSL_String name)
{
m_host.AddScriptLPS(1);
SceneObjectGroup sog = m_host.ParentGroup;
if(sog== null || sog.IsDeleted)
return -1;
return sog.GetLinkNumber(name);
}
}
}

View File

@ -1144,5 +1144,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
{
m_OSSL_Functions.osTeleportObject(objectUUID, targetPos, targetrotation, flags);
}
public LSL_Integer osGetLinkNumber(LSL_String name)
{
return m_OSSL_Functions.osGetLinkNumber(name);
}
}
}