Pipe Throttle Update Event to EventManager, client --> ScenePresence --> EventManager, so that modules can know when throttles are updated. The event contains no client specific data to preserve the possibility of 'multiple clients' and you must still call ControllingClient.GetThrottlesPacked(f) to see what the throttles actually are once the event fires. Hook EventManager.OnUpdateThrottle to GetTextureModule.

avinationmerge
teravus 2012-11-04 22:57:24 -05:00
parent 08b37efc32
commit 4fa088bafb
8 changed files with 75 additions and 3 deletions

View File

@ -1038,7 +1038,7 @@ namespace OpenSim.Framework
event MuteListEntryRemove OnRemoveMuteListEntry; event MuteListEntryRemove OnRemoveMuteListEntry;
event GodlikeMessage onGodlikeMessage; event GodlikeMessage onGodlikeMessage;
event GodUpdateRegionInfoUpdate OnGodUpdateRegionInfoUpdate; event GodUpdateRegionInfoUpdate OnGodUpdateRegionInfoUpdate;
event GenericCall2 OnUpdateThrottles;
/// <summary> /// <summary>
/// Set the debug level at which packet output should be printed to console. /// Set the debug level at which packet output should be printed to console.
/// </summary> /// </summary>

View File

@ -91,6 +91,7 @@ namespace OpenSim.Region.ClientStack.Linden
{ {
m_scene.EventManager.OnRegisterCaps -= RegisterCaps; m_scene.EventManager.OnRegisterCaps -= RegisterCaps;
m_scene.EventManager.OnDeregisterCaps -= DeregisterCaps; m_scene.EventManager.OnDeregisterCaps -= DeregisterCaps;
m_scene.EventManager.OnThrottleUpdate -= ThrottleUpdate;
m_scene = null; m_scene = null;
} }
@ -101,6 +102,7 @@ namespace OpenSim.Region.ClientStack.Linden
m_scene.EventManager.OnRegisterCaps += RegisterCaps; m_scene.EventManager.OnRegisterCaps += RegisterCaps;
m_scene.EventManager.OnDeregisterCaps += DeregisterCaps; m_scene.EventManager.OnDeregisterCaps += DeregisterCaps;
m_scene.EventManager.OnThrottleUpdate += ThrottleUpdate;
if (m_workerThreads == null) if (m_workerThreads == null)
{ {
@ -118,6 +120,46 @@ namespace OpenSim.Region.ClientStack.Linden
} }
} }
} }
private int ExtractImageThrottle(byte[] pthrottles)
{
byte[] adjData;
int pos = 0;
if (!BitConverter.IsLittleEndian)
{
byte[] newData = new byte[7 * 4];
Buffer.BlockCopy(pthrottles, 0, newData, 0, 7 * 4);
for (int i = 0; i < 7; i++)
Array.Reverse(newData, i * 4, 4);
adjData = newData;
}
else
{
adjData = pthrottles;
}
// 0.125f converts from bits to bytes
//int resend = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); pos += 4;
// int land = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); pos += 4;
// int wind = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); pos += 4;
// int cloud = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); pos += 4;
// int task = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); pos += 4;
pos = pos + 16;
int texture = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); pos += 4;
//int asset = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f);
return texture;
}
// Now we know when the throttle is changed by the client in the case of a root agent or by a neighbor region in the case of a child agent.
public void ThrottleUpdate(ScenePresence p)
{
byte[] throttles = p.ControllingClient.GetThrottlesPacked(1);
UUID user = p.UUID;
int imagethrottle = ExtractImageThrottle(throttles);
}
public void PostInitialise() public void PostInitialise()
{ {

View File

@ -295,6 +295,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
public event MuteListEntryRemove OnRemoveMuteListEntry; public event MuteListEntryRemove OnRemoveMuteListEntry;
public event GodlikeMessage onGodlikeMessage; public event GodlikeMessage onGodlikeMessage;
public event GodUpdateRegionInfoUpdate OnGodUpdateRegionInfoUpdate; public event GodUpdateRegionInfoUpdate OnGodUpdateRegionInfoUpdate;
public event GenericCall2 OnUpdateThrottles;
#endregion Events #endregion Events
@ -6729,6 +6730,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP
#endregion #endregion
m_udpClient.SetThrottles(atpack.Throttle.Throttles); m_udpClient.SetThrottles(atpack.Throttle.Throttles);
GenericCall2 handler = OnUpdateThrottles;
if (handler != null)
{
handler();
}
return true; return true;
} }
@ -11870,6 +11876,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP
public void SetChildAgentThrottle(byte[] throttles) public void SetChildAgentThrottle(byte[] throttles)
{ {
m_udpClient.SetThrottles(throttles); m_udpClient.SetThrottles(throttles);
GenericCall2 handler = OnUpdateThrottles;
if (handler != null)
{
handler();
}
} }
/// <summary> /// <summary>

View File

@ -376,6 +376,10 @@ namespace OpenSim.Region.Framework.Scenes
public event ParcelPrimCountTainted OnParcelPrimCountTainted; public event ParcelPrimCountTainted OnParcelPrimCountTainted;
public event GetScriptRunning OnGetScriptRunning; public event GetScriptRunning OnGetScriptRunning;
public delegate void ThrottleUpdate(ScenePresence scenePresence);
public event ThrottleUpdate OnThrottleUpdate;
/// <summary> /// <summary>
/// RegisterCapsEvent is called by Scene after the Caps object /// RegisterCapsEvent is called by Scene after the Caps object
/// has been instantiated and before it is return to the /// has been instantiated and before it is return to the
@ -2641,5 +2645,14 @@ namespace OpenSim.Region.Framework.Scenes
} }
} }
} }
public void TriggerThrottleUpdate(ScenePresence scenePresence)
{
ThrottleUpdate handler = OnThrottleUpdate;
if (handler != null)
{
handler(scenePresence);
}
}
} }
} }

View File

@ -793,6 +793,7 @@ namespace OpenSim.Region.Framework.Scenes
ControllingClient.OnChangeAnim += avnHandleChangeAnim; ControllingClient.OnChangeAnim += avnHandleChangeAnim;
ControllingClient.OnForceReleaseControls += HandleForceReleaseControls; ControllingClient.OnForceReleaseControls += HandleForceReleaseControls;
ControllingClient.OnAutoPilotGo += MoveToTarget; ControllingClient.OnAutoPilotGo += MoveToTarget;
ControllingClient.OnUpdateThrottles += RaiseUpdateThrottles;
// ControllingClient.OnChildAgentStatus += new StatusChange(this.ChildStatusChange); // ControllingClient.OnChildAgentStatus += new StatusChange(this.ChildStatusChange);
// ControllingClient.OnStopMovement += new GenericCall2(this.StopMovement); // ControllingClient.OnStopMovement += new GenericCall2(this.StopMovement);
@ -3166,6 +3167,10 @@ namespace OpenSim.Region.Framework.Scenes
} }
private static Vector3 marker = new Vector3(-1f, -1f, -1f); private static Vector3 marker = new Vector3(-1f, -1f, -1f);
private void RaiseUpdateThrottles()
{
m_scene.EventManager.TriggerThrottleUpdate(this);
}
/// <summary> /// <summary>
/// This updates important decision making data about a child agent /// This updates important decision making data about a child agent
/// The main purpose is to figure out what objects to send to a child agent that's in a neighboring region /// The main purpose is to figure out what objects to send to a child agent that's in a neighboring region

View File

@ -873,6 +873,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
public event MuteListEntryRemove OnRemoveMuteListEntry; public event MuteListEntryRemove OnRemoveMuteListEntry;
public event GodlikeMessage onGodlikeMessage; public event GodlikeMessage onGodlikeMessage;
public event GodUpdateRegionInfoUpdate OnGodUpdateRegionInfoUpdate; public event GodUpdateRegionInfoUpdate OnGodUpdateRegionInfoUpdate;
public event GenericCall2 OnUpdateThrottles;
#pragma warning restore 67 #pragma warning restore 67

View File

@ -473,7 +473,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
public event MuteListEntryRemove OnRemoveMuteListEntry; public event MuteListEntryRemove OnRemoveMuteListEntry;
public event GodlikeMessage onGodlikeMessage; public event GodlikeMessage onGodlikeMessage;
public event GodUpdateRegionInfoUpdate OnGodUpdateRegionInfoUpdate; public event GodUpdateRegionInfoUpdate OnGodUpdateRegionInfoUpdate;
public event GenericCall2 OnUpdateThrottles;
#pragma warning restore 67 #pragma warning restore 67
#endregion #endregion

View File

@ -320,7 +320,7 @@ namespace OpenSim.Tests.Common.Mock
public event MuteListEntryRemove OnRemoveMuteListEntry; public event MuteListEntryRemove OnRemoveMuteListEntry;
public event GodlikeMessage onGodlikeMessage; public event GodlikeMessage onGodlikeMessage;
public event GodUpdateRegionInfoUpdate OnGodUpdateRegionInfoUpdate; public event GodUpdateRegionInfoUpdate OnGodUpdateRegionInfoUpdate;
public event GenericCall2 OnUpdateThrottles;
#pragma warning restore 67 #pragma warning restore 67
/// <value> /// <value>