mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-11 21:01:29 +00:00
[Tasks] Extend IsTaskCompleted to also be aware of shared task completion (#4714)
* [Tasks] Extend IsTaskCompleted to also be aware of shared task completion * Fix my stupidity * Update client.h
This commit is contained in:
parent
80e8634a48
commit
fa2ab11676
@ -1289,6 +1289,27 @@ public:
|
|||||||
void SendSpellTypePrompts(bool commanded_types = false, bool client_only_types = false);
|
void SendSpellTypePrompts(bool commanded_types = false, bool client_only_types = false);
|
||||||
|
|
||||||
// Task System Methods
|
// Task System Methods
|
||||||
|
inline void LoadClientSharedCompletedTasks()
|
||||||
|
{
|
||||||
|
std::string query = fmt::format(R"(
|
||||||
|
SELECT
|
||||||
|
cst.task_id
|
||||||
|
FROM completed_shared_task_members cstm
|
||||||
|
JOIN completed_shared_tasks cst ON cstm.shared_task_id = cst.id
|
||||||
|
WHERE cstm.character_id = {}
|
||||||
|
GROUP BY cst.task_id;
|
||||||
|
)", CharacterID());
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(query);
|
||||||
|
if (!results.Success()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
m_completed_shared_tasks.push_back(std::stoi(row[0]));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
inline std::vector<uint32_t> GetCompletedSharedTasks() const { return m_completed_shared_tasks; };
|
||||||
void LoadClientTaskState();
|
void LoadClientTaskState();
|
||||||
void RemoveClientTaskState();
|
void RemoveClientTaskState();
|
||||||
void SendTaskActivityComplete(int task_id, int activity_id, int task_index, TaskType task_type, int task_incomplete=1);
|
void SendTaskActivityComplete(int task_id, int activity_id, int task_index, TaskType task_type, int task_incomplete=1);
|
||||||
@ -1459,7 +1480,10 @@ public:
|
|||||||
{
|
{
|
||||||
return (task_state ? task_state->EnabledTaskCount(task_set_id) : -1);
|
return (task_state ? task_state->EnabledTaskCount(task_set_id) : -1);
|
||||||
}
|
}
|
||||||
inline bool IsTaskCompleted(int task_id) { return (task_state ? task_state->IsTaskCompleted(task_id) : false); }
|
inline bool IsTaskCompleted(int task_id)
|
||||||
|
{
|
||||||
|
return (task_state ? task_state->IsTaskCompleted(task_id, this) : false);
|
||||||
|
}
|
||||||
inline bool AreTasksCompleted(std::vector<int> task_ids)
|
inline bool AreTasksCompleted(std::vector<int> task_ids)
|
||||||
{
|
{
|
||||||
return (task_state ? task_state->AreTasksCompleted(task_ids) : false);
|
return (task_state ? task_state->AreTasksCompleted(task_ids) : false);
|
||||||
@ -2290,6 +2314,8 @@ private:
|
|||||||
bool m_has_quest_compass = false;
|
bool m_has_quest_compass = false;
|
||||||
std::vector<uint32_t> m_dynamic_zone_ids;
|
std::vector<uint32_t> m_dynamic_zone_ids;
|
||||||
|
|
||||||
|
std::vector<uint32_t> m_completed_shared_tasks;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum BotOwnerOption : size_t {
|
enum BotOwnerOption : size_t {
|
||||||
booDeathMarquee,
|
booDeathMarquee,
|
||||||
|
|||||||
@ -952,6 +952,8 @@ int ClientTaskState::IncrementDoneCount(
|
|||||||
|
|
||||||
client->CancelTask(task_index, task_data->type);
|
client->CancelTask(task_index, task_data->type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
client->LoadClientSharedCompletedTasks();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -1561,7 +1563,7 @@ int ClientTaskState::TaskTimeLeft(int task_id)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ClientTaskState::IsTaskCompleted(int task_id)
|
bool ClientTaskState::IsTaskCompleted(int task_id, Client *c)
|
||||||
{
|
{
|
||||||
if (!RuleB(TaskSystem, RecordCompletedTasks)) {
|
if (!RuleB(TaskSystem, RecordCompletedTasks)) {
|
||||||
return false;
|
return false;
|
||||||
@ -1574,6 +1576,14 @@ bool ClientTaskState::IsTaskCompleted(int task_id)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (c) {
|
||||||
|
for (auto &e: c->GetCompletedSharedTasks()) {
|
||||||
|
if (e == task_id) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -45,7 +45,7 @@ public:
|
|||||||
void AcceptNewTask(Client *client, int task_id, int npc_type_id, time_t accept_time, bool enforce_level_requirement = false);
|
void AcceptNewTask(Client *client, int task_id, int npc_type_id, time_t accept_time, bool enforce_level_requirement = false);
|
||||||
void FailTask(Client *client, int task_id);
|
void FailTask(Client *client, int task_id);
|
||||||
int TaskTimeLeft(int task_id);
|
int TaskTimeLeft(int task_id);
|
||||||
bool IsTaskCompleted(int task_id);
|
bool IsTaskCompleted(int task_id, Client *c = nullptr);
|
||||||
bool AreTasksCompleted(const std::vector<int>& task_ids);
|
bool AreTasksCompleted(const std::vector<int>& task_ids);
|
||||||
bool IsTaskActive(int task_id);
|
bool IsTaskActive(int task_id);
|
||||||
bool IsTaskActivityActive(int task_id, int activity_id);
|
bool IsTaskActivityActive(int task_id, int activity_id);
|
||||||
|
|||||||
@ -15,8 +15,9 @@ extern QueryServ *QServ;
|
|||||||
void Client::LoadClientTaskState()
|
void Client::LoadClientTaskState()
|
||||||
{
|
{
|
||||||
if (RuleB(TaskSystem, EnableTaskSystem) && task_manager) {
|
if (RuleB(TaskSystem, EnableTaskSystem) && task_manager) {
|
||||||
safe_delete(task_state);
|
LoadClientSharedCompletedTasks();
|
||||||
|
|
||||||
|
safe_delete(task_state);
|
||||||
task_state = new ClientTaskState();
|
task_state = new ClientTaskState();
|
||||||
if (!task_manager->LoadClientState(this, task_state)) {
|
if (!task_manager->LoadClientState(this, task_state)) {
|
||||||
safe_delete(task_state);
|
safe_delete(task_state);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user