Core/Achievements: Minor fixes

Port From (https://github.com/TrinityCore/TrinityCore/commit/3e833739071a689dc34e33f7a511d8cc50e00b94)
This commit is contained in:
hondacrx
2020-05-22 14:11:32 -04:00
parent 13cb4fb0ee
commit 3b44a21d76
3 changed files with 91 additions and 46 deletions
+49 -11
View File
@@ -296,6 +296,7 @@ namespace Game.Achievements
CriteriaProgress progress = new CriteriaProgress();
progress.Counter = counter;
progress.Date = date;
progress.PlayerGUID = _owner.GetGUID();
progress.Changed = false;
_criteriaProgress[id] = progress;
@@ -391,6 +392,7 @@ namespace Game.Achievements
public override void SendAllData(Player receiver)
{
AllAccountCriteria allAccountCriteria = new AllAccountCriteria();
AllAchievementData achievementData = new AllAchievementData();
foreach (var pair in _completedAchievements)
@@ -412,6 +414,8 @@ namespace Game.Achievements
foreach (var pair in _criteriaProgress)
{
Criteria criteria = Global.CriteriaMgr.GetCriteria(pair.Key);
CriteriaProgressPkt progress = new CriteriaProgressPkt();
progress.Id = pair.Key;
progress.Quantity = pair.Value.Counter;
@@ -421,8 +425,24 @@ namespace Game.Achievements
progress.TimeFromStart = 0;
progress.TimeFromCreate = 0;
achievementData.Data.Progress.Add(progress);
if (criteria.FlagsCu.HasAnyFlag(CriteriaFlagsCu.Account))
{
CriteriaProgressPkt accountProgress = new CriteriaProgressPkt();
accountProgress.Id = pair.Key;
accountProgress.Quantity = pair.Value.Counter;
accountProgress.Player = _owner.GetSession().GetBattlenetAccountGUID();
accountProgress.Flags = 0;
accountProgress.Date = pair.Value.Date;
accountProgress.TimeFromStart = 0;
accountProgress.TimeFromCreate = 0;
allAccountCriteria.Progress.Add(accountProgress);
}
}
if (!allAccountCriteria.Progress.Empty())
SendPacket(allAccountCriteria);
SendPacket(achievementData);
}
@@ -576,20 +596,38 @@ namespace Game.Achievements
public override void SendCriteriaUpdate(Criteria criteria, CriteriaProgress progress, uint timeElapsed, bool timedCompleted)
{
CriteriaUpdate criteriaUpdate = new CriteriaUpdate();
if (criteria.FlagsCu.HasAnyFlag(CriteriaFlagsCu.Account))
{
AccountCriteriaUpdate criteriaUpdate = new AccountCriteriaUpdate();
criteriaUpdate.Progress.Id = criteria.Id;
criteriaUpdate.Progress.Quantity = progress.Counter;
criteriaUpdate.Progress.Player = _owner.GetSession().GetBattlenetAccountGUID();
criteriaUpdate.Progress.Flags = 0;
if (criteria.Entry.StartTimer != 0)
criteriaUpdate.Progress.Flags = timedCompleted ? 1 : 0u; // 1 is for keeping the counter at 0 in client
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.Progress.Date = progress.Date;
criteriaUpdate.Progress.TimeFromStart = timeElapsed;
criteriaUpdate.Progress.TimeFromCreate = 0;
SendPacket(criteriaUpdate);
}
else
{
CriteriaUpdate criteriaUpdate = new CriteriaUpdate();
criteriaUpdate.CurrentTime = progress.Date;
criteriaUpdate.ElapsedTime = timeElapsed;
criteriaUpdate.CreationTime = 0;
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
SendPacket(criteriaUpdate);
criteriaUpdate.CurrentTime = progress.Date;
criteriaUpdate.ElapsedTime = timeElapsed;
criteriaUpdate.CreationTime = 0;
SendPacket(criteriaUpdate);
}
}
public override void SendCriteriaProgressRemoved(uint criteriaId)