コード例 #1
0
        /// <summary>
        /// Sends the specified character relation lists to the specified character
        /// </summary>
        /// <param name="character">The character to send the list</param>
        /// <param name="flag">Flag indicating which lists should be sent to the character</param>
        internal void SendRelationList(Character character, RelationTypeFlag flag)
        {
            Dictionary <uint, RelationListEntry> flatRelations =
                GetFlatRelations(character.EntityId.Low, flag);

            using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.SMSG_CONTACT_LIST))
            {
                packet.WriteUInt((uint)flag);
                packet.WriteUInt((uint)flatRelations.Count);
                foreach (RelationListEntry relationListEntry in flatRelations.Values)
                {
                    packet.Write(EntityId.GetPlayerId(relationListEntry.RelatedCharacterId));
                    packet.WriteUInt((uint)relationListEntry.Flag);
                    packet.WriteCString(relationListEntry.Note);
                    if (relationListEntry.Flag.HasFlag(RelationTypeFlag.Friend))
                    {
                        Character character1 = World.GetCharacter(relationListEntry.RelatedCharacterId);
                        if (character1 != null)
                        {
                            packet.WriteByte((byte)character1.Status);
                            packet.Write(character1.Zone != null ? (int)character1.Zone.Id : 0);
                            packet.Write(character1.Level);
                            packet.Write((int)character1.Class);
                        }
                        else
                        {
                            packet.WriteByte((byte)0);
                        }
                    }
                }

                character.Client.Send(packet, false);
            }
        }
コード例 #2
0
ファイル: RelationMgr.cs プロジェクト: 0xFh/Asda2-Project
        /// <summary>
        /// Sends the specified character relation lists to the specified character
        /// </summary>
        /// <param name="character">The character to send the list</param>
        /// <param name="flag">Flag indicating which lists should be sent to the character</param>
        internal void SendRelationList(Character character, RelationTypeFlag flag)
        {
            var relations = GetFlatRelations(character.EntityId.Low, flag);

            using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_CONTACT_LIST))
            {
                //Write the requested list flag
                packet.WriteUInt((uint)flag);

                //Write the relations count
                packet.WriteUInt((uint)relations.Count);

                foreach (var entry in relations.Values)
                {
                    //Write the related char Id
                    packet.Write(EntityId.GetPlayerId(entry.RelatedCharacterId));

                    //Write the contact flag
                    packet.WriteUInt((uint)entry.Flag);

                    //Write the contact note
                    packet.WriteCString(entry.Note);

                    //If this relation type requires online notification
                    if (entry.Flag.HasFlag(RelationTypeFlag.Friend))
                    {
                        var relatedChar = World.GetCharacter(entry.RelatedCharacterId);
                        if (relatedChar != null)
                        {
                            packet.WriteByte((byte)relatedChar.Status);
                            packet.Write(relatedChar.Zone != null ? (int)relatedChar.Zone.Id : 0);
                            packet.Write(relatedChar.Level);
                            packet.Write((int)relatedChar.Class);
                        }
                        else
                        {
                            packet.WriteByte((byte)CharacterStatus.OFFLINE);
                        }
                    }
                }
                character.Client.Send(packet, addEnd: false);
            }
        }
コード例 #3
0
 public static bool HasAnyFlag(this RelationTypeFlag flags, RelationTypeFlag otherFlags)
 {
     return((flags & otherFlags) != 0);
 }
コード例 #4
0
ファイル: RelationMgr.cs プロジェクト: 0xFh/Asda2-Project
 public RelationListEntry(IBaseRelation relation, RelationTypeFlag flag)
 {
     RelatedCharacterId = relation.RelatedCharacterId;
     Flag = flag;
     Note = relation.Note;
 }
コード例 #5
0
ファイル: RelationMgr.cs プロジェクト: 0xFh/Asda2-Project
        private Dictionary <uint, RelationListEntry> GetFlatRelations(uint characterId, RelationTypeFlag flags)
        {
            var relations = new Dictionary <uint, RelationListEntry>();

            HashSet <IBaseRelation> friendRelations = GetRelations(characterId, CharacterRelationType.Friend);

            if (friendRelations != null)
            {
                foreach (IBaseRelation relation in friendRelations)
                {
                    relations[relation.RelatedCharacterId] = new RelationListEntry(relation, RelationTypeFlag.Friend);
                }
            }

            HashSet <IBaseRelation> ignoreRelations = GetRelations(characterId, CharacterRelationType.Ignored);

            if (ignoreRelations != null)
            {
                foreach (IBaseRelation relation in ignoreRelations)
                {
                    if (relations.ContainsKey(relation.RelatedCharacterId))
                    {
                        relations[relation.RelatedCharacterId].Flag |= RelationTypeFlag.Ignore;
                    }
                    else
                    {
                        relations[relation.RelatedCharacterId] = new RelationListEntry(relation, RelationTypeFlag.Ignore);
                    }
                }
            }

            HashSet <IBaseRelation> mutedRelations = GetRelations(characterId, CharacterRelationType.Muted);

            if (mutedRelations != null)
            {
                foreach (IBaseRelation relation in mutedRelations)
                {
                    if (relations.ContainsKey(relation.RelatedCharacterId))
                    {
                        relations[relation.RelatedCharacterId].Flag |= RelationTypeFlag.Muted;
                    }
                    else
                    {
                        relations[relation.RelatedCharacterId] = new RelationListEntry(relation, RelationTypeFlag.Muted);
                    }
                }
            }

            var removedKeys = from entry in relations
                              where !entry.Value.Flag.HasAnyFlag(flags)
                              select entry.Key;

            foreach (uint key in removedKeys)
            {
                relations.Remove(key);
            }

            return(relations);
        }
コード例 #6
0
        private Dictionary <uint, RelationListEntry> GetFlatRelations(uint characterId,
                                                                      RelationTypeFlag flags)
        {
            Dictionary <uint, RelationListEntry> source =
                new Dictionary <uint, RelationListEntry>();
            HashSet <IBaseRelation> relations1 = GetRelations(characterId, CharacterRelationType.Friend);

            if (relations1 != null)
            {
                foreach (IBaseRelation relation in relations1)
                {
                    source[relation.RelatedCharacterId] =
                        new RelationListEntry(relation, RelationTypeFlag.Friend);
                }
            }

            HashSet <IBaseRelation> relations2 = GetRelations(characterId, CharacterRelationType.Ignored);

            if (relations2 != null)
            {
                foreach (IBaseRelation relation in relations2)
                {
                    if (source.ContainsKey(relation.RelatedCharacterId))
                    {
                        source[relation.RelatedCharacterId].Flag |= RelationTypeFlag.Ignore;
                    }
                    else
                    {
                        source[relation.RelatedCharacterId] =
                            new RelationListEntry(relation, RelationTypeFlag.Ignore);
                    }
                }
            }

            HashSet <IBaseRelation> relations3 = GetRelations(characterId, CharacterRelationType.Muted);

            if (relations3 != null)
            {
                foreach (IBaseRelation relation in relations3)
                {
                    if (source.ContainsKey(relation.RelatedCharacterId))
                    {
                        source[relation.RelatedCharacterId].Flag |= RelationTypeFlag.Muted;
                    }
                    else
                    {
                        source[relation.RelatedCharacterId] =
                            new RelationListEntry(relation, RelationTypeFlag.Muted);
                    }
                }
            }

            foreach (uint key in source
                     .Where(
                         entry =>
                         !entry.Value.Flag.HasAnyFlag(flags))
                     .Select(
                         entry => entry.Key))
            {
                source.Remove(key);
            }
            return(source);
        }
コード例 #7
0
        /// <summary>Handles an incoming friend list request</summary>
        /// <param name="client">the client that sent the packet</param>
        /// <param name="packet">the packet we received</param>
        public static void ContactListRequest(IRealmClient client, RealmPacketIn packet)
        {
            RelationTypeFlag flag = (RelationTypeFlag)packet.ReadUInt32();

            Singleton <RelationMgr> .Instance.SendRelationList(client.ActiveCharacter, flag);
        }
コード例 #8
0
ファイル: Extensions.cs プロジェクト: WCellFR/WCellFR
		public static bool HasAnyFlag(this RelationTypeFlag flags, RelationTypeFlag otherFlags)
		{
			return (flags & otherFlags) != 0;
		}