Пример #1
0
        static bool HandleInstanceUnbind(StringArguments args, CommandHandler handler)
        {
            if (args.Empty())
            {
                return(false);
            }

            Player player = handler.getSelectedPlayer();

            if (!player)
            {
                player = handler.GetSession().GetPlayer();
            }

            string map   = args.NextString();
            string pDiff = args.NextString();
            sbyte  diff  = -1;

            if (string.IsNullOrEmpty(pDiff))
            {
                diff = sbyte.Parse(pDiff);
            }
            ushort counter = 0;
            ushort MapId   = 0;

            if (map != "all")
            {
                MapId = ushort.Parse(map);
                if (MapId == 0)
                {
                    return(false);
                }
            }

            for (byte i = 0; i < (int)Difficulty.Max; ++i)
            {
                var binds = player.GetBoundInstances((Difficulty)i);
                foreach (var pair in binds)
                {
                    InstanceSave save = pair.Value.save;
                    if (pair.Key != player.GetMapId() && (MapId == 0 || MapId == pair.Key) && (diff == -1 || diff == (sbyte)save.GetDifficultyID()))
                    {
                        string timeleft = Time.GetTimeString(save.GetResetTime() - Time.UnixTime);
                        handler.SendSysMessage("unbinding map: {0} inst: {1} perm: {2} diff: {3} canReset: {4} TTR: {5}", pair.Key, save.GetInstanceId(),
                                               pair.Value.perm ? "yes" : "no", save.GetDifficultyID(), save.CanReset() ? "yes" : "no", timeleft);
                        player.UnbindInstance(pair.Key, (Difficulty)i);
                        counter++;
                    }
                }
            }
            handler.SendSysMessage("instances unbound: {0}", counter);

            return(true);
        }
Пример #2
0
        static bool HandleInstanceUnbind(CommandHandler handler, StringArguments args)
        {
            if (args.Empty())
            {
                return(false);
            }

            Player player = handler.GetSelectedPlayer();

            if (!player)
            {
                player = handler.GetSession().GetPlayer();
            }

            string map = args.NextString();

            if (!sbyte.TryParse(args.NextString(), out sbyte diff))
            {
                diff = -1;
            }

            ushort counter = 0;
            ushort MapId   = 0;

            if (map != "all")
            {
                if (!ushort.TryParse(map, out MapId) || MapId == 0)
                {
                    return(false);
                }
            }

            foreach (var difficulty in CliDB.DifficultyStorage.Values)
            {
                var binds = player.GetBoundInstances((Difficulty)difficulty.Id);
                foreach (var pair in binds)
                {
                    InstanceSave save = pair.Value.save;
                    if (pair.Key != player.GetMapId() && (MapId == 0 || MapId == pair.Key) && (diff == -1 || diff == (sbyte)save.GetDifficultyID()))
                    {
                        string timeleft = Time.GetTimeString(save.GetResetTime() - GameTime.GetGameTime());
                        handler.SendSysMessage("unbinding map: {0} inst: {1} perm: {2} diff: {3} canReset: {4} TTR: {5}", pair.Key, save.GetInstanceId(),
                                               pair.Value.perm ? "yes" : "no", save.GetDifficultyID(), save.CanReset() ? "yes" : "no", timeleft);
                        player.UnbindInstance(pair.Key, (Difficulty)difficulty.Id);
                        counter++;
                    }
                }
            }
            handler.SendSysMessage("instances unbound: {0}", counter);

            return(true);
        }
Пример #3
0
        public void SendRaidInfo()
        {
            InstanceInfoPkt instanceInfo = new InstanceInfoPkt();

            long now = Time.UnixTime;

            for (byte i = 0; i < (int)Difficulty.Max; ++i)
            {
                foreach (var pair in m_boundInstances[i])
                {
                    InstanceBind bind = pair.Value;
                    if (bind.perm)
                    {
                        InstanceSave save = pair.Value.save;

                        InstanceLockInfos lockInfos;

                        lockInfos.InstanceID   = save.GetInstanceId();
                        lockInfos.MapID        = save.GetMapId();
                        lockInfos.DifficultyID = (uint)save.GetDifficultyID();
                        if (bind.extendState != BindExtensionState.Extended)
                        {
                            lockInfos.TimeRemaining = (int)(save.GetResetTime() - now);
                        }
                        else
                        {
                            lockInfos.TimeRemaining = (int)(Global.InstanceSaveMgr.GetSubsequentResetTime(save.GetMapId(), save.GetDifficultyID(), save.GetResetTime()) - now);
                        }

                        lockInfos.CompletedMask = 0;
                        Map map = Global.MapMgr.FindMap(save.GetMapId(), save.GetInstanceId());
                        if (map != null)
                        {
                            InstanceScript instanceScript = ((InstanceMap)map).GetInstanceScript();
                            if (instanceScript != null)
                            {
                                lockInfos.CompletedMask = instanceScript.GetCompletedEncounterMask();
                            }
                        }

                        lockInfos.Locked   = bind.extendState != BindExtensionState.Expired;
                        lockInfos.Extended = bind.extendState == BindExtensionState.Extended;

                        instanceInfo.LockList.Add(lockInfos);
                    }
                }
            }

            SendPacket(instanceInfo);
        }
Пример #4
0
        public void SendRaidInfo()
        {
            InstanceInfoPkt instanceInfo = new();

            long now = GameTime.GetGameTime();

            foreach (var difficultyDic in m_boundInstances.Values)
            {
                foreach (var instanceBind in difficultyDic.Values)
                {
                    if (instanceBind.perm)
                    {
                        InstanceSave save = instanceBind.save;

                        InstanceLock lockInfos;
                        lockInfos.InstanceID   = save.GetInstanceId();
                        lockInfos.MapID        = save.GetMapId();
                        lockInfos.DifficultyID = (uint)save.GetDifficultyID();
                        if (instanceBind.extendState != BindExtensionState.Extended)
                        {
                            lockInfos.TimeRemaining = (int)(save.GetResetTime() - now);
                        }
                        else
                        {
                            lockInfos.TimeRemaining = (int)(Global.InstanceSaveMgr.GetSubsequentResetTime(save.GetMapId(), save.GetDifficultyID(), save.GetResetTime()) - now);
                        }

                        lockInfos.CompletedMask = 0;
                        Map map = Global.MapMgr.FindMap(save.GetMapId(), save.GetInstanceId());
                        if (map != null)
                        {
                            InstanceScript instanceScript = ((InstanceMap)map).GetInstanceScript();
                            if (instanceScript != null)
                            {
                                lockInfos.CompletedMask = instanceScript.GetCompletedEncounterMask();
                            }
                        }

                        lockInfos.Locked   = instanceBind.extendState != BindExtensionState.Expired;
                        lockInfos.Extended = instanceBind.extendState == BindExtensionState.Extended;

                        instanceInfo.LockList.Add(lockInfos);
                    }
                }
            }

            SendPacket(instanceInfo);
        }
Пример #5
0
        static bool HandleInstanceListBinds(StringArguments args, CommandHandler handler)
        {
            Player player = handler.GetSelectedPlayer();

            if (!player)
            {
                player = handler.GetSession().GetPlayer();
            }

            string format = "map: {0} inst: {1} perm: {2} diff: {3} canReset: {4} TTR: {5}";

            uint counter = 0;

            for (byte i = 0; i < (int)Difficulty.Max; ++i)
            {
                var binds = player.GetBoundInstances((Difficulty)i);
                foreach (var pair in binds)
                {
                    InstanceSave save     = pair.Value.save;
                    string       timeleft = Time.GetTimeString(save.GetResetTime() - Time.UnixTime);
                    handler.SendSysMessage(format, pair.Key, save.GetInstanceId(), pair.Value.perm ? "yes" : "no", save.GetDifficultyID(), save.CanReset() ? "yes" : "no", timeleft);
                    counter++;
                }
            }
            handler.SendSysMessage("player binds: {0}", counter);

            counter = 0;
            Group group = player.GetGroup();

            if (group)
            {
                for (byte i = 0; i < (int)Difficulty.Max; ++i)
                {
                    var binds = group.GetBoundInstances((Difficulty)i);
                    foreach (var pair in binds)
                    {
                        InstanceSave save     = pair.Value.save;
                        string       timeleft = Time.GetTimeString(save.GetResetTime() - Time.UnixTime);
                        handler.SendSysMessage(format, pair.Key, save.GetInstanceId(), pair.Value.perm ? "yes" : "no", save.GetDifficultyID(), save.CanReset() ? "yes" : "no", timeleft);
                        counter++;
                    }
                }
            }
            handler.SendSysMessage("group binds: {0}", counter);

            return(true);
        }
Пример #6
0
        public void SendCalendarRaidLockoutUpdated(InstanceSave save)
        {
            if (save == null)
            {
                return;
            }

            long currTime = GameTime.GetGameTime();

            CalendarRaidLockoutUpdated packet = new();

            packet.DifficultyID     = (uint)save.GetDifficultyID();
            packet.MapID            = (int)save.GetMapId();
            packet.NewTimeRemaining = 0; // FIXME
            packet.OldTimeRemaining = (int)(save.GetResetTime() - currTime);

            SendPacket(packet);
        }
Пример #7
0
        public void SendCalendarRaidLockoutUpdated(InstanceSave save)
        {
            if (save == null)
            {
                return;
            }

            ObjectGuid guid     = GetPlayer().GetGUID();
            long       currTime = Time.UnixTime;

            CalendarRaidLockoutUpdated packet = new CalendarRaidLockoutUpdated();

            packet.DifficultyID     = (uint)save.GetDifficultyID();
            packet.MapID            = (int)save.GetMapId();
            packet.NewTimeRemaining = 0; // FIXME
            packet.OldTimeRemaining = (int)(save.GetResetTime() - currTime);

            SendPacket(packet);
        }
Пример #8
0
        public void SendCalendarRaidLockout(InstanceSave save, bool add)
        {
            long currTime = GameTime.GetGameTime();

            if (add)
            {
                CalendarRaidLockoutAdded calendarRaidLockoutAdded = new();
                calendarRaidLockoutAdded.InstanceID    = save.GetInstanceId();
                calendarRaidLockoutAdded.ServerTime    = (uint)currTime;
                calendarRaidLockoutAdded.MapID         = (int)save.GetMapId();
                calendarRaidLockoutAdded.DifficultyID  = save.GetDifficultyID();
                calendarRaidLockoutAdded.TimeRemaining = (int)(save.GetResetTime() - currTime);
                SendPacket(calendarRaidLockoutAdded);
            }
            else
            {
                CalendarRaidLockoutRemoved calendarRaidLockoutRemoved = new();
                calendarRaidLockoutRemoved.InstanceID   = save.GetInstanceId();
                calendarRaidLockoutRemoved.MapID        = (int)save.GetMapId();
                calendarRaidLockoutRemoved.DifficultyID = save.GetDifficultyID();
                SendPacket(calendarRaidLockoutRemoved);
            }
        }
Пример #9
0
        void HandleCalendarGetCalendar(CalendarGetCalendar calendarGetCalendar)
        {
            ObjectGuid guid = GetPlayer().GetGUID();

            long currTime = GameTime.GetGameTime();

            CalendarSendCalendar packet = new();

            packet.ServerTime = currTime;

            var invites = Global.CalendarMgr.GetPlayerInvites(guid);

            foreach (var invite in invites)
            {
                CalendarSendCalendarInviteInfo inviteInfo = new();
                inviteInfo.EventID     = invite.EventId;
                inviteInfo.InviteID    = invite.InviteId;
                inviteInfo.InviterGuid = invite.SenderGuid;
                inviteInfo.Status      = invite.Status;
                inviteInfo.Moderator   = invite.Rank;
                CalendarEvent calendarEvent = Global.CalendarMgr.GetEvent(invite.EventId);
                if (calendarEvent != null)
                {
                    inviteInfo.InviteType = (byte)(calendarEvent.IsGuildEvent() && calendarEvent.GuildId == _player.GetGuildId() ? 1 : 0);
                }

                packet.Invites.Add(inviteInfo);
            }

            var playerEvents = Global.CalendarMgr.GetPlayerEvents(guid);

            foreach (var calendarEvent in playerEvents)
            {
                CalendarSendCalendarEventInfo eventInfo;
                eventInfo.EventID     = calendarEvent.EventId;
                eventInfo.Date        = calendarEvent.Date;
                eventInfo.EventClubID = calendarEvent.GuildId;
                eventInfo.EventName   = calendarEvent.Title;
                eventInfo.EventType   = calendarEvent.EventType;
                eventInfo.Flags       = calendarEvent.Flags;
                eventInfo.OwnerGuid   = calendarEvent.OwnerGuid;
                eventInfo.TextureID   = calendarEvent.TextureId;

                packet.Events.Add(eventInfo);
            }

            foreach (var difficulty in CliDB.DifficultyStorage.Values)
            {
                var boundInstances = _player.GetBoundInstances((Difficulty)difficulty.Id);
                if (boundInstances != null)
                {
                    foreach (var boundInstance in boundInstances.Values)
                    {
                        if (boundInstance.perm)
                        {
                            CalendarSendCalendarRaidLockoutInfo lockoutInfo;

                            InstanceSave save = boundInstance.save;
                            lockoutInfo.MapID        = (int)save.GetMapId();
                            lockoutInfo.DifficultyID = (uint)save.GetDifficultyID();
                            lockoutInfo.ExpireTime   = save.GetResetTime() - currTime;
                            lockoutInfo.InstanceID   = save.GetInstanceId(); // instance save id as unique instance copy id

                            packet.RaidLockouts.Add(lockoutInfo);
                        }
                    }
                }
            }

            SendPacket(packet);
        }