mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-15 23:20:36 +01:00
Core/Players: Added helper function to check quest completion using QuestV2 bits
This commit is contained in:
@@ -2290,9 +2290,8 @@ bool CriteriaHandler::ModifierSatisfied(ModifierTreeEntry const* modifier, uint6
|
||||
break;
|
||||
}
|
||||
case ModifierTreeType::PlayerHasCompletedQuest: // 110
|
||||
if (uint32 questBit = sDB2Manager.GetQuestUniqueBitFlag(reqValue))
|
||||
if (!(referencePlayer->m_activePlayerData->QuestCompleted[((questBit - 1) >> 6)] & (UI64LIT(1) << ((questBit - 1) & 63))))
|
||||
return false;
|
||||
if (!referencePlayer->IsQuestCompletedBitSet(reqValue))
|
||||
return false;
|
||||
break;
|
||||
case ModifierTreeType::PlayerIsReadyToTurnInQuest: // 111
|
||||
if (referencePlayer->GetQuestStatus(reqValue) != QUEST_STATUS_COMPLETE)
|
||||
|
||||
@@ -3004,8 +3004,7 @@ bool ConditionMgr::IsPlayerMeetingCondition(Player const* player, PlayerConditio
|
||||
std::array<bool, std::tuple_size_v<decltype(condition->PrevQuestID)>> results;
|
||||
results.fill(true);
|
||||
for (std::size_t i = 0; i < condition->PrevQuestID.size(); ++i)
|
||||
if (uint32 questBit = sDB2Manager.GetQuestUniqueBitFlag(condition->PrevQuestID[i]))
|
||||
results[i] = (player->m_activePlayerData->QuestCompleted[((questBit - 1) >> 6)] & (UI64LIT(1) << ((questBit - 1) & 63))) != 0;
|
||||
results[i] = player->IsQuestCompletedBitSet(condition->PrevQuestID[i]);
|
||||
|
||||
if (!PlayerConditionLogic(condition->PrevQuestLogic, results))
|
||||
return false;
|
||||
|
||||
@@ -16548,6 +16548,20 @@ void Player::RemoveQuestSlotObjectiveFlag(uint16 slot, int8 objectiveIndex)
|
||||
.ModifyValue(&UF::QuestLog::ObjectiveFlags), 1 << objectiveIndex);
|
||||
}
|
||||
|
||||
bool Player::IsQuestCompletedBitSet(uint32 questId) const
|
||||
{
|
||||
uint32 questBit = sDB2Manager.GetQuestUniqueBitFlag(questId);
|
||||
if (!questBit)
|
||||
return false;
|
||||
|
||||
uint32 fieldOffset = (questBit - 1) / QUESTS_COMPLETED_BITS_PER_BLOCK;
|
||||
if (fieldOffset >= m_activePlayerData->BitVectors->Values[PLAYER_DATA_FLAG_CHARACTER_QUEST_COMPLETED_INDEX].Values.size())
|
||||
return false;
|
||||
|
||||
uint64 flag = UI64LIT(1) << ((questBit - 1) % QUESTS_COMPLETED_BITS_PER_BLOCK);
|
||||
return (m_activePlayerData->BitVectors->Values[PLAYER_DATA_FLAG_CHARACTER_QUEST_COMPLETED_INDEX].Values[fieldOffset] & flag) != 0;
|
||||
}
|
||||
|
||||
void Player::SetQuestCompletedBit(uint32 questBit, bool completed)
|
||||
{
|
||||
if (!questBit)
|
||||
|
||||
@@ -1709,6 +1709,7 @@ class TC_GAME_API Player final : public Unit, public GridObject<Player>
|
||||
void SetQuestSlotEndTime(uint16 slot, time_t endTime);
|
||||
void SetQuestSlotObjectiveFlag(uint16 slot, int8 objectiveIndex);
|
||||
void RemoveQuestSlotObjectiveFlag(uint16 slot, int8 objectiveIndex);
|
||||
bool IsQuestCompletedBitSet(uint32 questId) const;
|
||||
void SetQuestCompletedBit(uint32 questBit, bool completed);
|
||||
|
||||
uint16 GetReqKillOrCastCurrentCount(uint32 quest_id, int32 entry) const;
|
||||
|
||||
Reference in New Issue
Block a user