Consolidated LoadAnims and AvatarAnimations constructor.

Fixes locking issues with Animations in ScenePresence (bug #324)
ThreadPoolClientBranch
Jeff Ames 2008-02-06 10:19:30 +00:00
parent 530d24da14
commit 3b42b5f098
3 changed files with 9 additions and 40 deletions

View File

@ -25,6 +25,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* *
*/ */
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Xml; using System.Xml;
@ -35,18 +36,11 @@ namespace OpenSim.Region.Environment.Scenes
{ {
public class AvatarAnimations public class AvatarAnimations
{ {
private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
public Dictionary<string, LLUUID> AnimsLLUUID = new Dictionary<string, LLUUID>(); public Dictionary<string, LLUUID> AnimsLLUUID = new Dictionary<string, LLUUID>();
public Dictionary<LLUUID, string> AnimsNames = new Dictionary<LLUUID, string>(); public Dictionary<LLUUID, string> AnimsNames = new Dictionary<LLUUID, string>();
public AvatarAnimations() public AvatarAnimations()
{ {
}
public void LoadAnims()
{
//m_log.Info("[CLIENT]: Loading avatar animations");
using (XmlTextReader reader = new XmlTextReader("data/avataranimations.xml")) using (XmlTextReader reader = new XmlTextReader("data/avataranimations.xml"))
{ {
XmlDocument doc = new XmlDocument(); XmlDocument doc = new XmlDocument();
@ -55,24 +49,13 @@ namespace OpenSim.Region.Environment.Scenes
{ {
if (nod.Attributes["name"] != null) if (nod.Attributes["name"] != null)
{ {
AnimsLLUUID.Add((string)nod.Attributes["name"].Value, (LLUUID)nod.InnerText); string name = (string)nod.Attributes["name"].Value;
} LLUUID id = (LLUUID)nod.InnerText;
}
}
// m_log.Info("[CLIENT]: Loaded " + AnimsLLUUID.Count.ToString() + " animation(s)"); AnimsLLUUID.Add(name, id);
AnimsNames.Add(id, name);
try
{
//Mantis: 0000224: 2755 - Enumeration Operation may not execute [immediate crash] (ODE/2750/WIN2003)
foreach (KeyValuePair<string, LLUUID> kp in ScenePresence.Animations.AnimsLLUUID)
{
AnimsNames.Add(kp.Value, kp.Key);
} }
} }
catch (InvalidOperationException)
{
m_log.Warn("[AVATAR]: Unable to load animation names for an Avatar");
} }
} }
} }

View File

@ -278,8 +278,6 @@ namespace OpenSim.Region.Environment.Scenes
m_log.Info("[SCENE]: Creating LandMap"); m_log.Info("[SCENE]: Creating LandMap");
Terrain = new TerrainEngine((int) RegionInfo.RegionLocX, (int) RegionInfo.RegionLocY); Terrain = new TerrainEngine((int) RegionInfo.RegionLocX, (int) RegionInfo.RegionLocY);
ScenePresence.LoadAnims();
httpListener = httpServer; httpListener = httpServer;
m_dumpAssetsToFile = dumpAssetsToFile; m_dumpAssetsToFile = dumpAssetsToFile;

View File

@ -41,8 +41,9 @@ namespace OpenSim.Region.Environment.Scenes
{ {
private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
public static AvatarAnimations Animations; public static AvatarAnimations Animations = new AvatarAnimations();
public static byte[] DefaultTexture; public static byte[] DefaultTexture;
public LLUUID currentParcelUUID = LLUUID.Zero; public LLUUID currentParcelUUID = LLUUID.Zero;
private List<LLUUID> m_animations = new List<LLUUID>(); private List<LLUUID> m_animations = new List<LLUUID>();
private List<int> m_animationSeqs = new List<int>(); private List<int> m_animationSeqs = new List<int>();
@ -333,12 +334,6 @@ namespace OpenSim.Region.Environment.Scenes
AbsolutePosition = m_controllingClient.StartPos; AbsolutePosition = m_controllingClient.StartPos;
Animations = new AvatarAnimations();
lock (Animations)
{
Animations.LoadAnims();
}
// TODO: m_animations and m_animationSeqs should always be of the same length. // TODO: m_animations and m_animationSeqs should always be of the same length.
// Move them into an object to (hopefully) avoid threading issues. // Move them into an object to (hopefully) avoid threading issues.
try try
@ -1642,13 +1637,6 @@ namespace OpenSim.Region.Environment.Scenes
//m_velocity = cAgentData.Velocity; //m_velocity = cAgentData.Velocity;
} }
/// <summary>
///
/// </summary>
public static void LoadAnims()
{
}
/// <summary> /// <summary>
/// Handles part of the PID controller function for moving an avatar. /// Handles part of the PID controller function for moving an avatar.
/// </summary> /// </summary>