namespace Supercell.Laser.Logic.Command.Home { using Supercell.Laser.Logic.Club; using Supercell.Laser.Logic.Data; using Supercell.Laser.Logic.Data.Helper; using Supercell.Laser.Logic.Friends; using Supercell.Laser.Logic.Home; using Supercell.Laser.Logic.Listener; using Supercell.Laser.Logic.Message.Friends; using Supercell.Laser.Titan.DataStream; public class LogicSetPlayerThumbnailCommand : Command { public int ThumbnailInstanceId; public override void Decode(ByteStream stream) { base.Decode(stream); stream.ReadVInt(); ThumbnailInstanceId = stream.ReadVInt(); } public override int Execute(HomeMode homeMode) { if (ThumbnailInstanceId < 0) return 1; if (ThumbnailInstanceId > DataTables.Get(DataType.PlayerThumbnail).Count) return 2; homeMode.Home.ThumbnailId = GlobalId.CreateGlobalId(28, ThumbnailInstanceId); if (homeMode.Avatar.AllianceId > 0) { Alliance alliance = LogicServerListener.Instance.GetAlliance(homeMode.Avatar.AllianceId); if (alliance != null) { AllianceMember member = alliance.GetMemberById(homeMode.Avatar.AccountId); if (member != null) member.DisplayData.ThumbnailId = homeMode.Home.ThumbnailId; } } foreach (Friend friend in homeMode.Avatar.Friends) { if (friend.Avatar == null) continue; Friend entry = friend.Avatar.GetFriendById(homeMode.Avatar.AccountId); if (entry == null) continue; entry.DisplayData.ThumbnailId = homeMode.Home.ThumbnailId; if (LogicServerListener.Instance.IsPlayerOnline(friend.AccountId)) { LogicServerListener.Instance.GetGameListener(friend.AccountId) .SendTCPMessage(new FriendListUpdateMessage { Entry = entry }); } } return 0; } public override int GetCommandType() => 505; } }