Пример #1
0
 private void LoadRelations(uint charId)
 {
     m_lock.EnterWriteLock();
     try
     {
         foreach (PersistedRelation persistedRelation in PersistedRelation.GetByCharacterId(charId))
         {
             HashSet <IBaseRelation> baseRelationSet;
             if (!m_activeRelations[(int)persistedRelation.Type]
                 .TryGetValue(persistedRelation.CharacterId, out baseRelationSet))
             {
                 m_activeRelations[(int)persistedRelation.Type].Add(persistedRelation.CharacterId,
                                                                    baseRelationSet = new HashSet <IBaseRelation>());
             }
             baseRelationSet.Add(persistedRelation);
             if (!m_passiveRelations[(int)persistedRelation.Type]
                 .TryGetValue(persistedRelation.CharacterId, out baseRelationSet))
             {
                 m_passiveRelations[(int)persistedRelation.Type].Add(persistedRelation.RelatedCharacterId,
                                                                     baseRelationSet = new HashSet <IBaseRelation>());
             }
             baseRelationSet.Add(persistedRelation);
         }
     }
     finally
     {
         m_lock.ExitWriteLock();
     }
 }
Пример #2
0
        private void LoadRelations(uint charId)
        {
            m_lock.EnterWriteLock();
            try
            {
                //Add the character relations to the global dictionaries
                foreach (PersistedRelation cr in PersistedRelation.GetByCharacterId(charId))
                {
                    HashSet <IBaseRelation> relations;
                    if (!m_activeRelations[(int)cr.Type].TryGetValue(cr.CharacterId, out relations))
                    {
                        m_activeRelations[(int)cr.Type].Add(cr.CharacterId, relations = new HashSet <IBaseRelation>());
                    }
                    relations.Add(cr);

                    if (!m_passiveRelations[(int)cr.Type].TryGetValue(cr.CharacterId, out relations))
                    {
                        m_passiveRelations[(int)cr.Type].Add(cr.RelatedCharacterId, relations = new HashSet <IBaseRelation>());
                    }
                    relations.Add(cr);
                }
            }
            finally
            {
                m_lock.ExitWriteLock();
            }
        }
Пример #3
0
        private void Initialize()
        {
            BaseRelation[] all;
            try
            {
                all = PersistedRelation.GetAll();
            }
            catch (Exception ex)
            {
                RealmDBMgr.OnDBError(ex);
                all = PersistedRelation.GetAll();
            }

            m_lock.EnterWriteLock();
            try
            {
                foreach (PersistedRelation persistedRelation in all)
                {
                    HashSet <IBaseRelation> baseRelationSet;
                    if (!m_activeRelations[(int)persistedRelation.Type]
                        .TryGetValue(persistedRelation.CharacterId, out baseRelationSet))
                    {
                        m_activeRelations[(int)persistedRelation.Type].Add(persistedRelation.CharacterId,
                                                                           baseRelationSet = new HashSet <IBaseRelation>());
                    }
                    baseRelationSet.Add(persistedRelation);
                    if (!m_passiveRelations[(int)persistedRelation.Type]
                        .TryGetValue(persistedRelation.RelatedCharacterId, out baseRelationSet))
                    {
                        m_passiveRelations[(int)persistedRelation.Type].Add(persistedRelation.RelatedCharacterId,
                                                                            baseRelationSet = new HashSet <IBaseRelation>());
                    }
                    baseRelationSet.Add(persistedRelation);
                }
            }
            finally
            {
                m_lock.ExitWriteLock();
            }
        }
Пример #4
0
        private void Initialize()
        {
            BaseRelation[] found;
            try
            {
                found = PersistedRelation.GetAll();
            }
            catch (Exception e)
            {
                RealmDBMgr.OnDBError(e);
                found = PersistedRelation.GetAll();
            }

            m_lock.EnterWriteLock();
            try
            {
                foreach (PersistedRelation relation in found)
                {
                    HashSet <IBaseRelation> relations;
                    if (!m_activeRelations[(int)relation.Type].TryGetValue(relation.CharacterId, out relations))
                    {
                        m_activeRelations[(int)relation.Type].Add(relation.CharacterId, relations = new HashSet <IBaseRelation>());
                    }
                    relations.Add(relation);

                    if (!m_passiveRelations[(int)relation.Type].TryGetValue(relation.RelatedCharacterId, out relations))
                    {
                        m_passiveRelations[(int)relation.Type].Add(relation.RelatedCharacterId, relations = new HashSet <IBaseRelation>());
                    }
                    relations.Add(relation);
                }
            }
            finally
            {
                m_lock.ExitWriteLock();
            }
        }