コード例 #1
0
        public void SendCalendarRaidLockout(InstanceSave save, bool add)
        {
            long currTime = Time.UnixTime;

            if (add)
            {
                CalendarRaidLockoutAdded calendarRaidLockoutAdded = new CalendarRaidLockoutAdded();
                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();
                calendarRaidLockoutRemoved.InstanceID   = save.GetInstanceId();
                calendarRaidLockoutRemoved.MapID        = (int)save.GetMapId();
                calendarRaidLockoutRemoved.DifficultyID = save.GetDifficultyID();
                SendPacket(calendarRaidLockoutRemoved);
            }
        }
コード例 #2
0
ファイル: Player.Map.cs プロジェクト: query-wow/CypherCore
        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);
        }
コード例 #3
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);
        }
コード例 #4
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);
        }
コード例 #5
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);
        }
コード例 #6
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);
        }
コード例 #7
0
ファイル: Player.Map.cs プロジェクト: jungrok5/CypherCore
        public InstanceBind BindToInstance(InstanceSave save, bool permanent, BindExtensionState extendState = BindExtensionState.Normal, bool load = false)
        {
            if (save != null)
            {
                InstanceBind bind = new InstanceBind();
                if (m_boundInstances[(int)save.GetDifficultyID()].ContainsKey(save.GetMapId()))
                {
                    bind = m_boundInstances[(int)save.GetDifficultyID()][save.GetMapId()];
                }

                if (extendState == BindExtensionState.Keep) // special flag, keep the player's current extend state when updating for new boss down
                {
                    if (save == bind.save)
                    {
                        extendState = bind.extendState;
                    }
                    else
                    {
                        extendState = BindExtensionState.Normal;
                    }
                }

                if (!load)
                {
                    PreparedStatement stmt;
                    if (bind.save != null)
                    {
                        // update the save when the group kills a boss
                        if (permanent != bind.perm || save != bind.save || extendState != bind.extendState)
                        {
                            stmt = DB.Characters.GetPreparedStatement(CharStatements.UPD_CHAR_INSTANCE);

                            stmt.AddValue(0, save.GetInstanceId());
                            stmt.AddValue(1, permanent);
                            stmt.AddValue(2, extendState);
                            stmt.AddValue(3, GetGUID().GetCounter());
                            stmt.AddValue(4, bind.save.GetInstanceId());

                            DB.Characters.Execute(stmt);
                        }
                    }
                    else
                    {
                        stmt = DB.Characters.GetPreparedStatement(CharStatements.INS_CHAR_INSTANCE);
                        stmt.AddValue(0, GetGUID().GetCounter());
                        stmt.AddValue(1, save.GetInstanceId());
                        stmt.AddValue(2, permanent);
                        stmt.AddValue(3, extendState);
                        DB.Characters.Execute(stmt);
                    }
                }

                if (bind.save != save)
                {
                    if (bind.save != null)
                    {
                        bind.save.RemovePlayer(this);
                    }
                    save.AddPlayer(this);
                }

                if (permanent)
                {
                    save.SetCanReset(false);
                }

                bind.save        = save;
                bind.perm        = permanent;
                bind.extendState = extendState;
                if (!load)
                {
                    Log.outDebug(LogFilter.Maps, "Player.BindToInstance: Player '{0}' ({1}) is now bound to map (ID: {2}, Instance {3}, Difficulty {4})", GetName(), GetGUID().ToString(), save.GetMapId(), save.GetInstanceId(), save.GetDifficultyID());
                }

                Global.ScriptMgr.OnPlayerBindToInstance(this, save.GetDifficultyID(), save.GetMapId(), permanent, extendState);

                m_boundInstances[(int)save.GetDifficultyID()][save.GetMapId()] = bind;
                return(bind);
            }

            return(null);
        }
コード例 #8
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);
        }