Core/Criteria: Use std::chrono type for CriteriaHandler::SendCriteriaUpdate
Port From (https://github.com/TrinityCore/TrinityCore/commit/33bce9e28b28f018dc43a31ed37790fa1fc81f88)
This commit is contained in:
@@ -602,7 +602,7 @@ namespace Game.Achievements
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void SendCriteriaUpdate(Criteria criteria, CriteriaProgress progress, uint timeElapsed, bool timedCompleted)
|
public override void SendCriteriaUpdate(Criteria criteria, CriteriaProgress progress, TimeSpan timeElapsed, bool timedCompleted)
|
||||||
{
|
{
|
||||||
if (criteria.FlagsCu.HasAnyFlag(CriteriaFlagsCu.Account))
|
if (criteria.FlagsCu.HasAnyFlag(CriteriaFlagsCu.Account))
|
||||||
{
|
{
|
||||||
@@ -615,7 +615,7 @@ namespace Game.Achievements
|
|||||||
criteriaUpdate.Progress.Flags = timedCompleted ? 1 : 0u; // 1 is for keeping the counter at 0 in client
|
criteriaUpdate.Progress.Flags = timedCompleted ? 1 : 0u; // 1 is for keeping the counter at 0 in client
|
||||||
|
|
||||||
criteriaUpdate.Progress.Date = progress.Date;
|
criteriaUpdate.Progress.Date = progress.Date;
|
||||||
criteriaUpdate.Progress.TimeFromStart = timeElapsed;
|
criteriaUpdate.Progress.TimeFromStart = (uint)timeElapsed.TotalSeconds;
|
||||||
criteriaUpdate.Progress.TimeFromCreate = 0;
|
criteriaUpdate.Progress.TimeFromCreate = 0;
|
||||||
SendPacket(criteriaUpdate);
|
SendPacket(criteriaUpdate);
|
||||||
}
|
}
|
||||||
@@ -631,7 +631,7 @@ namespace Game.Achievements
|
|||||||
criteriaUpdate.Flags = timedCompleted ? 1 : 0u; // 1 is for keeping the counter at 0 in client
|
criteriaUpdate.Flags = timedCompleted ? 1 : 0u; // 1 is for keeping the counter at 0 in client
|
||||||
|
|
||||||
criteriaUpdate.CurrentTime = progress.Date;
|
criteriaUpdate.CurrentTime = progress.Date;
|
||||||
criteriaUpdate.ElapsedTime = timeElapsed;
|
criteriaUpdate.ElapsedTime = (uint)timeElapsed.TotalSeconds;
|
||||||
criteriaUpdate.CreationTime = 0;
|
criteriaUpdate.CreationTime = 0;
|
||||||
|
|
||||||
SendPacket(criteriaUpdate);
|
SendPacket(criteriaUpdate);
|
||||||
@@ -1013,7 +1013,7 @@ namespace Game.Achievements
|
|||||||
UpdateCriteria(CriteriaTypes.EarnAchievementPoints, achievement.Points, 0, 0, null, referencePlayer);
|
UpdateCriteria(CriteriaTypes.EarnAchievementPoints, achievement.Points, 0, 0, null, referencePlayer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void SendCriteriaUpdate(Criteria entry, CriteriaProgress progress, uint timeElapsed, bool timedCompleted)
|
public override void SendCriteriaUpdate(Criteria entry, CriteriaProgress progress, TimeSpan timeElapsed, bool timedCompleted)
|
||||||
{
|
{
|
||||||
GuildCriteriaUpdate guildCriteriaUpdate = new();
|
GuildCriteriaUpdate guildCriteriaUpdate = new();
|
||||||
|
|
||||||
|
|||||||
@@ -609,18 +609,18 @@ namespace Game.Achievements
|
|||||||
progress.PlayerGUID = referencePlayer ? referencePlayer.GetGUID() : ObjectGuid.Empty;
|
progress.PlayerGUID = referencePlayer ? referencePlayer.GetGUID() : ObjectGuid.Empty;
|
||||||
_criteriaProgress[criteria.Id] = progress;
|
_criteriaProgress[criteria.Id] = progress;
|
||||||
|
|
||||||
uint timeElapsed = 0;
|
TimeSpan timeElapsed = TimeSpan.Zero;
|
||||||
if (criteria.Entry.StartTimer != 0)
|
if (criteria.Entry.StartTimer != 0)
|
||||||
{
|
{
|
||||||
Cypher.Assert(trees != null);
|
Cypher.Assert(trees != null);
|
||||||
|
|
||||||
foreach (CriteriaTree tree in trees)
|
foreach (CriteriaTree tree in trees)
|
||||||
{
|
{
|
||||||
var timedIter = _timeCriteriaTrees.LookupByKey(tree.Id);
|
var timed = _timeCriteriaTrees.LookupByKey(tree.Id);
|
||||||
if (timedIter != 0)
|
if (timed != 0)
|
||||||
{
|
{
|
||||||
// Client expects this in packet
|
// Client expects this in packet
|
||||||
timeElapsed = criteria.Entry.StartTimer - (timedIter / Time.InMilliseconds);
|
timeElapsed = TimeSpan.FromSeconds(criteria.Entry.StartTimer - (timed / Time.InMilliseconds));
|
||||||
|
|
||||||
// Remove the timer, we wont need it anymore
|
// Remove the timer, we wont need it anymore
|
||||||
if (IsCompletedCriteriaTree(tree))
|
if (IsCompletedCriteriaTree(tree))
|
||||||
@@ -2590,7 +2590,7 @@ namespace Game.Achievements
|
|||||||
}
|
}
|
||||||
|
|
||||||
public virtual void SendAllData(Player receiver) { }
|
public virtual void SendAllData(Player receiver) { }
|
||||||
public virtual void SendCriteriaUpdate(Criteria criteria, CriteriaProgress progress, uint timeElapsed, bool timedCompleted) { }
|
public virtual void SendCriteriaUpdate(Criteria criteria, CriteriaProgress progress, TimeSpan timeElapsed, bool timedCompleted) { }
|
||||||
public virtual void SendCriteriaProgressRemoved(uint criteriaId) { }
|
public virtual void SendCriteriaProgressRemoved(uint criteriaId) { }
|
||||||
|
|
||||||
public virtual void CompletedCriteriaTree(CriteriaTree tree, Player referencePlayer) { }
|
public virtual void CompletedCriteriaTree(CriteriaTree tree, Player referencePlayer) { }
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ using Game.Achievements;
|
|||||||
using Game.Entities;
|
using Game.Entities;
|
||||||
using Game.Networking;
|
using Game.Networking;
|
||||||
using Game.Networking.Packets;
|
using Game.Networking.Packets;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Game
|
namespace Game
|
||||||
@@ -240,7 +241,7 @@ namespace Game
|
|||||||
return _completedObjectives.Contains(questObjective.Id);
|
return _completedObjectives.Contains(questObjective.Id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void SendCriteriaUpdate(Criteria criteria, CriteriaProgress progress, uint timeElapsed, bool timedCompleted)
|
public override void SendCriteriaUpdate(Criteria criteria, CriteriaProgress progress, TimeSpan timeElapsed, bool timedCompleted)
|
||||||
{
|
{
|
||||||
CriteriaUpdate criteriaUpdate = new();
|
CriteriaUpdate criteriaUpdate = new();
|
||||||
|
|
||||||
@@ -252,7 +253,7 @@ namespace Game
|
|||||||
criteriaUpdate.Flags = timedCompleted ? 1 : 0u; // 1 is for keeping the counter at 0 in client
|
criteriaUpdate.Flags = timedCompleted ? 1 : 0u; // 1 is for keeping the counter at 0 in client
|
||||||
|
|
||||||
criteriaUpdate.CurrentTime = progress.Date;
|
criteriaUpdate.CurrentTime = progress.Date;
|
||||||
criteriaUpdate.ElapsedTime = timeElapsed;
|
criteriaUpdate.ElapsedTime = (uint)timeElapsed.TotalSeconds;
|
||||||
criteriaUpdate.CreationTime = 0;
|
criteriaUpdate.CreationTime = 0;
|
||||||
|
|
||||||
SendPacket(criteriaUpdate);
|
SendPacket(criteriaUpdate);
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ using Game.DataStorage;
|
|||||||
using Game.Entities;
|
using Game.Entities;
|
||||||
using Game.Networking;
|
using Game.Networking;
|
||||||
using Game.Networking.Packets;
|
using Game.Networking.Packets;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Game.Scenarios
|
namespace Game.Scenarios
|
||||||
@@ -153,7 +154,7 @@ namespace Game.Scenarios
|
|||||||
return _stepStates[step];
|
return _stepStates[step];
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void SendCriteriaUpdate(Criteria criteria, CriteriaProgress progress, uint timeElapsed, bool timedCompleted)
|
public override void SendCriteriaUpdate(Criteria criteria, CriteriaProgress progress, TimeSpan timeElapsed, bool timedCompleted)
|
||||||
{
|
{
|
||||||
ScenarioProgressUpdate progressUpdate = new();
|
ScenarioProgressUpdate progressUpdate = new();
|
||||||
progressUpdate.CriteriaProgress.Id = criteria.Id;
|
progressUpdate.CriteriaProgress.Id = criteria.Id;
|
||||||
@@ -163,7 +164,7 @@ namespace Game.Scenarios
|
|||||||
if (criteria.Entry.StartTimer != 0)
|
if (criteria.Entry.StartTimer != 0)
|
||||||
progressUpdate.CriteriaProgress.Flags = timedCompleted ? 1 : 0u;
|
progressUpdate.CriteriaProgress.Flags = timedCompleted ? 1 : 0u;
|
||||||
|
|
||||||
progressUpdate.CriteriaProgress.TimeFromStart = timeElapsed;
|
progressUpdate.CriteriaProgress.TimeFromStart = (uint)timeElapsed.TotalSeconds;
|
||||||
progressUpdate.CriteriaProgress.TimeFromCreate = 0;
|
progressUpdate.CriteriaProgress.TimeFromCreate = 0;
|
||||||
|
|
||||||
SendPacket(progressUpdate);
|
SendPacket(progressUpdate);
|
||||||
|
|||||||
Reference in New Issue
Block a user