mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-18 11:21:29 +00:00
Move TaskManager::LoadTaskSets() loading to repositories
This commit is contained in:
parent
8d863a507b
commit
11eab9c284
@ -41,51 +41,46 @@ Copyright (C) 2001-2008 EQEMu Development Team (http://eqemulator.net)
|
|||||||
#include "queryserv.h"
|
#include "queryserv.h"
|
||||||
#include "quest_parser_collection.h"
|
#include "quest_parser_collection.h"
|
||||||
#include "../common/repositories/completed_tasks_repository.h"
|
#include "../common/repositories/completed_tasks_repository.h"
|
||||||
|
#include "../common/repositories/tasksets_repository.h"
|
||||||
|
|
||||||
extern QueryServ *QServ;
|
extern QueryServ *QServ;
|
||||||
|
|
||||||
TaskManager::TaskManager()
|
TaskManager::TaskManager()
|
||||||
{
|
{
|
||||||
for (auto &Task : p_task_data)
|
for (auto &task : p_task_data) {
|
||||||
Task = nullptr;
|
task = nullptr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TaskManager::~TaskManager()
|
TaskManager::~TaskManager()
|
||||||
{
|
{
|
||||||
for (auto &Task : p_task_data) {
|
for (auto &task : p_task_data) {
|
||||||
if (Task != nullptr) {
|
if (task != nullptr) {
|
||||||
safe_delete(Task);
|
safe_delete(task);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TaskManager::LoadTaskSets()
|
bool TaskManager::LoadTaskSets()
|
||||||
{
|
{
|
||||||
|
|
||||||
// Clear all task sets in memory. Done so we can reload them on the fly if required by just calling
|
// Clear all task sets in memory. Done so we can reload them on the fly if required by just calling
|
||||||
// this method again.
|
// this method again.
|
||||||
for (auto &TaskSet : task_sets)
|
for (auto &task_set : task_sets) {
|
||||||
TaskSet.clear();
|
task_set.clear();
|
||||||
|
|
||||||
std::string query = StringFormat(
|
|
||||||
"SELECT `id`, `taskid` from `tasksets` "
|
|
||||||
"WHERE `id` > 0 AND `id` < %i "
|
|
||||||
"AND `taskid` >= 0 AND `taskid` < %i "
|
|
||||||
"ORDER BY `id`, `taskid` ASC",
|
|
||||||
MAXTASKSETS, MAXTASKS
|
|
||||||
);
|
|
||||||
auto results = content_db.QueryDatabase(query);
|
|
||||||
if (!results.Success()) {
|
|
||||||
LogError("Error in TaskManager::LoadTaskSets: [{}]", results.ErrorMessage().c_str());
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
auto task_set_results = TasksetsRepository::GetWhere(
|
||||||
int taskSet = atoi(row[0]);
|
content_db,
|
||||||
int taskID = atoi(row[1]);
|
fmt::format(
|
||||||
|
"`id` > 0 AND `id` < {} AND `taskid` >= 0 AND `taskid` < {} ORDER BY `id`, `taskid` ASC",
|
||||||
|
MAXTASKSETS,
|
||||||
|
MAXTASKS
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
task_sets[taskSet].push_back(taskID);
|
for (auto &task_set: task_set_results) {
|
||||||
Log(Logs::General, Logs::Tasks, "[GLOBALLOAD] Adding task_id %4i to TaskSet %4i", taskID, taskSet);
|
task_sets[task_set.id].push_back(task_set.taskid);
|
||||||
|
LogTasksDetail("[LoadTaskSets] Adding task_id [{}] to task_set [{}]", task_set.taskid, task_set.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -93,10 +88,10 @@ bool TaskManager::LoadTaskSets()
|
|||||||
|
|
||||||
void TaskManager::ReloadGoalLists()
|
void TaskManager::ReloadGoalLists()
|
||||||
{
|
{
|
||||||
|
if (!goal_list_manager.LoadLists()) {
|
||||||
if (!goal_list_manager.LoadLists())
|
|
||||||
Log(Logs::Detail, Logs::Tasks, "TaskManager::LoadTasks LoadLists failed");
|
Log(Logs::Detail, Logs::Tasks, "TaskManager::LoadTasks LoadLists failed");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool TaskManager::LoadTasks(int single_task)
|
bool TaskManager::LoadTasks(int single_task)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -365,7 +365,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
TaskGoalListManager goal_list_manager;
|
TaskGoalListManager goal_list_manager;
|
||||||
TaskProximityManager proximity_manager;
|
TaskProximityManager proximity_manager;
|
||||||
TaskInformation *p_task_data[MAXTASKS];
|
TaskInformation *p_task_data[MAXTASKS]{};
|
||||||
std::vector<int> task_sets[MAXTASKSETS];
|
std::vector<int> task_sets[MAXTASKSETS];
|
||||||
void SendActiveTaskDescription(
|
void SendActiveTaskDescription(
|
||||||
Client *client,
|
Client *client,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user