コード例 #1
0
        public CalendarInvite(ulong inviteId, ulong eventId, ObjectGuid invitee, ObjectGuid senderGUID, long responseTime, CalendarInviteStatus status, CalendarModerationRank rank, string note)
        {
            InviteId     = inviteId;
            EventId      = eventId;
            InviteeGuid  = invitee;
            SenderGuid   = senderGUID;
            ResponseTime = responseTime;

            Status = status;
            Rank   = rank;
            Note   = note;
        }
コード例 #2
0
        void HandleCalendarEventSignup(CalendarEventSignUp calendarEventSignUp)
        {
            ObjectGuid guid = GetPlayer().GetGUID();

            CalendarEvent calendarEvent = Global.CalendarMgr.GetEvent(calendarEventSignUp.EventID);

            if (calendarEvent != null)
            {
                if (calendarEvent.IsGuildEvent() && calendarEvent.GuildId != GetPlayer().GetGuildId())
                {
                    Global.CalendarMgr.SendCalendarCommandResult(guid, CalendarError.GuildPlayerNotInGuild);
                    return;
                }

                CalendarInviteStatus status = calendarEventSignUp.Tentative ? CalendarInviteStatus.Tentative : CalendarInviteStatus.SignedUp;
                CalendarInvite       invite = new(Global.CalendarMgr.GetFreeInviteId(), calendarEventSignUp.EventID, guid, guid, GameTime.GetGameTime(), status, CalendarModerationRank.Player, "");
                Global.CalendarMgr.AddInvite(calendarEvent, invite);
                Global.CalendarMgr.SendCalendarClearPendingAction(guid);
            }
            else
            {
                Global.CalendarMgr.SendCalendarCommandResult(guid, CalendarError.EventInvalid);
            }
        }
コード例 #3
0
        void SendCalendarEventInviteRemoveAlert(ObjectGuid guid, CalendarEvent calendarEvent, CalendarInviteStatus status)
        {
            Player player = Global.ObjAccessor.FindPlayer(guid);

            if (player)
            {
                CalendarEventInviteRemovedAlert packet = new CalendarEventInviteRemovedAlert();
                packet.Date    = calendarEvent.Date;
                packet.EventID = calendarEvent.EventId;
                packet.Flags   = calendarEvent.Flags;
                packet.Status  = status;

                player.SendPacket(packet);
            }
        }
コード例 #4
0
        public void LoadFromDB()
        {
            uint count = 0;

            _maxEventId  = 0;
            _maxInviteId = 0;

            //                                              0        1      2      3            4          5          6     7      8
            SQLResult result = DB.Characters.Query("SELECT EventID, Owner, Title, Description, EventType, TextureID, Date, Flags, LockDate FROM calendar_events");

            if (!result.IsEmpty())
            {
                do
                {
                    ulong             eventID     = result.Read <ulong>(0);
                    ObjectGuid        ownerGUID   = ObjectGuid.Create(HighGuid.Player, result.Read <ulong>(1));
                    string            title       = result.Read <string>(2);
                    string            description = result.Read <string>(3);
                    CalendarEventType type        = (CalendarEventType)result.Read <byte>(4);
                    int           textureID       = result.Read <int>(5);
                    uint          date            = result.Read <uint>(6);
                    CalendarFlags flags           = (CalendarFlags)result.Read <uint>(7);
                    uint          lockDate        = result.Read <uint>(8);
                    ulong         guildID         = 0;

                    if (flags.HasAnyFlag(CalendarFlags.GuildEvent) || flags.HasAnyFlag(CalendarFlags.WithoutInvites))
                    {
                        guildID = Global.CharacterCacheStorage.GetCharacterGuildIdByGuid(ownerGUID);
                    }

                    CalendarEvent calendarEvent = new CalendarEvent(eventID, ownerGUID, guildID, type, textureID, date, flags, title, description, lockDate);
                    _events.Add(calendarEvent);

                    _maxEventId = Math.Max(_maxEventId, eventID);

                    ++count;
                }while (result.NextRow());
            }

            Log.outInfo(LogFilter.ServerLoading, "Loaded {0} calendar events", count);
            count = 0;

            //                                    0         1        2        3       4       5             6               7
            result = DB.Characters.Query("SELECT InviteID, EventID, Invitee, Sender, Status, ResponseTime, ModerationRank, Note FROM calendar_invites");
            if (!result.IsEmpty())
            {
                do
                {
                    ulong                inviteId   = result.Read <ulong>(0);
                    ulong                eventId    = result.Read <ulong>(1);
                    ObjectGuid           invitee    = ObjectGuid.Create(HighGuid.Player, result.Read <ulong>(2));
                    ObjectGuid           senderGUID = ObjectGuid.Create(HighGuid.Player, result.Read <ulong>(3));
                    CalendarInviteStatus status     = (CalendarInviteStatus)result.Read <byte>(4);
                    uint responseTime           = result.Read <uint>(5);
                    CalendarModerationRank rank = (CalendarModerationRank)result.Read <byte>(6);
                    string note = result.Read <string>(7);

                    CalendarInvite invite = new CalendarInvite(inviteId, eventId, invitee, senderGUID, responseTime, status, rank, note);
                    _invites.Add(eventId, invite);

                    _maxInviteId = Math.Max(_maxInviteId, inviteId);

                    ++count;
                }while (result.NextRow());
            }

            Log.outInfo(LogFilter.ServerLoading, "Loaded {0} calendar invites", count);

            for (ulong i = 1; i < _maxEventId; ++i)
            {
                if (GetEvent(i) == null)
                {
                    _freeEventIds.Add(i);
                }
            }

            for (ulong i = 1; i < _maxInviteId; ++i)
            {
                if (GetInvite(i) == null)
                {
                    _freeInviteIds.Add(i);
                }
            }
        }