mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-15 16:41:29 +00:00
[Tasks] Add enabled column (#3804)
* [Tasks] Add enabled column * Update task_manager.cpp * Update task_manager.cpp * Update base_tasks_repository.h
This commit is contained in:
parent
473c5096f6
commit
8bedcd8751
@ -5143,6 +5143,17 @@ CHANGE COLUMN `temporary` `class_list` text CHARACTER SET latin1 COLLATE latin1_
|
|||||||
.match = "",
|
.match = "",
|
||||||
.sql = R"(
|
.sql = R"(
|
||||||
ALTER TABLE `npc_emotes` DROP INDEX `emoteid`;
|
ALTER TABLE `npc_emotes` DROP INDEX `emoteid`;
|
||||||
|
)"
|
||||||
|
},
|
||||||
|
ManifestEntry{
|
||||||
|
.version = 9249,
|
||||||
|
.description = "2023_12_26_add_tasks_enabled_column.sql",
|
||||||
|
.check = "SHOW COLUMNS FROM `tasks` LIKE 'enabled'",
|
||||||
|
.condition = "empty",
|
||||||
|
.match = "",
|
||||||
|
.sql = R"(
|
||||||
|
ALTER TABLE `tasks`
|
||||||
|
ADD COLUMN `enabled` smallint NULL DEFAULT 1 AFTER `faction_amount`
|
||||||
)"
|
)"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
* Any modifications to base repositories are to be made by the generator only
|
* Any modifications to base repositories are to be made by the generator only
|
||||||
*
|
*
|
||||||
* @generator ./utils/scripts/generators/repository-generator.pl
|
* @generator ./utils/scripts/generators/repository-generator.pl
|
||||||
* @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories
|
* @docs https://docs.eqemu.io/developer/repositories
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef EQEMU_BASE_TASKS_REPOSITORY_H
|
#ifndef EQEMU_BASE_TASKS_REPOSITORY_H
|
||||||
@ -16,6 +16,7 @@
|
|||||||
#include "../../strings.h"
|
#include "../../strings.h"
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
|
|
||||||
|
|
||||||
class BaseTasksRepository {
|
class BaseTasksRepository {
|
||||||
public:
|
public:
|
||||||
struct Tasks {
|
struct Tasks {
|
||||||
@ -47,6 +48,7 @@ public:
|
|||||||
uint32_t dz_template_id;
|
uint32_t dz_template_id;
|
||||||
int32_t lock_activity_id;
|
int32_t lock_activity_id;
|
||||||
int32_t faction_amount;
|
int32_t faction_amount;
|
||||||
|
int16_t enabled;
|
||||||
};
|
};
|
||||||
|
|
||||||
static std::string PrimaryKey()
|
static std::string PrimaryKey()
|
||||||
@ -85,6 +87,7 @@ public:
|
|||||||
"dz_template_id",
|
"dz_template_id",
|
||||||
"lock_activity_id",
|
"lock_activity_id",
|
||||||
"faction_amount",
|
"faction_amount",
|
||||||
|
"enabled",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,6 +122,7 @@ public:
|
|||||||
"dz_template_id",
|
"dz_template_id",
|
||||||
"lock_activity_id",
|
"lock_activity_id",
|
||||||
"faction_amount",
|
"faction_amount",
|
||||||
|
"enabled",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -187,6 +191,7 @@ public:
|
|||||||
e.dz_template_id = 0;
|
e.dz_template_id = 0;
|
||||||
e.lock_activity_id = -1;
|
e.lock_activity_id = -1;
|
||||||
e.faction_amount = 0;
|
e.faction_amount = 0;
|
||||||
|
e.enabled = 1;
|
||||||
|
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
@ -212,8 +217,9 @@ public:
|
|||||||
{
|
{
|
||||||
auto results = db.QueryDatabase(
|
auto results = db.QueryDatabase(
|
||||||
fmt::format(
|
fmt::format(
|
||||||
"{} WHERE id = {} LIMIT 1",
|
"{} WHERE {} = {} LIMIT 1",
|
||||||
BaseSelect(),
|
BaseSelect(),
|
||||||
|
PrimaryKey(),
|
||||||
tasks_id
|
tasks_id
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@ -250,6 +256,7 @@ public:
|
|||||||
e.dz_template_id = static_cast<uint32_t>(strtoul(row[25], nullptr, 10));
|
e.dz_template_id = static_cast<uint32_t>(strtoul(row[25], nullptr, 10));
|
||||||
e.lock_activity_id = static_cast<int32_t>(atoi(row[26]));
|
e.lock_activity_id = static_cast<int32_t>(atoi(row[26]));
|
||||||
e.faction_amount = static_cast<int32_t>(atoi(row[27]));
|
e.faction_amount = static_cast<int32_t>(atoi(row[27]));
|
||||||
|
e.enabled = static_cast<int16_t>(atoi(row[28]));
|
||||||
|
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
@ -311,6 +318,7 @@ public:
|
|||||||
v.push_back(columns[25] + " = " + std::to_string(e.dz_template_id));
|
v.push_back(columns[25] + " = " + std::to_string(e.dz_template_id));
|
||||||
v.push_back(columns[26] + " = " + std::to_string(e.lock_activity_id));
|
v.push_back(columns[26] + " = " + std::to_string(e.lock_activity_id));
|
||||||
v.push_back(columns[27] + " = " + std::to_string(e.faction_amount));
|
v.push_back(columns[27] + " = " + std::to_string(e.faction_amount));
|
||||||
|
v.push_back(columns[28] + " = " + std::to_string(e.enabled));
|
||||||
|
|
||||||
auto results = db.QueryDatabase(
|
auto results = db.QueryDatabase(
|
||||||
fmt::format(
|
fmt::format(
|
||||||
@ -360,6 +368,7 @@ public:
|
|||||||
v.push_back(std::to_string(e.dz_template_id));
|
v.push_back(std::to_string(e.dz_template_id));
|
||||||
v.push_back(std::to_string(e.lock_activity_id));
|
v.push_back(std::to_string(e.lock_activity_id));
|
||||||
v.push_back(std::to_string(e.faction_amount));
|
v.push_back(std::to_string(e.faction_amount));
|
||||||
|
v.push_back(std::to_string(e.enabled));
|
||||||
|
|
||||||
auto results = db.QueryDatabase(
|
auto results = db.QueryDatabase(
|
||||||
fmt::format(
|
fmt::format(
|
||||||
@ -417,6 +426,7 @@ public:
|
|||||||
v.push_back(std::to_string(e.dz_template_id));
|
v.push_back(std::to_string(e.dz_template_id));
|
||||||
v.push_back(std::to_string(e.lock_activity_id));
|
v.push_back(std::to_string(e.lock_activity_id));
|
||||||
v.push_back(std::to_string(e.faction_amount));
|
v.push_back(std::to_string(e.faction_amount));
|
||||||
|
v.push_back(std::to_string(e.enabled));
|
||||||
|
|
||||||
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
|
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
|
||||||
}
|
}
|
||||||
@ -478,6 +488,7 @@ public:
|
|||||||
e.dz_template_id = static_cast<uint32_t>(strtoul(row[25], nullptr, 10));
|
e.dz_template_id = static_cast<uint32_t>(strtoul(row[25], nullptr, 10));
|
||||||
e.lock_activity_id = static_cast<int32_t>(atoi(row[26]));
|
e.lock_activity_id = static_cast<int32_t>(atoi(row[26]));
|
||||||
e.faction_amount = static_cast<int32_t>(atoi(row[27]));
|
e.faction_amount = static_cast<int32_t>(atoi(row[27]));
|
||||||
|
e.enabled = static_cast<int16_t>(atoi(row[28]));
|
||||||
|
|
||||||
all_entries.push_back(e);
|
all_entries.push_back(e);
|
||||||
}
|
}
|
||||||
@ -530,6 +541,7 @@ public:
|
|||||||
e.dz_template_id = static_cast<uint32_t>(strtoul(row[25], nullptr, 10));
|
e.dz_template_id = static_cast<uint32_t>(strtoul(row[25], nullptr, 10));
|
||||||
e.lock_activity_id = static_cast<int32_t>(atoi(row[26]));
|
e.lock_activity_id = static_cast<int32_t>(atoi(row[26]));
|
||||||
e.faction_amount = static_cast<int32_t>(atoi(row[27]));
|
e.faction_amount = static_cast<int32_t>(atoi(row[27]));
|
||||||
|
e.enabled = static_cast<int16_t>(atoi(row[28]));
|
||||||
|
|
||||||
all_entries.push_back(e);
|
all_entries.push_back(e);
|
||||||
}
|
}
|
||||||
@ -588,6 +600,118 @@ public:
|
|||||||
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
|
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static std::string BaseReplace()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"REPLACE INTO {} ({}) ",
|
||||||
|
TableName(),
|
||||||
|
ColumnsRaw()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int ReplaceOne(
|
||||||
|
Database& db,
|
||||||
|
const Tasks &e
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> v;
|
||||||
|
|
||||||
|
v.push_back(std::to_string(e.id));
|
||||||
|
v.push_back(std::to_string(e.type));
|
||||||
|
v.push_back(std::to_string(e.duration));
|
||||||
|
v.push_back(std::to_string(e.duration_code));
|
||||||
|
v.push_back("'" + Strings::Escape(e.title) + "'");
|
||||||
|
v.push_back("'" + Strings::Escape(e.description) + "'");
|
||||||
|
v.push_back("'" + Strings::Escape(e.reward_text) + "'");
|
||||||
|
v.push_back("'" + Strings::Escape(e.reward_id_list) + "'");
|
||||||
|
v.push_back(std::to_string(e.cash_reward));
|
||||||
|
v.push_back(std::to_string(e.exp_reward));
|
||||||
|
v.push_back(std::to_string(e.reward_method));
|
||||||
|
v.push_back(std::to_string(e.reward_points));
|
||||||
|
v.push_back(std::to_string(e.reward_point_type));
|
||||||
|
v.push_back(std::to_string(e.min_level));
|
||||||
|
v.push_back(std::to_string(e.max_level));
|
||||||
|
v.push_back(std::to_string(e.level_spread));
|
||||||
|
v.push_back(std::to_string(e.min_players));
|
||||||
|
v.push_back(std::to_string(e.max_players));
|
||||||
|
v.push_back(std::to_string(e.repeatable));
|
||||||
|
v.push_back(std::to_string(e.faction_reward));
|
||||||
|
v.push_back("'" + Strings::Escape(e.completion_emote) + "'");
|
||||||
|
v.push_back(std::to_string(e.replay_timer_group));
|
||||||
|
v.push_back(std::to_string(e.replay_timer_seconds));
|
||||||
|
v.push_back(std::to_string(e.request_timer_group));
|
||||||
|
v.push_back(std::to_string(e.request_timer_seconds));
|
||||||
|
v.push_back(std::to_string(e.dz_template_id));
|
||||||
|
v.push_back(std::to_string(e.lock_activity_id));
|
||||||
|
v.push_back(std::to_string(e.faction_amount));
|
||||||
|
v.push_back(std::to_string(e.enabled));
|
||||||
|
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES ({})",
|
||||||
|
BaseReplace(),
|
||||||
|
Strings::Implode(",", v)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int ReplaceMany(
|
||||||
|
Database& db,
|
||||||
|
const std::vector<Tasks> &entries
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_chunks;
|
||||||
|
|
||||||
|
for (auto &e: entries) {
|
||||||
|
std::vector<std::string> v;
|
||||||
|
|
||||||
|
v.push_back(std::to_string(e.id));
|
||||||
|
v.push_back(std::to_string(e.type));
|
||||||
|
v.push_back(std::to_string(e.duration));
|
||||||
|
v.push_back(std::to_string(e.duration_code));
|
||||||
|
v.push_back("'" + Strings::Escape(e.title) + "'");
|
||||||
|
v.push_back("'" + Strings::Escape(e.description) + "'");
|
||||||
|
v.push_back("'" + Strings::Escape(e.reward_text) + "'");
|
||||||
|
v.push_back("'" + Strings::Escape(e.reward_id_list) + "'");
|
||||||
|
v.push_back(std::to_string(e.cash_reward));
|
||||||
|
v.push_back(std::to_string(e.exp_reward));
|
||||||
|
v.push_back(std::to_string(e.reward_method));
|
||||||
|
v.push_back(std::to_string(e.reward_points));
|
||||||
|
v.push_back(std::to_string(e.reward_point_type));
|
||||||
|
v.push_back(std::to_string(e.min_level));
|
||||||
|
v.push_back(std::to_string(e.max_level));
|
||||||
|
v.push_back(std::to_string(e.level_spread));
|
||||||
|
v.push_back(std::to_string(e.min_players));
|
||||||
|
v.push_back(std::to_string(e.max_players));
|
||||||
|
v.push_back(std::to_string(e.repeatable));
|
||||||
|
v.push_back(std::to_string(e.faction_reward));
|
||||||
|
v.push_back("'" + Strings::Escape(e.completion_emote) + "'");
|
||||||
|
v.push_back(std::to_string(e.replay_timer_group));
|
||||||
|
v.push_back(std::to_string(e.replay_timer_seconds));
|
||||||
|
v.push_back(std::to_string(e.request_timer_group));
|
||||||
|
v.push_back(std::to_string(e.request_timer_seconds));
|
||||||
|
v.push_back(std::to_string(e.dz_template_id));
|
||||||
|
v.push_back(std::to_string(e.lock_activity_id));
|
||||||
|
v.push_back(std::to_string(e.faction_amount));
|
||||||
|
v.push_back(std::to_string(e.enabled));
|
||||||
|
|
||||||
|
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> v;
|
||||||
|
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES {}",
|
||||||
|
BaseReplace(),
|
||||||
|
Strings::Implode(",", insert_chunks)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //EQEMU_BASE_TASKS_REPOSITORY_H
|
#endif //EQEMU_BASE_TASKS_REPOSITORY_H
|
||||||
|
|||||||
@ -42,7 +42,7 @@
|
|||||||
* Manifest: https://github.com/EQEmu/Server/blob/master/utils/sql/db_update_manifest.txt
|
* Manifest: https://github.com/EQEmu/Server/blob/master/utils/sql/db_update_manifest.txt
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define CURRENT_BINARY_DATABASE_VERSION 9248
|
#define CURRENT_BINARY_DATABASE_VERSION 9249
|
||||||
|
|
||||||
#define CURRENT_BINARY_BOTS_DATABASE_VERSION 9041
|
#define CURRENT_BINARY_BOTS_DATABASE_VERSION 9041
|
||||||
|
|
||||||
|
|||||||
@ -460,7 +460,7 @@ void SharedTaskManager::LoadSharedTaskState()
|
|||||||
|
|
||||||
SharedTaskManager *SharedTaskManager::LoadTaskData()
|
SharedTaskManager *SharedTaskManager::LoadTaskData()
|
||||||
{
|
{
|
||||||
m_task_data = TasksRepository::All(*m_content_database);
|
m_task_data = TasksRepository::GetWhere(*m_content_database, "enabled = 1");
|
||||||
m_task_activity_data = TaskActivitiesRepository::All(*m_content_database);
|
m_task_activity_data = TaskActivitiesRepository::All(*m_content_database);
|
||||||
|
|
||||||
LogTasks("Loaded tasks [{}] activities [{}]", m_task_data.size(), m_task_activity_data.size());
|
LogTasks("Loaded tasks [{}] activities [{}]", m_task_data.size(), m_task_activity_data.size());
|
||||||
|
|||||||
@ -52,6 +52,8 @@ bool TaskManager::LoadTasks(int single_task)
|
|||||||
task_query_filter = fmt::format("id > 0");
|
task_query_filter = fmt::format("id > 0");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
task_query_filter += " AND enabled = 1";
|
||||||
|
|
||||||
// load task level data
|
// load task level data
|
||||||
auto repo_tasks = TasksRepository::GetWhere(content_db, task_query_filter);
|
auto repo_tasks = TasksRepository::GetWhere(content_db, task_query_filter);
|
||||||
m_task_data.reserve(repo_tasks.size());
|
m_task_data.reserve(repo_tasks.size());
|
||||||
@ -127,7 +129,7 @@ bool TaskManager::LoadTasks(int single_task)
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
LogTasks("Loaded [{}] Tasks", repo_tasks.size());
|
LogInfo("Loaded [{}] task(s)", repo_tasks.size());
|
||||||
|
|
||||||
std::string activities_query_filter = fmt::format(
|
std::string activities_query_filter = fmt::format(
|
||||||
"taskid = {} and activityid < {} ORDER BY taskid, activityid ASC",
|
"taskid = {} and activityid < {} ORDER BY taskid, activityid ASC",
|
||||||
@ -256,7 +258,7 @@ bool TaskManager::LoadTasks(int single_task)
|
|||||||
task_data->activity_count++;
|
task_data->activity_count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
LogTasks("Loaded [{}] Task Activities", task_activities.size());
|
LogInfo("Loaded [{}] task activities", task_activities.size());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user