mirror of
https://github.com/opensim/opensim.git
synced 2026-08-12 20:55:43 +08:00
Merge branch 'master' of https://github.com/opensim/opensim
This commit is contained in:
@@ -1003,6 +1003,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
// reset agent update args
|
||||
m_thisAgentUpdateArgs.CameraAtAxis.X = float.MinValue;
|
||||
m_thisAgentUpdateArgs.lastUpdateTS = 0;
|
||||
m_thisAgentUpdateArgs.lastMoveUpdateTS = 0;
|
||||
m_thisAgentUpdateArgs.ControlFlags = 0;
|
||||
|
||||
UDPPacketBuffer buf = OpenSimUDPBase.GetNewUDPBuffer(m_udpClient.RemoteEndPoint);
|
||||
@@ -8500,28 +8501,21 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
// Threshold for camera rotation to be a significant agent update
|
||||
private const float VDELTA = 0.01f;
|
||||
|
||||
/// <summary>
|
||||
/// This checks the update significance against the last update made.
|
||||
/// </summary>
|
||||
/// <remarks>Can only be called by one thread at a time</remarks>
|
||||
/// <returns></returns>
|
||||
/// <param name='x'></param>
|
||||
public bool CheckAgentUpdateSignificance(AgentUpdatePacket.AgentDataBlock x)
|
||||
{
|
||||
return CheckAgentMovementUpdateSignificance(x) || CheckAgentCameraUpdateSignificance(x);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This checks the movement/state update significance against the last update made.
|
||||
/// </summary>
|
||||
/// <remarks>Can only be called by one thread at a time</remarks>
|
||||
/// <returns></returns>
|
||||
/// <param name='x'></param>
|
||||
private bool CheckAgentMovementUpdateSignificance(AgentUpdatePacket.AgentDataBlock x)
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private bool CheckAgentMovementUpdateSignificance(AgentUpdatePacket.AgentDataBlock x, double now)
|
||||
{
|
||||
if(
|
||||
if((x.ControlFlags & ~(uint)AgentManager.ControlFlags.AGENT_CONTROL_FINISH_ANIM) != (uint)AgentManager.ControlFlags.NONE &&
|
||||
now > m_thisAgentUpdateArgs.lastMoveUpdateTS + 20)
|
||||
return true;
|
||||
|
||||
if (
|
||||
(x.ControlFlags != m_thisAgentUpdateArgs.ControlFlags) // significant if control flags changed
|
||||
|| (x.ControlFlags & ~(uint)AgentManager.ControlFlags.AGENT_CONTROL_FINISH_ANIM) != (uint)AgentManager.ControlFlags.NONE
|
||||
|| (x.Flags != m_thisAgentUpdateArgs.Flags) // significant if Flags changed
|
||||
|| (x.State != m_thisAgentUpdateArgs.State) // significant if Stats changed
|
||||
|| (MathF.Abs(x.Far - m_thisAgentUpdateArgs.Far) >= 32f) // significant if far distance changed
|
||||
@@ -8538,6 +8532,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
/// <remarks>Can only be called by one thread at a time</remarks>
|
||||
/// <returns></returns>
|
||||
/// <param name='x'></param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private bool CheckAgentCameraUpdateSignificance(AgentUpdatePacket.AgentDataBlock x)
|
||||
{
|
||||
return (MathF.Abs(x.CameraCenter.X - m_thisAgentUpdateArgs.CameraCenter.X) > VDELTA ||
|
||||
@@ -8575,26 +8570,28 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
|
||||
c.m_thisAgentUpdateArgs.lastpacketSequence = seq;
|
||||
|
||||
c.OnPreAgentUpdate?.Invoke(c, c.m_thisAgentUpdateArgs);
|
||||
|
||||
bool movement;
|
||||
bool camera;
|
||||
|
||||
double now = Util.GetTimeStampMS();
|
||||
if(now - c.m_thisAgentUpdateArgs.lastUpdateTS > 500.0) // at least 2 per sec
|
||||
if (now - c.m_thisAgentUpdateArgs.lastUpdateTS > 500.0) // at least 2 per sec
|
||||
{
|
||||
movement = true;
|
||||
camera = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
movement = c.CheckAgentMovementUpdateSignificance(x);
|
||||
movement = c.CheckAgentMovementUpdateSignificance(x, now);
|
||||
camera = c.CheckAgentCameraUpdateSignificance(x);
|
||||
}
|
||||
|
||||
c.OnPreAgentUpdate?.Invoke(c, c.m_thisAgentUpdateArgs);
|
||||
|
||||
// Was there a significant movement/state change?
|
||||
if (movement)
|
||||
{
|
||||
c.m_thisAgentUpdateArgs.lastMoveUpdateTS = now;
|
||||
|
||||
c.m_thisAgentUpdateArgs.BodyRotation = x.BodyRotation;
|
||||
c.m_thisAgentUpdateArgs.ControlFlags = x.ControlFlags;
|
||||
c.m_thisAgentUpdateArgs.Far = x.Far;
|
||||
|
||||
@@ -267,7 +267,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
return UUID.Zero;
|
||||
}
|
||||
|
||||
if (item.OwnerID.NotEqual(avatarId))
|
||||
if (!Permissions.CanEditObjectInventory(objectID, avatarId))
|
||||
return UUID.Zero;
|
||||
|
||||
InventoryType itemType = (InventoryType)item.InvType;
|
||||
|
||||
@@ -7788,17 +7788,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
public void llSetCameraEyeOffset(LSL_Vector offset)
|
||||
{
|
||||
m_host.SetCameraEyeOffset(offset);
|
||||
|
||||
if (m_host.ParentGroup.RootPart.GetCameraEyeOffset().IsZero())
|
||||
m_host.ParentGroup.RootPart.SetCameraEyeOffset(offset);
|
||||
}
|
||||
|
||||
public void llSetCameraAtOffset(LSL_Vector offset)
|
||||
{
|
||||
m_host.SetCameraAtOffset(offset);
|
||||
|
||||
if (m_host.ParentGroup.RootPart.GetCameraAtOffset().IsZero())
|
||||
m_host.ParentGroup.RootPart.SetCameraAtOffset(offset);
|
||||
}
|
||||
|
||||
public void llSetLinkCamera(LSL_Integer link, LSL_Vector eye, LSL_Vector at)
|
||||
@@ -14991,6 +14985,33 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
return tid.ToString();
|
||||
}
|
||||
|
||||
public LSL_String llGetNotecardLineSync(string name, int line)
|
||||
{
|
||||
if (line < 0)
|
||||
return ScriptBaseClass.NAK;
|
||||
|
||||
if (!UUID.TryParse(name, out UUID assetID))
|
||||
{
|
||||
TaskInventoryItem item = m_host.Inventory.GetInventoryItem(name, 7);
|
||||
|
||||
if (item is null)
|
||||
{
|
||||
Error("llGetNotecardLineSync", "Can't find notecard '" + name + "'");
|
||||
return ScriptBaseClass.NAK;
|
||||
}
|
||||
assetID = item.AssetID;
|
||||
}
|
||||
|
||||
if (NotecardCache.IsCached(assetID))
|
||||
{
|
||||
return NotecardCache.GetllLine(assetID, line, 1024);
|
||||
}
|
||||
else
|
||||
{
|
||||
return ScriptBaseClass.NAK;
|
||||
}
|
||||
}
|
||||
|
||||
public LSL_Key llGetNotecardLine(string name, int line)
|
||||
{
|
||||
if (!UUID.TryParse(name, out UUID assetID))
|
||||
@@ -18768,6 +18789,37 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public LSL_Integer llDerezObject(LSL_Key objectUUID, LSL_Integer flag)
|
||||
{
|
||||
if (!UUID.TryParse(objectUUID, out UUID objUUID))
|
||||
return new LSL_Integer(0);
|
||||
|
||||
if (objUUID.IsZero())
|
||||
return new LSL_Integer(0);
|
||||
|
||||
SceneObjectGroup sceneOG = World.GetSceneObjectGroup(objUUID);
|
||||
|
||||
if (sceneOG is null || sceneOG.IsDeleted || sceneOG.IsAttachment)
|
||||
return new LSL_Integer(0);
|
||||
|
||||
if (sceneOG.OwnerID.NotEqual(m_host.OwnerID))
|
||||
return new LSL_Integer(0);
|
||||
|
||||
// restrict to objects rezzed by host
|
||||
if (sceneOG.RezzerID.NotEqual(m_host.ParentGroup.UUID))
|
||||
return new LSL_Integer(0);
|
||||
|
||||
if (sceneOG.UUID.Equals(m_host.ParentGroup.UUID))
|
||||
return new LSL_Integer(0);
|
||||
|
||||
if (flag.value == 0)
|
||||
World.DeleteSceneObject(sceneOG, false);
|
||||
else
|
||||
sceneOG.RootPart.AddFlag(PrimFlags.TemporaryOnRez);
|
||||
|
||||
return new LSL_Integer(1);
|
||||
}
|
||||
}
|
||||
|
||||
public class NotecardCache
|
||||
@@ -18811,6 +18863,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
return "";
|
||||
}
|
||||
|
||||
public static string GetllLine(UUID assetID, int lineNumber, int maxLength)
|
||||
{
|
||||
if (m_Notecards.TryGetValue(assetID, 30000, out string[] text))
|
||||
{
|
||||
if (lineNumber >= text.Length)
|
||||
return "\n\n\n";
|
||||
|
||||
return text[lineNumber].Length < maxLength ? text[lineNumber] : text[lineNumber][..maxLength];
|
||||
}
|
||||
return ScriptBaseClass.NAK;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get a notecard line.
|
||||
/// </summary>
|
||||
|
||||
@@ -176,6 +176,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
|
||||
void llGetNextEmail(string address, string subject);
|
||||
LSL_Key llGetNotecardLine(string name, int line);
|
||||
LSL_Key llGetNumberOfNotecardLines(string name);
|
||||
LSL_String llGetNotecardLineSync(string name, int line);
|
||||
LSL_Integer llGetNumberOfPrims();
|
||||
LSL_Integer llGetNumberOfSides();
|
||||
LSL_String llGetObjectDesc();
|
||||
@@ -521,5 +522,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
|
||||
LSL_Integer llLinksetDataWriteProtected(LSL_String name, LSL_String value, LSL_String pass);
|
||||
|
||||
LSL_Integer llIsFriend(LSL_Key agent_id);
|
||||
LSL_Integer llDerezObject(LSL_Key objectUUID, LSL_Integer flag);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -609,6 +609,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
|
||||
|
||||
public const string NULL_KEY = "00000000-0000-0000-0000-000000000000";
|
||||
public const string EOF = "\n\n\n";
|
||||
public const string NAK = "\n\u0015\n";
|
||||
public const double PI = 3.14159274f;
|
||||
public const double TWO_PI = 6.28318548f;
|
||||
public const double PI_BY_TWO = 1.57079637f;
|
||||
|
||||
@@ -758,6 +758,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
|
||||
return m_LSL_Functions.llGetNumberOfNotecardLines(name);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public LSL_String llGetNotecardLineSync(string name, int line)
|
||||
{
|
||||
return m_LSL_Functions.llGetNotecardLineSync(name, line);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public LSL_Integer llGetNumberOfPrims()
|
||||
{
|
||||
@@ -2796,11 +2802,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
|
||||
{
|
||||
return m_LSL_Functions.llLinksetDataFindKeys(pattern, start, count);
|
||||
}
|
||||
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public LSL_Integer llIsFriend(LSL_Key agent_id)
|
||||
{
|
||||
return m_LSL_Functions.llIsFriend(agent_id);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public LSL_Integer llDerezObject(LSL_Key objectUUID, LSL_Integer flag)
|
||||
{
|
||||
return m_LSL_Functions.llDerezObject(objectUUID, flag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user