public FriendInfo(ObjectGuid accountGuid, SocialFlag flags, string note) { WowAccountGuid = accountGuid; Status = FriendStatus.Offline; Flags = flags; Note = note; }
public void SendSocialList(Player player, SocialFlag flags) { if (!player) { return; } ContactList contactList = new ContactList(); contactList.Flags = flags; foreach (var v in _playerSocialMap) { if (!v.Value.Flags.HasAnyFlag(flags)) { continue; } Global.SocialMgr.GetFriendInfo(player, v.Key, v.Value); contactList.Contacts.Add(new ContactInfo(v.Key, v.Value)); // client's friends list and ignore list limit if (contactList.Contacts.Count >= (((flags & SocialFlag.Friend) != 0) ? SocialManager.FriendLimit : SocialManager.IgnoreLimit)) { break; } } player.SendPacket(contactList); }
public void RemoveFromSocialList(ObjectGuid friendGuid, SocialFlag flag) { var friendInfo = _playerSocialMap.LookupByKey(friendGuid); if (friendInfo == null) // not exist { return; } friendInfo.Flags &= ~flag; if (friendInfo.Flags == 0) { PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.DEL_CHARACTER_SOCIAL); stmt.AddValue(0, GetPlayerGUID().GetCounter()); stmt.AddValue(1, friendGuid.GetCounter()); DB.Characters.Execute(stmt); _playerSocialMap.Remove(friendGuid); } else { PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.UPD_CHARACTER_SOCIAL_FLAGS); stmt.AddValue(0, friendInfo.Flags); stmt.AddValue(1, GetPlayerGUID().GetCounter()); stmt.AddValue(2, friendGuid.GetCounter()); DB.Characters.Execute(stmt); } }
public bool AddToSocialList(ObjectGuid friendGuid, SocialFlag flag) { // check client limits if (GetNumberOfSocialsWithFlag(flag) >= (((flag & SocialFlag.Friend) != 0) ? SocialManager.FriendLimit : SocialManager.IgnoreLimit)) { return(false); } var friendInfo = _playerSocialMap.LookupByKey(friendGuid); if (friendInfo != null) { friendInfo.Flags |= flag; PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.UPD_CHARACTER_SOCIAL_FLAGS); stmt.AddValue(0, friendInfo.Flags); stmt.AddValue(1, GetPlayerGUID().GetCounter()); stmt.AddValue(2, friendGuid.GetCounter()); DB.Characters.Execute(stmt); } else { FriendInfo fi = new FriendInfo(); fi.Flags |= flag; _playerSocialMap[friendGuid] = fi; PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.INS_CHARACTER_SOCIAL); stmt.AddValue(0, GetPlayerGUID().GetCounter()); stmt.AddValue(1, friendGuid.GetCounter()); stmt.AddValue(2, flag); DB.Characters.Execute(stmt); } return(true); }
protected override void InternalParse() { Output.AppendLine("Mask: " + (SocialFlag)Reader.ReadUInt32()); int size = Reader.ReadInt32(); Output.AppendLine("Friends Count: " + size); for (int i = 0; i < size; ++i) { Output.AppendLine(); Output.AppendLine("Player GUID: " + Reader.ReadGuid()); SocialFlag sflag = (SocialFlag)Reader.ReadUInt32(); Output.AppendFormatLine("Social Flag: {0} ({0:D})", sflag); Output.AppendLine("Note: " + Reader.ReadCString()); if ((sflag & SocialFlag.Friend) != 0) { FriendStatus second = (FriendStatus)Reader.ReadByte(); Output.AppendLine("Friend Status: " + second); if ((byte)second > 0) { Output.AppendFormatLine("Area: {0:D} {0}", (Zones)Reader.ReadUInt32()); Output.AppendLine("Level: " + Reader.ReadUInt32()); Output.AppendFormatLine("Class: {0:D} {0}", (Classes)Reader.ReadUInt32()); } } } if (!Reader.IsRead) Output.AppendLine("Bot Check ARC4 Key: " + Reader.ReadBytes(16).ToHexString()); }
bool _HasContact(ObjectGuid guid, SocialFlag flags) { var friendInfo = _playerSocialMap.LookupByKey(guid); if (friendInfo != null) { return(friendInfo.Flags.HasAnyFlag(flags)); } return(false); }
uint GetNumberOfSocialsWithFlag(SocialFlag flag) { uint counter = 0; foreach (var pair in _playerSocialMap) { if (pair.Value.Flags.HasAnyFlag(flag)) { ++counter; } } return(counter); }
public PlayerSocial LoadFromDB(SQLResult result, ObjectGuid guid) { PlayerSocial social = new PlayerSocial(); social.SetPlayerGUID(guid); if (!result.IsEmpty()) { do { ObjectGuid friendGuid = ObjectGuid.Create(HighGuid.Player, result.Read <ulong>(0)); ObjectGuid friendAccountGuid = ObjectGuid.Create(HighGuid.WowAccount, result.Read <uint>(1)); SocialFlag flags = (SocialFlag)result.Read <byte>(2); social._playerSocialMap[friendGuid] = new FriendInfo(friendAccountGuid, flags, result.Read <string>(3)); }while (result.NextRow()); } _socialMap[guid] = social; return(social); }