Exemple #1
0
        public void LoadFromDB(SQLResult objectiveResult, SQLResult criteriaResult)
        {
            if (!objectiveResult.IsEmpty())
            {
                do
                {
                    uint objectiveId = objectiveResult.Read <uint>(0);

                    QuestObjective objective = Global.ObjectMgr.GetQuestObjective(objectiveId);
                    if (objective == null)
                    {
                        continue;
                    }

                    _completedObjectives.Add(objectiveId);
                } while (objectiveResult.NextRow());
            }

            if (!criteriaResult.IsEmpty())
            {
                long now = Time.UnixTime;
                do
                {
                    uint  criteriaId = criteriaResult.Read <uint>(0);
                    ulong counter    = criteriaResult.Read <ulong>(1);
                    long  date       = criteriaResult.Read <uint>(2);

                    Criteria criteria = Global.CriteriaMgr.GetCriteria(criteriaId);
                    if (criteria == null)
                    {
                        // Removing non-existing criteria data for all characters
                        Log.outError(LogFilter.Player, "Non-existing quest objective criteria {criteriaId} data has been removed from the table `character_queststatus_objectives_criteria_progress`.");

                        PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.DEL_INVALID_QUEST_PROGRESS_CRITERIA);
                        stmt.AddValue(0, criteriaId);
                        DB.Characters.Execute(stmt);

                        continue;
                    }

                    if (criteria.Entry.StartTimer != 0 && date + criteria.Entry.StartTimer < now)
                    {
                        continue;
                    }

                    CriteriaProgress progress = new CriteriaProgress();
                    progress.Counter = counter;
                    progress.Date    = date;
                    progress.Changed = false;

                    _criteriaProgress[criteriaId] = progress;
                } while (criteriaResult.NextRow());
            }
        }
Exemple #2
0
        public override void SendCriteriaUpdate(Criteria criteria, CriteriaProgress progress, uint timeElapsed, bool timedCompleted)
        {
            ScenarioProgressUpdate progressUpdate = new ScenarioProgressUpdate();

            progressUpdate.CriteriaProgress.Id       = criteria.Id;
            progressUpdate.CriteriaProgress.Quantity = progress.Counter;
            progressUpdate.CriteriaProgress.Player   = progress.PlayerGUID;
            progressUpdate.CriteriaProgress.Date     = progress.Date;
            if (criteria.Entry.StartTimer != 0)
            {
                progressUpdate.CriteriaProgress.Flags = timedCompleted ? 1 : 0u;
            }

            progressUpdate.CriteriaProgress.TimeFromStart  = timeElapsed;
            progressUpdate.CriteriaProgress.TimeFromCreate = 0;

            SendPacket(progressUpdate);
        }
        public override void SendCriteriaUpdate(Criteria criteria, CriteriaProgress progress, TimeSpan timeElapsed, bool timedCompleted)
        {
            CriteriaUpdate criteriaUpdate = new();

            criteriaUpdate.CriteriaID = criteria.Id;
            criteriaUpdate.Quantity   = progress.Counter;
            criteriaUpdate.PlayerGUID = _owner.GetGUID();
            criteriaUpdate.Flags      = 0;
            if (criteria.Entry.StartTimer != 0)
            {
                criteriaUpdate.Flags = timedCompleted ? 1 : 0u; // 1 is for keeping the counter at 0 in client
            }
            criteriaUpdate.CurrentTime  = progress.Date;
            criteriaUpdate.ElapsedTime  = (uint)timeElapsed.TotalSeconds;
            criteriaUpdate.CreationTime = 0;

            SendPacket(criteriaUpdate);
        }
Exemple #4
0
 public override void Write()
 {
     CriteriaProgress.Write(_worldPacket);
 }