From 50102e0ff0d27b772481788ae28ffb831f302107 Mon Sep 17 00:00:00 2001 From: Rushi <44952533+Skyliegirl33@users.noreply.github.com> Date: Thu, 17 Feb 2022 04:26:19 +0100 Subject: [PATCH] Add method for quest completion --- src/world/Actor/Player.h | 2 ++ src/world/Actor/PlayerQuest.cpp | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/src/world/Actor/Player.h b/src/world/Actor/Player.h index df7fea04..02d0db58 100644 --- a/src/world/Actor/Player.h +++ b/src/world/Actor/Player.h @@ -107,6 +107,8 @@ namespace Sapphire::Entity /*! remove a given quest */ void removeQuest( uint16_t questId ); + bool isQuestCompleted( uint32_t questId ); + /*! add a quest to the completed quests mask */ void updateQuestsCompleted( uint32_t questId ); diff --git a/src/world/Actor/PlayerQuest.cpp b/src/world/Actor/PlayerQuest.cpp index c0409141..1cade20b 100644 --- a/src/world/Actor/PlayerQuest.cpp +++ b/src/world/Actor/PlayerQuest.cpp @@ -152,6 +152,16 @@ void Sapphire::Entity::Player::updateQuestsCompleted( uint32_t questId ) m_questCompleteFlags[ index ] |= value; } +bool Sapphire::Entity::Player::isQuestCompleted( uint32_t questId ) +{ + uint8_t index = questId / 8; + uint8_t bitIndex = ( questId ) % 8; + + uint8_t value = 0x80 >> bitIndex; + + return m_questCompleteFlags[ index ] & value; +} + void Sapphire::Entity::Player::removeQuestsCompleted( uint32_t questId ) { uint8_t index = questId / 8;