Example #1
0
        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_log.Error("[AVATARSERVICE]: Error saving appearance for " + principalID + ", data follows " +
                        kvp.Key + ", " + kvp.Value);
                    m_Database.Delete("PrincipalID", principalID.ToString());
                    return false;
                }
            }

            return true;
        }
Example #2
0
 public void CacheWearableData(UUID principalID, AvatarWearable wearable)
 {
     if (!m_enableCacheBakedTextures)
     {
         IAssetService service = m_registry.RequestModuleInterface<IAssetService>();
         if (service != null)
         {
             //Remove the old baked textures then from the DB as we don't want to keep them around
             foreach (UUID texture in wearable.GetItems().Values)
             {
                 service.Delete(texture.ToString());
             }
         }
         return;
     }
     wearable.MaxItems = 0; //Unlimited items
     
     AvatarBaseData baseData = new AvatarBaseData();
     AvatarBaseData[] av = m_CacheDatabase.Get("PrincipalID", principalID.ToString());
     foreach (AvatarBaseData abd in av)
     {
         //If we have one already made, keep what is already there
         if (abd.Data["Name"] == "CachedWearables")
         {
             baseData = abd;
             OSDArray array = (OSDArray)OSDParser.DeserializeJson(abd.Data["Value"]);
             AvatarWearable w = new AvatarWearable();
             w.MaxItems = 0; //Unlimited items
             w.Unpack(array);
             foreach (KeyValuePair<UUID, UUID> kvp in w.GetItems())
             {
                 wearable.Add(kvp.Key, kvp.Value);
             }
         }
     }
     //If we don't have one, set it up for saving a new one
     if (baseData.Data == null)
     {
         baseData.PrincipalID = principalID;
         baseData.Data = new Dictionary<string, string>();
         baseData.Data.Add("Name", "CachedWearables");
     }
     baseData.Data["Value"] = OSDParser.SerializeJsonString(wearable.Pack());
     try
     {
         bool store = m_CacheDatabase.Store(baseData);
         if (!store)
         {
             m_log.Warn("[AvatarService]: Issue saving the cached wearables to the database.");
         }
     }
     catch
     {
     }
 }
Example #3
0
        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;
        }
Example #4
0
        public bool SetAvatar(UUID principalID, AvatarData avatar)
        {
            m_log.DebugFormat("[AVATAR SERVICE]: SetAvatar for {0}", principalID);
            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_log.Error("[AvatarService]: Issue in SetAvatar, could not save appearance to the database.");
                    //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;
        }
Example #6
0
 public bool Store(AvatarBaseData data)
 {
     m_DataByUUID[data.PrincipalID] = data;
     return true;
 }