Core/Commands: Implement command for adding (completing) achievements
--HG-- branch : trunk
This commit is contained in:
@@ -1900,11 +1900,11 @@ void AchievementMgr::RemoveTimedAchievement(AchievementCriteriaTimedTypes type,
|
||||
}
|
||||
}
|
||||
|
||||
void AchievementMgr::CompletedAchievement(AchievementEntry const* achievement)
|
||||
void AchievementMgr::CompletedAchievement(AchievementEntry const* achievement, bool ignoreGMAllowAchievementConfig)
|
||||
{
|
||||
sLog.outDetail("AchievementMgr::CompletedAchievement(%u)", achievement->ID);
|
||||
|
||||
if (!sWorld.getBoolConfig(CONFIG_GM_ALLOW_ACHIEVEMENT_GAINS) && m_player->GetSession()->GetSecurity() > SEC_PLAYER)
|
||||
if (!sWorld.getBoolConfig(CONFIG_GM_ALLOW_ACHIEVEMENT_GAINS) && m_player->GetSession()->GetSecurity() > SEC_PLAYER && !ignoreGMAllowAchievementConfig)
|
||||
return;
|
||||
|
||||
if (achievement->flags & ACHIEVEMENT_FLAG_COUNTER || HasAchieved(achievement))
|
||||
|
||||
@@ -247,7 +247,7 @@ class AchievementMgr
|
||||
void SaveToDB(SQLTransaction& trans);
|
||||
void ResetAchievementCriteria(AchievementCriteriaTypes type, uint32 miscvalue1 = 0, uint32 miscvalue2 = 0, bool evenIfCriteriaComplete = false);
|
||||
void UpdateAchievementCriteria(AchievementCriteriaTypes type, uint32 miscvalue1 = 0, uint32 miscvalue2 = 0, Unit *unit = NULL, uint32 time = 0);
|
||||
void CompletedAchievement(AchievementEntry const* entry);
|
||||
void CompletedAchievement(AchievementEntry const* entry, bool ignoreGMAllowAchievementConfig = false);
|
||||
void CheckAllAchievementCriteria();
|
||||
void SendAllAchievementData();
|
||||
void SendRespondInspectAchievements(Player* player);
|
||||
|
||||
@@ -692,9 +692,16 @@ ChatCommand * ChatHandler::getCommandTable()
|
||||
{ NULL, 0, false, NULL, "", NULL }
|
||||
};
|
||||
|
||||
static ChatCommand achievementCommandTable[] =
|
||||
{
|
||||
{ "add", SEC_ADMINISTRATOR, false, &ChatHandler::HandleAchievementAddCommand, "", NULL},
|
||||
{ NULL, 0, false, NULL, "", NULL }
|
||||
};
|
||||
|
||||
static ChatCommand commandTable[] =
|
||||
{
|
||||
{ "account", SEC_PLAYER, true, NULL, "", accountCommandTable },
|
||||
{ "achievement", SEC_ADMINISTRATOR, false, NULL, "", achievementCommandTable},
|
||||
{ "gm", SEC_MODERATOR, true, NULL, "", gmCommandTable },
|
||||
{ "npc", SEC_MODERATOR, false, NULL, "", npcCommandTable },
|
||||
{ "go", SEC_MODERATOR, false, NULL, "", goCommandTable },
|
||||
|
||||
@@ -568,6 +568,9 @@ class ChatHandler
|
||||
bool HandleChangeWeather(const char* args);
|
||||
bool HandleKickPlayerCommand(const char * args);
|
||||
|
||||
// Achievement commands
|
||||
bool HandleAchievementAddCommand(const char* args);
|
||||
|
||||
// GM ticket command handlers
|
||||
bool HandleGMTicketListCommand(const char* args);
|
||||
bool HandleGMTicketListOnlineCommand(const char* args);
|
||||
|
||||
@@ -1408,6 +1408,34 @@ bool ChatHandler::HandleSetSkillCommand(const char *args)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ChatHandler::HandleAchievementAddCommand(const char *args)
|
||||
{
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
uint32 achievementId = atoi((char*)args);
|
||||
if (!achievementId)
|
||||
{
|
||||
if (char* cId = extractKeyFromLink((char*)args, "Hachievement"))
|
||||
achievementId = atoi(cId);
|
||||
if (!achievementId)
|
||||
return false;
|
||||
}
|
||||
|
||||
Player* target = getSelectedPlayer();
|
||||
if (!target)
|
||||
{
|
||||
SendSysMessage(LANG_NO_CHAR_SELECTED);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (AchievementEntry const* pAE = GetAchievementStore()->LookupEntry(achievementId))
|
||||
target->CompletedAchievement(pAE, true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ChatHandler::HandleUnLearnCommand(const char *args)
|
||||
{
|
||||
if (!*args)
|
||||
|
||||
@@ -23031,9 +23031,9 @@ void Player::UpdateAchievementCriteria(AchievementCriteriaTypes type, uint32 mis
|
||||
GetAchievementMgr().UpdateAchievementCriteria(type, miscvalue1, miscvalue2, unit, time);
|
||||
}
|
||||
|
||||
void Player::CompletedAchievement(AchievementEntry const* entry)
|
||||
void Player::CompletedAchievement(AchievementEntry const* entry, bool ignoreGMAllowAchievementConfig)
|
||||
{
|
||||
GetAchievementMgr().CompletedAchievement(entry);
|
||||
GetAchievementMgr().CompletedAchievement(entry, ignoreGMAllowAchievementConfig);
|
||||
}
|
||||
|
||||
void Player::LearnTalent(uint32 talentId, uint32 talentRank)
|
||||
|
||||
@@ -2362,7 +2362,7 @@ class Player : public Unit, public GridObject<Player>
|
||||
AchievementMgr& GetAchievementMgr() { return m_achievementMgr; }
|
||||
AchievementMgr const& GetAchievementMgr() const { return m_achievementMgr; }
|
||||
void UpdateAchievementCriteria(AchievementCriteriaTypes type, uint32 miscvalue1 = 0, uint32 miscvalue2 = 0, Unit *unit = NULL, uint32 time = 0);
|
||||
void CompletedAchievement(AchievementEntry const* entry);
|
||||
void CompletedAchievement(AchievementEntry const* entry, bool ignoreGMAllowAchievementConfig = false);
|
||||
|
||||
bool HasTitle(uint32 bitIndex);
|
||||
bool HasTitle(CharTitlesEntry const* title) { return HasTitle(title->bit_index); }
|
||||
|
||||
Reference in New Issue
Block a user