mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-31 00:46:46 +00:00
[Repositories] Add GetMaxId, Count (#2371)
* [Repositories] Add GetMaxId, Count * Update cmake with repositories, regenerate extended repos * Remove license from files * Simplify receivers * Receiver simplify remaining * Simplify receivers final * Pass params by const reference * Modernize grid tables * Remove guild members since it doesn't conform as a generatable table * PR comment
This commit is contained in:
@@ -154,40 +154,40 @@ public:
|
||||
|
||||
static Tasks NewEntity()
|
||||
{
|
||||
Tasks entry{};
|
||||
Tasks e{};
|
||||
|
||||
entry.id = 0;
|
||||
entry.type = 0;
|
||||
entry.duration = 0;
|
||||
entry.duration_code = 0;
|
||||
entry.title = "";
|
||||
entry.description = "";
|
||||
entry.reward = "";
|
||||
entry.rewardid = 0;
|
||||
entry.cashreward = 0;
|
||||
entry.xpreward = 0;
|
||||
entry.rewardmethod = 2;
|
||||
entry.reward_points = 0;
|
||||
entry.reward_point_type = 0;
|
||||
entry.minlevel = 0;
|
||||
entry.maxlevel = 0;
|
||||
entry.level_spread = 0;
|
||||
entry.min_players = 0;
|
||||
entry.max_players = 0;
|
||||
entry.repeatable = 1;
|
||||
entry.faction_reward = 0;
|
||||
entry.completion_emote = "";
|
||||
entry.replay_timer_group = 0;
|
||||
entry.replay_timer_seconds = 0;
|
||||
entry.request_timer_group = 0;
|
||||
entry.request_timer_seconds = 0;
|
||||
entry.dz_template_id = 0;
|
||||
entry.lock_activity_id = -1;
|
||||
e.id = 0;
|
||||
e.type = 0;
|
||||
e.duration = 0;
|
||||
e.duration_code = 0;
|
||||
e.title = "";
|
||||
e.description = "";
|
||||
e.reward = "";
|
||||
e.rewardid = 0;
|
||||
e.cashreward = 0;
|
||||
e.xpreward = 0;
|
||||
e.rewardmethod = 2;
|
||||
e.reward_points = 0;
|
||||
e.reward_point_type = 0;
|
||||
e.minlevel = 0;
|
||||
e.maxlevel = 0;
|
||||
e.level_spread = 0;
|
||||
e.min_players = 0;
|
||||
e.max_players = 0;
|
||||
e.repeatable = 1;
|
||||
e.faction_reward = 0;
|
||||
e.completion_emote = "";
|
||||
e.replay_timer_group = 0;
|
||||
e.replay_timer_seconds = 0;
|
||||
e.request_timer_group = 0;
|
||||
e.request_timer_seconds = 0;
|
||||
e.dz_template_id = 0;
|
||||
e.lock_activity_id = -1;
|
||||
|
||||
return entry;
|
||||
return e;
|
||||
}
|
||||
|
||||
static Tasks GetTasksEntry(
|
||||
static Tasks GetTasks(
|
||||
const std::vector<Tasks> &taskss,
|
||||
int tasks_id
|
||||
)
|
||||
@@ -216,37 +216,37 @@ public:
|
||||
|
||||
auto row = results.begin();
|
||||
if (results.RowCount() == 1) {
|
||||
Tasks entry{};
|
||||
Tasks e{};
|
||||
|
||||
entry.id = atoi(row[0]);
|
||||
entry.type = atoi(row[1]);
|
||||
entry.duration = atoi(row[2]);
|
||||
entry.duration_code = atoi(row[3]);
|
||||
entry.title = row[4] ? row[4] : "";
|
||||
entry.description = row[5] ? row[5] : "";
|
||||
entry.reward = row[6] ? row[6] : "";
|
||||
entry.rewardid = atoi(row[7]);
|
||||
entry.cashreward = atoi(row[8]);
|
||||
entry.xpreward = atoi(row[9]);
|
||||
entry.rewardmethod = atoi(row[10]);
|
||||
entry.reward_points = atoi(row[11]);
|
||||
entry.reward_point_type = atoi(row[12]);
|
||||
entry.minlevel = atoi(row[13]);
|
||||
entry.maxlevel = atoi(row[14]);
|
||||
entry.level_spread = atoi(row[15]);
|
||||
entry.min_players = atoi(row[16]);
|
||||
entry.max_players = atoi(row[17]);
|
||||
entry.repeatable = atoi(row[18]);
|
||||
entry.faction_reward = atoi(row[19]);
|
||||
entry.completion_emote = row[20] ? row[20] : "";
|
||||
entry.replay_timer_group = atoi(row[21]);
|
||||
entry.replay_timer_seconds = atoi(row[22]);
|
||||
entry.request_timer_group = atoi(row[23]);
|
||||
entry.request_timer_seconds = atoi(row[24]);
|
||||
entry.dz_template_id = atoi(row[25]);
|
||||
entry.lock_activity_id = atoi(row[26]);
|
||||
e.id = atoi(row[0]);
|
||||
e.type = atoi(row[1]);
|
||||
e.duration = atoi(row[2]);
|
||||
e.duration_code = atoi(row[3]);
|
||||
e.title = row[4] ? row[4] : "";
|
||||
e.description = row[5] ? row[5] : "";
|
||||
e.reward = row[6] ? row[6] : "";
|
||||
e.rewardid = atoi(row[7]);
|
||||
e.cashreward = atoi(row[8]);
|
||||
e.xpreward = atoi(row[9]);
|
||||
e.rewardmethod = atoi(row[10]);
|
||||
e.reward_points = atoi(row[11]);
|
||||
e.reward_point_type = atoi(row[12]);
|
||||
e.minlevel = atoi(row[13]);
|
||||
e.maxlevel = atoi(row[14]);
|
||||
e.level_spread = atoi(row[15]);
|
||||
e.min_players = atoi(row[16]);
|
||||
e.max_players = atoi(row[17]);
|
||||
e.repeatable = atoi(row[18]);
|
||||
e.faction_reward = atoi(row[19]);
|
||||
e.completion_emote = row[20] ? row[20] : "";
|
||||
e.replay_timer_group = atoi(row[21]);
|
||||
e.replay_timer_seconds = atoi(row[22]);
|
||||
e.request_timer_group = atoi(row[23]);
|
||||
e.request_timer_seconds = atoi(row[24]);
|
||||
e.dz_template_id = atoi(row[25]);
|
||||
e.lock_activity_id = atoi(row[26]);
|
||||
|
||||
return entry;
|
||||
return e;
|
||||
}
|
||||
|
||||
return NewEntity();
|
||||
@@ -271,48 +271,48 @@ public:
|
||||
|
||||
static int UpdateOne(
|
||||
Database& db,
|
||||
Tasks tasks_entry
|
||||
const Tasks &e
|
||||
)
|
||||
{
|
||||
std::vector<std::string> update_values;
|
||||
std::vector<std::string> v;
|
||||
|
||||
auto columns = Columns();
|
||||
|
||||
update_values.push_back(columns[0] + " = " + std::to_string(tasks_entry.id));
|
||||
update_values.push_back(columns[1] + " = " + std::to_string(tasks_entry.type));
|
||||
update_values.push_back(columns[2] + " = " + std::to_string(tasks_entry.duration));
|
||||
update_values.push_back(columns[3] + " = " + std::to_string(tasks_entry.duration_code));
|
||||
update_values.push_back(columns[4] + " = '" + Strings::Escape(tasks_entry.title) + "'");
|
||||
update_values.push_back(columns[5] + " = '" + Strings::Escape(tasks_entry.description) + "'");
|
||||
update_values.push_back(columns[6] + " = '" + Strings::Escape(tasks_entry.reward) + "'");
|
||||
update_values.push_back(columns[7] + " = " + std::to_string(tasks_entry.rewardid));
|
||||
update_values.push_back(columns[8] + " = " + std::to_string(tasks_entry.cashreward));
|
||||
update_values.push_back(columns[9] + " = " + std::to_string(tasks_entry.xpreward));
|
||||
update_values.push_back(columns[10] + " = " + std::to_string(tasks_entry.rewardmethod));
|
||||
update_values.push_back(columns[11] + " = " + std::to_string(tasks_entry.reward_points));
|
||||
update_values.push_back(columns[12] + " = " + std::to_string(tasks_entry.reward_point_type));
|
||||
update_values.push_back(columns[13] + " = " + std::to_string(tasks_entry.minlevel));
|
||||
update_values.push_back(columns[14] + " = " + std::to_string(tasks_entry.maxlevel));
|
||||
update_values.push_back(columns[15] + " = " + std::to_string(tasks_entry.level_spread));
|
||||
update_values.push_back(columns[16] + " = " + std::to_string(tasks_entry.min_players));
|
||||
update_values.push_back(columns[17] + " = " + std::to_string(tasks_entry.max_players));
|
||||
update_values.push_back(columns[18] + " = " + std::to_string(tasks_entry.repeatable));
|
||||
update_values.push_back(columns[19] + " = " + std::to_string(tasks_entry.faction_reward));
|
||||
update_values.push_back(columns[20] + " = '" + Strings::Escape(tasks_entry.completion_emote) + "'");
|
||||
update_values.push_back(columns[21] + " = " + std::to_string(tasks_entry.replay_timer_group));
|
||||
update_values.push_back(columns[22] + " = " + std::to_string(tasks_entry.replay_timer_seconds));
|
||||
update_values.push_back(columns[23] + " = " + std::to_string(tasks_entry.request_timer_group));
|
||||
update_values.push_back(columns[24] + " = " + std::to_string(tasks_entry.request_timer_seconds));
|
||||
update_values.push_back(columns[25] + " = " + std::to_string(tasks_entry.dz_template_id));
|
||||
update_values.push_back(columns[26] + " = " + std::to_string(tasks_entry.lock_activity_id));
|
||||
v.push_back(columns[0] + " = " + std::to_string(e.id));
|
||||
v.push_back(columns[1] + " = " + std::to_string(e.type));
|
||||
v.push_back(columns[2] + " = " + std::to_string(e.duration));
|
||||
v.push_back(columns[3] + " = " + std::to_string(e.duration_code));
|
||||
v.push_back(columns[4] + " = '" + Strings::Escape(e.title) + "'");
|
||||
v.push_back(columns[5] + " = '" + Strings::Escape(e.description) + "'");
|
||||
v.push_back(columns[6] + " = '" + Strings::Escape(e.reward) + "'");
|
||||
v.push_back(columns[7] + " = " + std::to_string(e.rewardid));
|
||||
v.push_back(columns[8] + " = " + std::to_string(e.cashreward));
|
||||
v.push_back(columns[9] + " = " + std::to_string(e.xpreward));
|
||||
v.push_back(columns[10] + " = " + std::to_string(e.rewardmethod));
|
||||
v.push_back(columns[11] + " = " + std::to_string(e.reward_points));
|
||||
v.push_back(columns[12] + " = " + std::to_string(e.reward_point_type));
|
||||
v.push_back(columns[13] + " = " + std::to_string(e.minlevel));
|
||||
v.push_back(columns[14] + " = " + std::to_string(e.maxlevel));
|
||||
v.push_back(columns[15] + " = " + std::to_string(e.level_spread));
|
||||
v.push_back(columns[16] + " = " + std::to_string(e.min_players));
|
||||
v.push_back(columns[17] + " = " + std::to_string(e.max_players));
|
||||
v.push_back(columns[18] + " = " + std::to_string(e.repeatable));
|
||||
v.push_back(columns[19] + " = " + std::to_string(e.faction_reward));
|
||||
v.push_back(columns[20] + " = '" + Strings::Escape(e.completion_emote) + "'");
|
||||
v.push_back(columns[21] + " = " + std::to_string(e.replay_timer_group));
|
||||
v.push_back(columns[22] + " = " + std::to_string(e.replay_timer_seconds));
|
||||
v.push_back(columns[23] + " = " + std::to_string(e.request_timer_group));
|
||||
v.push_back(columns[24] + " = " + std::to_string(e.request_timer_seconds));
|
||||
v.push_back(columns[25] + " = " + std::to_string(e.dz_template_id));
|
||||
v.push_back(columns[26] + " = " + std::to_string(e.lock_activity_id));
|
||||
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"UPDATE {} SET {} WHERE {} = {}",
|
||||
TableName(),
|
||||
Strings::Implode(", ", update_values),
|
||||
Strings::Implode(", ", v),
|
||||
PrimaryKey(),
|
||||
tasks_entry.id
|
||||
e.id
|
||||
)
|
||||
);
|
||||
|
||||
@@ -321,99 +321,99 @@ public:
|
||||
|
||||
static Tasks InsertOne(
|
||||
Database& db,
|
||||
Tasks tasks_entry
|
||||
Tasks e
|
||||
)
|
||||
{
|
||||
std::vector<std::string> insert_values;
|
||||
std::vector<std::string> v;
|
||||
|
||||
insert_values.push_back(std::to_string(tasks_entry.id));
|
||||
insert_values.push_back(std::to_string(tasks_entry.type));
|
||||
insert_values.push_back(std::to_string(tasks_entry.duration));
|
||||
insert_values.push_back(std::to_string(tasks_entry.duration_code));
|
||||
insert_values.push_back("'" + Strings::Escape(tasks_entry.title) + "'");
|
||||
insert_values.push_back("'" + Strings::Escape(tasks_entry.description) + "'");
|
||||
insert_values.push_back("'" + Strings::Escape(tasks_entry.reward) + "'");
|
||||
insert_values.push_back(std::to_string(tasks_entry.rewardid));
|
||||
insert_values.push_back(std::to_string(tasks_entry.cashreward));
|
||||
insert_values.push_back(std::to_string(tasks_entry.xpreward));
|
||||
insert_values.push_back(std::to_string(tasks_entry.rewardmethod));
|
||||
insert_values.push_back(std::to_string(tasks_entry.reward_points));
|
||||
insert_values.push_back(std::to_string(tasks_entry.reward_point_type));
|
||||
insert_values.push_back(std::to_string(tasks_entry.minlevel));
|
||||
insert_values.push_back(std::to_string(tasks_entry.maxlevel));
|
||||
insert_values.push_back(std::to_string(tasks_entry.level_spread));
|
||||
insert_values.push_back(std::to_string(tasks_entry.min_players));
|
||||
insert_values.push_back(std::to_string(tasks_entry.max_players));
|
||||
insert_values.push_back(std::to_string(tasks_entry.repeatable));
|
||||
insert_values.push_back(std::to_string(tasks_entry.faction_reward));
|
||||
insert_values.push_back("'" + Strings::Escape(tasks_entry.completion_emote) + "'");
|
||||
insert_values.push_back(std::to_string(tasks_entry.replay_timer_group));
|
||||
insert_values.push_back(std::to_string(tasks_entry.replay_timer_seconds));
|
||||
insert_values.push_back(std::to_string(tasks_entry.request_timer_group));
|
||||
insert_values.push_back(std::to_string(tasks_entry.request_timer_seconds));
|
||||
insert_values.push_back(std::to_string(tasks_entry.dz_template_id));
|
||||
insert_values.push_back(std::to_string(tasks_entry.lock_activity_id));
|
||||
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) + "'");
|
||||
v.push_back(std::to_string(e.rewardid));
|
||||
v.push_back(std::to_string(e.cashreward));
|
||||
v.push_back(std::to_string(e.xpreward));
|
||||
v.push_back(std::to_string(e.rewardmethod));
|
||||
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.minlevel));
|
||||
v.push_back(std::to_string(e.maxlevel));
|
||||
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));
|
||||
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"{} VALUES ({})",
|
||||
BaseInsert(),
|
||||
Strings::Implode(",", insert_values)
|
||||
Strings::Implode(",", v)
|
||||
)
|
||||
);
|
||||
|
||||
if (results.Success()) {
|
||||
tasks_entry.id = results.LastInsertedID();
|
||||
return tasks_entry;
|
||||
e.id = results.LastInsertedID();
|
||||
return e;
|
||||
}
|
||||
|
||||
tasks_entry = NewEntity();
|
||||
e = NewEntity();
|
||||
|
||||
return tasks_entry;
|
||||
return e;
|
||||
}
|
||||
|
||||
static int InsertMany(
|
||||
Database& db,
|
||||
std::vector<Tasks> tasks_entries
|
||||
const std::vector<Tasks> &entries
|
||||
)
|
||||
{
|
||||
std::vector<std::string> insert_chunks;
|
||||
|
||||
for (auto &tasks_entry: tasks_entries) {
|
||||
std::vector<std::string> insert_values;
|
||||
for (auto &e: entries) {
|
||||
std::vector<std::string> v;
|
||||
|
||||
insert_values.push_back(std::to_string(tasks_entry.id));
|
||||
insert_values.push_back(std::to_string(tasks_entry.type));
|
||||
insert_values.push_back(std::to_string(tasks_entry.duration));
|
||||
insert_values.push_back(std::to_string(tasks_entry.duration_code));
|
||||
insert_values.push_back("'" + Strings::Escape(tasks_entry.title) + "'");
|
||||
insert_values.push_back("'" + Strings::Escape(tasks_entry.description) + "'");
|
||||
insert_values.push_back("'" + Strings::Escape(tasks_entry.reward) + "'");
|
||||
insert_values.push_back(std::to_string(tasks_entry.rewardid));
|
||||
insert_values.push_back(std::to_string(tasks_entry.cashreward));
|
||||
insert_values.push_back(std::to_string(tasks_entry.xpreward));
|
||||
insert_values.push_back(std::to_string(tasks_entry.rewardmethod));
|
||||
insert_values.push_back(std::to_string(tasks_entry.reward_points));
|
||||
insert_values.push_back(std::to_string(tasks_entry.reward_point_type));
|
||||
insert_values.push_back(std::to_string(tasks_entry.minlevel));
|
||||
insert_values.push_back(std::to_string(tasks_entry.maxlevel));
|
||||
insert_values.push_back(std::to_string(tasks_entry.level_spread));
|
||||
insert_values.push_back(std::to_string(tasks_entry.min_players));
|
||||
insert_values.push_back(std::to_string(tasks_entry.max_players));
|
||||
insert_values.push_back(std::to_string(tasks_entry.repeatable));
|
||||
insert_values.push_back(std::to_string(tasks_entry.faction_reward));
|
||||
insert_values.push_back("'" + Strings::Escape(tasks_entry.completion_emote) + "'");
|
||||
insert_values.push_back(std::to_string(tasks_entry.replay_timer_group));
|
||||
insert_values.push_back(std::to_string(tasks_entry.replay_timer_seconds));
|
||||
insert_values.push_back(std::to_string(tasks_entry.request_timer_group));
|
||||
insert_values.push_back(std::to_string(tasks_entry.request_timer_seconds));
|
||||
insert_values.push_back(std::to_string(tasks_entry.dz_template_id));
|
||||
insert_values.push_back(std::to_string(tasks_entry.lock_activity_id));
|
||||
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) + "'");
|
||||
v.push_back(std::to_string(e.rewardid));
|
||||
v.push_back(std::to_string(e.cashreward));
|
||||
v.push_back(std::to_string(e.xpreward));
|
||||
v.push_back(std::to_string(e.rewardmethod));
|
||||
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.minlevel));
|
||||
v.push_back(std::to_string(e.maxlevel));
|
||||
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));
|
||||
|
||||
insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")");
|
||||
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
|
||||
}
|
||||
|
||||
std::vector<std::string> insert_values;
|
||||
std::vector<std::string> v;
|
||||
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
@@ -440,43 +440,43 @@ public:
|
||||
all_entries.reserve(results.RowCount());
|
||||
|
||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||
Tasks entry{};
|
||||
Tasks e{};
|
||||
|
||||
entry.id = atoi(row[0]);
|
||||
entry.type = atoi(row[1]);
|
||||
entry.duration = atoi(row[2]);
|
||||
entry.duration_code = atoi(row[3]);
|
||||
entry.title = row[4] ? row[4] : "";
|
||||
entry.description = row[5] ? row[5] : "";
|
||||
entry.reward = row[6] ? row[6] : "";
|
||||
entry.rewardid = atoi(row[7]);
|
||||
entry.cashreward = atoi(row[8]);
|
||||
entry.xpreward = atoi(row[9]);
|
||||
entry.rewardmethod = atoi(row[10]);
|
||||
entry.reward_points = atoi(row[11]);
|
||||
entry.reward_point_type = atoi(row[12]);
|
||||
entry.minlevel = atoi(row[13]);
|
||||
entry.maxlevel = atoi(row[14]);
|
||||
entry.level_spread = atoi(row[15]);
|
||||
entry.min_players = atoi(row[16]);
|
||||
entry.max_players = atoi(row[17]);
|
||||
entry.repeatable = atoi(row[18]);
|
||||
entry.faction_reward = atoi(row[19]);
|
||||
entry.completion_emote = row[20] ? row[20] : "";
|
||||
entry.replay_timer_group = atoi(row[21]);
|
||||
entry.replay_timer_seconds = atoi(row[22]);
|
||||
entry.request_timer_group = atoi(row[23]);
|
||||
entry.request_timer_seconds = atoi(row[24]);
|
||||
entry.dz_template_id = atoi(row[25]);
|
||||
entry.lock_activity_id = atoi(row[26]);
|
||||
e.id = atoi(row[0]);
|
||||
e.type = atoi(row[1]);
|
||||
e.duration = atoi(row[2]);
|
||||
e.duration_code = atoi(row[3]);
|
||||
e.title = row[4] ? row[4] : "";
|
||||
e.description = row[5] ? row[5] : "";
|
||||
e.reward = row[6] ? row[6] : "";
|
||||
e.rewardid = atoi(row[7]);
|
||||
e.cashreward = atoi(row[8]);
|
||||
e.xpreward = atoi(row[9]);
|
||||
e.rewardmethod = atoi(row[10]);
|
||||
e.reward_points = atoi(row[11]);
|
||||
e.reward_point_type = atoi(row[12]);
|
||||
e.minlevel = atoi(row[13]);
|
||||
e.maxlevel = atoi(row[14]);
|
||||
e.level_spread = atoi(row[15]);
|
||||
e.min_players = atoi(row[16]);
|
||||
e.max_players = atoi(row[17]);
|
||||
e.repeatable = atoi(row[18]);
|
||||
e.faction_reward = atoi(row[19]);
|
||||
e.completion_emote = row[20] ? row[20] : "";
|
||||
e.replay_timer_group = atoi(row[21]);
|
||||
e.replay_timer_seconds = atoi(row[22]);
|
||||
e.request_timer_group = atoi(row[23]);
|
||||
e.request_timer_seconds = atoi(row[24]);
|
||||
e.dz_template_id = atoi(row[25]);
|
||||
e.lock_activity_id = atoi(row[26]);
|
||||
|
||||
all_entries.push_back(entry);
|
||||
all_entries.push_back(e);
|
||||
}
|
||||
|
||||
return all_entries;
|
||||
}
|
||||
|
||||
static std::vector<Tasks> GetWhere(Database& db, std::string where_filter)
|
||||
static std::vector<Tasks> GetWhere(Database& db, const std::string &where_filter)
|
||||
{
|
||||
std::vector<Tasks> all_entries;
|
||||
|
||||
@@ -491,43 +491,43 @@ public:
|
||||
all_entries.reserve(results.RowCount());
|
||||
|
||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||
Tasks entry{};
|
||||
Tasks e{};
|
||||
|
||||
entry.id = atoi(row[0]);
|
||||
entry.type = atoi(row[1]);
|
||||
entry.duration = atoi(row[2]);
|
||||
entry.duration_code = atoi(row[3]);
|
||||
entry.title = row[4] ? row[4] : "";
|
||||
entry.description = row[5] ? row[5] : "";
|
||||
entry.reward = row[6] ? row[6] : "";
|
||||
entry.rewardid = atoi(row[7]);
|
||||
entry.cashreward = atoi(row[8]);
|
||||
entry.xpreward = atoi(row[9]);
|
||||
entry.rewardmethod = atoi(row[10]);
|
||||
entry.reward_points = atoi(row[11]);
|
||||
entry.reward_point_type = atoi(row[12]);
|
||||
entry.minlevel = atoi(row[13]);
|
||||
entry.maxlevel = atoi(row[14]);
|
||||
entry.level_spread = atoi(row[15]);
|
||||
entry.min_players = atoi(row[16]);
|
||||
entry.max_players = atoi(row[17]);
|
||||
entry.repeatable = atoi(row[18]);
|
||||
entry.faction_reward = atoi(row[19]);
|
||||
entry.completion_emote = row[20] ? row[20] : "";
|
||||
entry.replay_timer_group = atoi(row[21]);
|
||||
entry.replay_timer_seconds = atoi(row[22]);
|
||||
entry.request_timer_group = atoi(row[23]);
|
||||
entry.request_timer_seconds = atoi(row[24]);
|
||||
entry.dz_template_id = atoi(row[25]);
|
||||
entry.lock_activity_id = atoi(row[26]);
|
||||
e.id = atoi(row[0]);
|
||||
e.type = atoi(row[1]);
|
||||
e.duration = atoi(row[2]);
|
||||
e.duration_code = atoi(row[3]);
|
||||
e.title = row[4] ? row[4] : "";
|
||||
e.description = row[5] ? row[5] : "";
|
||||
e.reward = row[6] ? row[6] : "";
|
||||
e.rewardid = atoi(row[7]);
|
||||
e.cashreward = atoi(row[8]);
|
||||
e.xpreward = atoi(row[9]);
|
||||
e.rewardmethod = atoi(row[10]);
|
||||
e.reward_points = atoi(row[11]);
|
||||
e.reward_point_type = atoi(row[12]);
|
||||
e.minlevel = atoi(row[13]);
|
||||
e.maxlevel = atoi(row[14]);
|
||||
e.level_spread = atoi(row[15]);
|
||||
e.min_players = atoi(row[16]);
|
||||
e.max_players = atoi(row[17]);
|
||||
e.repeatable = atoi(row[18]);
|
||||
e.faction_reward = atoi(row[19]);
|
||||
e.completion_emote = row[20] ? row[20] : "";
|
||||
e.replay_timer_group = atoi(row[21]);
|
||||
e.replay_timer_seconds = atoi(row[22]);
|
||||
e.request_timer_group = atoi(row[23]);
|
||||
e.request_timer_seconds = atoi(row[24]);
|
||||
e.dz_template_id = atoi(row[25]);
|
||||
e.lock_activity_id = atoi(row[26]);
|
||||
|
||||
all_entries.push_back(entry);
|
||||
all_entries.push_back(e);
|
||||
}
|
||||
|
||||
return all_entries;
|
||||
}
|
||||
|
||||
static int DeleteWhere(Database& db, std::string where_filter)
|
||||
static int DeleteWhere(Database& db, const std::string &where_filter)
|
||||
{
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
@@ -552,6 +552,32 @@ public:
|
||||
return (results.Success() ? results.RowsAffected() : 0);
|
||||
}
|
||||
|
||||
static int64 GetMaxId(Database& db)
|
||||
{
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"SELECT COALESCE(MAX({}), 0) FROM {}",
|
||||
PrimaryKey(),
|
||||
TableName()
|
||||
)
|
||||
);
|
||||
|
||||
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
|
||||
}
|
||||
|
||||
static int64 Count(Database& db, const std::string &where_filter = "")
|
||||
{
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"SELECT COUNT(*) FROM {} {}",
|
||||
TableName(),
|
||||
(where_filter.empty() ? "" : "WHERE " + where_filter)
|
||||
)
|
||||
);
|
||||
|
||||
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif //EQEMU_BASE_TASKS_REPOSITORY_H
|
||||
|
||||
Reference in New Issue
Block a user