Core/Social: Implemented account ignores
Port From (https://github.com/TrinityCore/TrinityCore/commit/f40c0dfd5588798115bfa61236be1804a32ba24f)
This commit is contained in:
@@ -658,7 +658,8 @@ namespace Game.Chat
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SendToAll(new ChannelSayBuilder(this, lang, what, guid, _channelGuid), !playerInfo.IsModerator() ? guid : ObjectGuid.Empty);
|
Player player = Global.ObjAccessor.FindConnectedPlayer(guid);
|
||||||
|
SendToAll(new ChannelSayBuilder(this, lang, what, guid, _channelGuid), !playerInfo.IsModerator() ? guid : ObjectGuid.Empty, !playerInfo.IsModerator() && player ? player.GetSession().GetAccountGUID() : ObjectGuid.Empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddonSay(ObjectGuid guid, string prefix, string what, bool isLogged)
|
public void AddonSay(ObjectGuid guid, string prefix, string what, bool isLogged)
|
||||||
@@ -683,7 +684,9 @@ namespace Game.Chat
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SendToAllWithAddon(new ChannelWhisperBuilder(this, isLogged ? Language.AddonLogged : Language.Addon, what, prefix, guid), prefix, !playerInfo.IsModerator() ? guid : ObjectGuid.Empty);
|
Player player = Global.ObjAccessor.FindConnectedPlayer(guid);
|
||||||
|
SendToAllWithAddon(new ChannelWhisperBuilder(this, isLogged ? Language.AddonLogged : Language.Addon, what, prefix, guid), prefix, !playerInfo.IsModerator() ? guid : ObjectGuid.Empty,
|
||||||
|
!playerInfo.IsModerator() && player ? player.GetSession().GetAccountGUID() : ObjectGuid.Empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Invite(Player player, string newname)
|
public void Invite(Player player, string newname)
|
||||||
@@ -728,7 +731,7 @@ namespace Game.Chat
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!newp.GetSocial().HasIgnore(guid))
|
if (!newp.GetSocial().HasIgnore(guid, player.GetSession().GetAccountGUID()))
|
||||||
{
|
{
|
||||||
ChannelNameBuilder builder = new(this, new InviteAppend(guid));
|
ChannelNameBuilder builder = new(this, new InviteAppend(guid));
|
||||||
SendToOne(builder, newp.GetGUID());
|
SendToOne(builder, newp.GetGUID());
|
||||||
@@ -832,7 +835,7 @@ namespace Game.Chat
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SendToAll(MessageBuilder builder, ObjectGuid guid = default)
|
void SendToAll(MessageBuilder builder, ObjectGuid guid = default, ObjectGuid accountGuid = default)
|
||||||
{
|
{
|
||||||
LocalizedDo localizer = new(builder);
|
LocalizedDo localizer = new(builder);
|
||||||
|
|
||||||
@@ -840,7 +843,7 @@ namespace Game.Chat
|
|||||||
{
|
{
|
||||||
Player player = Global.ObjAccessor.FindConnectedPlayer(pair.Key);
|
Player player = Global.ObjAccessor.FindConnectedPlayer(pair.Key);
|
||||||
if (player)
|
if (player)
|
||||||
if (guid.IsEmpty() || !player.GetSocial().HasIgnore(guid))
|
if (guid.IsEmpty() || !player.GetSocial().HasIgnore(guid, accountGuid))
|
||||||
localizer.Invoke(player);
|
localizer.Invoke(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -869,7 +872,7 @@ namespace Game.Chat
|
|||||||
localizer.Invoke(player);
|
localizer.Invoke(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SendToAllWithAddon(MessageBuilder builder, string addonPrefix, ObjectGuid guid = default)
|
void SendToAllWithAddon(MessageBuilder builder, string addonPrefix, ObjectGuid guid = default, ObjectGuid accountGuid = default)
|
||||||
{
|
{
|
||||||
LocalizedDo localizer = new(builder);
|
LocalizedDo localizer = new(builder);
|
||||||
|
|
||||||
@@ -877,7 +880,7 @@ namespace Game.Chat
|
|||||||
{
|
{
|
||||||
Player player = Global.ObjAccessor.FindConnectedPlayer(pair.Key);
|
Player player = Global.ObjAccessor.FindConnectedPlayer(pair.Key);
|
||||||
if (player)
|
if (player)
|
||||||
if (player.GetSession().IsAddonRegistered(addonPrefix) && (guid.IsEmpty() || !player.GetSocial().HasIgnore(guid)))
|
if (player.GetSession().IsAddonRegistered(addonPrefix) && (guid.IsEmpty() || !player.GetSocial().HasIgnore(guid, accountGuid)))
|
||||||
localizer.Invoke(player);
|
localizer.Invoke(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1789,7 +1789,9 @@ namespace Game.DungeonFinding
|
|||||||
{
|
{
|
||||||
Player plr1 = Global.ObjAccessor.FindPlayer(guid1);
|
Player plr1 = Global.ObjAccessor.FindPlayer(guid1);
|
||||||
Player plr2 = Global.ObjAccessor.FindPlayer(guid2);
|
Player plr2 = Global.ObjAccessor.FindPlayer(guid2);
|
||||||
return plr1 && plr2 && (plr1.GetSocial().HasIgnore(guid2) || plr2.GetSocial().HasIgnore(guid1));
|
return plr1 != null && plr2 != null
|
||||||
|
&& (plr1.GetSocial().HasIgnore(guid2, plr2.GetSession().GetAccountGUID())
|
||||||
|
|| plr2.GetSocial().HasIgnore(guid1, plr1.GetSession().GetAccountGUID()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SendLfgRoleChosen(ObjectGuid guid, ObjectGuid pguid, LfgRoles roles)
|
public void SendLfgRoleChosen(ObjectGuid guid, ObjectGuid pguid, LfgRoles roles)
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ using Game.Networking;
|
|||||||
using Game.Networking.Packets;
|
using Game.Networking.Packets;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace Game.Entities
|
namespace Game.Entities
|
||||||
{
|
{
|
||||||
@@ -47,7 +48,7 @@ namespace Game.Entities
|
|||||||
if (!target)
|
if (!target)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var playerFriendInfo = player.GetSocial()._playerSocialMap.LookupByKey(friendGUID);
|
var playerFriendInfo = player.GetSocial().PlayerSocialMap.LookupByKey(friendGUID);
|
||||||
if (playerFriendInfo != null)
|
if (playerFriendInfo != null)
|
||||||
friendInfo.Note = playerFriendInfo.Note;
|
friendInfo.Note = playerFriendInfo.Note;
|
||||||
|
|
||||||
@@ -103,7 +104,7 @@ namespace Game.Entities
|
|||||||
AccountTypes gmSecLevel = (AccountTypes)WorldConfig.GetIntValue(WorldCfg.GmLevelInWhoList);
|
AccountTypes gmSecLevel = (AccountTypes)WorldConfig.GetIntValue(WorldCfg.GmLevelInWhoList);
|
||||||
foreach (var pair in _socialMap)
|
foreach (var pair in _socialMap)
|
||||||
{
|
{
|
||||||
var info = pair.Value._playerSocialMap.LookupByKey(player.GetGUID());
|
var info = pair.Value.PlayerSocialMap.LookupByKey(player.GetGUID());
|
||||||
if (info != null && info.Flags.HasAnyFlag(SocialFlag.Friend))
|
if (info != null && info.Flags.HasAnyFlag(SocialFlag.Friend))
|
||||||
{
|
{
|
||||||
Player target = Global.ObjAccessor.FindPlayer(pair.Key);
|
Player target = Global.ObjAccessor.FindPlayer(pair.Key);
|
||||||
@@ -136,7 +137,9 @@ namespace Game.Entities
|
|||||||
ObjectGuid friendAccountGuid = ObjectGuid.Create(HighGuid.WowAccount, result.Read<uint>(1));
|
ObjectGuid friendAccountGuid = ObjectGuid.Create(HighGuid.WowAccount, result.Read<uint>(1));
|
||||||
SocialFlag flags = (SocialFlag)result.Read<byte>(2);
|
SocialFlag flags = (SocialFlag)result.Read<byte>(2);
|
||||||
|
|
||||||
social._playerSocialMap[friendGuid] = new FriendInfo(friendAccountGuid, flags, result.Read<string>(3));
|
social.PlayerSocialMap[friendGuid] = new FriendInfo(friendAccountGuid, flags, result.Read<string>(3));
|
||||||
|
if (flags.HasFlag(SocialFlag.Ignored))
|
||||||
|
social.IgnoredAccounts.Add(friendAccountGuid);
|
||||||
}
|
}
|
||||||
while (result.NextRow());
|
while (result.NextRow());
|
||||||
}
|
}
|
||||||
@@ -151,29 +154,31 @@ namespace Game.Entities
|
|||||||
|
|
||||||
public class PlayerSocial
|
public class PlayerSocial
|
||||||
{
|
{
|
||||||
public Dictionary<ObjectGuid, FriendInfo> _playerSocialMap = new();
|
public Dictionary<ObjectGuid, FriendInfo> PlayerSocialMap = new();
|
||||||
|
public List<ObjectGuid> IgnoredAccounts = new();
|
||||||
ObjectGuid m_playerGUID;
|
ObjectGuid m_playerGUID;
|
||||||
|
|
||||||
uint GetNumberOfSocialsWithFlag(SocialFlag flag)
|
uint GetNumberOfSocialsWithFlag(SocialFlag flag)
|
||||||
{
|
{
|
||||||
uint counter = 0;
|
uint counter = 0;
|
||||||
foreach (var pair in _playerSocialMap)
|
foreach (var pair in PlayerSocialMap)
|
||||||
if (pair.Value.Flags.HasAnyFlag(flag))
|
if (pair.Value.Flags.HasAnyFlag(flag))
|
||||||
++counter;
|
++counter;
|
||||||
|
|
||||||
return counter;
|
return counter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool AddToSocialList(ObjectGuid friendGuid, SocialFlag flag)
|
public bool AddToSocialList(ObjectGuid friendGuid, ObjectGuid accountGuid, SocialFlag flag)
|
||||||
{
|
{
|
||||||
// check client limits
|
// check client limits
|
||||||
if (GetNumberOfSocialsWithFlag(flag) >= (((flag & SocialFlag.Friend) != 0) ? SocialManager.FriendLimit : SocialManager.IgnoreLimit))
|
if (GetNumberOfSocialsWithFlag(flag) >= (((flag & SocialFlag.Friend) != 0) ? SocialManager.FriendLimit : SocialManager.IgnoreLimit))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
var friendInfo = _playerSocialMap.LookupByKey(friendGuid);
|
var friendInfo = PlayerSocialMap.LookupByKey(friendGuid);
|
||||||
if (friendInfo != null)
|
if (friendInfo != null)
|
||||||
{
|
{
|
||||||
friendInfo.Flags |= flag;
|
friendInfo.Flags |= flag;
|
||||||
|
friendInfo.WowAccountGuid = accountGuid;
|
||||||
|
|
||||||
PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.UPD_CHARACTER_SOCIAL_FLAGS);
|
PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.UPD_CHARACTER_SOCIAL_FLAGS);
|
||||||
stmt.AddValue(0, (byte)friendInfo.Flags);
|
stmt.AddValue(0, (byte)friendInfo.Flags);
|
||||||
@@ -185,7 +190,8 @@ namespace Game.Entities
|
|||||||
{
|
{
|
||||||
FriendInfo fi = new();
|
FriendInfo fi = new();
|
||||||
fi.Flags |= flag;
|
fi.Flags |= flag;
|
||||||
_playerSocialMap[friendGuid] = fi;
|
fi.WowAccountGuid = accountGuid;
|
||||||
|
PlayerSocialMap[friendGuid] = fi;
|
||||||
|
|
||||||
PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.INS_CHARACTER_SOCIAL);
|
PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.INS_CHARACTER_SOCIAL);
|
||||||
stmt.AddValue(0, GetPlayerGUID().GetCounter());
|
stmt.AddValue(0, GetPlayerGUID().GetCounter());
|
||||||
@@ -193,12 +199,16 @@ namespace Game.Entities
|
|||||||
stmt.AddValue(2, (byte)flag);
|
stmt.AddValue(2, (byte)flag);
|
||||||
DB.Characters.Execute(stmt);
|
DB.Characters.Execute(stmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (flag.HasFlag(SocialFlag.Ignored))
|
||||||
|
IgnoredAccounts.Add(accountGuid);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RemoveFromSocialList(ObjectGuid friendGuid, SocialFlag flag)
|
public void RemoveFromSocialList(ObjectGuid friendGuid, SocialFlag flag)
|
||||||
{
|
{
|
||||||
var friendInfo = _playerSocialMap.LookupByKey(friendGuid);
|
var friendInfo = PlayerSocialMap.LookupByKey(friendGuid);
|
||||||
if (friendInfo == null) // not exist
|
if (friendInfo == null) // not exist
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -211,7 +221,16 @@ namespace Game.Entities
|
|||||||
stmt.AddValue(1, friendGuid.GetCounter());
|
stmt.AddValue(1, friendGuid.GetCounter());
|
||||||
DB.Characters.Execute(stmt);
|
DB.Characters.Execute(stmt);
|
||||||
|
|
||||||
_playerSocialMap.Remove(friendGuid);
|
ObjectGuid accountGuid = friendInfo.WowAccountGuid;
|
||||||
|
|
||||||
|
PlayerSocialMap.Remove(friendGuid);
|
||||||
|
|
||||||
|
if (flag.HasFlag(SocialFlag.Ignored))
|
||||||
|
{
|
||||||
|
var otherIgnoreForAccount = PlayerSocialMap.Any(social => social.Value.Flags.HasFlag(SocialFlag.Ignored) && social.Value.WowAccountGuid == accountGuid);
|
||||||
|
if (!otherIgnoreForAccount)
|
||||||
|
IgnoredAccounts.Remove(accountGuid);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -225,7 +244,7 @@ namespace Game.Entities
|
|||||||
|
|
||||||
public void SetFriendNote(ObjectGuid friendGuid, string note)
|
public void SetFriendNote(ObjectGuid friendGuid, string note)
|
||||||
{
|
{
|
||||||
if (!_playerSocialMap.ContainsKey(friendGuid)) // not exist
|
if (!PlayerSocialMap.ContainsKey(friendGuid)) // not exist
|
||||||
return;
|
return;
|
||||||
|
|
||||||
PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.UPD_CHARACTER_SOCIAL_NOTE);
|
PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.UPD_CHARACTER_SOCIAL_NOTE);
|
||||||
@@ -234,7 +253,7 @@ namespace Game.Entities
|
|||||||
stmt.AddValue(2, friendGuid.GetCounter());
|
stmt.AddValue(2, friendGuid.GetCounter());
|
||||||
DB.Characters.Execute(stmt);
|
DB.Characters.Execute(stmt);
|
||||||
|
|
||||||
_playerSocialMap[friendGuid].Note = note;
|
PlayerSocialMap[friendGuid].Note = note;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SendSocialList(Player player, SocialFlag flags)
|
public void SendSocialList(Player player, SocialFlag flags)
|
||||||
@@ -245,7 +264,7 @@ namespace Game.Entities
|
|||||||
ContactList contactList = new();
|
ContactList contactList = new();
|
||||||
contactList.Flags = flags;
|
contactList.Flags = flags;
|
||||||
|
|
||||||
foreach (var v in _playerSocialMap)
|
foreach (var v in PlayerSocialMap)
|
||||||
{
|
{
|
||||||
if (!v.Value.Flags.HasAnyFlag(flags))
|
if (!v.Value.Flags.HasAnyFlag(flags))
|
||||||
continue;
|
continue;
|
||||||
@@ -264,7 +283,7 @@ namespace Game.Entities
|
|||||||
|
|
||||||
bool _HasContact(ObjectGuid guid, SocialFlag flags)
|
bool _HasContact(ObjectGuid guid, SocialFlag flags)
|
||||||
{
|
{
|
||||||
var friendInfo = _playerSocialMap.LookupByKey(guid);
|
var friendInfo = PlayerSocialMap.LookupByKey(guid);
|
||||||
if (friendInfo != null)
|
if (friendInfo != null)
|
||||||
return friendInfo.Flags.HasAnyFlag(flags);
|
return friendInfo.Flags.HasAnyFlag(flags);
|
||||||
|
|
||||||
@@ -276,9 +295,9 @@ namespace Game.Entities
|
|||||||
return _HasContact(friendGuid, SocialFlag.Friend);
|
return _HasContact(friendGuid, SocialFlag.Friend);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool HasIgnore(ObjectGuid ignoreGuid)
|
public bool HasIgnore(ObjectGuid ignoreGuid, ObjectGuid ignoreAccountGuid)
|
||||||
{
|
{
|
||||||
return _HasContact(ignoreGuid, SocialFlag.Ignored);
|
return _HasContact(ignoreGuid, SocialFlag.Ignored) || IgnoredAccounts.Contains(ignoreAccountGuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
ObjectGuid GetPlayerGUID() { return m_playerGUID; }
|
ObjectGuid GetPlayerGUID() { return m_playerGUID; }
|
||||||
|
|||||||
@@ -556,7 +556,7 @@ namespace Game.Guilds
|
|||||||
|
|
||||||
Player player = session.GetPlayer();
|
Player player = session.GetPlayer();
|
||||||
// Do not show invitations from ignored players
|
// Do not show invitations from ignored players
|
||||||
if (pInvitee.GetSocial().HasIgnore(player.GetGUID()))
|
if (pInvitee.GetSocial().HasIgnore(player.GetGUID(), player.GetSession().GetAccountGUID()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!WorldConfig.GetBoolValue(WorldCfg.AllowTwoSideInteractionGuild) && pInvitee.GetTeam() != player.GetTeam())
|
if (!WorldConfig.GetBoolValue(WorldCfg.AllowTwoSideInteractionGuild) && pInvitee.GetTeam() != player.GetTeam())
|
||||||
@@ -1424,7 +1424,7 @@ namespace Game.Guilds
|
|||||||
Player player = member.FindPlayer();
|
Player player = member.FindPlayer();
|
||||||
if (player != null)
|
if (player != null)
|
||||||
if (player.GetSession() != null && _HasRankRight(player, officerOnly ? GuildRankRights.OffChatListen : GuildRankRights.GChatListen) &&
|
if (player.GetSession() != null && _HasRankRight(player, officerOnly ? GuildRankRights.OffChatListen : GuildRankRights.GChatListen) &&
|
||||||
!player.GetSocial().HasIgnore(session.GetPlayer().GetGUID()))
|
!player.GetSocial().HasIgnore(session.GetPlayer().GetGUID(), session.GetAccountGUID()))
|
||||||
player.SendPacket(data);
|
player.SendPacket(data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1442,7 +1442,7 @@ namespace Game.Guilds
|
|||||||
if (player)
|
if (player)
|
||||||
{
|
{
|
||||||
if (player.GetSession() != null && _HasRankRight(player, officerOnly ? GuildRankRights.OffChatListen : GuildRankRights.GChatListen) &&
|
if (player.GetSession() != null && _HasRankRight(player, officerOnly ? GuildRankRights.OffChatListen : GuildRankRights.GChatListen) &&
|
||||||
!player.GetSocial().HasIgnore(session.GetPlayer().GetGUID()) && player.GetSession().IsAddonRegistered(prefix))
|
!player.GetSocial().HasIgnore(session.GetPlayer().GetGUID(), session.GetAccountGUID()) && player.GetSession().IsAddonRegistered(prefix))
|
||||||
player.SendPacket(data);
|
player.SendPacket(data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2710,7 +2710,7 @@ namespace Game.Guilds
|
|||||||
public List<uint> GetTrackedCriteriaIds() { return m_trackedCriteriaIds; }
|
public List<uint> GetTrackedCriteriaIds() { return m_trackedCriteriaIds; }
|
||||||
public void SetTrackedCriteriaIds(List<uint> criteriaIds) { m_trackedCriteriaIds = criteriaIds; }
|
public void SetTrackedCriteriaIds(List<uint> criteriaIds) { m_trackedCriteriaIds = criteriaIds; }
|
||||||
public bool IsTrackingCriteriaId(uint criteriaId) { return m_trackedCriteriaIds.Contains(criteriaId); }
|
public bool IsTrackingCriteriaId(uint criteriaId) { return m_trackedCriteriaIds.Contains(criteriaId); }
|
||||||
public bool IsOnline() { return m_flags.HasAnyFlag(GuildMemberFlags.Online); }
|
public bool IsOnline() { return m_flags.HasFlag(GuildMemberFlags.Online); }
|
||||||
|
|
||||||
public void UpdateLogoutTime() { m_logoutTime = (ulong)GameTime.GetGameTime(); }
|
public void UpdateLogoutTime() { m_logoutTime = (ulong)GameTime.GetGameTime(); }
|
||||||
public bool IsRank(byte rankId) { return m_rankId == rankId; }
|
public bool IsRank(byte rankId) { return m_rankId == rankId; }
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ namespace Game
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (invitedPlayer.GetSocial().HasIgnore(invitingPlayer.GetGUID()))
|
if (invitedPlayer.GetSocial().HasIgnore(invitingPlayer.GetGUID(), invitingPlayer.GetSession().GetAccountGUID()))
|
||||||
{
|
{
|
||||||
SendPartyResult(PartyOperation.Invite, invitedPlayer.GetName(), PartyResult.IgnoringYouS);
|
SendPartyResult(PartyOperation.Invite, invitedPlayer.GetName(), PartyResult.IgnoringYouS);
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -223,36 +223,36 @@ namespace Game
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
FriendsResult friendResult = FriendsResult.NotFound;
|
FriendsResult friendResult = FriendsResult.NotFound;
|
||||||
ObjectGuid friendGuid = Global.CharacterCacheStorage.GetCharacterGuidByName(packet.Name);
|
ObjectGuid friendGuid = ObjectGuid.Empty;
|
||||||
if (!friendGuid.IsEmpty())
|
|
||||||
|
CharacterCacheEntry characterInfo = Global.CharacterCacheStorage.GetCharacterCacheByName(packet.Name);
|
||||||
|
if (characterInfo != null)
|
||||||
{
|
{
|
||||||
CharacterCacheEntry characterInfo = Global.CharacterCacheStorage.GetCharacterCacheByGuid(friendGuid);
|
friendGuid = characterInfo.Guid;
|
||||||
if (characterInfo != null)
|
ObjectGuid friendAccountGuid = ObjectGuid.Create(HighGuid.WowAccount, characterInfo.AccountId);
|
||||||
|
Team team = Player.TeamForRace(characterInfo.RaceId);
|
||||||
|
uint friendAccountId = characterInfo.AccountId;
|
||||||
|
|
||||||
|
if (HasPermission(RBACPermissions.AllowGmFriend) || Global.AccountMgr.IsPlayerAccount(Global.AccountMgr.GetSecurity(friendAccountId, (int)Global.WorldMgr.GetRealm().Id.Index)))
|
||||||
{
|
{
|
||||||
Team team = Player.TeamForRace(characterInfo.RaceId);
|
if (friendGuid == GetPlayer().GetGUID())
|
||||||
uint friendAccountId = characterInfo.AccountId;
|
friendResult = FriendsResult.Self;
|
||||||
|
else if (GetPlayer().GetTeam() != team && !HasPermission(RBACPermissions.TwoSideAddFriend))
|
||||||
if (HasPermission(RBACPermissions.AllowGmFriend) || Global.AccountMgr.IsPlayerAccount(Global.AccountMgr.GetSecurity(friendAccountId, (int)Global.WorldMgr.GetRealm().Id.Index)))
|
friendResult = FriendsResult.Enemy;
|
||||||
|
else if (GetPlayer().GetSocial().HasFriend(friendGuid))
|
||||||
|
friendResult = FriendsResult.Already;
|
||||||
|
else
|
||||||
{
|
{
|
||||||
if (friendGuid == GetPlayer().GetGUID())
|
Player playerFriend = Global.ObjAccessor.FindPlayer(friendGuid);
|
||||||
friendResult = FriendsResult.Self;
|
if (playerFriend && playerFriend.IsVisibleGloballyFor(GetPlayer()))
|
||||||
else if (GetPlayer().GetTeam() != team && !HasPermission(RBACPermissions.TwoSideAddFriend))
|
friendResult = FriendsResult.AddedOnline;
|
||||||
friendResult = FriendsResult.Enemy;
|
|
||||||
else if (GetPlayer().GetSocial().HasFriend(friendGuid))
|
|
||||||
friendResult = FriendsResult.Already;
|
|
||||||
else
|
else
|
||||||
{
|
friendResult = FriendsResult.AddedOffline;
|
||||||
Player playerFriend = Global.ObjAccessor.FindPlayer(friendGuid);
|
|
||||||
if (playerFriend && playerFriend.IsVisibleGloballyFor(GetPlayer()))
|
|
||||||
friendResult = FriendsResult.AddedOnline;
|
|
||||||
else
|
|
||||||
friendResult = FriendsResult.AddedOffline;
|
|
||||||
|
|
||||||
if (GetPlayer().GetSocial().AddToSocialList(friendGuid, SocialFlag.Friend))
|
if (GetPlayer().GetSocial().AddToSocialList(friendGuid, friendAccountGuid, SocialFlag.Friend))
|
||||||
GetPlayer().GetSocial().SetFriendNote(friendGuid, packet.Notes);
|
GetPlayer().GetSocial().SetFriendNote(friendGuid, packet.Notes);
|
||||||
else
|
else
|
||||||
friendResult = FriendsResult.ListFull;
|
friendResult = FriendsResult.ListFull;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -275,25 +275,29 @@ namespace Game
|
|||||||
if (!ObjectManager.NormalizePlayerName(ref packet.Name))
|
if (!ObjectManager.NormalizePlayerName(ref packet.Name))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ObjectGuid IgnoreGuid = Global.CharacterCacheStorage.GetCharacterGuidByName(packet.Name);
|
ObjectGuid ignoreGuid;
|
||||||
FriendsResult ignoreResult = FriendsResult.IgnoreNotFound;
|
FriendsResult ignoreResult = FriendsResult.IgnoreNotFound;
|
||||||
if (IgnoreGuid.IsEmpty())
|
|
||||||
|
CharacterCacheEntry characterInfo = Global.CharacterCacheStorage.GetCharacterCacheByName(packet.Name);
|
||||||
|
if (characterInfo != null)
|
||||||
{
|
{
|
||||||
if (IgnoreGuid == GetPlayer().GetGUID()) //not add yourself
|
ignoreGuid = characterInfo.Guid;
|
||||||
|
ObjectGuid ignoreAccountGuid = ObjectGuid.Create(HighGuid.WowAccount, characterInfo.AccountId);
|
||||||
|
if (ignoreGuid == GetPlayer().GetGUID()) //not add yourself
|
||||||
ignoreResult = FriendsResult.IgnoreSelf;
|
ignoreResult = FriendsResult.IgnoreSelf;
|
||||||
else if (GetPlayer().GetSocial().HasIgnore(IgnoreGuid))
|
else if (GetPlayer().GetSocial().HasIgnore(ignoreGuid, ignoreAccountGuid))
|
||||||
ignoreResult = FriendsResult.IgnoreAlready;
|
ignoreResult = FriendsResult.IgnoreAlready;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ignoreResult = FriendsResult.IgnoreAdded;
|
ignoreResult = FriendsResult.IgnoreAdded;
|
||||||
|
|
||||||
// ignore list full
|
// ignore list full
|
||||||
if (!GetPlayer().GetSocial().AddToSocialList(IgnoreGuid, SocialFlag.Ignored))
|
if (!GetPlayer().GetSocial().AddToSocialList(ignoreGuid, ignoreAccountGuid, SocialFlag.Ignored))
|
||||||
ignoreResult = FriendsResult.IgnoreFull;
|
ignoreResult = FriendsResult.IgnoreFull;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Global.SocialMgr.SendFriendStatus(GetPlayer(), ignoreResult, IgnoreGuid);
|
Global.SocialMgr.SendFriendStatus(GetPlayer(), ignoreResult, ObjectGuid.Empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
[WorldPacketHandler(ClientOpcodes.DelIgnore)]
|
[WorldPacketHandler(ClientOpcodes.DelIgnore)]
|
||||||
|
|||||||
@@ -642,7 +642,7 @@ namespace Game
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pOther.GetSocial().HasIgnore(GetPlayer().GetGUID()))
|
if (pOther.GetSocial().HasIgnore(GetPlayer().GetGUID(), GetPlayer().GetSession().GetAccountGUID()))
|
||||||
{
|
{
|
||||||
info.Status = TradeStatus.PlayerIgnored;
|
info.Status = TradeStatus.PlayerIgnored;
|
||||||
SendTradeStatus(info);
|
SendTradeStatus(info);
|
||||||
|
|||||||
@@ -3236,7 +3236,7 @@ namespace Game.Spells
|
|||||||
Player target = unitTarget.ToPlayer();
|
Player target = unitTarget.ToPlayer();
|
||||||
|
|
||||||
// caster or target already have requested duel
|
// caster or target already have requested duel
|
||||||
if (caster.duel != null || target.duel != null || target.GetSocial() == null || target.GetSocial().HasIgnore(caster.GetGUID()))
|
if (caster.duel != null || target.duel != null || target.GetSocial() == null || target.GetSocial().HasIgnore(caster.GetGUID(), caster.GetSession().GetAccountGUID()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Players can only fight a duel in zones with this flag
|
// Players can only fight a duel in zones with this flag
|
||||||
|
|||||||
Reference in New Issue
Block a user