Another fix quest flags, Implement support weekly quests cooldowns(Original patch by GriffonHeart), also code cleanups.
--HG-- branch : trunk
This commit is contained in:
+83
-6
@@ -1198,7 +1198,7 @@ void Player::Update(uint32 p_time)
|
||||
|
||||
if (!m_timedquests.empty())
|
||||
{
|
||||
std::set<uint32>::iterator iter = m_timedquests.begin();
|
||||
QuestSet::iterator iter = m_timedquests.begin();
|
||||
while (iter != m_timedquests.end())
|
||||
{
|
||||
QuestStatusData& q_status = mQuestStatus[*iter];
|
||||
@@ -13578,7 +13578,7 @@ void Player::SendPreparedQuest(uint64 guid)
|
||||
PlayerTalkClass->SendQuestGiverRequestItems(pQuest, guid, CanRewardQuest(pQuest, false), true);
|
||||
// Send completable on repeatable and autoCompletable quest if player don't have quest
|
||||
// TODO: verify if check for !pQuest->IsDaily() is really correct (possibly not)
|
||||
else if (pQuest->IsAutoComplete() && pQuest->IsRepeatable() && !pQuest->IsDaily())
|
||||
else if (pQuest->IsAutoComplete() && pQuest->IsRepeatable() && !pQuest->IsDailyOrWeekly())
|
||||
PlayerTalkClass->SendQuestGiverRequestItems(pQuest, guid, CanCompleteRepeatableQuest(pQuest), true);
|
||||
else
|
||||
PlayerTalkClass->SendQuestGiverQuestDetails(pQuest, guid, true);
|
||||
@@ -13696,7 +13696,7 @@ bool Player::CanSeeStartQuest(Quest const *pQuest)
|
||||
if (SatisfyQuestRace(pQuest, false) && SatisfyQuestSkillOrClass(pQuest, false) &&
|
||||
SatisfyQuestExclusiveGroup(pQuest, false) && SatisfyQuestReputation(pQuest, false) &&
|
||||
SatisfyQuestPreviousQuest(pQuest, false) && SatisfyQuestNextChain(pQuest, false) &&
|
||||
SatisfyQuestPrevChain(pQuest, false) && SatisfyQuestDay(pQuest, false))
|
||||
SatisfyQuestPrevChain(pQuest, false) && SatisfyQuestDay(pQuest, false) && SatisfyQuestWeek(pQuest, false))
|
||||
{
|
||||
return getLevel() + sWorld.getConfig(CONFIG_QUEST_HIGH_LEVEL_HIDE_DIFF) >= pQuest->GetMinLevel();
|
||||
}
|
||||
@@ -13711,7 +13711,7 @@ bool Player::CanTakeQuest(Quest const *pQuest, bool msg)
|
||||
&& SatisfyQuestSkillOrClass(pQuest, msg) && SatisfyQuestReputation(pQuest, msg)
|
||||
&& SatisfyQuestPreviousQuest(pQuest, msg) && SatisfyQuestTimed(pQuest, msg)
|
||||
&& SatisfyQuestNextChain(pQuest, msg) && SatisfyQuestPrevChain(pQuest, msg)
|
||||
&& SatisfyQuestDay(pQuest, msg);
|
||||
&& SatisfyQuestDay(pQuest, msg) && SatisfyQuestWeek(pQuest, msg);
|
||||
}
|
||||
|
||||
bool Player::CanAddQuest(Quest const *pQuest, bool msg)
|
||||
@@ -13831,7 +13831,7 @@ bool Player::CanRewardQuest(Quest const *pQuest, bool msg)
|
||||
return false;
|
||||
|
||||
// daily quest can't be rewarded (25 daily quest already completed)
|
||||
if (!SatisfyQuestDay(pQuest,true))
|
||||
if (!SatisfyQuestDay(pQuest,true) || !SatisfyQuestWeek(pQuest,true))
|
||||
return false;
|
||||
|
||||
// rewarded and not repeatable quest (only cheating case, then ignore without message)
|
||||
@@ -14126,6 +14126,9 @@ void Player::RewardQuest(Quest const *pQuest, uint32 reward, Object* questGiver,
|
||||
GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_DAILY_QUEST, 1);
|
||||
}
|
||||
|
||||
if (pQuest->IsWeekly())
|
||||
SetWeeklyQuestStatus(quest_id);
|
||||
|
||||
if (!pQuest->IsRepeatable())
|
||||
SetQuestStatus(quest_id, QUEST_STATUS_COMPLETE);
|
||||
else
|
||||
@@ -14472,10 +14475,11 @@ bool Player::SatisfyQuestExclusiveGroup(Quest const* qInfo, bool msg)
|
||||
|
||||
// not allow have daily quest if daily quest from exclusive group already recently completed
|
||||
Quest const* Nquest = objmgr.GetQuestTemplate(exclude_Id);
|
||||
if (!SatisfyQuestDay(Nquest, false))
|
||||
if (!SatisfyQuestDay(Nquest, false) || !SatisfyQuestWeek(Nquest, false))
|
||||
{
|
||||
if (msg)
|
||||
SendCanTakeQuestResponse(INVALIDREASON_DONT_HAVE_REQ);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -14574,6 +14578,15 @@ bool Player::SatisfyQuestDay(Quest const* qInfo, bool msg)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Player::SatisfyQuestWeek( Quest const* qInfo, bool msg )
|
||||
{
|
||||
if (!qInfo->IsWeekly() || m_weeklyquests.empty())
|
||||
return true;
|
||||
|
||||
// if not found in cooldown list
|
||||
return m_weeklyquests.find(qInfo->GetQuestId()) == m_weeklyquests.end();
|
||||
}
|
||||
|
||||
bool Player::GiveQuestSourceItem(Quest const *pQuest)
|
||||
{
|
||||
uint32 srcitem = pQuest->GetSrcItemId();
|
||||
@@ -16047,6 +16060,7 @@ bool Player::LoadFromDB(uint32 guid, SqlQueryHolder *holder)
|
||||
// after spell load, learn rewarded spell if need also
|
||||
_LoadQuestStatus(holder->GetResult(PLAYER_LOGIN_QUERY_LOADQUESTSTATUS));
|
||||
_LoadDailyQuestStatus(holder->GetResult(PLAYER_LOGIN_QUERY_LOADDAILYQUESTSTATUS));
|
||||
_LoadWeeklyQuestStatus(holder->GetResult(PLAYER_LOGIN_QUERY_LOADWEKLYQUESTSTATUS));
|
||||
|
||||
// after spell and quest load
|
||||
InitTalentForLevel();
|
||||
@@ -16820,6 +16834,33 @@ void Player::_LoadDailyQuestStatus(QueryResult_AutoPtr result)
|
||||
m_DailyQuestChanged = false;
|
||||
}
|
||||
|
||||
void Player::_LoadWeeklyQuestStatus(QueryResult_AutoPtr result)
|
||||
{
|
||||
m_weeklyquests.clear();
|
||||
|
||||
if (result)
|
||||
{
|
||||
do
|
||||
{
|
||||
Field *fields = result->Fetch();
|
||||
|
||||
uint32 quest_id = fields[0].GetUInt32();
|
||||
|
||||
Quest const* pQuest = objmgr.GetQuestTemplate(quest_id);
|
||||
|
||||
if (!pQuest)
|
||||
continue;
|
||||
|
||||
m_weeklyquests.insert(quest_id);
|
||||
|
||||
sLog.outDebug("Weekly quest {%u} cooldown for player (GUID: %u)", quest_id, GetGUIDLow());
|
||||
}
|
||||
while(result->NextRow());
|
||||
}
|
||||
|
||||
m_WeeklyQuestChanged = false;
|
||||
}
|
||||
|
||||
void Player::_LoadSpells(QueryResult_AutoPtr result)
|
||||
{
|
||||
//QueryResult *result = CharacterDatabase.PQuery("SELECT spell,active,disabled FROM character_spell WHERE guid = '%u'",GetGUIDLow());
|
||||
@@ -17434,6 +17475,7 @@ void Player::SaveToDB()
|
||||
_SaveInventory();
|
||||
_SaveQuestStatus();
|
||||
_SaveDailyQuestStatus();
|
||||
_SaveWeeklyQuestStatus();
|
||||
_SaveTalents();
|
||||
_SaveSpells();
|
||||
_SaveSpellCooldowns();
|
||||
@@ -17730,6 +17772,24 @@ void Player::_SaveDailyQuestStatus()
|
||||
GetGUIDLow(), GetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1+quest_daily_idx),uint64(m_lastDailyQuestTime));
|
||||
}
|
||||
|
||||
void Player::_SaveWeeklyQuestStatus()
|
||||
{
|
||||
if (!m_WeeklyQuestChanged || m_weeklyquests.empty())
|
||||
return;
|
||||
|
||||
// we don't need transactions here.
|
||||
CharacterDatabase.PExecute("DELETE FROM character_queststatus_weekly WHERE guid = '%u'",GetGUIDLow());
|
||||
|
||||
for (QuestSet::const_iterator iter = m_weeklyquests.begin(); iter != m_weeklyquests.end(); ++iter)
|
||||
{
|
||||
uint32 quest_id = *iter;
|
||||
|
||||
CharacterDatabase.PExecute("INSERT INTO character_queststatus_weekly (guid,quest) VALUES ('%u', '%u')", GetGUIDLow(), quest_id);
|
||||
}
|
||||
|
||||
m_WeeklyQuestChanged = false;
|
||||
}
|
||||
|
||||
void Player::_SaveSkills()
|
||||
{
|
||||
// we don't need transactions here.
|
||||
@@ -20905,6 +20965,13 @@ void Player::SetDailyQuestStatus(uint32 quest_id)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Player::SetWeeklyQuestStatus(uint32 quest_id)
|
||||
{
|
||||
m_weeklyquests.insert(quest_id);
|
||||
m_WeeklyQuestChanged = true;
|
||||
}
|
||||
|
||||
void Player::ResetDailyQuestStatus()
|
||||
{
|
||||
for (uint32 quest_daily_idx = 0; quest_daily_idx < PLAYER_MAX_DAILY_QUESTS; ++quest_daily_idx)
|
||||
@@ -20915,6 +20982,16 @@ void Player::ResetDailyQuestStatus()
|
||||
m_lastDailyQuestTime = 0;
|
||||
}
|
||||
|
||||
void Player::ResetWeeklyQuestStatus()
|
||||
{
|
||||
if (m_weeklyquests.empty())
|
||||
return;
|
||||
|
||||
m_weeklyquests.clear();
|
||||
// DB data deleted in caller
|
||||
m_WeeklyQuestChanged = false;
|
||||
}
|
||||
|
||||
BattleGround* Player::GetBattleGround() const
|
||||
{
|
||||
if (GetBattleGroundId() == 0)
|
||||
|
||||
Reference in New Issue
Block a user