From 6252114ea02c07bab2b61fa882f4a26264cbb347 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 11 Jul 2012 09:03:18 +0100 Subject: remove expensive and leaked ( in Xengine at least) SayShout timer and replace it by a simpler function that should do the same (?) (don't like much those 10 + 1 bursts) --- .../Shared/Api/Implementation/LSL_Api.cs | 28 ++++++++++++++++++---- 1 file changed, 23 insertions(+), 5 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 05bb161..ca62bac 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -108,8 +108,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api protected Dictionary m_userInfoCache = new Dictionary(); - protected Timer m_ShoutSayTimer; +// protected Timer m_ShoutSayTimer; protected int m_SayShoutCount = 0; + DateTime m_lastSayShoutCheck; private Dictionary MovementAnimationsForLSL = new Dictionary { @@ -135,10 +136,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, uint localID, UUID itemID) { +/* m_ShoutSayTimer = new Timer(1000); m_ShoutSayTimer.Elapsed += SayShoutTimerElapsed; m_ShoutSayTimer.AutoReset = true; m_ShoutSayTimer.Start(); +*/ + m_lastSayShoutCheck = DateTime.UtcNow; m_ScriptEngine = ScriptEngine; m_host = host; @@ -900,12 +904,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api wComm.DeliverMessage(ChatTypeEnum.Whisper, channelID, m_host.Name, m_host.UUID, text); } + private void CheckSayShoutTime() + { + DateTime now = DateTime.UtcNow; + if ((now - m_lastSayShoutCheck).Ticks > 10000000) // 1sec + { + m_lastSayShoutCheck = now; + m_SayShoutCount = 0; + } + else + m_SayShoutCount++; + } + public void llSay(int channelID, string text) { m_host.AddScriptLPS(1); if (channelID == 0) - m_SayShoutCount++; +// m_SayShoutCount++; + CheckSayShoutTime(); if (m_SayShoutCount >= 11) ScriptSleep(2000); @@ -933,7 +950,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_host.AddScriptLPS(1); if (channelID == 0) - m_SayShoutCount++; +// m_SayShoutCount++; + CheckSayShoutTime(); if (m_SayShoutCount >= 11) ScriptSleep(2000); @@ -12373,12 +12391,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return rq.ToString(); } - +/* private void SayShoutTimerElapsed(Object sender, ElapsedEventArgs args) { m_SayShoutCount = 0; } - +*/ private struct Tri { public Vector3 p1; -- cgit v1.1