public bool SetItems(UUID principalID, string[] names, string[] values)
        {
            AvatarBaseData av = new AvatarBaseData();

            av.Data        = new Dictionary <string, string>();
            av.PrincipalID = principalID;

            if (names.Length != values.Length)
            {
                return(false);
            }

            for (int i = 0; i < names.Length; i++)
            {
                av.Data["Name"]  = names[i];
                av.Data["Value"] = values[i];

                if (!m_Database.Store(av))
                {
                    return(false);
                }
            }

            return(true);
        }
        public bool SetAvatar(UUID principalID, AvatarData avatar)
        {
            int count = 0;

            foreach (KeyValuePair <string, string> kvp in avatar.Data)
            {
                if (kvp.Key.StartsWith("_"))
                {
                    count++;
                }
            }

            m_log.DebugFormat("[AVATAR SERVICE]: SetAvatar for {0}, attachs={1}", principalID, count);
            m_Database.Delete("PrincipalID", principalID.ToString());

            AvatarBaseData av = new AvatarBaseData();

            av.Data = new Dictionary <string, string>();

            av.PrincipalID   = principalID;
            av.Data["Name"]  = "AvatarType";
            av.Data["Value"] = avatar.AvatarType.ToString();

            if (!m_Database.Store(av))
            {
                return(false);
            }

            foreach (KeyValuePair <string, string> kvp in avatar.Data)
            {
                av.Data["Name"]  = kvp.Key;
                av.Data["Value"] = kvp.Value;

                if (!m_Database.Store(av))
                {
                    m_Database.Delete("PrincipalID", principalID.ToString());
                    return(false);
                }
            }

            return(true);
        }
        public bool SetAvatar(UUID principalID, AvatarData avatar)
        {
            int count = 0;

            foreach (KeyValuePair <string, string> kvp in avatar.Data)
            {
                if (kvp.Key.StartsWith("_"))
                {
                    count++;
                }
            }

            m_log.DebugFormat("[AVATAR SERVICE]: SetAvatar for {0}, attachs={1}", principalID, count);
            m_Database.Delete("PrincipalID", principalID.ToString());

            AvatarBaseData av = new AvatarBaseData();

            av.Data = new Dictionary <string, string>();

            av.PrincipalID   = principalID;
            av.Data["Name"]  = "AvatarType";
            av.Data["Value"] = avatar.AvatarType.ToString();

            if (!m_Database.Store(av))
            {
                return(false);
            }

            foreach (KeyValuePair <string, string> kvp in avatar.Data)
            {
                av.Data["Name"] = kvp.Key;

                // justincc 20110730.  Yes, this is a hack to get around the fact that a bug in OpenSim is causing
                // various simulators on osgrid to inject bad values.  Since these simulators might be around for a
                // long time, we are going to manually police the value.
                //
                // It should be possible to remove this in half a year if we don't want to police values server side.
                if (kvp.Key == "AvatarHeight")
                {
                    float height;
                    if (!float.TryParse(kvp.Value, out height) || height < 0 || height > 10)
                    {
                        string rawHeight = kvp.Value.Replace(",", ".");

                        if (!float.TryParse(rawHeight, out height) || height < 0 || height > 10)
                        {
                            height = 1.771488f;
                        }

                        m_log.DebugFormat(
                            "[AVATAR SERVICE]: Rectifying height of avatar {0} from {1} to {2}",
                            principalID, kvp.Value, height);
                    }

                    av.Data["Value"] = height.ToString();
                }
                else
                {
                    av.Data["Value"] = kvp.Value;
                }

                if (!m_Database.Store(av))
                {
                    m_Database.Delete("PrincipalID", principalID.ToString());
                    return(false);
                }
            }

            return(true);
        }
Esempio n. 4
0
 public bool Store(AvatarBaseData data)
 {
     m_DataByUUID[data.PrincipalID] = data;
     return true;
 }
Esempio n. 5
0
 public bool Store(AvatarBaseData data)
 {
     m_DataByUUID[data.PrincipalID] = data;
     return(true);
 }