Core/Achievements: Minor fixes
Port From (https://github.com/TrinityCore/TrinityCore/commit/3e833739071a689dc34e33f7a511d8cc50e00b94)
This commit is contained in:
@@ -296,6 +296,7 @@ namespace Game.Achievements
|
|||||||
CriteriaProgress progress = new CriteriaProgress();
|
CriteriaProgress progress = new CriteriaProgress();
|
||||||
progress.Counter = counter;
|
progress.Counter = counter;
|
||||||
progress.Date = date;
|
progress.Date = date;
|
||||||
|
progress.PlayerGUID = _owner.GetGUID();
|
||||||
progress.Changed = false;
|
progress.Changed = false;
|
||||||
|
|
||||||
_criteriaProgress[id] = progress;
|
_criteriaProgress[id] = progress;
|
||||||
@@ -391,6 +392,7 @@ namespace Game.Achievements
|
|||||||
|
|
||||||
public override void SendAllData(Player receiver)
|
public override void SendAllData(Player receiver)
|
||||||
{
|
{
|
||||||
|
AllAccountCriteria allAccountCriteria = new AllAccountCriteria();
|
||||||
AllAchievementData achievementData = new AllAchievementData();
|
AllAchievementData achievementData = new AllAchievementData();
|
||||||
|
|
||||||
foreach (var pair in _completedAchievements)
|
foreach (var pair in _completedAchievements)
|
||||||
@@ -412,6 +414,8 @@ namespace Game.Achievements
|
|||||||
|
|
||||||
foreach (var pair in _criteriaProgress)
|
foreach (var pair in _criteriaProgress)
|
||||||
{
|
{
|
||||||
|
Criteria criteria = Global.CriteriaMgr.GetCriteria(pair.Key);
|
||||||
|
|
||||||
CriteriaProgressPkt progress = new CriteriaProgressPkt();
|
CriteriaProgressPkt progress = new CriteriaProgressPkt();
|
||||||
progress.Id = pair.Key;
|
progress.Id = pair.Key;
|
||||||
progress.Quantity = pair.Value.Counter;
|
progress.Quantity = pair.Value.Counter;
|
||||||
@@ -421,7 +425,23 @@ namespace Game.Achievements
|
|||||||
progress.TimeFromStart = 0;
|
progress.TimeFromStart = 0;
|
||||||
progress.TimeFromCreate = 0;
|
progress.TimeFromCreate = 0;
|
||||||
achievementData.Data.Progress.Add(progress);
|
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);
|
SendPacket(achievementData);
|
||||||
}
|
}
|
||||||
@@ -575,6 +595,23 @@ namespace Game.Achievements
|
|||||||
}
|
}
|
||||||
|
|
||||||
public override void SendCriteriaUpdate(Criteria criteria, CriteriaProgress progress, uint timeElapsed, bool timedCompleted)
|
public override void SendCriteriaUpdate(Criteria criteria, CriteriaProgress progress, uint timeElapsed, bool timedCompleted)
|
||||||
|
{
|
||||||
|
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.Progress.Date = progress.Date;
|
||||||
|
criteriaUpdate.Progress.TimeFromStart = timeElapsed;
|
||||||
|
criteriaUpdate.Progress.TimeFromCreate = 0;
|
||||||
|
SendPacket(criteriaUpdate);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
CriteriaUpdate criteriaUpdate = new CriteriaUpdate();
|
CriteriaUpdate criteriaUpdate = new CriteriaUpdate();
|
||||||
|
|
||||||
@@ -591,6 +628,7 @@ namespace Game.Achievements
|
|||||||
|
|
||||||
SendPacket(criteriaUpdate);
|
SendPacket(criteriaUpdate);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public override void SendCriteriaProgressRemoved(uint criteriaId)
|
public override void SendCriteriaProgressRemoved(uint criteriaId)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1596,6 +1596,7 @@ namespace Game.Achievements
|
|||||||
return false;
|
return false;
|
||||||
break;
|
break;
|
||||||
case CriteriaAdditionalCondition.HasAchievement: // 86
|
case CriteriaAdditionalCondition.HasAchievement: // 86
|
||||||
|
case CriteriaAdditionalCondition.HasAchievementOnCharacter: // 87
|
||||||
if (!referencePlayer.HasAchieved(reqValue))
|
if (!referencePlayer.HasAchieved(reqValue))
|
||||||
return false;
|
return false;
|
||||||
break;
|
break;
|
||||||
@@ -2498,12 +2499,9 @@ namespace Game.Achievements
|
|||||||
// Build tree
|
// Build tree
|
||||||
foreach (var treeNode in _criteriaModifiers.Values)
|
foreach (var treeNode in _criteriaModifiers.Values)
|
||||||
{
|
{
|
||||||
if (treeNode.Entry.Parent == 0)
|
ModifierTreeNode parentNode = _criteriaModifiers.LookupByKey(treeNode.Entry.Parent);
|
||||||
continue;
|
if (parentNode != null)
|
||||||
|
parentNode.Children.Add(treeNode);
|
||||||
var parent = _criteriaModifiers.LookupByKey(treeNode.Entry.Parent);
|
|
||||||
if (parent != null)
|
|
||||||
parent.Children.Add(treeNode);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.outInfo(LogFilter.ServerLoading, "Loaded {0} criteria modifiers in {1} ms", _criteriaModifiers.Count, Time.GetMSTimeDiffToNow(oldMSTime));
|
Log.outInfo(LogFilter.ServerLoading, "Loaded {0} criteria modifiers in {1} ms", _criteriaModifiers.Count, Time.GetMSTimeDiffToNow(oldMSTime));
|
||||||
@@ -2535,12 +2533,6 @@ namespace Game.Achievements
|
|||||||
{
|
{
|
||||||
uint oldMSTime = Time.GetMSTime();
|
uint oldMSTime = Time.GetMSTime();
|
||||||
|
|
||||||
if (CliDB.CriteriaTreeStorage.Empty())
|
|
||||||
{
|
|
||||||
Log.outError(LogFilter.ServerLoading, "Loaded 0 criteria.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Dictionary<uint /*criteriaTreeID*/, AchievementRecord> achievementCriteriaTreeIds = new Dictionary<uint, AchievementRecord>();
|
Dictionary<uint /*criteriaTreeID*/, AchievementRecord> achievementCriteriaTreeIds = new Dictionary<uint, AchievementRecord>();
|
||||||
foreach (AchievementRecord achievement in CliDB.AchievementStorage.Values)
|
foreach (AchievementRecord achievement in CliDB.AchievementStorage.Values)
|
||||||
if (achievement.CriteriaTree != 0)
|
if (achievement.CriteriaTree != 0)
|
||||||
@@ -2589,25 +2581,11 @@ namespace Game.Achievements
|
|||||||
// Build tree
|
// Build tree
|
||||||
foreach (var pair in _criteriaTrees)
|
foreach (var pair in _criteriaTrees)
|
||||||
{
|
{
|
||||||
if (pair.Value.Entry.Parent == 0)
|
CriteriaTree parent = _criteriaTrees.LookupByKey(pair.Value.Entry.Parent);
|
||||||
continue;
|
|
||||||
|
|
||||||
var parent = _criteriaTrees.LookupByKey(pair.Value.Entry.Parent);
|
|
||||||
if (parent != null)
|
if (parent != null)
|
||||||
{
|
|
||||||
parent.Children.Add(pair.Value);
|
parent.Children.Add(pair.Value);
|
||||||
while (parent != null)
|
|
||||||
{
|
if (CliDB.CriteriaStorage.HasRecord(pair.Value.Entry.CriteriaID))
|
||||||
var cur = parent;
|
|
||||||
parent = _criteriaTrees.LookupByKey(parent.Entry.Parent);
|
|
||||||
if (parent == null)
|
|
||||||
{
|
|
||||||
if (CliDB.CriteriaStorage.ContainsKey(pair.Value.Entry.CriteriaID))
|
|
||||||
_criteriaTreeByCriteria.Add(pair.Value.Entry.CriteriaID, cur);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (CliDB.CriteriaStorage.ContainsKey(pair.Value.Entry.CriteriaID))
|
|
||||||
_criteriaTreeByCriteria.Add(pair.Value.Entry.CriteriaID, pair.Value);
|
_criteriaTreeByCriteria.Add(pair.Value.Entry.CriteriaID, pair.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2633,14 +2611,14 @@ namespace Game.Achievements
|
|||||||
Criteria criteria = new Criteria();
|
Criteria criteria = new Criteria();
|
||||||
criteria.Id = criteriaEntry.Id;
|
criteria.Id = criteriaEntry.Id;
|
||||||
criteria.Entry = criteriaEntry;
|
criteria.Entry = criteriaEntry;
|
||||||
var mod = _criteriaModifiers.LookupByKey(criteriaEntry.ModifierTreeId);
|
criteria.Modifier = _criteriaModifiers.LookupByKey(criteriaEntry.ModifierTreeId);
|
||||||
if (mod != null)
|
|
||||||
criteria.Modifier = mod;
|
|
||||||
|
|
||||||
_criteria[criteria.Id] = criteria;
|
_criteria[criteria.Id] = criteria;
|
||||||
|
|
||||||
foreach (CriteriaTree tree in treeList)
|
foreach (CriteriaTree tree in treeList)
|
||||||
{
|
{
|
||||||
|
tree.Criteria = criteria;
|
||||||
|
|
||||||
AchievementRecord achievement = tree.Achievement;
|
AchievementRecord achievement = tree.Achievement;
|
||||||
if (achievement != null)
|
if (achievement != null)
|
||||||
{
|
{
|
||||||
@@ -2688,9 +2666,6 @@ namespace Game.Achievements
|
|||||||
_criteriasByFailEvent[criteriaEntry.FailEvent].Add((int)criteriaEntry.FailAsset, criteria);
|
_criteriasByFailEvent[criteriaEntry.FailEvent].Add((int)criteriaEntry.FailAsset, criteria);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var p in _criteriaTrees)
|
|
||||||
p.Value.Criteria = GetCriteria(p.Value.Entry.CriteriaID);
|
|
||||||
|
|
||||||
Log.outInfo(LogFilter.ServerLoading, $"Loaded {criterias} criteria, {guildCriterias} guild criteria, {scenarioCriterias} scenario criteria and {questObjectiveCriterias} quest objective criteria in {Time.GetMSTimeDiffToNow(oldMSTime)} ms.");
|
Log.outInfo(LogFilter.ServerLoading, $"Loaded {criterias} criteria, {guildCriterias} guild criteria, {scenarioCriterias} scenario criteria and {questObjectiveCriterias} quest objective criteria in {Time.GetMSTimeDiffToNow(oldMSTime)} ms.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -35,6 +35,20 @@ namespace Game.Network.Packets
|
|||||||
public AllAchievements Data = new AllAchievements();
|
public AllAchievements Data = new AllAchievements();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class AllAccountCriteria : ServerPacket
|
||||||
|
{
|
||||||
|
public AllAccountCriteria() : base(ServerOpcodes.AllAccountCriteria, ConnectionType.Instance) { }
|
||||||
|
|
||||||
|
public override void Write()
|
||||||
|
{
|
||||||
|
_worldPacket.WriteInt32(Progress.Count);
|
||||||
|
foreach (var progress in Progress)
|
||||||
|
progress.Write(_worldPacket);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<CriteriaProgressPkt> Progress = new List<CriteriaProgressPkt>();
|
||||||
|
}
|
||||||
|
|
||||||
public class RespondInspectAchievements : ServerPacket
|
public class RespondInspectAchievements : ServerPacket
|
||||||
{
|
{
|
||||||
public RespondInspectAchievements() : base(ServerOpcodes.RespondInspectAchievements, ConnectionType.Instance) { }
|
public RespondInspectAchievements() : base(ServerOpcodes.RespondInspectAchievements, ConnectionType.Instance) { }
|
||||||
@@ -62,6 +76,11 @@ namespace Game.Network.Packets
|
|||||||
_worldPacket.WritePackedTime(CurrentTime);
|
_worldPacket.WritePackedTime(CurrentTime);
|
||||||
_worldPacket.WriteUInt32(ElapsedTime);
|
_worldPacket.WriteUInt32(ElapsedTime);
|
||||||
_worldPacket.WriteUInt32(CreationTime);
|
_worldPacket.WriteUInt32(CreationTime);
|
||||||
|
_worldPacket.WriteBit(RafAcceptanceID.HasValue);
|
||||||
|
_worldPacket.FlushBits();
|
||||||
|
|
||||||
|
if (RafAcceptanceID.HasValue)
|
||||||
|
_worldPacket.WriteUInt64(RafAcceptanceID.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public uint CriteriaID;
|
public uint CriteriaID;
|
||||||
@@ -71,6 +90,19 @@ namespace Game.Network.Packets
|
|||||||
public long CurrentTime;
|
public long CurrentTime;
|
||||||
public uint ElapsedTime;
|
public uint ElapsedTime;
|
||||||
public uint CreationTime;
|
public uint CreationTime;
|
||||||
|
public Optional<ulong> RafAcceptanceID;
|
||||||
|
}
|
||||||
|
|
||||||
|
class AccountCriteriaUpdate : ServerPacket
|
||||||
|
{
|
||||||
|
public AccountCriteriaUpdate() : base(ServerOpcodes.AccountCriteriaUpdate) { }
|
||||||
|
|
||||||
|
public override void Write()
|
||||||
|
{
|
||||||
|
Progress.Write(_worldPacket);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CriteriaProgressPkt Progress;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class CriteriaDeleted : ServerPacket
|
public class CriteriaDeleted : ServerPacket
|
||||||
|
|||||||
Reference in New Issue
Block a user