AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
AchievementMgr Class Reference

#include "AchievementMgr.h"

Public Member Functions

 AchievementMgr (Player *player)
 
 ~AchievementMgr ()
 
void Reset ()
 
void LoadFromDB (PreparedQueryResult achievementResult, PreparedQueryResult criteriaResult, PreparedQueryResult offlineUpdatesResult)
 
void SaveToDB (CharacterDatabaseTransaction trans)
 
void ResetAchievementCriteria (AchievementCriteriaCondition condition, uint32 value, bool evenIfCriteriaComplete=false)
 
void UpdateAchievementCriteria (AchievementCriteriaTypes type, uint32 miscValue1=0, uint32 miscValue2=0, Unit *unit=nullptr)
 
void CompletedAchievement (AchievementEntry const *entry)
 
void CheckAllAchievementCriteria ()
 
void SendAllAchievementData () const
 
void SendRespondInspectAchievements (Player *player) const
 
bool HasAchieved (uint32 achievementId) const
 
PlayerGetPlayer () const
 
void Update (uint32 timeDiff)
 
void StartTimedAchievement (AchievementCriteriaTimedTypes type, uint32 entry, uint32 timeLost=0)
 
void RemoveTimedAchievement (AchievementCriteriaTimedTypes type, uint32 entry)
 
void RemoveCriteriaProgress (AchievementCriteriaEntry const *entry)
 
CriteriaProgressGetCriteriaProgress (AchievementCriteriaEntry const *entry)
 
CompletedAchievementMap const & GetCompletedAchievements ()
 

Static Public Member Functions

static void DeleteFromDB (ObjectGuid::LowType lowguid)
 

Private Types

enum  ProgressType {
  PROGRESS_SET ,
  PROGRESS_ACCUMULATE ,
  PROGRESS_HIGHEST ,
  PROGRESS_RESET
}
 
typedef std::map< uint32, uint32TimedAchievementMap
 

Private Member Functions

void SendAchievementEarned (AchievementEntry const *achievement) const
 
void SendCriteriaUpdate (AchievementCriteriaEntry const *entry, CriteriaProgress const *progress, uint32 timeElapsed, bool timedCompleted) const
 
void SetCriteriaProgress (AchievementCriteriaEntry const *entry, uint32 changeValue, ProgressType ptype=PROGRESS_SET)
 
void CompletedCriteriaFor (AchievementEntry const *achievement)
 
bool IsCompletedCriteria (AchievementCriteriaEntry const *achievementCriteria, AchievementEntry const *achievement)
 
bool IsCompletedAchievement (AchievementEntry const *entry)
 
bool CanUpdateCriteria (AchievementCriteriaEntry const *criteria, AchievementEntry const *achievement)
 
void BuildAllDataPacket (WorldPacket *data) const
 
void UpdateTimedAchievements (uint32 timeDiff)
 
void ProcessOfflineUpdate (AchievementOfflinePlayerUpdate const &update)
 
void ProcessOfflineUpdatesQueue ()
 

Private Attributes

Player_player
 
CriteriaProgressMap _criteriaProgress
 
CompletedAchievementMap _completedAchievements
 
TimedAchievementMap _timedAchievements
 
uint32 _offlineUpdatesDelayTimer
 
std::vector< AchievementOfflinePlayerUpdate_offlineUpdatesQueue
 

Detailed Description

Member Typedef Documentation

◆ TimedAchievementMap

Member Enumeration Documentation

◆ ProgressType

Enumerator
PROGRESS_SET 
PROGRESS_ACCUMULATE 
PROGRESS_HIGHEST 
PROGRESS_RESET 
@ PROGRESS_SET
Definition: AchievementMgr.h:321
@ PROGRESS_HIGHEST
Definition: AchievementMgr.h:321
@ PROGRESS_ACCUMULATE
Definition: AchievementMgr.h:321
@ PROGRESS_RESET
Definition: AchievementMgr.h:321

Constructor & Destructor Documentation

◆ AchievementMgr()

AchievementMgr::AchievementMgr ( Player player)
482{
483 _player = player;
485}
Player * _player
Definition: AchievementMgr.h:337
uint32 _offlineUpdatesDelayTimer
Definition: AchievementMgr.h:346

References _offlineUpdatesDelayTimer, and _player.

◆ ~AchievementMgr()

AchievementMgr::~AchievementMgr ( )
488{
489}

Member Function Documentation

◆ BuildAllDataPacket()

void AchievementMgr::BuildAllDataPacket ( WorldPacket data) const
private

used by SMSG_RESPOND_INSPECT_ACHIEVEMENT and SMSG_ALL_ACHIEVEMENT_DATA

Todo:
: This should be 1 if it is a failed timed criteria
2401{
2402 for (CompletedAchievementMap::const_iterator iter = _completedAchievements.begin(); iter != _completedAchievements.end(); ++iter)
2403 {
2404 // Skip hidden achievements
2405 AchievementEntry const* achievement = sAchievementStore.LookupEntry(iter->first);
2406 if (!achievement || achievement->flags & ACHIEVEMENT_FLAG_HIDDEN)
2407 continue;
2408
2409 *data << uint32(iter->first);
2410 data->AppendPackedTime(iter->second.date);
2411 }
2412
2413 *data << int32(-1);
2414 time_t now = GameTime::GetGameTime().count();
2415
2416 for (CriteriaProgressMap::const_iterator iter = _criteriaProgress.begin(); iter != _criteriaProgress.end(); ++iter)
2417 {
2418 *data << uint32(iter->first);
2419 data->appendPackGUID(iter->second.counter);
2420 *data << GetPlayer()->GetPackGUID();
2421 *data << uint32(0);
2422 data->AppendPackedTime(iter->second.date);
2423 *data << uint32(now - iter->second.date);
2424
2425 if (sAchievementMgr->IsAverageCriteria(sAchievementCriteriaStore.LookupEntry(iter->first)))
2426 *data << uint32(now - GetPlayer()->GetCreationTime().count()); // for average achievements
2427 else
2428 *data << uint32(now - iter->second.date);
2429 }
2430
2431 *data << int32(-1);
2432}
std::int32_t int32
Definition: Define.h:103
std::uint32_t uint32
Definition: Define.h:107
DBCStorage< AchievementCriteriaEntry > sAchievementCriteriaStore(AchievementCriteriafmt)
DBCStorage< AchievementEntry > sAchievementStore(Achievementfmt)
#define sAchievementMgr
Definition: AchievementMgr.h:452
@ ACHIEVEMENT_FLAG_HIDDEN
Definition: DBCEnums.h:72
Seconds GetGameTime()
Definition: GameTime.cpp:38
Player * GetPlayer() const
Definition: AchievementMgr.h:310
CompletedAchievementMap _completedAchievements
Definition: AchievementMgr.h:339
CriteriaProgressMap _criteriaProgress
Definition: AchievementMgr.h:338
PackedGuid const & GetPackGUID() const
Definition: Object.h:111
Definition: DBCStructure.h:40
uint32 flags
Definition: DBCStructure.h:52
void appendPackGUID(uint64 guid)
Definition: ByteBuffer.h:503
void AppendPackedTime(time_t time)
Definition: ByteBuffer.cpp:137

References _completedAchievements, _criteriaProgress, ACHIEVEMENT_FLAG_HIDDEN, ByteBuffer::AppendPackedTime(), ByteBuffer::appendPackGUID(), AchievementEntry::flags, GameTime::GetGameTime(), Object::GetPackGUID(), GetPlayer(), sAchievementCriteriaStore, sAchievementMgr, and sAchievementStore.

Referenced by SendAllAchievementData(), and SendRespondInspectAchievements().

◆ CanUpdateCriteria()

bool AchievementMgr::CanUpdateCriteria ( AchievementCriteriaEntry const *  criteria,
AchievementEntry const *  achievement 
)
private
2440{
2442 return false;
2443
2444 if (achievement->mapID != -1 && GetPlayer()->GetMapId() != uint32(achievement->mapID))
2445 return false;
2446
2447 if ((achievement->requiredFaction == ACHIEVEMENT_FACTION_HORDE && GetPlayer()->GetTeamId(true) != TEAM_HORDE) ||
2448 (achievement->requiredFaction == ACHIEVEMENT_FACTION_ALLIANCE && GetPlayer()->GetTeamId(true) != TEAM_ALLIANCE))
2449 return false;
2450
2451 for (uint32 i = 0; i < MAX_CRITERIA_REQUIREMENTS; ++i)
2452 {
2453 if (!criteria->additionalRequirements[i].additionalRequirement_type)
2454 continue;
2455
2456 switch (criteria->additionalRequirements[i].additionalRequirement_type)
2457 {
2459 if (GetPlayer()->GetMapId() != criteria->additionalRequirements[i].additionalRequirement_value)
2460 return false;
2461 break;
2463 if (GetPlayer()->GetGroup())
2464 return false;
2465 break;
2466 default:
2467 break;
2468 }
2469 }
2470
2471 // don't update already completed criteria
2472 if (IsCompletedCriteria(criteria, achievement))
2473 return false;
2474
2475 return true;
2476}
@ DISABLE_TYPE_ACHIEVEMENT_CRITERIA
Definition: DisableMgr.h:33
TeamId GetTeamId(PvPTeamId teamId)
Definition: SharedDefines.h:3462
@ TEAM_ALLIANCE
Definition: SharedDefines.h:760
@ TEAM_HORDE
Definition: SharedDefines.h:761
@ ACHIEVEMENT_FACTION_HORDE
Definition: DBCEnums.h:64
@ ACHIEVEMENT_FACTION_ALLIANCE
Definition: DBCEnums.h:65
@ ACHIEVEMENT_CRITERIA_CONDITION_NOT_IN_GROUP
Definition: DBCEnums.h:93
@ ACHIEVEMENT_CRITERIA_CONDITION_BG_MAP
Definition: DBCEnums.h:90
#define MAX_CRITERIA_REQUIREMENTS
Definition: DBCEnums.h:83
bool IsDisabledFor(DisableType type, uint32 entry, Unit const *unit, uint8 flags)
Definition: DisableMgr.cpp:306
bool IsCompletedCriteria(AchievementCriteriaEntry const *achievementCriteria, AchievementEntry const *achievement)
Definition: AchievementMgr.cpp:1823

References ACHIEVEMENT_CRITERIA_CONDITION_BG_MAP, ACHIEVEMENT_CRITERIA_CONDITION_NOT_IN_GROUP, ACHIEVEMENT_FACTION_ALLIANCE, ACHIEVEMENT_FACTION_HORDE, AchievementCriteriaEntry::additionalRequirement_type, AchievementCriteriaEntry::additionalRequirement_value, AchievementCriteriaEntry::additionalRequirements, DISABLE_TYPE_ACHIEVEMENT_CRITERIA, GetPlayer(), GetTeamId(), AchievementCriteriaEntry::ID, IsCompletedCriteria(), DisableMgr::IsDisabledFor(), AchievementEntry::mapID, MAX_CRITERIA_REQUIREMENTS, AchievementEntry::requiredFaction, TEAM_ALLIANCE, and TEAM_HORDE.

Referenced by UpdateAchievementCriteria().

◆ CheckAllAchievementCriteria()

void AchievementMgr::CheckAllAchievementCriteria ( )

called at player login. The player might have fulfilled some achievements when the achievement system wasn't working yet.

801{
802 // suppress sending packets
803 for (uint32 i = 0; i < ACHIEVEMENT_CRITERIA_TYPE_TOTAL; ++i)
805}
AchievementCriteriaTypes
Definition: DBCEnums.h:121
@ ACHIEVEMENT_CRITERIA_TYPE_TOTAL
Definition: DBCEnums.h:224
void UpdateAchievementCriteria(AchievementCriteriaTypes type, uint32 miscValue1=0, uint32 miscValue2=0, Unit *unit=nullptr)
Definition: AchievementMgr.cpp:822

References ACHIEVEMENT_CRITERIA_TYPE_TOTAL, and UpdateAchievementCriteria().

Referenced by Player::CheckAllAchievementCriteria(), and Reset().

◆ CompletedAchievement()

void AchievementMgr::CompletedAchievement ( AchievementEntry const *  entry)

Currently there's only one achievement that deals with gender-specific titles. Since no common attributes were found, (not even in titleRewardFlags field) we explicitly check by ID. Maybe in the future we could move the achievement_reward condition fields to the condition system.

2271{
2272 // disable for gamemasters with GM-mode enabled
2273 if (_player->IsGameMaster())
2274 {
2275 LOG_INFO("achievement", "Not available in GM mode.");
2276 ChatHandler(_player->GetSession()).PSendSysMessage("Not available in GM mode");
2277 return;
2278 }
2279
2280 if (!sScriptMgr->OnBeforeAchievementComplete(GetPlayer(), achievement))
2281 {
2282 return;
2283 }
2284
2285 if (achievement->flags & ACHIEVEMENT_FLAG_COUNTER || HasAchieved(achievement->ID))
2286 return;
2287
2288 LOG_DEBUG("achievement", "AchievementMgr::CompletedAchievement({})", achievement->ID);
2289
2290 SendAchievementEarned(achievement);
2291 CompletedAchievementData& ca = _completedAchievements[achievement->ID];
2292 ca.date = GameTime::GetGameTime().count();
2293 ca.changed = true;
2294
2295 sScriptMgr->OnAchievementComplete(GetPlayer(), achievement);
2296
2297 // pussywizard: set all progress counters to 0, so progress will be deleted from db during save
2298 {
2299 bool allRefsCompleted = true;
2300 uint32 achiCheckId = achievement->refAchievement ? achievement->refAchievement : achievement->ID;
2301
2302 if (AchievementEntryList const* achRefList = sAchievementMgr->GetAchievementByReferencedId(achiCheckId))
2303 for (AchievementEntryList::const_iterator itr = achRefList->begin(); itr != achRefList->end(); ++itr)
2304 if (!IsCompletedAchievement(*itr))
2305 {
2306 allRefsCompleted = false;
2307 break;
2308 }
2309
2310 if (allRefsCompleted)
2311 if (AchievementCriteriaEntryList const* cList = sAchievementMgr->GetAchievementCriteriaByAchievement(achiCheckId))
2312 for (AchievementCriteriaEntryList::const_iterator itr = cList->begin(); itr != cList->end(); ++itr)
2313 if (CriteriaProgress* progress = GetCriteriaProgress(*itr))
2314 {
2315 progress->changed = true;
2316 progress->counter = 0;
2317 }
2318 }
2319
2321 sAchievementMgr->SetRealmCompleted(achievement);
2322
2325
2326 // reward items and titles if any
2327 AchievementReward const* reward = sAchievementMgr->GetAchievementReward(achievement);
2328
2329 // no rewards
2330 if (!reward)
2331 return;
2332
2333 // titles
2338 if (uint32 titleId = reward->titleId[achievement->ID == 1793 ? GetPlayer()->getGender() : uint8(GetPlayer()->GetTeamId())])
2339 if (CharTitlesEntry const* titleEntry = sCharTitlesStore.LookupEntry(titleId))
2340 GetPlayer()->SetTitle(titleEntry);
2341
2342 // mail
2343 if (reward->sender)
2344 {
2345 MailDraft draft(reward->mailTemplate);
2346
2347 if (!reward->mailTemplate)
2348 {
2349 std::string subject = reward->subject;
2350 std::string text = reward->text;
2351
2353 if (localeConstant != LOCALE_enUS)
2354 {
2355 if (AchievementRewardLocale const* loc = sAchievementMgr->GetAchievementRewardLocale(achievement))
2356 {
2357 ObjectMgr::GetLocaleString(loc->Subject, localeConstant, subject);
2358 ObjectMgr::GetLocaleString(loc->Text, localeConstant, text);
2359 }
2360 }
2361
2362 draft = MailDraft(subject, text);
2363 }
2364
2365 CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
2366
2367 Item* item = reward->itemId ? Item::CreateItem(reward->itemId, 1, GetPlayer()) : nullptr;
2368 if (item)
2369 {
2370 // save new item before send
2371 item->SaveToDB(trans); // save for prevent lost at next mail load, if send fail then item will deleted
2372
2373 // item
2374 draft.AddItem(item);
2375 }
2376
2377 draft.SendMailTo(trans, GetPlayer(), MailSender(MAIL_CREATURE, reward->sender));
2378 CharacterDatabase.CommitTransaction(trans);
2379 }
2380}
LocaleConstant
Definition: Common.h:65
@ LOCALE_enUS
Definition: Common.h:66
#define LOG_INFO(filterType__,...)
Definition: Log.h:164
#define LOG_DEBUG(filterType__,...)
Definition: Log.h:168
std::uint8_t uint8
Definition: Define.h:109
#define sScriptMgr
Definition: ScriptMgr.h:708
DBCStorage< CharTitlesEntry > sCharTitlesStore(CharTitlesEntryfmt)
std::list< AchievementCriteriaEntry const * > AchievementCriteriaEntryList
Definition: AchievementMgr.h:30
std::list< AchievementEntry const * > AchievementEntryList
Definition: AchievementMgr.h:31
@ MAIL_CREATURE
Definition: Mail.h:40
SQLTransaction< CharacterDatabaseConnection > CharacterDatabaseTransaction
Definition: DatabaseEnvFwd.h:70
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
@ ACHIEVEMENT_FLAG_COUNTER
Definition: DBCEnums.h:71
@ ACHIEVEMENT_FLAG_REALM_FIRST_REACH
Definition: DBCEnums.h:79
@ ACHIEVEMENT_FLAG_REALM_FIRST_KILL
Definition: DBCEnums.h:80
@ ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_ACHIEVEMENT
Definition: DBCEnums.h:126
@ ACHIEVEMENT_CRITERIA_TYPE_EARN_ACHIEVEMENT_POINTS
Definition: DBCEnums.h:221
bool IsPlayerAccount(uint32 gmlevel)
Definition: AccountMgr.cpp:305
Definition: AchievementMgr.h:51
Definition: AchievementMgr.h:261
std::string subject
Definition: AchievementMgr.h:265
std::string text
Definition: AchievementMgr.h:266
uint32 titleId[2]
Definition: AchievementMgr.h:262
uint32 sender
Definition: AchievementMgr.h:264
uint32 mailTemplate
Definition: AchievementMgr.h:267
uint32 itemId
Definition: AchievementMgr.h:263
Definition: AchievementMgr.h:273
Definition: AchievementMgr.h:281
time_t date
Definition: AchievementMgr.h:282
bool changed
Definition: AchievementMgr.h:283
CriteriaProgress * GetCriteriaProgress(AchievementCriteriaEntry const *entry)
Definition: AchievementMgr.cpp:2089
bool HasAchieved(uint32 achievementId) const
Definition: AchievementMgr.cpp:2434
bool IsCompletedAchievement(AchievementEntry const *entry)
Definition: AchievementMgr.cpp:2027
void SendAchievementEarned(AchievementEntry const *achievement) const
Definition: AchievementMgr.cpp:701
Definition: Chat.h:39
void PSendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition: Chat.cpp:213
Definition: Item.h:220
static Item * CreateItem(uint32 item, uint32 count, Player const *player=nullptr, bool clone=false, uint32 randomPropertyId=0)
Definition: Item.cpp:1088
virtual void SaveToDB(CharacterDatabaseTransaction trans)
Definition: Item.cpp:337
WorldSession * GetSession() const
Definition: Player.h:1978
bool IsGameMaster() const
Definition: Player.h:1158
void SetTitle(CharTitlesEntry const *title, bool lost=false)
Definition: Player.cpp:13334
static std::string_view GetLocaleString(std::vector< std::string > const &data, std::size_t locale)
Definition: ObjectMgr.h:1405
Definition: Mail.h:84
Definition: Mail.h:120
AccountTypes GetSecurity() const
Definition: WorldSession.h:359
LocaleConstant GetSessionDbLocaleIndex() const
Definition: WorldSession.h:498
Definition: DBCStructure.h:632

References _completedAchievements, _player, ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_ACHIEVEMENT, ACHIEVEMENT_CRITERIA_TYPE_EARN_ACHIEVEMENT_POINTS, ACHIEVEMENT_FLAG_COUNTER, ACHIEVEMENT_FLAG_REALM_FIRST_KILL, ACHIEVEMENT_FLAG_REALM_FIRST_REACH, MailDraft::AddItem(), CompletedAchievementData::changed, CharacterDatabase, Item::CreateItem(), CompletedAchievementData::date, AchievementEntry::flags, GetCriteriaProgress(), GameTime::GetGameTime(), ObjectMgr::GetLocaleString(), GetPlayer(), WorldSession::GetSecurity(), Player::GetSession(), WorldSession::GetSessionDbLocaleIndex(), GetTeamId(), HasAchieved(), AchievementEntry::ID, IsCompletedAchievement(), Player::IsGameMaster(), AccountMgr::IsPlayerAccount(), AchievementReward::itemId, LOCALE_enUS, LOG_DEBUG, LOG_INFO, MAIL_CREATURE, AchievementReward::mailTemplate, AchievementEntry::points, ChatHandler::PSendSysMessage(), AchievementEntry::refAchievement, sAchievementMgr, Item::SaveToDB(), sCharTitlesStore, SendAchievementEarned(), AchievementReward::sender, MailDraft::SendMailTo(), Player::SetTitle(), sScriptMgr, AchievementReward::subject, AchievementReward::text, AchievementReward::titleId, and UpdateAchievementCriteria().

Referenced by Player::CompletedAchievement(), CompletedCriteriaFor(), ProcessOfflineUpdate(), and UpdateAchievementCriteria().

◆ CompletedCriteriaFor()

void AchievementMgr::CompletedCriteriaFor ( AchievementEntry const *  achievement)
private
2014{
2015 // counter can never complete
2016 if (achievement->flags & ACHIEVEMENT_FLAG_COUNTER)
2017 return;
2018
2019 // already completed and stored
2020 if (HasAchieved(achievement->ID))
2021 return;
2022
2023 if (IsCompletedAchievement(achievement))
2024 CompletedAchievement(achievement);
2025}
void CompletedAchievement(AchievementEntry const *entry)
Definition: AchievementMgr.cpp:2270

References ACHIEVEMENT_FLAG_COUNTER, CompletedAchievement(), AchievementEntry::flags, HasAchieved(), AchievementEntry::ID, and IsCompletedAchievement().

Referenced by UpdateAchievementCriteria().

◆ DeleteFromDB()

void AchievementMgr::DeleteFromDB ( ObjectGuid::LowType  lowguid)
static
543{
544 CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
545
547 stmt->SetData(0, lowguid);
548 trans->Append(stmt);
549
550 stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_ACHIEVEMENT_PROGRESS);
551 stmt->SetData(0, lowguid);
552 trans->Append(stmt);
553
555 stmt->SetData(0, lowguid);
556 trans->Append(stmt);
557
558 CharacterDatabase.CommitTransaction(trans);
559}
@ CHAR_DEL_CHAR_ACHIEVEMENT_OFFLINE_UPDATES
Definition: CharacterDatabase.h:370
@ CHAR_DEL_CHAR_ACHIEVEMENT_PROGRESS
Definition: CharacterDatabase.h:364
@ CHAR_DEL_CHAR_ACHIEVEMENT
Definition: CharacterDatabase.h:363
Definition: PreparedStatement.h:158
Acore::Types::is_default< T > SetData(const uint8 index, T value)
Definition: PreparedStatement.h:78

References CHAR_DEL_CHAR_ACHIEVEMENT, CHAR_DEL_CHAR_ACHIEVEMENT_OFFLINE_UPDATES, CHAR_DEL_CHAR_ACHIEVEMENT_PROGRESS, CharacterDatabase, and PreparedStatementBase::SetData().

Referenced by reset_commandscript::HandleResetAchievementsCommand(), and Reset().

◆ GetCompletedAchievements()

CompletedAchievementMap const & AchievementMgr::GetCompletedAchievements ( )
2479{
2481}

References _completedAchievements.

◆ GetCriteriaProgress()

CriteriaProgress * AchievementMgr::GetCriteriaProgress ( AchievementCriteriaEntry const *  entry)
2090{
2091 CriteriaProgressMap::iterator iter = _criteriaProgress.find(entry->ID);
2092
2093 if (iter == _criteriaProgress.end())
2094 return nullptr;
2095
2096 return &(iter->second);
2097}

References _criteriaProgress, and AchievementCriteriaEntry::ID.

Referenced by CompletedAchievement(), IsCompletedAchievement(), IsCompletedCriteria(), SetCriteriaProgress(), and UpdateAchievementCriteria().

◆ GetPlayer()

◆ HasAchieved()

bool AchievementMgr::HasAchieved ( uint32  achievementId) const

◆ IsCompletedAchievement()

bool AchievementMgr::IsCompletedAchievement ( AchievementEntry const *  entry)
private
2028{
2029 // counter can never complete
2030 if (entry->flags & ACHIEVEMENT_FLAG_COUNTER)
2031 return false;
2032
2033 // for achievement with referenced achievement criterias get from referenced and counter from self
2034 uint32 achievmentForTestId = entry->refAchievement ? entry->refAchievement : entry->ID;
2035 uint32 achievmentForTestCount = entry->count;
2036
2037 AchievementCriteriaEntryList const* cList = sAchievementMgr->GetAchievementCriteriaByAchievement(achievmentForTestId);
2038 if (!cList)
2039 return false;
2040 uint32 count = 0;
2041
2042 // For SUMM achievements, we have to count the progress of each criteria of the achievement.
2043 // Oddly, the target count is NOT countained in the achievement, but in each individual criteria
2044 if (entry->flags & ACHIEVEMENT_FLAG_SUMM)
2045 {
2046 for (AchievementCriteriaEntryList::const_iterator itr = cList->begin(); itr != cList->end(); ++itr)
2047 {
2048 AchievementCriteriaEntry const* criteria = *itr;
2049
2050 CriteriaProgress const* progress = GetCriteriaProgress(criteria);
2051 if (!progress)
2052 continue;
2053
2054 count += progress->counter;
2055
2056 // for counters, field4 contains the main count requirement
2057 if (count >= criteria->raw.count)
2058 return true;
2059 }
2060 return false;
2061 }
2062
2063 // Default case - need complete all or
2064 bool completed_all = true;
2065 for (AchievementCriteriaEntryList::const_iterator itr = cList->begin(); itr != cList->end(); ++itr)
2066 {
2067 AchievementCriteriaEntry const* criteria = *itr;
2068
2069 bool completed = IsCompletedCriteria(criteria, entry);
2070
2071 // found an uncompleted criteria, but DONT return false yet - there might be a completed criteria with ACHIEVEMENT_CRITERIA_COMPLETE_FLAG_ALL
2072 if (completed)
2073 ++count;
2074 else
2075 completed_all = false;
2076
2077 // completed as have req. count of completed criterias
2078 if (achievmentForTestCount > 0 && achievmentForTestCount <= count)
2079 return true;
2080 }
2081
2082 // all criterias completed requirement
2083 if (completed_all && achievmentForTestCount == 0)
2084 return true;
2085
2086 return false;
2087}
@ ACHIEVEMENT_FLAG_SUMM
Definition: DBCEnums.h:74
uint32 counter
Definition: AchievementMgr.h:52
Definition: DBCStructure.h:70
uint32 count
Definition: DBCStructure.h:223
struct AchievementCriteriaEntry::@307::@371 raw

References ACHIEVEMENT_FLAG_COUNTER, ACHIEVEMENT_FLAG_SUMM, AchievementEntry::count, AchievementCriteriaEntry::count, CriteriaProgress::counter, AchievementEntry::flags, GetCriteriaProgress(), AchievementEntry::ID, IsCompletedCriteria(), AchievementCriteriaEntry::raw, AchievementEntry::refAchievement, and sAchievementMgr.

Referenced by CompletedAchievement(), CompletedCriteriaFor(), IsCompletedCriteria(), and UpdateAchievementCriteria().

◆ IsCompletedCriteria()

bool AchievementMgr::IsCompletedCriteria ( AchievementCriteriaEntry const *  achievementCriteria,
AchievementEntry const *  achievement 
)
private
1824{
1825 // counter can never complete
1826 if (achievement->flags & ACHIEVEMENT_FLAG_COUNTER)
1827 return false;
1828
1830 {
1831 // someone on this realm has already completed that achievement
1832 if (sAchievementMgr->IsRealmCompleted(achievement))
1833 return false;
1834 }
1835
1836 // pussywizard: progress will be deleted after getting the achievement (optimization)
1837 // finished achievement should indicate criteria completed, since not finding progress would start some timed achievements and probably other things
1838 if (HasAchieved(achievement->ID))
1839 {
1840 bool completed = true;
1841
1842 // completed only after all referenced achievements are also completed
1843 if (AchievementEntryList const* achRefList = sAchievementMgr->GetAchievementByReferencedId(achievement->ID))
1844 for (AchievementEntryList::const_iterator itr = achRefList->begin(); itr != achRefList->end(); ++itr)
1845 if (!IsCompletedAchievement(*itr))
1846 {
1847 completed = false;
1848 break;
1849 }
1850
1851 if (completed)
1852 return true;
1853 }
1854
1855 CriteriaProgress const* progress = GetCriteriaProgress(achievementCriteria);
1856 if (!progress)
1857 return false;
1858
1859 if (!sScriptMgr->IsCompletedCriteria(this, achievementCriteria, achievement, progress))
1860 return false;
1861
1862 switch (achievementCriteria->requiredType)
1863 {
1865 return progress->counter >= achievementCriteria->win_bg.winCount;
1867 return progress->counter >= achievementCriteria->kill_creature.creatureCount;
1869 return progress->counter >= achievementCriteria->reach_level.level;
1871 return progress->counter >= achievementCriteria->reach_skill_level.skillLevel;
1873 return progress->counter >= 1;
1875 return progress->counter >= achievementCriteria->complete_quest_count.totalQuestCount;
1877 return progress->counter >= achievementCriteria->complete_daily_quest_daily.numberOfDays;
1879 return progress->counter >= achievementCriteria->complete_quests_in_zone.questCount;
1882 return progress->counter >= achievementCriteria->healing_done.count;
1884 return progress->counter >= achievementCriteria->complete_daily_quest.questCount;
1886 return progress->counter >= achievementCriteria->fall_without_dying.fallHeight;
1888 return progress->counter >= 1;
1891 return progress->counter >= achievementCriteria->be_spell_target.spellCount;
1894 return progress->counter >= achievementCriteria->cast_spell.castCount;
1896 return progress->counter >= achievementCriteria->bg_objective.completeCount;
1898 return progress->counter >= achievementCriteria->honorable_kill_at_area.killCount;
1900 return progress->counter >= 1;
1903 return progress->counter >= achievementCriteria->honorable_kill.killCount;
1905 return progress->counter >= achievementCriteria->own_item.itemCount;
1907 return progress->counter >= achievementCriteria->win_rated_arena.count;
1909 return progress->counter >= achievementCriteria->highest_personal_rating.PersonalRating;
1911 return progress->counter >= (achievementCriteria->learn_skill_level.skillLevel * 75);
1913 return progress->counter >= achievementCriteria->use_item.itemCount;
1915 return progress->counter >= achievementCriteria->loot_item.itemCount;
1917 return progress->counter >= 1;
1919 return progress->counter >= achievementCriteria->buy_bank_slot.numberOfSlots;
1921 return progress->counter >= achievementCriteria->gain_reputation.reputationAmount;
1923 return progress->counter >= achievementCriteria->gain_exalted_reputation.numberOfExaltedFactions;
1925 return progress->counter >= achievementCriteria->visit_barber.numberOfVisits;
1927 return progress->counter >= achievementCriteria->equip_epic_item.count;
1930 return progress->counter >= achievementCriteria->roll_greed_on_loot.count;
1932 return progress->counter >= achievementCriteria->hk_class.count;
1934 return progress->counter >= achievementCriteria->hk_race.count;
1936 return progress->counter >= achievementCriteria->do_emote.count;
1938 return progress->counter >= achievementCriteria->equip_item.count;
1940 return progress->counter >= achievementCriteria->quest_reward_money.goldInCopper;
1942 return progress->counter >= achievementCriteria->loot_money.goldInCopper;
1944 return progress->counter >= achievementCriteria->use_gameobject.useCount;
1946 return progress->counter >= achievementCriteria->special_pvp_kill.killCount;
1948 return progress->counter >= achievementCriteria->fish_in_gameobject.lootCount;
1950 return progress->counter >= achievementCriteria->learn_skillline_spell.spellCount;
1952 return progress->counter >= achievementCriteria->win_duel.duelCount;
1954 return progress->counter >= achievementCriteria->loot_type.lootTypeCount;
1956 return progress->counter >= achievementCriteria->learn_skill_line.spellCount;
1958 return progress->counter >= 9000;
1960 return progress->counter >= achievementCriteria->use_lfg.dungeonsComplete;
1962 return progress->counter >= achievementCriteria->get_killing_blow.killCount;
1964 return true;
1966 return achievementCriteria->win_arena.count && progress->counter >= achievementCriteria->win_arena.count;
1968 return true;
1969 // handle all statistic-only criteria here
2007 default:
2008 break;
2009 }
2010 return false;
2011}
@ ACHIEVEMENT_CRITERIA_TYPE_CREATE_AUCTION
Definition: DBCEnums.h:190
@ ACHIEVEMENT_CRITERIA_TYPE_LOOT_TYPE
Definition: DBCEnums.h:216
@ ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET2
Definition: DBCEnums.h:181
@ ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_QUESTS_IN_ZONE
Definition: DBCEnums.h:129
@ ACHIEVEMENT_CRITERIA_TYPE_USE_ITEM
Definition: DBCEnums.h:155
@ ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_DAILY_QUEST_DAILY
Definition: DBCEnums.h:128
@ ACHIEVEMENT_CRITERIA_TYPE_FLIGHT_PATHS_TAKEN
Definition: DBCEnums.h:215
@ ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_GOLD_VALUE_OWNED
Definition: DBCEnums.h:194
@ ACHIEVEMENT_CRITERIA_TYPE_REACH_SKILL_LEVEL
Definition: DBCEnums.h:125
@ ACHIEVEMENT_CRITERIA_TYPE_GOLD_SPENT_FOR_MAIL
Definition: DBCEnums.h:178
@ ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_QUEST_COUNT
Definition: DBCEnums.h:127
@ ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET
Definition: DBCEnums.h:142
@ ACHIEVEMENT_CRITERIA_TYPE_EQUIP_ITEM
Definition: DBCEnums.h:171
@ ACHIEVEMENT_CRITERIA_TYPE_PLAY_ARENA
Definition: DBCEnums.h:147
@ ACHIEVEMENT_CRITERIA_TYPE_FISH_IN_GAMEOBJECT
Definition: DBCEnums.h:183
@ ACHIEVEMENT_CRITERIA_TYPE_FALL_WITHOUT_DYING
Definition: DBCEnums.h:139
@ ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL
Definition: DBCEnums.h:143
@ ACHIEVEMENT_CRITERIA_TYPE_LOOT_ITEM
Definition: DBCEnums.h:156
@ ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_ARMOR
Definition: DBCEnums.h:206
@ ACHIEVEMENT_CRITERIA_TYPE_VISIT_BARBER_SHOP
Definition: DBCEnums.h:162
@ ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_DAILY_QUEST
Definition: DBCEnums.h:131
@ ACHIEVEMENT_CRITERIA_TYPE_GOLD_EARNED_BY_AUCTIONS
Definition: DBCEnums.h:189
@ ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_BATTLEGROUND
Definition: DBCEnums.h:132
@ ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_HEALTH
Definition: DBCEnums.h:202
@ ACHIEVEMENT_CRITERIA_TYPE_OWN_RANK
Definition: DBCEnums.h:158
@ ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_RAID
Definition: DBCEnums.h:136
@ ACHIEVEMENT_CRITERIA_TYPE_ROLL_GREED_ON_LOOT
Definition: DBCEnums.h:165
@ ACHIEVEMENT_CRITERIA_TYPE_GOLD_SPENT_AT_BARBER
Definition: DBCEnums.h:177
@ ACHIEVEMENT_CRITERIA_TYPE_USE_GAMEOBJECT
Definition: DBCEnums.h:180
@ ACHIEVEMENT_CRITERIA_TYPE_DO_EMOTE
Definition: DBCEnums.h:168
@ ACHIEVEMENT_CRITERIA_TYPE_WON_AUCTIONS
Definition: DBCEnums.h:192
@ ACHIEVEMENT_CRITERIA_TYPE_OWN_ITEM
Definition: DBCEnums.h:150
@ ACHIEVEMENT_CRITERIA_TYPE_GAIN_EXALTED_REPUTATION
Definition: DBCEnums.h:161
@ ACHIEVEMENT_CRITERIA_TYPE_USE_LFD_TO_GROUP_WITH_PLAYERS
Definition: DBCEnums.h:223
@ ACHIEVEMENT_CRITERIA_TYPE_QUEST_ABANDONED
Definition: DBCEnums.h:214
@ ACHIEVEMENT_CRITERIA_TYPE_DEATH_AT_MAP
Definition: DBCEnums.h:133
@ ACHIEVEMENT_CRITERIA_TYPE_LEARN_SPELL
Definition: DBCEnums.h:148
@ ACHIEVEMENT_CRITERIA_TYPE_BUY_BANK_SLOT
Definition: DBCEnums.h:159
@ ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILLLINE_SPELLS
Definition: DBCEnums.h:185
@ ACHIEVEMENT_CRITERIA_TYPE_ROLL_GREED
Definition: DBCEnums.h:201
@ ACHIEVEMENT_CRITERIA_TYPE_REACH_LEVEL
Definition: DBCEnums.h:124
@ ACHIEVEMENT_CRITERIA_TYPE_EARN_HONORABLE_KILL
Definition: DBCEnums.h:219
@ ACHIEVEMENT_CRITERIA_TYPE_HEALING_DONE
Definition: DBCEnums.h:169
@ ACHIEVEMENT_CRITERIA_TYPE_KILL_CREATURE_TYPE
Definition: DBCEnums.h:188
@ ACHIEVEMENT_CRITERIA_TYPE_DEATHS_FROM
Definition: DBCEnums.h:140
@ ACHIEVEMENT_CRITERIA_TYPE_GAIN_REVERED_REPUTATION
Definition: DBCEnums.h:195
@ ACHIEVEMENT_CRITERIA_TYPE_MONEY_FROM_QUEST_REWARD
Definition: DBCEnums.h:175
@ ACHIEVEMENT_CRITERIA_TYPE_KILLED_BY_PLAYER
Definition: DBCEnums.h:138
@ ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_SPELLPOWER
Definition: DBCEnums.h:205
@ ACHIEVEMENT_CRITERIA_TYPE_LOOT_EPIC_ITEM
Definition: DBCEnums.h:198
@ ACHIEVEMENT_CRITERIA_TYPE_HONORABLE_KILL
Definition: DBCEnums.h:149
@ ACHIEVEMENT_CRITERIA_TYPE_GAIN_REPUTATION
Definition: DBCEnums.h:160
@ ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL2
Definition: DBCEnums.h:217
@ ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILL_LINE
Definition: DBCEnums.h:218
@ ACHIEVEMENT_CRITERIA_TYPE_GOLD_SPENT_FOR_TALENTS
Definition: DBCEnums.h:173
@ ACHIEVEMENT_CRITERIA_TYPE_DAMAGE_DONE
Definition: DBCEnums.h:130
@ ACHIEVEMENT_CRITERIA_TYPE_ROLL_DISENCHANT
Definition: DBCEnums.h:222
@ ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_QUEST
Definition: DBCEnums.h:141
@ ACHIEVEMENT_CRITERIA_TYPE_WIN_RATED_ARENA
Definition: DBCEnums.h:151
@ ACHIEVEMENT_CRITERIA_TYPE_HK_RACE
Definition: DBCEnums.h:167
@ ACHIEVEMENT_CRITERIA_TYPE_KNOWN_FACTIONS
Definition: DBCEnums.h:197
@ ACHIEVEMENT_CRITERIA_TYPE_DEATH
Definition: DBCEnums.h:134
@ ACHIEVEMENT_CRITERIA_TYPE_EXPLORE_AREA
Definition: DBCEnums.h:157
@ ACHIEVEMENT_CRITERIA_TYPE_MONEY_FROM_VENDORS
Definition: DBCEnums.h:172
@ ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILL_LEVEL
Definition: DBCEnums.h:154
@ ACHIEVEMENT_CRITERIA_TYPE_KILLED_BY_CREATURE
Definition: DBCEnums.h:137
@ ACHIEVEMENT_CRITERIA_TYPE_EQUIP_EPIC_ITEM
Definition: DBCEnums.h:163
@ ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_AUCTION_BID
Definition: DBCEnums.h:191
@ ACHIEVEMENT_CRITERIA_TYPE_KILL_CREATURE
Definition: DBCEnums.h:122
@ ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_AUCTION_SOLD
Definition: DBCEnums.h:193
@ ACHIEVEMENT_CRITERIA_TYPE_DEATH_IN_DUNGEON
Definition: DBCEnums.h:135
@ ACHIEVEMENT_CRITERIA_TYPE_WIN_DUEL
Definition: DBCEnums.h:186
@ ACHIEVEMENT_CRITERIA_TYPE_ACCEPTED_SUMMONINGS
Definition: DBCEnums.h:220
@ ACHIEVEMENT_CRITERIA_TYPE_HONORABLE_KILL_AT_AREA
Definition: DBCEnums.h:145
@ ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_TEAM_RATING
Definition: DBCEnums.h:152
@ ACHIEVEMENT_CRITERIA_TYPE_WIN_BG
Definition: DBCEnums.h:123
@ ACHIEVEMENT_CRITERIA_TYPE_GAIN_HONORED_REPUTATION
Definition: DBCEnums.h:196
@ ACHIEVEMENT_CRITERIA_TYPE_SPECIAL_PVP_KILL
Definition: DBCEnums.h:182
@ ACHIEVEMENT_CRITERIA_TYPE_BG_OBJECTIVE_CAPTURE
Definition: DBCEnums.h:144
@ ACHIEVEMENT_CRITERIA_TYPE_GET_KILLING_BLOWS
Definition: DBCEnums.h:170
@ ACHIEVEMENT_CRITERIA_TYPE_LOOT_MONEY
Definition: DBCEnums.h:179
@ ACHIEVEMENT_CRITERIA_TYPE_WIN_ARENA
Definition: DBCEnums.h:146
@ ACHIEVEMENT_CRITERIA_TYPE_NUMBER_OF_TALENT_RESETS
Definition: DBCEnums.h:174
@ ACHIEVEMENT_CRITERIA_TYPE_ROLL_NEED_ON_LOOT
Definition: DBCEnums.h:164
@ ACHIEVEMENT_CRITERIA_TYPE_RECEIVE_EPIC_ITEM
Definition: DBCEnums.h:199
@ ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_PERSONAL_RATING
Definition: DBCEnums.h:153
@ ACHIEVEMENT_CRITERIA_TYPE_HK_CLASS
Definition: DBCEnums.h:166
@ ACHIEVEMENT_CRITERIA_TYPE_ROLL_NEED
Definition: DBCEnums.h:200
@ ACHIEVEMENT_CRITERIA_TYPE_ON_LOGIN
Definition: DBCEnums.h:184
@ ACHIEVEMENT_CRITERIA_TYPE_LOSE_DUEL
Definition: DBCEnums.h:187

References ACHIEVEMENT_CRITERIA_TYPE_ACCEPTED_SUMMONINGS, ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET, ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET2, ACHIEVEMENT_CRITERIA_TYPE_BG_OBJECTIVE_CAPTURE, ACHIEVEMENT_CRITERIA_TYPE_BUY_BANK_SLOT, ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL, ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL2, ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_ACHIEVEMENT, ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_BATTLEGROUND, ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_DAILY_QUEST, ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_DAILY_QUEST_DAILY, ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_QUEST, ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_QUEST_COUNT, ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_QUESTS_IN_ZONE, ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_RAID, ACHIEVEMENT_CRITERIA_TYPE_CREATE_AUCTION, ACHIEVEMENT_CRITERIA_TYPE_DAMAGE_DONE, ACHIEVEMENT_CRITERIA_TYPE_DEATH, ACHIEVEMENT_CRITERIA_TYPE_DEATH_AT_MAP, ACHIEVEMENT_CRITERIA_TYPE_DEATH_IN_DUNGEON, ACHIEVEMENT_CRITERIA_TYPE_DEATHS_FROM, ACHIEVEMENT_CRITERIA_TYPE_DO_EMOTE, ACHIEVEMENT_CRITERIA_TYPE_EARN_ACHIEVEMENT_POINTS, ACHIEVEMENT_CRITERIA_TYPE_EARN_HONORABLE_KILL, ACHIEVEMENT_CRITERIA_TYPE_EQUIP_EPIC_ITEM, ACHIEVEMENT_CRITERIA_TYPE_EQUIP_ITEM, ACHIEVEMENT_CRITERIA_TYPE_EXPLORE_AREA, ACHIEVEMENT_CRITERIA_TYPE_FALL_WITHOUT_DYING, ACHIEVEMENT_CRITERIA_TYPE_FISH_IN_GAMEOBJECT, ACHIEVEMENT_CRITERIA_TYPE_FLIGHT_PATHS_TAKEN, ACHIEVEMENT_CRITERIA_TYPE_GAIN_EXALTED_REPUTATION, ACHIEVEMENT_CRITERIA_TYPE_GAIN_HONORED_REPUTATION, ACHIEVEMENT_CRITERIA_TYPE_GAIN_REPUTATION, ACHIEVEMENT_CRITERIA_TYPE_GAIN_REVERED_REPUTATION, ACHIEVEMENT_CRITERIA_TYPE_GET_KILLING_BLOWS, ACHIEVEMENT_CRITERIA_TYPE_GOLD_EARNED_BY_AUCTIONS, ACHIEVEMENT_CRITERIA_TYPE_GOLD_SPENT_AT_BARBER, ACHIEVEMENT_CRITERIA_TYPE_GOLD_SPENT_FOR_MAIL, ACHIEVEMENT_CRITERIA_TYPE_GOLD_SPENT_FOR_TALENTS, ACHIEVEMENT_CRITERIA_TYPE_HEALING_DONE, ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_ARMOR, ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_AUCTION_BID, ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_AUCTION_SOLD, ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_GOLD_VALUE_OWNED, ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_HEALTH, ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_PERSONAL_RATING, ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_SPELLPOWER, ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_TEAM_RATING, ACHIEVEMENT_CRITERIA_TYPE_HK_CLASS, ACHIEVEMENT_CRITERIA_TYPE_HK_RACE, ACHIEVEMENT_CRITERIA_TYPE_HONORABLE_KILL, ACHIEVEMENT_CRITERIA_TYPE_HONORABLE_KILL_AT_AREA, ACHIEVEMENT_CRITERIA_TYPE_KILL_CREATURE, ACHIEVEMENT_CRITERIA_TYPE_KILL_CREATURE_TYPE, ACHIEVEMENT_CRITERIA_TYPE_KILLED_BY_CREATURE, ACHIEVEMENT_CRITERIA_TYPE_KILLED_BY_PLAYER, ACHIEVEMENT_CRITERIA_TYPE_KNOWN_FACTIONS, ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILL_LEVEL, ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILL_LINE, ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILLLINE_SPELLS, ACHIEVEMENT_CRITERIA_TYPE_LEARN_SPELL, ACHIEVEMENT_CRITERIA_TYPE_LOOT_EPIC_ITEM, ACHIEVEMENT_CRITERIA_TYPE_LOOT_ITEM, ACHIEVEMENT_CRITERIA_TYPE_LOOT_MONEY, ACHIEVEMENT_CRITERIA_TYPE_LOOT_TYPE, ACHIEVEMENT_CRITERIA_TYPE_LOSE_DUEL, ACHIEVEMENT_CRITERIA_TYPE_MONEY_FROM_QUEST_REWARD, ACHIEVEMENT_CRITERIA_TYPE_MONEY_FROM_VENDORS, ACHIEVEMENT_CRITERIA_TYPE_NUMBER_OF_TALENT_RESETS, ACHIEVEMENT_CRITERIA_TYPE_ON_LOGIN, ACHIEVEMENT_CRITERIA_TYPE_OWN_ITEM, ACHIEVEMENT_CRITERIA_TYPE_OWN_RANK, ACHIEVEMENT_CRITERIA_TYPE_PLAY_ARENA, ACHIEVEMENT_CRITERIA_TYPE_QUEST_ABANDONED, ACHIEVEMENT_CRITERIA_TYPE_REACH_LEVEL, ACHIEVEMENT_CRITERIA_TYPE_REACH_SKILL_LEVEL, ACHIEVEMENT_CRITERIA_TYPE_RECEIVE_EPIC_ITEM, ACHIEVEMENT_CRITERIA_TYPE_ROLL_DISENCHANT, ACHIEVEMENT_CRITERIA_TYPE_ROLL_GREED, ACHIEVEMENT_CRITERIA_TYPE_ROLL_GREED_ON_LOOT, ACHIEVEMENT_CRITERIA_TYPE_ROLL_NEED, ACHIEVEMENT_CRITERIA_TYPE_ROLL_NEED_ON_LOOT, ACHIEVEMENT_CRITERIA_TYPE_SPECIAL_PVP_KILL, ACHIEVEMENT_CRITERIA_TYPE_USE_GAMEOBJECT, ACHIEVEMENT_CRITERIA_TYPE_USE_ITEM, ACHIEVEMENT_CRITERIA_TYPE_USE_LFD_TO_GROUP_WITH_PLAYERS, ACHIEVEMENT_CRITERIA_TYPE_VISIT_BARBER_SHOP, ACHIEVEMENT_CRITERIA_TYPE_WIN_ARENA, ACHIEVEMENT_CRITERIA_TYPE_WIN_BG, ACHIEVEMENT_CRITERIA_TYPE_WIN_DUEL, ACHIEVEMENT_CRITERIA_TYPE_WIN_RATED_ARENA, ACHIEVEMENT_CRITERIA_TYPE_WON_AUCTIONS, ACHIEVEMENT_FLAG_COUNTER, ACHIEVEMENT_FLAG_REALM_FIRST_KILL, ACHIEVEMENT_FLAG_REALM_FIRST_REACH, AchievementCriteriaEntry::be_spell_target, AchievementCriteriaEntry::bg_objective, AchievementCriteriaEntry::buy_bank_slot, AchievementCriteriaEntry::cast_spell, AchievementCriteriaEntry::castCount, AchievementCriteriaEntry::complete_daily_quest, AchievementCriteriaEntry::complete_daily_quest_daily, AchievementCriteriaEntry::complete_quest_count, AchievementCriteriaEntry::complete_quests_in_zone, AchievementCriteriaEntry::completeCount, AchievementCriteriaEntry::count, CriteriaProgress::counter, AchievementCriteriaEntry::creatureCount, AchievementCriteriaEntry::do_emote, AchievementCriteriaEntry::duelCount, AchievementCriteriaEntry::dungeonsComplete, AchievementCriteriaEntry::equip_epic_item, AchievementCriteriaEntry::equip_item, AchievementCriteriaEntry::fall_without_dying, AchievementCriteriaEntry::fallHeight, AchievementCriteriaEntry::fish_in_gameobject, AchievementEntry::flags, AchievementCriteriaEntry::gain_exalted_reputation, AchievementCriteriaEntry::gain_reputation, AchievementCriteriaEntry::get_killing_blow, GetCriteriaProgress(), AchievementCriteriaEntry::goldInCopper, HasAchieved(), AchievementCriteriaEntry::healing_done, AchievementCriteriaEntry::highest_personal_rating, AchievementCriteriaEntry::hk_class, AchievementCriteriaEntry::hk_race, AchievementCriteriaEntry::honorable_kill, AchievementCriteriaEntry::honorable_kill_at_area, AchievementEntry::ID, IsCompletedAchievement(), AchievementCriteriaEntry::itemCount, AchievementCriteriaEntry::kill_creature, AchievementCriteriaEntry::killCount, AchievementCriteriaEntry::learn_skill_level, AchievementCriteriaEntry::learn_skill_line, AchievementCriteriaEntry::learn_skillline_spell, AchievementCriteriaEntry::level, AchievementCriteriaEntry::loot_item, AchievementCriteriaEntry::loot_money, AchievementCriteriaEntry::loot_type, AchievementCriteriaEntry::lootCount, AchievementCriteriaEntry::lootTypeCount, AchievementCriteriaEntry::numberOfDays, AchievementCriteriaEntry::numberOfExaltedFactions, AchievementCriteriaEntry::numberOfSlots, AchievementCriteriaEntry::numberOfVisits, AchievementCriteriaEntry::own_item, AchievementCriteriaEntry::PersonalRating, AchievementCriteriaEntry::quest_reward_money, AchievementCriteriaEntry::questCount, AchievementCriteriaEntry::reach_level, AchievementCriteriaEntry::reach_skill_level, AchievementCriteriaEntry::reputationAmount, AchievementCriteriaEntry::requiredType, AchievementCriteriaEntry::roll_greed_on_loot, sAchievementMgr, AchievementCriteriaEntry::skillLevel, AchievementCriteriaEntry::special_pvp_kill, AchievementCriteriaEntry::spellCount, sScriptMgr, AchievementCriteriaEntry::totalQuestCount, AchievementCriteriaEntry::use_gameobject, AchievementCriteriaEntry::use_item, AchievementCriteriaEntry::use_lfg, AchievementCriteriaEntry::useCount, AchievementCriteriaEntry::visit_barber, AchievementCriteriaEntry::win_arena, AchievementCriteriaEntry::win_bg, AchievementCriteriaEntry::win_duel, AchievementCriteriaEntry::win_rated_arena, and AchievementCriteriaEntry::winCount.

Referenced by CanUpdateCriteria(), IsCompletedAchievement(), ResetAchievementCriteria(), SetCriteriaProgress(), StartTimedAchievement(), and UpdateAchievementCriteria().

◆ LoadFromDB()

void AchievementMgr::LoadFromDB ( PreparedQueryResult  achievementResult,
PreparedQueryResult  criteriaResult,
PreparedQueryResult  offlineUpdatesResult 
)
618{
619 if (achievementResult)
620 {
621 do
622 {
623 Field* fields = achievementResult->Fetch();
624 uint32 achievementid = fields[0].Get<uint16>();
625
626 // must not happen: cleanup at server startup in sAchievementMgr->LoadCompletedAchievements()
627 AchievementEntry const* achievement = sAchievementStore.LookupEntry(achievementid);
628 if (!achievement)
629 continue;
630
632 ca.date = time_t(fields[1].Get<uint32>());
633 ca.changed = false;
634
635 // title achievement rewards are retroactive
636 if (AchievementReward const* reward = sAchievementMgr->GetAchievementReward(achievement))
637 if (uint32 titleId = reward->titleId[Player::TeamIdForRace(GetPlayer()->getRace())])
638 if (CharTitlesEntry const* titleEntry = sCharTitlesStore.LookupEntry(titleId))
639 if (!GetPlayer()->HasTitle(titleEntry))
640 GetPlayer()->SetTitle(titleEntry);
641 } while (achievementResult->NextRow());
642 }
643
644 if (criteriaResult)
645 {
646 do
647 {
648 Field* fields = criteriaResult->Fetch();
649 uint32 id = fields[0].Get<uint16>();
650 uint32 counter = fields[1].Get<uint32>();
651 time_t date = time_t(fields[2].Get<uint32>());
652
653 AchievementCriteriaEntry const* criteria = sAchievementCriteriaStore.LookupEntry(id);
654 if (!criteria)
655 {
656 // we will remove not existed criteria for all characters
657 LOG_ERROR("achievement", "Non-existing achievement criteria {} data removed from table `character_achievement_progress`.", id);
658
660
661 stmt->SetData(0, uint16(id));
662
663 CharacterDatabase.Execute(stmt);
664
665 continue;
666 }
667
668 if (criteria->timeLimit && time_t(date + criteria->timeLimit) < GameTime::GetGameTime().count())
669 continue;
670
671 CriteriaProgress& progress = _criteriaProgress[id];
672 progress.counter = counter;
673 progress.date = date;
674 progress.changed = false;
675 } while (criteriaResult->NextRow());
676 }
677
678 if (offlineUpdatesResult)
679 {
680 uint32 count = 0;
681 do
682 {
683 Field* fields = offlineUpdatesResult->Fetch();
684
686 update.updateType = static_cast<AchievementOfflinePlayerUpdateType>(fields[0].Get<uint8>());
687 update.arg1 = fields[1].Get<uint32>();
688 update.arg2 = fields[2].Get<uint32>();
689 update.arg3 = fields[3].Get<uint32>();
690
691 _offlineUpdatesQueue.push_back(update);
692
693 ++count;
694 } while (offlineUpdatesResult->NextRow());
695
696 if (count > 0)
698 }
699}
constexpr auto SECOND
Definition: Common.h:46
constexpr auto IN_MILLISECONDS
Definition: Common.h:53
#define LOG_ERROR(filterType__,...)
Definition: Log.h:156
std::uint16_t uint16
Definition: Define.h:108
AchievementOfflinePlayerUpdateType
Definition: AchievementMgr.h:37
@ CHAR_DEL_INVALID_ACHIEV_PROGRESS_CRITERIA
Definition: CharacterDatabase.h:297
Class used to access individual fields of database query result.
Definition: Field.h:99
std::enable_if_t< std::is_arithmetic_v< T >, T > Get() const
Definition: Field.h:113
Definition: AchievementMgr.h:43
uint32 arg2
Definition: AchievementMgr.h:46
AchievementOfflinePlayerUpdateType updateType
Definition: AchievementMgr.h:44
uint32 arg1
Definition: AchievementMgr.h:45
uint32 arg3
Definition: AchievementMgr.h:47
time_t date
Definition: AchievementMgr.h:53
bool changed
Definition: AchievementMgr.h:54
std::vector< AchievementOfflinePlayerUpdate > _offlineUpdatesQueue
Definition: AchievementMgr.h:347
static TeamId TeamIdForRace(uint8 race)
Definition: Player.cpp:5830
uint32 timeLimit
Definition: DBCStructure.h:514

References _completedAchievements, _criteriaProgress, _offlineUpdatesDelayTimer, _offlineUpdatesQueue, AchievementOfflinePlayerUpdate::arg1, AchievementOfflinePlayerUpdate::arg2, AchievementOfflinePlayerUpdate::arg3, CriteriaProgress::changed, CompletedAchievementData::changed, CHAR_DEL_INVALID_ACHIEV_PROGRESS_CRITERIA, CharacterDatabase, CriteriaProgress::counter, CriteriaProgress::date, CompletedAchievementData::date, Field::Get(), GameTime::GetGameTime(), GetPlayer(), IN_MILLISECONDS, LOG_ERROR, sAchievementCriteriaStore, sAchievementMgr, sAchievementStore, sCharTitlesStore, SECOND, PreparedStatementBase::SetData(), Player::SetTitle(), Player::TeamIdForRace(), AchievementCriteriaEntry::timeLimit, and AchievementOfflinePlayerUpdate::updateType.

Referenced by Player::LoadFromDB().

◆ ProcessOfflineUpdate()

void AchievementMgr::ProcessOfflineUpdate ( AchievementOfflinePlayerUpdate const &  update)
private
2499{
2500 switch (update.updateType)
2501 {
2503 {
2504 AchievementEntry const* achievement = sAchievementStore.LookupEntry(update.arg1);
2505
2506 ASSERT(achievement, "Not found achievement to complete for offline achievements update. Wrong arg1 ({}) value?", update.arg1);
2507
2508 CompletedAchievement(achievement);
2509 break;
2510 }
2512 {
2513 AchievementCriteriaTypes criteriaType = static_cast<AchievementCriteriaTypes>(update.arg1);
2514 UpdateAchievementCriteria(criteriaType, update.arg2, update.arg3);
2515 break;
2516 }
2517 default:
2518 ASSERT(false, "Unknown offline achievement update type ({}) for player - {}", update.updateType, GetPlayer()->GetGUID().GetCounter());
2519 break;
2520 }
2521}
#define ASSERT
Definition: Errors.h:68
@ ACHIEVEMENT_OFFLINE_PLAYER_UPDATE_TYPE_COMPLETE_ACHIEVEMENT
Definition: AchievementMgr.h:38
@ ACHIEVEMENT_OFFLINE_PLAYER_UPDATE_TYPE_UPDATE_CRITERIA
Definition: AchievementMgr.h:39

References ACHIEVEMENT_OFFLINE_PLAYER_UPDATE_TYPE_COMPLETE_ACHIEVEMENT, ACHIEVEMENT_OFFLINE_PLAYER_UPDATE_TYPE_UPDATE_CRITERIA, AchievementOfflinePlayerUpdate::arg1, AchievementOfflinePlayerUpdate::arg2, AchievementOfflinePlayerUpdate::arg3, ASSERT, CompletedAchievement(), GetPlayer(), sAchievementStore, UpdateAchievementCriteria(), and AchievementOfflinePlayerUpdate::updateType.

Referenced by ProcessOfflineUpdatesQueue().

◆ ProcessOfflineUpdatesQueue()

void AchievementMgr::ProcessOfflineUpdatesQueue ( )
private
2484{
2485 if (_offlineUpdatesQueue.empty())
2486 return;
2487
2488 for (auto const& update : _offlineUpdatesQueue)
2489 ProcessOfflineUpdate(update);
2490
2491 _offlineUpdatesQueue.clear();
2492
2494 stmt->SetData(0, GetPlayer()->GetGUID().GetCounter());
2495 CharacterDatabase.Execute(stmt);
2496}
void ProcessOfflineUpdate(AchievementOfflinePlayerUpdate const &update)
Definition: AchievementMgr.cpp:2498

References _offlineUpdatesQueue, CHAR_DEL_CHAR_ACHIEVEMENT_OFFLINE_UPDATES, CharacterDatabase, GetPlayer(), ProcessOfflineUpdate(), and PreparedStatementBase::SetData().

Referenced by Update().

◆ RemoveCriteriaProgress()

void AchievementMgr::RemoveCriteriaProgress ( AchievementCriteriaEntry const *  entry)
2176{
2177 CriteriaProgressMap::iterator criteriaProgress = _criteriaProgress.find(entry->ID);
2178 if (criteriaProgress == _criteriaProgress.end())
2179 return;
2180
2182 data << uint32(entry->ID);
2183 _player->SendDirectMessage(&data);
2184
2185 _criteriaProgress.erase(criteriaProgress);
2186}
@ SMSG_CRITERIA_DELETED
Definition: Opcodes.h:1212
void SendDirectMessage(WorldPacket const *data) const
Definition: Player.cpp:5692
Definition: WorldPacket.h:27

References _criteriaProgress, _player, AchievementCriteriaEntry::ID, Player::SendDirectMessage(), and SMSG_CRITERIA_DELETED.

Referenced by RemoveTimedAchievement(), ResetAchievementCriteria(), and UpdateTimedAchievements().

◆ RemoveTimedAchievement()

void AchievementMgr::RemoveTimedAchievement ( AchievementCriteriaTimedTypes  type,
uint32  entry 
)
2250{
2251 AchievementCriteriaEntryList const& achievementCriteriaList = sAchievementMgr->GetTimedAchievementCriteriaByType(type);
2252 for (AchievementCriteriaEntryList::const_iterator i = achievementCriteriaList.begin(); i != achievementCriteriaList.end(); ++i)
2253 {
2254 if ((*i)->timerStartEvent != entry)
2255 continue;
2256
2257 TimedAchievementMap::iterator timedIter = _timedAchievements.find((*i)->ID);
2258 // We don't have timer for this achievement
2259 if (timedIter == _timedAchievements.end())
2260 continue;
2261
2262 // remove progress
2264
2265 // Remove the timer
2266 _timedAchievements.erase(timedIter);
2267 }
2268}
TimedAchievementMap _timedAchievements
Definition: AchievementMgr.h:341
void RemoveCriteriaProgress(AchievementCriteriaEntry const *entry)
Definition: AchievementMgr.cpp:2175

References _timedAchievements, RemoveCriteriaProgress(), and sAchievementMgr.

Referenced by Player::RemoveTimedAchievement().

◆ Reset()

void AchievementMgr::Reset ( )
492{
493 for (CompletedAchievementMap::const_iterator iter = _completedAchievements.begin(); iter != _completedAchievements.end(); ++iter)
494 {
496 data << uint32(iter->first);
498 }
499
500 for (CriteriaProgressMap::const_iterator iter = _criteriaProgress.begin(); iter != _criteriaProgress.end(); ++iter)
501 {
503 data << uint32(iter->first);
505 }
506
508 _criteriaProgress.clear();
510
511 // re-fill data
513}
@ SMSG_ACHIEVEMENT_DELETED
Definition: Opcodes.h:1213
void CheckAllAchievementCriteria()
Definition: AchievementMgr.cpp:800
static void DeleteFromDB(ObjectGuid::LowType lowguid)
Definition: AchievementMgr.cpp:542
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:109
LowType GetCounter() const
Definition: ObjectGuid.h:145

References _completedAchievements, _criteriaProgress, _player, CheckAllAchievementCriteria(), DeleteFromDB(), ObjectGuid::GetCounter(), Object::GetGUID(), Player::SendDirectMessage(), SMSG_ACHIEVEMENT_DELETED, and SMSG_CRITERIA_DELETED.

Referenced by Player::ResetAchievements().

◆ ResetAchievementCriteria()

void AchievementMgr::ResetAchievementCriteria ( AchievementCriteriaCondition  condition,
uint32  value,
bool  evenIfCriteriaComplete = false 
)
516{
517 // disable for gamemasters with GM-mode enabled
518 if (_player->IsGameMaster())
519 return;
520
521 LOG_DEBUG("achievement", "AchievementMgr::ResetAchievementCriteria({}, {}, {})", condition, value, evenIfCriteriaComplete);
522
523 AchievementCriteriaEntryList const* achievementCriteriaList = sAchievementMgr->GetAchievementCriteriaByCondition(condition, value);
524 if (!achievementCriteriaList)
525 return;
526
527 for (AchievementCriteriaEntryList::const_iterator i = achievementCriteriaList->begin(); i != achievementCriteriaList->end(); ++i)
528 {
529 AchievementCriteriaEntry const* achievementCriteria = (*i);
530 AchievementEntry const* achievement = sAchievementStore.LookupEntry(achievementCriteria->referredAchievement);
531 if (!achievement)
532 continue;
533
534 // don't update already completed criteria if not forced or achievement already complete
535 if ((IsCompletedCriteria(achievementCriteria, achievement) && !evenIfCriteriaComplete) || HasAchieved(achievement->ID))
536 continue;
537
538 RemoveCriteriaProgress(achievementCriteria);
539 }
540}
uint32 ID
Definition: DBCStructure.h:41
uint32 referredAchievement
Definition: DBCStructure.h:72

References _player, HasAchieved(), AchievementEntry::ID, IsCompletedCriteria(), Player::IsGameMaster(), LOG_DEBUG, AchievementCriteriaEntry::referredAchievement, RemoveCriteriaProgress(), sAchievementMgr, and sAchievementStore.

Referenced by Player::ResetAchievementCriteria().

◆ SaveToDB()

void AchievementMgr::SaveToDB ( CharacterDatabaseTransaction  trans)
562{
563 if (!_completedAchievements.empty())
564 {
565 for (CompletedAchievementMap::iterator iter = _completedAchievements.begin(); iter != _completedAchievements.end(); ++iter)
566 {
567 if (!iter->second.changed)
568 continue;
569
571 stmt->SetData(0, iter->first);
572 stmt->SetData(1, GetPlayer()->GetGUID().GetCounter());
573 trans->Append(stmt);
574
575 stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHAR_ACHIEVEMENT);
576 stmt->SetData(0, GetPlayer()->GetGUID().GetCounter());
577 stmt->SetData(1, iter->first);
578 stmt->SetData(2, uint32(iter->second.date));
579 trans->Append(stmt);
580
581 iter->second.changed = false;
582
583 sScriptMgr->OnAchievementSave(trans, GetPlayer(), iter->first, iter->second);
584 }
585 }
586
587 if (!_criteriaProgress.empty())
588 {
589 for (CriteriaProgressMap::iterator iter = _criteriaProgress.begin(); iter != _criteriaProgress.end(); ++iter)
590 {
591 if (!iter->second.changed)
592 continue;
593
595 stmt->SetData(0, GetPlayer()->GetGUID().GetCounter());
596 stmt->SetData(1, iter->first);
597 trans->Append(stmt);
598
599 // pussywizard: insert only for (counter != 0) is very important! this is how criteria of completed achievements gets deleted from db (by setting counter to 0); if conflicted during merge - contact me
600 if (iter->second.counter)
601 {
602 stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHAR_ACHIEVEMENT_PROGRESS);
603 stmt->SetData(0, GetPlayer()->GetGUID().GetCounter());
604 stmt->SetData(1, iter->first);
605 stmt->SetData(2, iter->second.counter);
606 stmt->SetData(3, uint32(iter->second.date));
607 trans->Append(stmt);
608 }
609
610 iter->second.changed = false;
611
612 sScriptMgr->OnCriteriaSave(trans, GetPlayer(), iter->first, iter->second);
613 }
614 }
615}
@ CHAR_DEL_CHAR_ACHIEVEMENT_PROGRESS_BY_CRITERIA
Definition: CharacterDatabase.h:366
@ CHAR_INS_CHAR_ACHIEVEMENT_PROGRESS
Definition: CharacterDatabase.h:367
@ CHAR_INS_CHAR_ACHIEVEMENT
Definition: CharacterDatabase.h:365
@ CHAR_DEL_CHAR_ACHIEVEMENT_BY_ACHIEVEMENT
Definition: CharacterDatabase.h:394

References _completedAchievements, _criteriaProgress, CHAR_DEL_CHAR_ACHIEVEMENT_BY_ACHIEVEMENT, CHAR_DEL_CHAR_ACHIEVEMENT_PROGRESS_BY_CRITERIA, CHAR_INS_CHAR_ACHIEVEMENT, CHAR_INS_CHAR_ACHIEVEMENT_PROGRESS, CharacterDatabase, GetPlayer(), PreparedStatementBase::SetData(), and sScriptMgr.

Referenced by Player::SaveToDB().

◆ SendAchievementEarned()

void AchievementMgr::SendAchievementEarned ( AchievementEntry const *  achievement) const
private
702{
703 if (GetPlayer()->GetSession()->PlayerLoading())
704 return;
705
706 // Don't send for achievements with ACHIEVEMENT_FLAG_TRACKING
707 if (achievement->flags & ACHIEVEMENT_FLAG_HIDDEN)
708 return;
709
710 LOG_DEBUG("achievement", "AchievementMgr::SendAchievementEarned({})", achievement->ID);
711
712 Guild* guild = sGuildMgr->GetGuildById(GetPlayer()->GetGuildId());
713 if (guild)
714 {
717 guild->BroadcastWorker(_localizer, GetPlayer());
718 }
719
721 {
722 // If guild exists - send its name to the server
723 // If guild does not exist - send player's name to the server
724 if (achievement->flags & ACHIEVEMENT_FLAG_REALM_FIRST_KILL && guild)
725 {
726 WorldPacket data(SMSG_SERVER_FIRST_ACHIEVEMENT, guild->GetName().size() + 1 + 8 + 4 + 4);
727 data << guild->GetName();
728 data << GetPlayer()->GetGUID();
729 data << uint32(achievement->ID);
730 data << uint32(0); // display name as plain string in chat (always 0 for guild)
731 sWorld->SendGlobalMessage(&data);
732 }
733 else
734 {
735 TeamId teamId = GetPlayer()->GetTeamId();
736
737 // broadcast realm first reached
738 WorldPacket data(SMSG_SERVER_FIRST_ACHIEVEMENT, GetPlayer()->GetName().size() + 1 + 8 + 4 + 4);
739 data << GetPlayer()->GetName();
740 data << GetPlayer()->GetGUID();
741 data << uint32(achievement->ID);
742 std::size_t linkTypePos = data.wpos();
743 data << uint32(1); // display name as clickable link in chat
744 sWorld->SendGlobalMessage(&data, nullptr, teamId);
745
746 data.put<uint32>(linkTypePos, 0); // display name as plain string in chat
747 sWorld->SendGlobalMessage(&data, nullptr, teamId == TEAM_ALLIANCE ? TEAM_HORDE : TEAM_ALLIANCE);
748 }
749 }
750 // if player is in world he can tell his friends about new achievement
751 else if (GetPlayer()->IsInWorld())
752 {
753 CellCoord p = Acore::ComputeCellCoord(GetPlayer()->GetPositionX(), GetPlayer()->GetPositionY());
754
755 Cell cell(p);
756 cell.SetNoCreate();
757
763 }
764
765 WorldPacket data(SMSG_ACHIEVEMENT_EARNED, 8 + 4 + 8);
766 data << GetPlayer()->GetPackGUID();
767 data << uint32(achievement->ID);
768 data.AppendPackedTime(GameTime::GetGameTime().count());
769 data << uint32(0);
770 GetPlayer()->SendMessageToSetInRange(&data, sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_SAY), true);
771}
#define sGuildMgr
Definition: GuildMgr.h:51
@ CONFIG_LISTEN_RANGE_SAY
Definition: IWorld.h:199
@ BROADCAST_TEXT_ACHIEVEMENT_EARNED
Definition: Language.h:23
@ CHAT_MSG_GUILD_ACHIEVEMENT
Definition: SharedDefines.h:3201
@ CHAT_MSG_ACHIEVEMENT
Definition: SharedDefines.h:3200
TeamId
Definition: SharedDefines.h:759
@ SMSG_ACHIEVEMENT_EARNED
Definition: Opcodes.h:1158
@ SMSG_SERVER_FIRST_ACHIEVEMENT
Definition: Opcodes.h:1206
#define sWorld
Definition: World.h:444
CellCoord ComputeCellCoord(float x, float y)
Definition: GridDefines.h:191
bool GetName(uint32 accountId, std::string &name)
Definition: AccountMgr.cpp:257
Definition: TypeContainer.h:101
Definition: TypeContainerVisitor.h:84
bool IsInWorld() const
Definition: Object.h:104
std::string const & GetName() const
Definition: Object.h:458
void SendMessageToSetInRange(WorldPacket const *data, float dist, bool self) const override
Definition: Player.cpp:5661
TeamId GetTeamId(bool original=false) const
Definition: Player.h:2088
Definition: Cell.h:46
static void VisitWorldObjects(WorldObject const *obj, T &visitor, float radius, bool dont_load=true)
Definition: CellImpl.h:193
Definition: GridNotifiers.h:592
Definition: GridNotifiers.h:1707
Definition: Guild.h:295
void BroadcastWorker(Do &_do, Player *except=nullptr)
Definition: Guild.h:754
std::string const & GetName() const
Definition: Guild.h:691
Definition: ChatTextBuilder.h:31

References ACHIEVEMENT_FLAG_HIDDEN, ACHIEVEMENT_FLAG_REALM_FIRST_KILL, ACHIEVEMENT_FLAG_REALM_FIRST_REACH, ByteBuffer::AppendPackedTime(), BROADCAST_TEXT_ACHIEVEMENT_EARNED, Guild::BroadcastWorker(), CHAT_MSG_ACHIEVEMENT, CHAT_MSG_GUILD_ACHIEVEMENT, Acore::ComputeCellCoord(), CONFIG_LISTEN_RANGE_SAY, AchievementEntry::flags, GameTime::GetGameTime(), Object::GetGUID(), WorldObject::GetName(), Guild::GetName(), Object::GetPackGUID(), GetPlayer(), Player::GetTeamId(), AchievementEntry::ID, Object::IsInWorld(), LOG_DEBUG, ByteBuffer::put(), Player::SendMessageToSetInRange(), Cell::SetNoCreate(), sGuildMgr, SMSG_ACHIEVEMENT_EARNED, SMSG_SERVER_FIRST_ACHIEVEMENT, sWorld, TEAM_ALLIANCE, TEAM_HORDE, Cell::VisitWorldObjects(), and ByteBuffer::wpos().

Referenced by CompletedAchievement().

◆ SendAllAchievementData()

void AchievementMgr::SendAllAchievementData ( ) const
2383{
2384 WorldPacket data(SMSG_ALL_ACHIEVEMENT_DATA, _completedAchievements.size() * 8 + 4 + _criteriaProgress.size() * 38 + 4);
2385 BuildAllDataPacket(&data);
2386 GetPlayer()->GetSession()->SendPacket(&data);
2387}
@ SMSG_ALL_ACHIEVEMENT_DATA
Definition: Opcodes.h:1179
void BuildAllDataPacket(WorldPacket *data) const
Definition: AchievementMgr.cpp:2400
void SendPacket(WorldPacket const *packet)
Send a packet to the client.
Definition: WorldSession.cpp:214

References _completedAchievements, _criteriaProgress, BuildAllDataPacket(), GetPlayer(), Player::GetSession(), WorldSession::SendPacket(), and SMSG_ALL_ACHIEVEMENT_DATA.

Referenced by Player::SendInitialPacketsBeforeAddToMap().

◆ SendCriteriaUpdate()

void AchievementMgr::SendCriteriaUpdate ( AchievementCriteriaEntry const *  entry,
CriteriaProgress const *  progress,
uint32  timeElapsed,
bool  timedCompleted 
) const
private
774{
775 WorldPacket data(SMSG_CRITERIA_UPDATE, 8 + 4 + 8);
776 data << uint32(entry->ID);
777
778 // the counter is packed like a packed Guid
779 data.appendPackGUID(progress->counter);
780
781 data << GetPlayer()->GetPackGUID();
782 if (!entry->timeLimit)
783 data << uint32(0);
784 else
785 data << uint32(timedCompleted ? 0 : 1); // 1 is for keeping the counter at 0 in client
786 data.AppendPackedTime(progress->date);
787 data << uint32(timeElapsed); // time elapsed in seconds
788
789 if (sAchievementMgr->IsAverageCriteria(entry))
790 data << uint32(GameTime::GetGameTime().count() - GetPlayer()->GetCreationTime().count()); // for average achievements
791 else
792 data << uint32(timeElapsed); // time elapsed in seconds
793
795}
@ SMSG_CRITERIA_UPDATE
Definition: Opcodes.h:1160

References ByteBuffer::AppendPackedTime(), ByteBuffer::appendPackGUID(), CriteriaProgress::counter, CriteriaProgress::date, GameTime::GetGameTime(), Object::GetPackGUID(), GetPlayer(), AchievementCriteriaEntry::ID, sAchievementMgr, Player::SendDirectMessage(), SMSG_CRITERIA_UPDATE, and AchievementCriteriaEntry::timeLimit.

Referenced by SetCriteriaProgress().

◆ SendRespondInspectAchievements()

void AchievementMgr::SendRespondInspectAchievements ( Player player) const

◆ SetCriteriaProgress()

void AchievementMgr::SetCriteriaProgress ( AchievementCriteriaEntry const *  entry,
uint32  changeValue,
ProgressType  ptype = PROGRESS_SET 
)
private
2100{
2101 // Don't allow to cheat - doing timed achievements without timer active
2102 TimedAchievementMap::iterator timedIter = _timedAchievements.find(entry->ID);
2103 if (entry->timeLimit && timedIter == _timedAchievements.end())
2104 return;
2105
2106 if (!sScriptMgr->OnBeforeCriteriaProgress(GetPlayer(), entry))
2107 {
2108 return;
2109 }
2110
2111 LOG_DEBUG("achievement", "AchievementMgr::SetCriteriaProgress({}, {}) for {}", entry->ID, changeValue, _player->GetGUID().ToString());
2112
2113 CriteriaProgress* progress = GetCriteriaProgress(entry);
2114 if (!progress)
2115 {
2116 // not create record for 0 counter but allow it for timed achievements
2117 // we will need to send 0 progress to client to start the timer
2118 if (changeValue == 0 && !entry->timeLimit)
2119 return;
2120
2121 progress = &_criteriaProgress[entry->ID];
2122 progress->counter = changeValue;
2123 }
2124 else
2125 {
2126 uint32 newValue = 0;
2127 switch (ptype)
2128 {
2129 case PROGRESS_SET:
2130 case PROGRESS_RESET:
2131 newValue = changeValue;
2132 break;
2134 {
2135 // avoid overflow
2136 uint32 max_value = std::numeric_limits<uint32>::max();
2137 newValue = max_value - progress->counter > changeValue ? progress->counter + changeValue : max_value;
2138 break;
2139 }
2140 case PROGRESS_HIGHEST:
2141 newValue = progress->counter < changeValue ? changeValue : progress->counter;
2142 break;
2143 }
2144
2145 // not update (not mark as changed) if counter will have same value
2146 if (ptype != PROGRESS_RESET && progress->counter == newValue && !entry->timeLimit)
2147 return;
2148
2149 progress->counter = newValue;
2150 }
2151
2152 progress->changed = true;
2153 progress->date = GameTime::GetGameTime().count(); // set the date to the latest update.
2154
2155 uint32 timeElapsed = 0;
2156 bool timedCompleted = false;
2157
2158 if (entry->timeLimit)
2159 {
2160 // has to exist else we wouldn't be here
2161 timedCompleted = IsCompletedCriteria(entry, sAchievementStore.LookupEntry(entry->referredAchievement));
2162 // Client expects this in packet
2163 timeElapsed = entry->timeLimit - (timedIter->second / IN_MILLISECONDS);
2164
2165 // Remove the timer, we wont need it anymore
2166 if (timedCompleted)
2167 _timedAchievements.erase(timedIter);
2168 }
2169
2170 SendCriteriaUpdate(entry, progress, timeElapsed, true);
2171
2172 sScriptMgr->OnCriteriaProgress(GetPlayer(), entry);
2173}
void SendCriteriaUpdate(AchievementCriteriaEntry const *entry, CriteriaProgress const *progress, uint32 timeElapsed, bool timedCompleted) const
Definition: AchievementMgr.cpp:773
std::string ToString() const
Definition: ObjectGuid.cpp:47

References _criteriaProgress, _player, _timedAchievements, CriteriaProgress::changed, CriteriaProgress::counter, CriteriaProgress::date, GetCriteriaProgress(), GameTime::GetGameTime(), Object::GetGUID(), GetPlayer(), AchievementCriteriaEntry::ID, IN_MILLISECONDS, IsCompletedCriteria(), LOG_DEBUG, PROGRESS_ACCUMULATE, PROGRESS_HIGHEST, PROGRESS_RESET, PROGRESS_SET, AchievementCriteriaEntry::referredAchievement, sAchievementStore, SendCriteriaUpdate(), sScriptMgr, AchievementCriteriaEntry::timeLimit, and ObjectGuid::ToString().

Referenced by StartTimedAchievement(), and UpdateAchievementCriteria().

◆ StartTimedAchievement()

void AchievementMgr::StartTimedAchievement ( AchievementCriteriaTimedTypes  type,
uint32  entry,
uint32  timeLost = 0 
)
2227{
2228 AchievementCriteriaEntryList const& achievementCriteriaList = sAchievementMgr->GetTimedAchievementCriteriaByType(type);
2229 for (AchievementCriteriaEntryList::const_iterator i = achievementCriteriaList.begin(); i != achievementCriteriaList.end(); ++i)
2230 {
2231 if ((*i)->timerStartEvent != entry)
2232 continue;
2233
2234 AchievementEntry const* achievement = sAchievementStore.LookupEntry((*i)->referredAchievement);
2235 if (_timedAchievements.find((*i)->ID) == _timedAchievements.end() && !IsCompletedCriteria(*i, achievement))
2236 {
2237 // Start the timer
2238 if ((*i)->timeLimit * IN_MILLISECONDS > timeLost)
2239 {
2240 _timedAchievements[(*i)->ID] = (*i)->timeLimit * IN_MILLISECONDS - timeLost;
2241
2242 // and at client too
2244 }
2245 }
2246 }
2247}
void SetCriteriaProgress(AchievementCriteriaEntry const *entry, uint32 changeValue, ProgressType ptype=PROGRESS_SET)
Definition: AchievementMgr.cpp:2099

References _timedAchievements, IN_MILLISECONDS, IsCompletedCriteria(), PROGRESS_SET, sAchievementMgr, sAchievementStore, and SetCriteriaProgress().

Referenced by Player::StartTimedAchievement().

◆ Update()

void AchievementMgr::Update ( uint32  timeDiff)
2189{
2191 {
2192 if (timeDiff >= _offlineUpdatesDelayTimer)
2193 {
2196 }
2197 else
2198 _offlineUpdatesDelayTimer -= timeDiff;
2199 }
2200
2201 UpdateTimedAchievements(timeDiff);
2202}
void UpdateTimedAchievements(uint32 timeDiff)
Definition: AchievementMgr.cpp:2204
void ProcessOfflineUpdatesQueue()
Definition: AchievementMgr.cpp:2483

References _offlineUpdatesDelayTimer, ProcessOfflineUpdatesQueue(), and UpdateTimedAchievements().

Referenced by Player::Update().

◆ UpdateAchievementCriteria()

void AchievementMgr::UpdateAchievementCriteria ( AchievementCriteriaTypes  type,
uint32  miscValue1 = 0,
uint32  miscValue2 = 0,
Unit unit = nullptr 
)

this function will be called whenever the user might have done a criteria relevant action

823{
824 // disable for gamemasters with GM-mode enabled
825 if (_player->IsGameMaster())
826 return;
827
829 {
830 LOG_DEBUG("achievement", "UpdateAchievementCriteria: Wrong criteria type {}", type);
831 return;
832 }
833
834 LOG_DEBUG("achievement", "AchievementMgr::UpdateAchievementCriteria({}, {}, {})", type, miscValue1, miscValue2);
835
836 AchievementCriteriaEntryList const* achievementCriteriaList = nullptr;
837
838 switch (type)
839 {
870 if (miscValue1)
871 {
872 achievementCriteriaList = sAchievementMgr->GetSpecialAchievementCriteriaByType(type, miscValue1);
873 break;
874 }
875 achievementCriteriaList = sAchievementMgr->GetAchievementCriteriaByType(type);
876 break;
878 if (miscValue2)
879 {
880 achievementCriteriaList = sAchievementMgr->GetSpecialAchievementCriteriaByType(type, miscValue2);
881 break;
882 }
883 achievementCriteriaList = sAchievementMgr->GetAchievementCriteriaByType(type);
884 break;
885 default:
886 achievementCriteriaList = sAchievementMgr->GetAchievementCriteriaByType(type);
887 break;
888 }
889
890 if (!achievementCriteriaList)
891 return;
892
893 sScriptMgr->OnBeforeCheckCriteria(this, achievementCriteriaList);
894
895 for (AchievementCriteriaEntryList::const_iterator i = achievementCriteriaList->begin(); i != achievementCriteriaList->end(); ++i)
896 {
897 AchievementCriteriaEntry const* achievementCriteria = (*i);
898 AchievementEntry const* achievement = sAchievementStore.LookupEntry(achievementCriteria->referredAchievement);
899 if (!achievement)
900 continue;
901
902 if (!CanUpdateCriteria(achievementCriteria, achievement))
903 continue;
904
905 if (!sScriptMgr->CanCheckCriteria(this, achievementCriteria))
906 continue;
907
908 switch (type)
909 {
910 // std. case: increment at 1
921 // AchievementMgr::UpdateAchievementCriteria might also be called on login - skip in this case
922 if (!miscValue1)
923 continue;
924 SetCriteriaProgress(achievementCriteria, 1, PROGRESS_ACCUMULATE);
925 break;
926 // std case: increment at miscvalue1
938 // AchievementMgr::UpdateAchievementCriteria might also be called on login - skip in this case
939 if (!miscValue1)
940 continue;
941 SetCriteriaProgress(achievementCriteria, miscValue1, PROGRESS_ACCUMULATE);
942 break;
943 // std case: high value at miscvalue1
950 // AchievementMgr::UpdateAchievementCriteria might also be called on login - skip in this case
951 if (!miscValue1)
952 continue;
953 SetCriteriaProgress(achievementCriteria, miscValue1, PROGRESS_HIGHEST);
954 break;
955
956 // specialized cases
958 {
959 // AchievementMgr::UpdateAchievementCriteria might also be called on login - skip in this case
960 if (!miscValue1)
961 continue;
962
963 if (achievement->categoryId == CATEGORY_CHILDRENS_WEEK)
964 {
965 AchievementCriteriaDataSet const* data = sAchievementMgr->GetCriteriaDataSet(achievementCriteria);
966 if (!data || !data->Meets(GetPlayer(), nullptr))
967 continue;
968 }
969
970 SetCriteriaProgress(achievementCriteria, 1, PROGRESS_ACCUMULATE);
971 break;
972 }
974 {
975 // AchievementMgr::UpdateAchievementCriteria might also be called on login - skip in this case
976 if (!miscValue1)
977 continue;
978 if (achievementCriteria->win_bg.bgMapID != GetPlayer()->GetMapId())
979 continue;
980
981 // those requirements couldn't be found in the dbc
982 AchievementCriteriaDataSet const* data = sAchievementMgr->GetCriteriaDataSet(achievementCriteria);
983 if (!data || !data->Meets(GetPlayer(), unit))
984 continue;
985
986 SetCriteriaProgress(achievementCriteria, 1, PROGRESS_ACCUMULATE);
987 break;
988 }
990 {
991 // AchievementMgr::UpdateAchievementCriteria might also be called on login - skip in this case
992 if (!miscValue1)
993 continue;
994 if (achievementCriteria->kill_creature.creatureID != miscValue1)
995 continue;
996
997 // those requirements couldn't be found in the dbc
998 AchievementCriteriaDataSet const* data = sAchievementMgr->GetCriteriaDataSet(achievementCriteria);
999 if (!data || !data->Meets(GetPlayer(), unit))
1000 continue;
1001
1002 SetCriteriaProgress(achievementCriteria, miscValue2, PROGRESS_ACCUMULATE);
1003 break;
1004 }
1006 {
1007 // AchievementMgr::UpdateAchievementCriteria might also be called on login - skip in this case
1008 if (!miscValue2)
1009 continue;
1010
1011 // those requirements couldn't be found in the dbc
1012 AchievementCriteriaDataSet const* data = sAchievementMgr->GetCriteriaDataSet(achievementCriteria);
1013 if (!data || !data->Meets(GetPlayer(), unit, miscValue1))
1014 continue;
1015
1016 SetCriteriaProgress(achievementCriteria, miscValue2, PROGRESS_ACCUMULATE);
1017 break;
1018 }
1020 if (AchievementCriteriaDataSet const* data = sAchievementMgr->GetCriteriaDataSet(achievementCriteria))
1021 if (!data->Meets(GetPlayer(), unit))
1022 continue;
1023 SetCriteriaProgress(achievementCriteria, GetPlayer()->GetLevel());
1024 break;
1026 // update at loading or specific skill update
1027 if (miscValue1 && miscValue1 != achievementCriteria->reach_skill_level.skillID)
1028 continue;
1029 if (uint32 skillvalue = GetPlayer()->GetBaseSkillValue(achievementCriteria->reach_skill_level.skillID))
1030 SetCriteriaProgress(achievementCriteria, skillvalue);
1031 break;
1033 // update at loading or specific skill update
1034 if (miscValue1 && miscValue1 != achievementCriteria->learn_skill_level.skillID)
1035 continue;
1036 if (uint32 maxSkillvalue = GetPlayer()->GetPureMaxSkillValue(achievementCriteria->learn_skill_level.skillID))
1037 SetCriteriaProgress(achievementCriteria, maxSkillvalue);
1038 break;
1040 if ((miscValue1 && achievementCriteria->complete_achievement.linkedAchievement == miscValue1) || (!miscValue1 && GetPlayer()->HasAchieved(achievementCriteria->complete_achievement.linkedAchievement)))
1041 SetCriteriaProgress(achievementCriteria, 1);
1042 break;
1044 {
1045 SetCriteriaProgress(achievementCriteria, GetPlayer()->GetRewardedQuestCount());
1046 break;
1047 }
1049 {
1050 Seconds nextDailyResetTime = sWorld->GetNextDailyQuestsResetTime();
1051 CriteriaProgress* progress = GetCriteriaProgress(achievementCriteria);
1052
1053 if (!miscValue1) // Login case.
1054 {
1055 // reset if player missed one day.
1056 if (progress && Seconds(progress->date) < (nextDailyResetTime - 2_days))
1057 SetCriteriaProgress(achievementCriteria, 0, PROGRESS_SET);
1058 continue;
1059 }
1060
1061 ProgressType progressType;
1062 if (!progress)
1063 // 1st time. Start count.
1064 progressType = PROGRESS_SET;
1065 else if (Seconds(progress->date) < (nextDailyResetTime - 2_days))
1066 // last progress is older than 2 days. Player missed 1 day => Retart count.
1067 progressType = PROGRESS_RESET;
1068 else if (Seconds(progress->date) < (nextDailyResetTime - 1_days))
1069 // last progress is between 1 and 2 days. => 1st time of the day.
1070 progressType = PROGRESS_ACCUMULATE;
1071 else
1072 // last progress is within the day before the reset => Already counted today.
1073 continue;
1074
1075 SetCriteriaProgress(achievementCriteria, 1, progressType);
1076 break;
1077 }
1079 {
1080 // speedup for non-login case
1081 if (miscValue1 && miscValue1 != achievementCriteria->complete_quests_in_zone.zoneID)
1082 continue;
1083
1084 uint32 counter = 0;
1085
1086 const RewardedQuestSet& rewQuests = GetPlayer()->getRewardedQuests();
1087 for (RewardedQuestSet::const_iterator itr = rewQuests.begin(); itr != rewQuests.end(); ++itr)
1088 {
1089 Quest const* quest = sObjectMgr->GetQuestTemplate(*itr);
1090 if (quest && quest->GetZoneOrSort() >= 0 && uint32(quest->GetZoneOrSort()) == achievementCriteria->complete_quests_in_zone.zoneID && !(quest->HasSpecialFlag(QUEST_SPECIAL_FLAGS_NO_LOREMASTER_COUNT)))
1091 ++counter;
1092 }
1093 SetCriteriaProgress(achievementCriteria, counter);
1094 break;
1095 }
1097 // AchievementMgr::UpdateAchievementCriteria might also be called on login - skip in this case
1098 if (!miscValue1)
1099 continue;
1100 if (GetPlayer()->GetMapId() != achievementCriteria->complete_battleground.mapID)
1101 continue;
1102 SetCriteriaProgress(achievementCriteria, 1, PROGRESS_ACCUMULATE);
1103 break;
1105 // AchievementMgr::UpdateAchievementCriteria might also be called on login - skip in this case
1106 if (!miscValue1)
1107 continue;
1108 if (GetPlayer()->GetMapId() != achievementCriteria->death_at_map.mapID)
1109 continue;
1110 SetCriteriaProgress(achievementCriteria, 1, PROGRESS_ACCUMULATE);
1111 break;
1113 {
1114 // AchievementMgr::UpdateAchievementCriteria might also be called on login - skip in this case
1115 if (!miscValue1)
1116 continue;
1117 // skip wrong arena achievements, if not achievIdByArenaSlot then normal total death counter
1118 bool notfit = false;
1119 for (int j = 0; j < MAX_ARENA_SLOT; ++j)
1120 {
1121 if (achievIdByArenaSlot[j] == achievement->ID)
1122 {
1124 if (!bg || !bg->isArena() || ArenaTeam::GetSlotByType(bg->GetArenaType()) != j)
1125 notfit = true;
1126
1127 break;
1128 }
1129 }
1130 if (notfit)
1131 continue;
1132
1133 SetCriteriaProgress(achievementCriteria, 1, PROGRESS_ACCUMULATE);
1134 break;
1135 }
1137 {
1138 // AchievementMgr::UpdateAchievementCriteria might also be called on login - skip in this case
1139 if (!miscValue1)
1140 continue;
1141
1142 Map const* map = GetPlayer()->IsInWorld() ? GetPlayer()->GetMap() : sMapMgr->FindMap(GetPlayer()->GetMapId(), GetPlayer()->GetInstanceId());
1143 if (!map || !map->IsDungeon())
1144 continue;
1145
1146 // search case
1147 bool found = false;
1148 for (int j = 0; achievIdForDungeon[j][0]; ++j)
1149 {
1150 if (achievIdForDungeon[j][0] == achievement->ID)
1151 {
1152 if (map->IsRaid())
1153 {
1154 // if raid accepted (ignore difficulty)
1155 if (!achievIdForDungeon[j][2])
1156 break; // for
1157 }
1158 else if (GetPlayer()->GetDungeonDifficulty() == DUNGEON_DIFFICULTY_NORMAL)
1159 {
1160 // dungeon in normal mode accepted
1161 if (!achievIdForDungeon[j][1])
1162 break; // for
1163 }
1164 else
1165 {
1166 // dungeon in heroic mode accepted
1167 if (!achievIdForDungeon[j][3])
1168 break; // for
1169 }
1170
1171 found = true;
1172 break; // for
1173 }
1174 }
1175 if (!found)
1176 continue;
1177
1178 //FIXME: work only for instances where max == min for players
1179 if (map->ToInstanceMap()->GetMaxPlayers() != achievementCriteria->death_in_dungeon.manLimit)
1180 continue;
1181 SetCriteriaProgress(achievementCriteria, 1, PROGRESS_ACCUMULATE);
1182 break;
1183 }
1185 {
1186 // AchievementMgr::UpdateAchievementCriteria might also be called on login - skip in this case
1187 if (!miscValue1)
1188 continue;
1189
1190 Map const* map = GetPlayer()->IsInWorld() ? GetPlayer()->GetMap() : sMapMgr->FindMap(GetPlayer()->GetMapId(), GetPlayer()->GetInstanceId());
1191 if (!map || !map->IsDungeon())
1192 continue;
1193
1194 if (map->ToInstanceMap()->GetMaxPlayers() != achievementCriteria->complete_raid.groupSize)
1195 continue;
1196 SetCriteriaProgress(achievementCriteria, 1, PROGRESS_ACCUMULATE);
1197 break;
1198 }
1200 // AchievementMgr::UpdateAchievementCriteria might also be called on login - skip in this case
1201 if (!miscValue1)
1202 continue;
1203 if (miscValue1 != achievementCriteria->killed_by_creature.creatureEntry)
1204 continue;
1205 SetCriteriaProgress(achievementCriteria, 1, PROGRESS_ACCUMULATE);
1206 break;
1208 // AchievementMgr::UpdateAchievementCriteria might also be called on login - skip in this case
1209 if (!miscValue1)
1210 continue;
1211
1212 // if team check required: must kill by opposition faction
1213 if (achievement->ID == 318 && miscValue2 == GetPlayer()->GetTeamId())
1214 continue;
1215
1216 SetCriteriaProgress(achievementCriteria, 1, PROGRESS_ACCUMULATE);
1217 break;
1219 {
1220 // AchievementMgr::UpdateAchievementCriteria might also be called on login - skip in this case
1221 if (!miscValue1)
1222 continue;
1223
1224 // those requirements couldn't be found in the dbc
1225 AchievementCriteriaDataSet const* data = sAchievementMgr->GetCriteriaDataSet(achievementCriteria);
1226 if (!data || !data->Meets(GetPlayer(), unit))
1227 continue;
1228
1229 // miscvalue1 is the ingame fallheight*100 as stored in dbc
1230 SetCriteriaProgress(achievementCriteria, miscValue1);
1231 break;
1232 }
1234 // AchievementMgr::UpdateAchievementCriteria might also be called on login - skip in this case
1235 if (!miscValue1)
1236 continue;
1237 if (miscValue2 != achievementCriteria->death_from.type)
1238 continue;
1239 SetCriteriaProgress(achievementCriteria, 1, PROGRESS_ACCUMULATE);
1240 break;
1242 {
1243 // if miscvalues != 0, it contains the questID.
1244 if (miscValue1)
1245 {
1246 if (miscValue1 != achievementCriteria->complete_quest.questID)
1247 continue;
1248 }
1249 else
1250 {
1251 // login case.
1252 if (!GetPlayer()->GetQuestRewardStatus(achievementCriteria->complete_quest.questID))
1253 continue;
1254 }
1255
1256 if (AchievementCriteriaDataSet const* data = sAchievementMgr->GetCriteriaDataSet(achievementCriteria))
1257 if (!data->Meets(GetPlayer(), unit))
1258 continue;
1259
1260 SetCriteriaProgress(achievementCriteria, 1);
1261 break;
1262 }
1265 {
1266 if (!miscValue1 || miscValue1 != achievementCriteria->be_spell_target.spellID)
1267 continue;
1268
1269 // those requirements couldn't be found in the dbc
1270 AchievementCriteriaDataSet const* data = sAchievementMgr->GetCriteriaDataSet(achievementCriteria);
1271 if (!data)
1272 continue;
1273
1274 if (!data->Meets(GetPlayer(), unit))
1275 continue;
1276
1277 SetCriteriaProgress(achievementCriteria, 1, PROGRESS_ACCUMULATE);
1278 break;
1279 }
1282 {
1283 if (!miscValue1 || miscValue1 != achievementCriteria->cast_spell.spellID)
1284 continue;
1285
1286 // those requirements couldn't be found in the dbc
1287 AchievementCriteriaDataSet const* data = sAchievementMgr->GetCriteriaDataSet(achievementCriteria);
1288 if (!data)
1289 continue;
1290
1291 if (!data->Meets(GetPlayer(), unit))
1292 continue;
1293
1294 SetCriteriaProgress(achievementCriteria, 1, PROGRESS_ACCUMULATE);
1295 break;
1296 }
1298 if (miscValue1 && miscValue1 != achievementCriteria->learn_spell.spellID)
1299 continue;
1300
1301 if (GetPlayer()->HasSpell(achievementCriteria->learn_spell.spellID))
1302 SetCriteriaProgress(achievementCriteria, 1);
1303 break;
1305 {
1306 // miscvalue1=loot_type (note: 0 = LOOT_CORPSE and then it ignored)
1307 // miscvalue2=count of item loot
1308 if (!miscValue1 || !miscValue2)
1309 continue;
1310 if (miscValue1 != achievementCriteria->loot_type.lootType)
1311 continue;
1312
1313 // zone specific
1314 if (achievementCriteria->loot_type.lootTypeCount == 1)
1315 {
1316 // those requirements couldn't be found in the dbc
1317 AchievementCriteriaDataSet const* data = sAchievementMgr->GetCriteriaDataSet(achievementCriteria);
1318 if (!data || !data->Meets(GetPlayer(), unit))
1319 continue;
1320 }
1321
1322 SetCriteriaProgress(achievementCriteria, miscValue2, PROGRESS_ACCUMULATE);
1323 break;
1324 }
1326 // speedup for non-login case
1327 if (miscValue1 && achievementCriteria->own_item.itemID != miscValue1)
1328 continue;
1329 SetCriteriaProgress(achievementCriteria, miscValue2, PROGRESS_ACCUMULATE);
1330 break;
1332 if (!miscValue1) // no update at login
1333 continue;
1334
1335 // additional requirements
1337 {
1338 // those requirements couldn't be found in the dbc
1339 AchievementCriteriaDataSet const* data = sAchievementMgr->GetCriteriaDataSet(achievementCriteria);
1340 if (!data || !data->Meets(GetPlayer(), unit, miscValue1))
1341 {
1342 // reset the progress as we have a win without the requirement.
1343 SetCriteriaProgress(achievementCriteria, 0);
1344 continue;
1345 }
1346 }
1347
1348 SetCriteriaProgress(achievementCriteria, 1, PROGRESS_ACCUMULATE);
1349 break;
1351 // AchievementMgr::UpdateAchievementCriteria might also be called on login - skip in this case
1352 if (!miscValue1)
1353 continue;
1354
1355 if (achievementCriteria->use_item.itemID != miscValue1)
1356 continue;
1357
1358 // Children's Week achievements have extra requirements
1359 //if (achievement->categoryId == CATEGORY_CHILDRENS_WEEK || achievement->ID == 1291) // Lonely?
1360 {
1361 // Xinef: skip progress only if data exists and is not meet
1362 AchievementCriteriaDataSet const* data = sAchievementMgr->GetCriteriaDataSet(achievementCriteria);
1363 if (data && !data->Meets(GetPlayer(), nullptr))
1364 continue;
1365 }
1366
1367 SetCriteriaProgress(achievementCriteria, 1, PROGRESS_ACCUMULATE);
1368 break;
1370 // You _have_ to loot that item, just owning it when logging in does _not_ count!
1371 if (!miscValue1)
1372 continue;
1373 if (miscValue1 != achievementCriteria->own_item.itemID)
1374 continue;
1375 SetCriteriaProgress(achievementCriteria, miscValue2, PROGRESS_ACCUMULATE);
1376 break;
1378 {
1379 WorldMapOverlayEntry const* worldOverlayEntry = sWorldMapOverlayStore.LookupEntry(achievementCriteria->explore_area.areaReference);
1380 if (!worldOverlayEntry)
1381 break;
1382
1383 bool matchFound = false;
1384 for (int j = 0; j < MAX_WORLD_MAP_OVERLAY_AREA_IDX; ++j)
1385 {
1386 AreaTableEntry const* area = sAreaTableStore.LookupEntry(worldOverlayEntry->areatableID[j]);
1387 if (!area)
1388 break;
1389
1390 uint32 playerIndexOffset = uint32(area->exploreFlag) / 32;
1391 if (playerIndexOffset >= PLAYER_EXPLORED_ZONES_SIZE)
1392 continue;
1393
1394 uint32 mask = 1 << (uint32(area->exploreFlag) % 32);
1395 if (GetPlayer()->GetUInt32Value(PLAYER_EXPLORED_ZONES_1 + playerIndexOffset) & mask)
1396 {
1397 matchFound = true;
1398 break;
1399 }
1400 }
1401
1402 if (matchFound)
1403 SetCriteriaProgress(achievementCriteria, 1);
1404 break;
1405 }
1407 SetCriteriaProgress(achievementCriteria, GetPlayer()->GetBankBagSlotCount());
1408 break;
1410 {
1411 // skip faction check only at loading
1412 if (miscValue1 && miscValue1 != achievementCriteria->gain_reputation.factionID)
1413 continue;
1414
1415 int32 reputation = GetPlayer()->GetReputationMgr().GetReputation(achievementCriteria->gain_reputation.factionID);
1416 if (reputation > 0)
1417 SetCriteriaProgress(achievementCriteria, reputation);
1418 break;
1419 }
1421 {
1422 SetCriteriaProgress(achievementCriteria, GetPlayer()->GetReputationMgr().GetExaltedFactionCount());
1423 break;
1424 }
1426 {
1427 // skip for login case
1428 if (!miscValue1)
1429 continue;
1430 SetCriteriaProgress(achievementCriteria, 1);
1431 break;
1432 }
1434 {
1435 // miscvalue1 = itemid
1436 // miscvalue2 = itemSlot
1437 if (!miscValue1)
1438 continue;
1439
1440 if (miscValue2 != achievementCriteria->equip_epic_item.itemSlot)
1441 continue;
1442
1443 // check item level and quality via achievement_criteria_data
1444 AchievementCriteriaDataSet const* data = sAchievementMgr->GetCriteriaDataSet(achievementCriteria);
1445 if (!data || !data->Meets(GetPlayer(), 0, miscValue1))
1446 continue;
1447
1448 SetCriteriaProgress(achievementCriteria, 1);
1449 break;
1450 }
1451
1454 {
1455 // miscvalue1 = itemid
1456 // miscvalue2 = diced value
1457 if (!miscValue1)
1458 continue;
1459 if (miscValue2 != achievementCriteria->roll_greed_on_loot.rollValue)
1460 continue;
1461
1462 ItemTemplate const* pProto = sObjectMgr->GetItemTemplate(miscValue1);
1463 if (!pProto)
1464 continue;
1465
1466 // check item level via achievement_criteria_data
1467 AchievementCriteriaDataSet const* data = sAchievementMgr->GetCriteriaDataSet(achievementCriteria);
1468 if (!data || !data->Meets(GetPlayer(), 0, pProto->ItemLevel))
1469 continue;
1470
1471 SetCriteriaProgress(achievementCriteria, 1, PROGRESS_ACCUMULATE);
1472 break;
1473 }
1475 {
1476 // miscvalue1 = emote
1477 if (!miscValue1)
1478 continue;
1479 if (miscValue1 != achievementCriteria->do_emote.emoteID)
1480 continue;
1481 if (achievementCriteria->do_emote.count)
1482 {
1483 // those requirements couldn't be found in the dbc
1484 AchievementCriteriaDataSet const* data = sAchievementMgr->GetCriteriaDataSet(achievementCriteria);
1485 if (!data || !data->Meets(GetPlayer(), unit))
1486 continue;
1487 }
1488
1489 SetCriteriaProgress(achievementCriteria, 1, PROGRESS_ACCUMULATE);
1490 break;
1491 }
1494 {
1495 if (!miscValue1)
1496 continue;
1497
1499 {
1500 if (GetPlayer()->GetMapId() != achievementCriteria->additionalRequirements[0].additionalRequirement_value)
1501 continue;
1502
1503 // map specific case (BG in fact) expected player targeted damage/heal
1504 if (!unit || !unit->IsPlayer())
1505 continue;
1506 }
1507
1508 SetCriteriaProgress(achievementCriteria, miscValue1, PROGRESS_ACCUMULATE);
1509 break;
1510 }
1512 // miscvalue1 = item_id
1513 if (!miscValue1)
1514 continue;
1515 if (miscValue1 != achievementCriteria->equip_item.itemID)
1516 continue;
1517
1518 SetCriteriaProgress(achievementCriteria, 1);
1519 break;
1521 // miscvalue1 = go entry
1522 if (!miscValue1)
1523 continue;
1524 if (miscValue1 != achievementCriteria->use_gameobject.goEntry)
1525 continue;
1526
1527 SetCriteriaProgress(achievementCriteria, 1, PROGRESS_ACCUMULATE);
1528 break;
1530 if (!miscValue1)
1531 continue;
1532 if (miscValue1 != achievementCriteria->fish_in_gameobject.goEntry)
1533 continue;
1534
1535 SetCriteriaProgress(achievementCriteria, 1, PROGRESS_ACCUMULATE);
1536 break;
1538 {
1539 if (miscValue1 && miscValue1 != achievementCriteria->learn_skillline_spell.skillLine)
1540 continue;
1541
1542 uint32 spellCount = 0;
1543 for (PlayerSpellMap::const_iterator spellIter = GetPlayer()->GetSpellMap().begin(); spellIter != GetPlayer()->GetSpellMap().end(); ++spellIter)
1544 {
1545 SkillLineAbilityMapBounds bounds = sSpellMgr->GetSkillLineAbilityMapBounds(spellIter->first);
1546 for (SkillLineAbilityMap::const_iterator skillIter = bounds.first; skillIter != bounds.second; ++skillIter)
1547 {
1548 if (skillIter->second->SkillLine == achievementCriteria->learn_skillline_spell.skillLine)
1549 {
1550 // xinef: do not add couter twice if by any chance skill is listed twice in dbc (eg. skill 777 and spell 22717)
1551 ++spellCount;
1552 break;
1553 }
1554 }
1555 }
1556
1557 SetCriteriaProgress(achievementCriteria, spellCount);
1558 break;
1559 }
1561 // AchievementMgr::UpdateAchievementCriteria might also be called on login - skip in this case
1562 if (!miscValue1)
1563 continue;
1564
1565 if (achievementCriteria->win_duel.duelCount)
1566 {
1567 // those requirements couldn't be found in the dbc
1568 AchievementCriteriaDataSet const* data = sAchievementMgr->GetCriteriaDataSet(achievementCriteria);
1569 if (!data)
1570 continue;
1571
1572 if (!data->Meets(GetPlayer(), unit))
1573 continue;
1574 }
1575
1576 SetCriteriaProgress(achievementCriteria, 1, PROGRESS_ACCUMULATE);
1577 break;
1579 SetCriteriaProgress(achievementCriteria, GetPlayer()->GetReputationMgr().GetReveredFactionCount());
1580 break;
1582 SetCriteriaProgress(achievementCriteria, GetPlayer()->GetReputationMgr().GetHonoredFactionCount());
1583 break;
1585 SetCriteriaProgress(achievementCriteria, GetPlayer()->GetReputationMgr().GetVisibleFactionCount());
1586 break;
1589 {
1590 // AchievementMgr::UpdateAchievementCriteria might also be called on login - skip in this case
1591 if (!miscValue1)
1592 continue;
1593 ItemTemplate const* proto = sObjectMgr->GetItemTemplate(miscValue1);
1594 if (!proto || proto->Quality < ITEM_QUALITY_EPIC)
1595 continue;
1596 AchievementCriteriaDataSet const* data = sAchievementMgr->GetCriteriaDataSet(achievementCriteria);
1597 if (!data || !data->Meets(GetPlayer(), unit, miscValue1))
1598 continue;
1599 SetCriteriaProgress(achievementCriteria, 1, PROGRESS_ACCUMULATE);
1600 break;
1601 }
1603 {
1604 if (miscValue1 && miscValue1 != achievementCriteria->learn_skill_line.skillLine)
1605 continue;
1606
1607 uint32 spellCount = 0;
1608 for (PlayerSpellMap::const_iterator spellIter = GetPlayer()->GetSpellMap().begin(); spellIter != GetPlayer()->GetSpellMap().end(); ++spellIter)
1609 {
1610 SkillLineAbilityMapBounds bounds = sSpellMgr->GetSkillLineAbilityMapBounds(spellIter->first);
1611 for (SkillLineAbilityMap::const_iterator skillIter = bounds.first; skillIter != bounds.second; ++skillIter)
1612 {
1613 if (skillIter->second->SkillLine == achievementCriteria->learn_skill_line.skillLine)
1614 {
1615 // xinef: do not add couter twice if by any chance skill is listed twice in dbc (eg. skill 777 and spell 22717)
1616 ++spellCount;
1617 break;
1618 }
1619 }
1620 }
1621
1622 SetCriteriaProgress(achievementCriteria, spellCount);
1623 break;
1624 }
1626 SetCriteriaProgress(achievementCriteria, GetPlayer()->GetUInt32Value(PLAYER_FIELD_LIFETIME_HONORABLE_KILLS));
1627 break;
1629 if (!miscValue1 || miscValue1 != achievementCriteria->hk_class.classID)
1630 continue;
1631
1632 SetCriteriaProgress(achievementCriteria, 1, PROGRESS_ACCUMULATE);
1633 break;
1635 if (!miscValue1 || miscValue1 != achievementCriteria->hk_race.raceID)
1636 continue;
1637
1638 SetCriteriaProgress(achievementCriteria, 1, PROGRESS_ACCUMULATE);
1639 break;
1641 SetCriteriaProgress(achievementCriteria, GetPlayer()->GetMoney(), PROGRESS_HIGHEST);
1642 break;
1644 {
1645 if (!miscValue1)
1646 {
1647 uint32 points = 0;
1648 for (CompletedAchievementMap::iterator itr = _completedAchievements.begin(); itr != _completedAchievements.end(); ++itr)
1649 if (AchievementEntry const* pAchievement = sAchievementStore.LookupEntry(itr->first))
1650 points += pAchievement->points;
1651 SetCriteriaProgress(achievementCriteria, points, PROGRESS_SET);
1652 }
1653 else
1654 SetCriteriaProgress(achievementCriteria, miscValue1, PROGRESS_ACCUMULATE);
1655 break;
1656 }
1658 {
1659 if (!miscValue1 || miscValue1 != achievementCriteria->bg_objective.objectiveId)
1660 continue;
1661
1662 // those requirements couldn't be found in the dbc
1663 AchievementCriteriaDataSet const* data = sAchievementMgr->GetCriteriaDataSet(achievementCriteria);
1664 if (!data || !data->Meets(GetPlayer(), unit))
1665 continue;
1666
1667 SetCriteriaProgress(achievementCriteria, 1, PROGRESS_ACCUMULATE);
1668 break;
1669 }
1673 {
1674 // skip login update
1675 if (!miscValue1)
1676 continue;
1677
1678 // those requirements couldn't be found in the dbc
1679 AchievementCriteriaDataSet const* data = sAchievementMgr->GetCriteriaDataSet(achievementCriteria);
1680 if (!data || !data->Meets(GetPlayer(), unit))
1681 continue;
1682
1683 SetCriteriaProgress(achievementCriteria, 1, PROGRESS_ACCUMULATE);
1684 break;
1685 }
1687 {
1688 if (!miscValue1 || miscValue1 != achievementCriteria->honorable_kill_at_area.areaID)
1689 continue;
1690
1691 SetCriteriaProgress(achievementCriteria, 1, PROGRESS_ACCUMULATE);
1692 break;
1693 }
1695 {
1696 uint32 reqTeamType = achievementCriteria->highest_team_rating.teamtype;
1697
1698 if (miscValue1)
1699 {
1700 if (miscValue2 != reqTeamType)
1701 continue;
1702
1703 SetCriteriaProgress(achievementCriteria, miscValue1, PROGRESS_HIGHEST);
1704 }
1705 else // login case
1706 {
1707 for (uint32 arena_slot = 0; arena_slot < MAX_ARENA_SLOT; ++arena_slot)
1708 {
1709 uint32 arenaTeamId = GetPlayer()->GetArenaTeamId(arena_slot);
1710 if (!arenaTeamId)
1711 continue;
1712
1713 ArenaTeam* team = sArenaTeamMgr->GetArenaTeamById(arenaTeamId);
1714 if (!team || team->GetType() != reqTeamType)
1715 continue;
1716
1717 SetCriteriaProgress(achievementCriteria, team->GetStats().Rating, PROGRESS_HIGHEST);
1718 break;
1719 }
1720 }
1721
1722 break;
1723 }
1725 {
1726 uint32 reqTeamType = achievementCriteria->highest_personal_rating.teamtype;
1727
1728 if (miscValue1)
1729 {
1730 if (miscValue2 != reqTeamType)
1731 continue;
1732
1733 SetCriteriaProgress(achievementCriteria, miscValue1, PROGRESS_HIGHEST);
1734 }
1735 else // login case
1736 {
1737 for (uint32 arena_slot = 0; arena_slot < MAX_ARENA_SLOT; ++arena_slot)
1738 {
1739 uint32 arenaTeamId = GetPlayer()->GetArenaTeamId(arena_slot);
1740 if (!arenaTeamId)
1741 continue;
1742
1743 ArenaTeam* team = sArenaTeamMgr->GetArenaTeamById(arenaTeamId);
1744 if (!team || team->GetType() != reqTeamType)
1745 continue;
1746
1747 if (ArenaTeamMember const* member = team->GetMember(GetPlayer()->GetGUID()))
1748 {
1749 SetCriteriaProgress(achievementCriteria, member->PersonalRating, PROGRESS_HIGHEST);
1750 break;
1751 }
1752 }
1753 }
1754
1755 break;
1756 }
1758 {
1759 // This criteria is only called directly after login - with expected miscvalue1 == 1
1760 if (!miscValue1)
1761 continue;
1762
1763 // They have no proper requirements in dbc
1764 AchievementCriteriaDataSet const* data = sAchievementMgr->GetCriteriaDataSet(achievementCriteria);
1765 if (!data || !data->Meets(GetPlayer(), unit))
1766 continue;
1767
1768 SetCriteriaProgress(achievementCriteria, 1, PROGRESS_ACCUMULATE);
1769 break;
1770 }
1772 case ACHIEVEMENT_CRITERIA_TYPE_WIN_ARENA: // This also behaves like ACHIEVEMENT_CRITERIA_TYPE_WIN_RATED_ARENA
1773 {
1774 // those requirements couldn't be found in the dbc
1775 AchievementCriteriaDataSet const* data = sAchievementMgr->GetCriteriaDataSet(achievementCriteria);
1776 if (!data || !data->Meets(GetPlayer(), nullptr))
1777 continue;
1778
1779 // Check map id requirement
1780 if (miscValue1 == achievementCriteria->win_arena.mapID)
1781 SetCriteriaProgress(achievementCriteria, 1, PROGRESS_ACCUMULATE);
1782 break;
1783 }
1785 {
1786 // those requirements couldn't be found in the dbc
1787 AchievementCriteriaDataSet const* data = sAchievementMgr->GetCriteriaDataSet(achievementCriteria);
1788 if (!data || !data->Meets(GetPlayer(), nullptr))
1789 continue;
1790
1791 SetCriteriaProgress(achievementCriteria, 1);
1792 break;
1793 }
1794 // std case: not exist in DBC, not triggered in code as result
1801 break;
1802 // FIXME: not triggered in code as result, need to implement
1804 break; // Not implemented yet :(
1805 }
1806
1807 if (IsCompletedCriteria(achievementCriteria, achievement))
1808 CompletedCriteriaFor(achievement);
1809
1810 // check again the completeness for SUMM and REQ COUNT achievements,
1811 // as they don't depend on the completed criteria but on the sum of the progress of each individual criteria
1812 if (achievement->flags & ACHIEVEMENT_FLAG_SUMM)
1813 if (IsCompletedAchievement(achievement))
1814 CompletedAchievement(achievement);
1815
1816 if (AchievementEntryList const* achRefList = sAchievementMgr->GetAchievementByReferencedId(achievement->ID))
1817 for (AchievementEntryList::const_iterator itr = achRefList->begin(); itr != achRefList->end(); ++itr)
1818 if (IsCompletedAchievement(*itr))
1820 }
1821}
std::chrono::seconds Seconds
Seconds shorthand typedef.
Definition: Duration.h:30
#define sArenaTeamMgr
Definition: ArenaTeamMgr.h:67
#define MAX_ARENA_SLOT
Definition: ArenaTeam.h:135
#define sMapMgr
Definition: MapMgr.h:221
@ QUEST_SPECIAL_FLAGS_NO_LOREMASTER_COUNT
Definition: QuestDef.h:168
#define sObjectMgr
Definition: ObjectMgr.h:1623
DBCStorage< WorldMapOverlayEntry > sWorldMapOverlayStore(WorldMapOverlayEntryfmt)
DBCStorage< AreaTableEntry > sAreaTableStore(AreaTableEntryfmt)
static const uint32 achievIdByArenaSlot[MAX_ARENA_SLOT]
Definition: AchievementMgr.cpp:807
static const uint32 achievIdForDungeon[][4]
Definition: AchievementMgr.cpp:808
@ PLAYER_EXPLORED_ZONES_1
Definition: UpdateFields.h:357
@ PLAYER_FIELD_LIFETIME_HONORABLE_KILLS
Definition: UpdateFields.h:377
std::unordered_set< uint32 > RewardedQuestSet
Definition: Player.h:615
#define PLAYER_EXPLORED_ZONES_SIZE
Definition: Player.h:72
#define sSpellMgr
Definition: SpellMgr.h:825
std::pair< SkillLineAbilityMap::const_iterator, SkillLineAbilityMap::const_iterator > SkillLineAbilityMapBounds
Definition: SpellMgr.h:584
@ ITEM_QUALITY_EPIC
Definition: SharedDefines.h:333
#define MAX_WORLD_MAP_OVERLAY_AREA_IDX
Definition: DBCStructure.h:2162
@ DUNGEON_DIFFICULTY_NORMAL
Definition: DBCEnums.h:269
@ ACHIEVEMENT_CRITERIA_CONDITION_NO_LOSE
Definition: DBCEnums.h:91
@ ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_POWER
Definition: DBCEnums.h:203
@ ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_HIT_RECEIVED
Definition: DBCEnums.h:209
@ ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_HEALING_RECEIVED
Definition: DBCEnums.h:213
@ ACHIEVEMENT_CRITERIA_TYPE_TOTAL_HEALING_RECEIVED
Definition: DBCEnums.h:212
@ ACHIEVEMENT_CRITERIA_TYPE_GOLD_SPENT_FOR_TRAVELLING
Definition: DBCEnums.h:176
@ ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_RATING
Definition: DBCEnums.h:207
@ ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_HEAL_CASTED
Definition: DBCEnums.h:211
@ ACHIEVEMENT_CRITERIA_TYPE_TOTAL_DAMAGE_RECEIVED
Definition: DBCEnums.h:210
@ ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_STAT
Definition: DBCEnums.h:204
@ ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_HIT_DEALT
Definition: DBCEnums.h:208
@ CATEGORY_CHILDRENS_WEEK
Definition: DBCEnums.h:229
Definition: AchievementMgr.h:247
bool Meets(Player const *source, Unit const *target, uint32 miscvalue=0) const
Definition: AchievementMgr.cpp:472
void CompletedCriteriaFor(AchievementEntry const *achievement)
Definition: AchievementMgr.cpp:2013
ProgressType
Definition: AchievementMgr.h:321
bool CanUpdateCriteria(AchievementCriteriaEntry const *criteria, AchievementEntry const *achievement)
Definition: AchievementMgr.cpp:2439
Definition: ArenaTeam.h:109
uint16 Rating
Definition: ArenaTeam.h:127
Definition: ArenaTeam.h:138
ArenaTeamMember * GetMember(ObjectGuid guid)
Definition: ArenaTeam.cpp:1012
uint32 GetType() const
Definition: ArenaTeam.h:150
const ArenaTeamStats & GetStats() const
Definition: ArenaTeam.h:156
static uint8 GetSlotByType(uint32 type)
Definition: ArenaTeam.cpp:618
Definition: Battleground.h:298
uint8 GetArenaType() const
Definition: Battleground.h:340
bool isArena() const
Definition: Battleground.h:396
Definition: ItemTemplate.h:619
uint32 Quality
Definition: ItemTemplate.h:626
uint32 ItemLevel
Definition: ItemTemplate.h:635
bool IsPlayer() const
Definition: Object.h:197
uint32 GetUInt32Value(uint16 index) const
Definition: Object.cpp:305
Map * GetMap() const
Definition: Object.h:531
RewardedQuestSet const & getRewardedQuests() const
Definition: Player.h:1613
Battleground * GetBattleground(bool create=false) const
Definition: Player.cpp:12192
PlayerSpellMap const & GetSpellMap() const
Definition: Player.h:1756
uint32 GetArenaTeamId(uint8 slot) const
Definition: Player.cpp:16212
ReputationMgr & GetReputationMgr()
Definition: Player.h:2105
Definition: Map.h:313
bool IsDungeon() const
Definition: Map.h:448
bool IsRaid() const
Definition: Map.h:450
InstanceMap * ToInstanceMap()
Definition: Map.h:546
uint32 GetMaxPlayers() const
Definition: Map.cpp:3214
Definition: QuestDef.h:210
bool HasSpecialFlag(uint32 flag) const
Definition: QuestDef.h:224
int32 GetZoneOrSort() const
Definition: QuestDef.h:230
int32 GetReputation(uint32 faction_id) const
Definition: ReputationMgr.cpp:78
uint32 categoryId
Definition: DBCStructure.h:49
struct AchievementCriteriaEntry::@307::@339 use_item
struct AchievementCriteriaEntry::@307::@319 complete_battleground
struct AchievementCriteriaEntry::@307::@329 bg_objective
struct AchievementCriteriaEntry::@307::@326 complete_quest
uint32 areaReference
Definition: DBCStructure.h:290
struct AchievementCriteriaEntry::@307::@320 death_at_map
struct AchievementCriteriaEntry::@307::@325 death_from
uint32 creatureEntry
Definition: DBCStructure.h:166
struct AchievementCriteriaEntry::@307::@360 fish_in_gameobject
uint32 skillLine
Definition: DBCStructure.h:432
struct AchievementCriteriaEntry::@307::@311 win_bg
uint32 objectiveId
Definition: DBCStructure.h:208
struct AchievementCriteriaEntry::@307::@321 death_in_dungeon
struct AchievementCriteriaEntry::@307::@362 win_duel
struct AchievementCriteriaEntry::@307::@349 roll_greed_on_loot
uint32 bgMapID
Definition: DBCStructure.h:87
struct AchievementCriteriaEntry::@307::@314 complete_achievement
struct AchievementCriteriaEntry::@307::@330 honorable_kill_at_area
uint32 manLimit
Definition: DBCStructure.h:154
uint32 zoneID
Definition: DBCStructure.h:128
uint32 itemID
Definition: DBCStructure.h:241
uint32 mapID
Definition: DBCStructure.h:142
struct AchievementCriteriaEntry::@307::@355 equip_item
uint32 rollValue
Definition: DBCStructure.h:339
uint32 spellID
Definition: DBCStructure.h:193
struct AchievementCriteriaEntry::@307::@317 complete_quests_in_zone
uint32 groupSize
Definition: DBCStructure.h:160
uint32 goEntry
Definition: DBCStructure.h:410
struct AchievementCriteriaEntry::@307::@361 learn_skillline_spell
struct AchievementCriteriaEntry::@307::@338 learn_skill_level
struct AchievementCriteriaEntry::@307::@327 be_spell_target
struct AchievementCriteriaEntry::@307::@368 learn_skill_line
uint32 emoteID
Definition: DBCStructure.h:367
uint32 skillID
Definition: DBCStructure.h:101
uint32 lootTypeCount
Definition: DBCStructure.h:471
struct AchievementCriteriaEntry::@307::@323 killed_by_creature
uint32 type
Definition: DBCStructure.h:179
struct AchievementCriteriaEntry::@307::@351 hk_race
uint32 classID
Definition: DBCStructure.h:352
uint32 lootType
Definition: DBCStructure.h:470
struct AchievementCriteriaEntry::@307::@367 loot_type
struct AchievementCriteriaEntry::@307::@328 cast_spell
struct AchievementCriteriaEntry::@307::@337 highest_personal_rating
uint32 itemSlot
Definition: DBCStructure.h:332
struct AchievementCriteriaEntry::@307::@334 own_item
struct AchievementCriteriaEntry::@307::@313 reach_skill_level
uint32 questID
Definition: DBCStructure.h:185
uint32 duelCount
Definition: DBCStructure.h:440
struct AchievementCriteriaEntry::@309 additionalRequirements[MAX_CRITERIA_REQUIREMENTS]
struct AchievementCriteriaEntry::@307::@344 gain_reputation
struct AchievementCriteriaEntry::@307::@341 explore_area
uint32 raceID
Definition: DBCStructure.h:359
struct AchievementCriteriaEntry::@307::@347 equip_epic_item
uint32 additionalRequirement_value
Definition: DBCStructure.h:504
uint32 linkedAchievement
Definition: DBCStructure.h:108
uint32 areaID
Definition: DBCStructure.h:215
uint32 creatureID
Definition: DBCStructure.h:80
struct AchievementCriteriaEntry::@307::@358 use_gameobject
uint32 additionalRequirement_type
Definition: DBCStructure.h:503
struct AchievementCriteriaEntry::@307::@350 hk_class
struct AchievementCriteriaEntry::@307::@336 highest_team_rating
struct AchievementCriteriaEntry::@307::@333 learn_spell
uint32 teamtype
Definition: DBCStructure.h:255
struct AchievementCriteriaEntry::@307::@310 kill_creature
uint32 factionID
Definition: DBCStructure.h:310
struct AchievementCriteriaEntry::@307::@322 complete_raid
struct AchievementCriteriaEntry::@307::@331 win_arena
struct AchievementCriteriaEntry::@307::@352 do_emote
Definition: DBCStructure.h:519
uint32 exploreFlag
Definition: DBCStructure.h:523
Definition: DBCStructure.h:2165
uint32 areatableID[MAX_WORLD_MAP_OVERLAY_AREA_IDX]
Definition: DBCStructure.h:2168

References _completedAchievements, _player, ACHIEVEMENT_CRITERIA_CONDITION_BG_MAP, ACHIEVEMENT_CRITERIA_CONDITION_NO_LOSE, ACHIEVEMENT_CRITERIA_TYPE_ACCEPTED_SUMMONINGS, ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET, ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET2, ACHIEVEMENT_CRITERIA_TYPE_BG_OBJECTIVE_CAPTURE, ACHIEVEMENT_CRITERIA_TYPE_BUY_BANK_SLOT, ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL, ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL2, ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_ACHIEVEMENT, ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_BATTLEGROUND, ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_DAILY_QUEST, ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_DAILY_QUEST_DAILY, ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_QUEST, ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_QUEST_COUNT, ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_QUESTS_IN_ZONE, ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_RAID, ACHIEVEMENT_CRITERIA_TYPE_CREATE_AUCTION, ACHIEVEMENT_CRITERIA_TYPE_DAMAGE_DONE, ACHIEVEMENT_CRITERIA_TYPE_DEATH, ACHIEVEMENT_CRITERIA_TYPE_DEATH_AT_MAP, ACHIEVEMENT_CRITERIA_TYPE_DEATH_IN_DUNGEON, ACHIEVEMENT_CRITERIA_TYPE_DEATHS_FROM, ACHIEVEMENT_CRITERIA_TYPE_DO_EMOTE, ACHIEVEMENT_CRITERIA_TYPE_EARN_ACHIEVEMENT_POINTS, ACHIEVEMENT_CRITERIA_TYPE_EARN_HONORABLE_KILL, ACHIEVEMENT_CRITERIA_TYPE_EQUIP_EPIC_ITEM, ACHIEVEMENT_CRITERIA_TYPE_EQUIP_ITEM, ACHIEVEMENT_CRITERIA_TYPE_EXPLORE_AREA, ACHIEVEMENT_CRITERIA_TYPE_FALL_WITHOUT_DYING, ACHIEVEMENT_CRITERIA_TYPE_FISH_IN_GAMEOBJECT, ACHIEVEMENT_CRITERIA_TYPE_FLIGHT_PATHS_TAKEN, ACHIEVEMENT_CRITERIA_TYPE_GAIN_EXALTED_REPUTATION, ACHIEVEMENT_CRITERIA_TYPE_GAIN_HONORED_REPUTATION, ACHIEVEMENT_CRITERIA_TYPE_GAIN_REPUTATION, ACHIEVEMENT_CRITERIA_TYPE_GAIN_REVERED_REPUTATION, ACHIEVEMENT_CRITERIA_TYPE_GET_KILLING_BLOWS, ACHIEVEMENT_CRITERIA_TYPE_GOLD_EARNED_BY_AUCTIONS, ACHIEVEMENT_CRITERIA_TYPE_GOLD_SPENT_AT_BARBER, ACHIEVEMENT_CRITERIA_TYPE_GOLD_SPENT_FOR_MAIL, ACHIEVEMENT_CRITERIA_TYPE_GOLD_SPENT_FOR_TALENTS, ACHIEVEMENT_CRITERIA_TYPE_GOLD_SPENT_FOR_TRAVELLING, ACHIEVEMENT_CRITERIA_TYPE_HEALING_DONE, ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_ARMOR, ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_AUCTION_BID, ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_AUCTION_SOLD, ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_GOLD_VALUE_OWNED, ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_HEAL_CASTED, ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_HEALING_RECEIVED, ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_HEALTH, ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_HIT_DEALT, ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_HIT_RECEIVED, ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_PERSONAL_RATING, ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_POWER, ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_RATING, ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_SPELLPOWER, ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_STAT, ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_TEAM_RATING, ACHIEVEMENT_CRITERIA_TYPE_HK_CLASS, ACHIEVEMENT_CRITERIA_TYPE_HK_RACE, ACHIEVEMENT_CRITERIA_TYPE_HONORABLE_KILL, ACHIEVEMENT_CRITERIA_TYPE_HONORABLE_KILL_AT_AREA, ACHIEVEMENT_CRITERIA_TYPE_KILL_CREATURE, ACHIEVEMENT_CRITERIA_TYPE_KILL_CREATURE_TYPE, ACHIEVEMENT_CRITERIA_TYPE_KILLED_BY_CREATURE, ACHIEVEMENT_CRITERIA_TYPE_KILLED_BY_PLAYER, ACHIEVEMENT_CRITERIA_TYPE_KNOWN_FACTIONS, ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILL_LEVEL, ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILL_LINE, ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILLLINE_SPELLS, ACHIEVEMENT_CRITERIA_TYPE_LEARN_SPELL, ACHIEVEMENT_CRITERIA_TYPE_LOOT_EPIC_ITEM, ACHIEVEMENT_CRITERIA_TYPE_LOOT_ITEM, ACHIEVEMENT_CRITERIA_TYPE_LOOT_MONEY, ACHIEVEMENT_CRITERIA_TYPE_LOOT_TYPE, ACHIEVEMENT_CRITERIA_TYPE_LOSE_DUEL, ACHIEVEMENT_CRITERIA_TYPE_MONEY_FROM_QUEST_REWARD, ACHIEVEMENT_CRITERIA_TYPE_MONEY_FROM_VENDORS, ACHIEVEMENT_CRITERIA_TYPE_NUMBER_OF_TALENT_RESETS, ACHIEVEMENT_CRITERIA_TYPE_ON_LOGIN, ACHIEVEMENT_CRITERIA_TYPE_OWN_ITEM, ACHIEVEMENT_CRITERIA_TYPE_OWN_RANK, ACHIEVEMENT_CRITERIA_TYPE_PLAY_ARENA, ACHIEVEMENT_CRITERIA_TYPE_QUEST_ABANDONED, ACHIEVEMENT_CRITERIA_TYPE_REACH_LEVEL, ACHIEVEMENT_CRITERIA_TYPE_REACH_SKILL_LEVEL, ACHIEVEMENT_CRITERIA_TYPE_RECEIVE_EPIC_ITEM, ACHIEVEMENT_CRITERIA_TYPE_ROLL_DISENCHANT, ACHIEVEMENT_CRITERIA_TYPE_ROLL_GREED, ACHIEVEMENT_CRITERIA_TYPE_ROLL_GREED_ON_LOOT, ACHIEVEMENT_CRITERIA_TYPE_ROLL_NEED, ACHIEVEMENT_CRITERIA_TYPE_ROLL_NEED_ON_LOOT, ACHIEVEMENT_CRITERIA_TYPE_SPECIAL_PVP_KILL, ACHIEVEMENT_CRITERIA_TYPE_TOTAL, ACHIEVEMENT_CRITERIA_TYPE_TOTAL_DAMAGE_RECEIVED, ACHIEVEMENT_CRITERIA_TYPE_TOTAL_HEALING_RECEIVED, ACHIEVEMENT_CRITERIA_TYPE_USE_GAMEOBJECT, ACHIEVEMENT_CRITERIA_TYPE_USE_ITEM, ACHIEVEMENT_CRITERIA_TYPE_USE_LFD_TO_GROUP_WITH_PLAYERS, ACHIEVEMENT_CRITERIA_TYPE_VISIT_BARBER_SHOP, ACHIEVEMENT_CRITERIA_TYPE_WIN_ARENA, ACHIEVEMENT_CRITERIA_TYPE_WIN_BG, ACHIEVEMENT_CRITERIA_TYPE_WIN_DUEL, ACHIEVEMENT_CRITERIA_TYPE_WIN_RATED_ARENA, ACHIEVEMENT_CRITERIA_TYPE_WON_AUCTIONS, ACHIEVEMENT_FLAG_SUMM, achievIdByArenaSlot, achievIdForDungeon, AchievementCriteriaEntry::additionalRequirement_type, AchievementCriteriaEntry::additionalRequirement_value, AchievementCriteriaEntry::additionalRequirements, AchievementCriteriaEntry::areaID, AchievementCriteriaEntry::areaReference, WorldMapOverlayEntry::areatableID, AchievementCriteriaEntry::be_spell_target, AchievementCriteriaEntry::bg_objective, AchievementCriteriaEntry::bgMapID, CanUpdateCriteria(), AchievementCriteriaEntry::cast_spell, CATEGORY_CHILDRENS_WEEK, AchievementEntry::categoryId, AchievementCriteriaEntry::classID, AchievementCriteriaEntry::complete_achievement, AchievementCriteriaEntry::complete_battleground, AchievementCriteriaEntry::complete_quest, AchievementCriteriaEntry::complete_quests_in_zone, AchievementCriteriaEntry::complete_raid, CompletedAchievement(), CompletedCriteriaFor(), AchievementCriteriaEntry::count, AchievementCriteriaEntry::creatureEntry, AchievementCriteriaEntry::creatureID, CriteriaProgress::date, AchievementCriteriaEntry::death_at_map, AchievementCriteriaEntry::death_from, AchievementCriteriaEntry::death_in_dungeon, AchievementCriteriaEntry::do_emote, AchievementCriteriaEntry::duelCount, DUNGEON_DIFFICULTY_NORMAL, AchievementCriteriaEntry::emoteID, AchievementCriteriaEntry::equip_epic_item, AchievementCriteriaEntry::equip_item, AchievementCriteriaEntry::explore_area, AreaTableEntry::exploreFlag, AchievementCriteriaEntry::factionID, AchievementCriteriaEntry::fish_in_gameobject, AchievementEntry::flags, AchievementCriteriaEntry::gain_reputation, Player::GetArenaTeamId(), Battleground::GetArenaType(), Player::GetBattleground(), GetCriteriaProgress(), WorldObject::GetMap(), InstanceMap::GetMaxPlayers(), ArenaTeam::GetMember(), GetPlayer(), ReputationMgr::GetReputation(), Player::GetReputationMgr(), Player::getRewardedQuests(), ArenaTeam::GetSlotByType(), Player::GetSpellMap(), ArenaTeam::GetStats(), GetTeamId(), ArenaTeam::GetType(), Object::GetUInt32Value(), Quest::GetZoneOrSort(), AchievementCriteriaEntry::goEntry, AchievementCriteriaEntry::groupSize, HasAchieved(), Quest::HasSpecialFlag(), AchievementCriteriaEntry::highest_personal_rating, AchievementCriteriaEntry::highest_team_rating, AchievementCriteriaEntry::hk_class, AchievementCriteriaEntry::hk_race, AchievementCriteriaEntry::honorable_kill_at_area, AchievementEntry::ID, Battleground::isArena(), IsCompletedAchievement(), IsCompletedCriteria(), Map::IsDungeon(), Player::IsGameMaster(), Object::IsInWorld(), Object::IsPlayer(), Map::IsRaid(), ITEM_QUALITY_EPIC, AchievementCriteriaEntry::itemID, ItemTemplate::ItemLevel, AchievementCriteriaEntry::itemSlot, AchievementCriteriaEntry::kill_creature, AchievementCriteriaEntry::killed_by_creature, AchievementCriteriaEntry::learn_skill_level, AchievementCriteriaEntry::learn_skill_line, AchievementCriteriaEntry::learn_skillline_spell, AchievementCriteriaEntry::learn_spell, AchievementCriteriaEntry::linkedAchievement, LOG_DEBUG, AchievementCriteriaEntry::loot_type, AchievementCriteriaEntry::lootType, AchievementCriteriaEntry::lootTypeCount, AchievementCriteriaEntry::manLimit, AchievementCriteriaEntry::mapID, MAX_ARENA_SLOT, MAX_WORLD_MAP_OVERLAY_AREA_IDX, AchievementCriteriaDataSet::Meets(), AchievementCriteriaEntry::objectiveId, AchievementCriteriaEntry::own_item, AchievementCriteriaEntry::PersonalRating, PLAYER_EXPLORED_ZONES_1, PLAYER_EXPLORED_ZONES_SIZE, PLAYER_FIELD_LIFETIME_HONORABLE_KILLS, PROGRESS_ACCUMULATE, PROGRESS_HIGHEST, PROGRESS_RESET, PROGRESS_SET, ItemTemplate::Quality, QUEST_SPECIAL_FLAGS_NO_LOREMASTER_COUNT, AchievementCriteriaEntry::questID, AchievementCriteriaEntry::raceID, ArenaTeamStats::Rating, AchievementCriteriaEntry::reach_skill_level, AchievementCriteriaEntry::referredAchievement, AchievementCriteriaEntry::roll_greed_on_loot, AchievementCriteriaEntry::rollValue, sAchievementMgr, sAchievementStore, sAreaTableStore, sArenaTeamMgr, SetCriteriaProgress(), AchievementCriteriaEntry::skillID, AchievementCriteriaEntry::skillLine, sMapMgr, sObjectMgr, AchievementCriteriaEntry::spellID, sScriptMgr, sSpellMgr, sWorld, sWorldMapOverlayStore, AchievementCriteriaEntry::teamtype, Map::ToInstanceMap(), AchievementCriteriaEntry::type, AchievementCriteriaEntry::use_gameobject, AchievementCriteriaEntry::use_item, AchievementCriteriaEntry::win_arena, AchievementCriteriaEntry::win_bg, AchievementCriteriaEntry::win_duel, and AchievementCriteriaEntry::zoneID.

Referenced by CheckAllAchievementCriteria(), CompletedAchievement(), ProcessOfflineUpdate(), and Player::UpdateAchievementCriteria().

◆ UpdateTimedAchievements()

void AchievementMgr::UpdateTimedAchievements ( uint32  timeDiff)
private
2205{
2206 if (!_timedAchievements.empty())
2207 {
2208 for (TimedAchievementMap::iterator itr = _timedAchievements.begin(); itr != _timedAchievements.end();)
2209 {
2210 // Time is up, remove timer and reset progress
2211 if (itr->second <= timeDiff)
2212 {
2213 AchievementCriteriaEntry const* entry = sAchievementCriteriaStore.LookupEntry(itr->first);
2215 _timedAchievements.erase(itr++);
2216 }
2217 else
2218 {
2219 itr->second -= timeDiff;
2220 ++itr;
2221 }
2222 }
2223 }
2224}

References _timedAchievements, RemoveCriteriaProgress(), and sAchievementCriteriaStore.

Referenced by Update().

Member Data Documentation

◆ _completedAchievements

◆ _criteriaProgress

◆ _offlineUpdatesDelayTimer

uint32 AchievementMgr::_offlineUpdatesDelayTimer
private

Referenced by AchievementMgr(), LoadFromDB(), and Update().

◆ _offlineUpdatesQueue

std::vector<AchievementOfflinePlayerUpdate> AchievementMgr::_offlineUpdatesQueue
private

◆ _player

◆ _timedAchievements