Ejemplo n.º 1
0
        public void OnClanState(SteamFriends.ClanStateCallback cb)
        {
            foreach (var e in cb.Events)
            {
                Core.Util.Buffer b = new Core.Util.Buffer();
                b.SetAlignment(4);

                b.WriteULong(e.ID);
                b.WriteULong(cb.ClanID);
                // TODO: pad to 256 characters
                b.WriteString(e.Headline);
                b.WriteUInt(Platform.ToUnixTime(e.EventTime));
                b.WriteULong(e.GameID);

                Instance.PostCallback(Common.CallbackId(Common.CallbackType.ClientFriends, 2), b);
            }

            // TODO: do something with announcements

            var clan = ClanGroup.Active.FindOrCreate(cb.ClanID);

            var name_changed     = clan.Name != cb.ClanName;
            var avatar_changed   = clan.AvatarHash != cb.AvatarHash;
            var acc_info_changed = clan.AccountFlags != cb.AccountFlags;

            // Might be completely unnecessary
            if (name_changed || avatar_changed || acc_info_changed)
            {
                Core.Util.Buffer b = new Core.Util.Buffer();
                b.SetAlignment(4);

                b.WriteULong(cb.ClanID);
                b.WriteBool(name_changed);
                b.WriteBool(avatar_changed);
                b.WriteBool(acc_info_changed);
                Instance.PostCallback(Common.CallbackId(Common.CallbackType.ClientFriends, 19), b);
            }

            // Set all the new info that we have
            clan.Name         = cb.ClanName;
            clan.AccountFlags = cb.AccountFlags;
            clan.AvatarHash   = cb.AvatarHash;

            clan.ChatRoomPrivate = cb.ChatRoomPrivate;

            clan.MemberChattingCount = cb.MemberChattingCount;
            clan.MemberInGameCount   = cb.MemberInGameCount;
            clan.MemberOnlineCount   = cb.MemberOnlineCount;
            clan.MemberTotal         = cb.MemberTotalCount;

            Log.WriteLine("OnClanState for {0} <{1}>", clan.Id, clan.Name);
        }