fix(Core/Achivement): Implement ACHIEVEMENT_FLAG_AVERAGE (#17263)

This commit is contained in:
Ludwig
2023-09-21 18:56:28 +02:00
committed by GitHub
parent 168192b731
commit f633eb8592
6 changed files with 38 additions and 5 deletions

View File

@@ -384,6 +384,8 @@ Player::Player(WorldSession* session): Unit(true), m_mover(this)
_activeCheats = CHEAT_NONE;
m_creationTime = 0s;
_cinematicMgr = new CinematicMgr(this);
m_achievementMgr = new AchievementMgr(this);

View File

@@ -2495,6 +2495,9 @@ public:
void CompletedAchievement(AchievementEntry const* entry);
[[nodiscard]] AchievementMgr* GetAchievementMgr() const { return m_achievementMgr; }
void SetCreationTime(Seconds creationTime) { m_creationTime = creationTime; }
[[nodiscard]] Seconds GetCreationTime() const { return m_creationTime; }
[[nodiscard]] bool HasTitle(uint32 bitIndex) const;
bool HasTitle(CharTitlesEntry const* title) const { return HasTitle(title->bit_index); }
void SetTitle(CharTitlesEntry const* title, bool lost = false);
@@ -2949,6 +2952,8 @@ private:
bool _wasOutdoor;
PlayerSettingMap m_charSettingsMap;
Seconds m_creationTime;
};
void AddItemsSetItem(Player* player, Item* item);

View File

@@ -4948,8 +4948,8 @@ bool Player::LoadFromDB(ObjectGuid playerGuid, CharacterDatabaseQueryHolder cons
//"arenaPoints, totalHonorPoints, todayHonorPoints, yesterdayHonorPoints, totalKills, todayKills, yesterdayKills, chosenTitle, knownCurrencies, watchedFaction, drunk, "
// 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
//"health, power1, power2, power3, power4, power5, power6, power7, instance_id, talentGroupsCount, activeTalentGroup, exploredZones, equipmentCache, ammoId, knownTitles,
// 70 71 72 73
//"actionBars, grantableLevels, innTriggerId, extraBonusTalentCount FROM characters WHERE guid = '{}'", guid);
// 70 71 72 73 74
//"actionBars, grantableLevels, innTriggerId, extraBonusTalentCount, UNIX_TIMESTAMP(creation_date) FROM characters WHERE guid = '{}'", guid);
PreparedQueryResult result = holder.GetPreparedResult(PLAYER_LOGIN_QUERY_LOAD_FROM);
if (!result)
@@ -5026,6 +5026,9 @@ bool Player::LoadFromDB(ObjectGuid playerGuid, CharacterDatabaseQueryHolder cons
SetObjectScale(1.0f);
SetFloatValue(UNIT_FIELD_HOVERHEIGHT, 1.0f);
// load character creation date, relevant for achievements of type average
SetCreationTime(fields[74].Get<Seconds>());
// load achievements before anything else to prevent multiple gains for the same achievement/criteria on every loading (as loading does call UpdateAchievementCriteria)
m_achievementMgr->LoadFromDB(holder.GetPreparedResult(PLAYER_LOGIN_QUERY_LOAD_ACHIEVEMENTS), holder.GetPreparedResult(PLAYER_LOGIN_QUERY_LOAD_CRITERIA_PROGRESS));