mirror of
https://github.com/EQEmu/Server.git
synced 2026-06-28 09:17:15 +00:00
[Repository] Add null integer column support, instance_list notes migration, regenerate repositories (#3969)
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
* Any modifications to base repositories are to be made by the generator only
|
||||
*
|
||||
* @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_TRADESKILL_RECIPE_REPOSITORY_H
|
||||
@@ -28,6 +28,7 @@ public:
|
||||
int8_t replace_container;
|
||||
std::string notes;
|
||||
int8_t must_learn;
|
||||
int32_t learned_by_item_id;
|
||||
int8_t quest;
|
||||
int8_t enabled;
|
||||
int8_t min_expansion;
|
||||
@@ -53,6 +54,7 @@ public:
|
||||
"replace_container",
|
||||
"notes",
|
||||
"must_learn",
|
||||
"learned_by_item_id",
|
||||
"quest",
|
||||
"enabled",
|
||||
"min_expansion",
|
||||
@@ -74,6 +76,7 @@ public:
|
||||
"replace_container",
|
||||
"notes",
|
||||
"must_learn",
|
||||
"learned_by_item_id",
|
||||
"quest",
|
||||
"enabled",
|
||||
"min_expansion",
|
||||
@@ -129,6 +132,7 @@ public:
|
||||
e.replace_container = 0;
|
||||
e.notes = "";
|
||||
e.must_learn = 0;
|
||||
e.learned_by_item_id = 0;
|
||||
e.quest = 0;
|
||||
e.enabled = 1;
|
||||
e.min_expansion = -1;
|
||||
@@ -160,8 +164,9 @@ public:
|
||||
{
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"{} WHERE id = {} LIMIT 1",
|
||||
"{} WHERE {} = {} LIMIT 1",
|
||||
BaseSelect(),
|
||||
PrimaryKey(),
|
||||
tradeskill_recipe_id
|
||||
)
|
||||
);
|
||||
@@ -179,12 +184,13 @@ public:
|
||||
e.replace_container = static_cast<int8_t>(atoi(row[6]));
|
||||
e.notes = row[7] ? row[7] : "";
|
||||
e.must_learn = static_cast<int8_t>(atoi(row[8]));
|
||||
e.quest = static_cast<int8_t>(atoi(row[9]));
|
||||
e.enabled = static_cast<int8_t>(atoi(row[10]));
|
||||
e.min_expansion = static_cast<int8_t>(atoi(row[11]));
|
||||
e.max_expansion = static_cast<int8_t>(atoi(row[12]));
|
||||
e.content_flags = row[13] ? row[13] : "";
|
||||
e.content_flags_disabled = row[14] ? row[14] : "";
|
||||
e.learned_by_item_id = static_cast<int32_t>(atoi(row[9]));
|
||||
e.quest = static_cast<int8_t>(atoi(row[10]));
|
||||
e.enabled = static_cast<int8_t>(atoi(row[11]));
|
||||
e.min_expansion = static_cast<int8_t>(atoi(row[12]));
|
||||
e.max_expansion = static_cast<int8_t>(atoi(row[13]));
|
||||
e.content_flags = row[14] ? row[14] : "";
|
||||
e.content_flags_disabled = row[15] ? row[15] : "";
|
||||
|
||||
return e;
|
||||
}
|
||||
@@ -226,12 +232,13 @@ public:
|
||||
v.push_back(columns[6] + " = " + std::to_string(e.replace_container));
|
||||
v.push_back(columns[7] + " = '" + Strings::Escape(e.notes) + "'");
|
||||
v.push_back(columns[8] + " = " + std::to_string(e.must_learn));
|
||||
v.push_back(columns[9] + " = " + std::to_string(e.quest));
|
||||
v.push_back(columns[10] + " = " + std::to_string(e.enabled));
|
||||
v.push_back(columns[11] + " = " + std::to_string(e.min_expansion));
|
||||
v.push_back(columns[12] + " = " + std::to_string(e.max_expansion));
|
||||
v.push_back(columns[13] + " = '" + Strings::Escape(e.content_flags) + "'");
|
||||
v.push_back(columns[14] + " = '" + Strings::Escape(e.content_flags_disabled) + "'");
|
||||
v.push_back(columns[9] + " = " + std::to_string(e.learned_by_item_id));
|
||||
v.push_back(columns[10] + " = " + std::to_string(e.quest));
|
||||
v.push_back(columns[11] + " = " + std::to_string(e.enabled));
|
||||
v.push_back(columns[12] + " = " + std::to_string(e.min_expansion));
|
||||
v.push_back(columns[13] + " = " + std::to_string(e.max_expansion));
|
||||
v.push_back(columns[14] + " = '" + Strings::Escape(e.content_flags) + "'");
|
||||
v.push_back(columns[15] + " = '" + Strings::Escape(e.content_flags_disabled) + "'");
|
||||
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
@@ -262,6 +269,7 @@ public:
|
||||
v.push_back(std::to_string(e.replace_container));
|
||||
v.push_back("'" + Strings::Escape(e.notes) + "'");
|
||||
v.push_back(std::to_string(e.must_learn));
|
||||
v.push_back(std::to_string(e.learned_by_item_id));
|
||||
v.push_back(std::to_string(e.quest));
|
||||
v.push_back(std::to_string(e.enabled));
|
||||
v.push_back(std::to_string(e.min_expansion));
|
||||
@@ -306,6 +314,7 @@ public:
|
||||
v.push_back(std::to_string(e.replace_container));
|
||||
v.push_back("'" + Strings::Escape(e.notes) + "'");
|
||||
v.push_back(std::to_string(e.must_learn));
|
||||
v.push_back(std::to_string(e.learned_by_item_id));
|
||||
v.push_back(std::to_string(e.quest));
|
||||
v.push_back(std::to_string(e.enabled));
|
||||
v.push_back(std::to_string(e.min_expansion));
|
||||
@@ -354,12 +363,13 @@ public:
|
||||
e.replace_container = static_cast<int8_t>(atoi(row[6]));
|
||||
e.notes = row[7] ? row[7] : "";
|
||||
e.must_learn = static_cast<int8_t>(atoi(row[8]));
|
||||
e.quest = static_cast<int8_t>(atoi(row[9]));
|
||||
e.enabled = static_cast<int8_t>(atoi(row[10]));
|
||||
e.min_expansion = static_cast<int8_t>(atoi(row[11]));
|
||||
e.max_expansion = static_cast<int8_t>(atoi(row[12]));
|
||||
e.content_flags = row[13] ? row[13] : "";
|
||||
e.content_flags_disabled = row[14] ? row[14] : "";
|
||||
e.learned_by_item_id = static_cast<int32_t>(atoi(row[9]));
|
||||
e.quest = static_cast<int8_t>(atoi(row[10]));
|
||||
e.enabled = static_cast<int8_t>(atoi(row[11]));
|
||||
e.min_expansion = static_cast<int8_t>(atoi(row[12]));
|
||||
e.max_expansion = static_cast<int8_t>(atoi(row[13]));
|
||||
e.content_flags = row[14] ? row[14] : "";
|
||||
e.content_flags_disabled = row[15] ? row[15] : "";
|
||||
|
||||
all_entries.push_back(e);
|
||||
}
|
||||
@@ -393,12 +403,13 @@ public:
|
||||
e.replace_container = static_cast<int8_t>(atoi(row[6]));
|
||||
e.notes = row[7] ? row[7] : "";
|
||||
e.must_learn = static_cast<int8_t>(atoi(row[8]));
|
||||
e.quest = static_cast<int8_t>(atoi(row[9]));
|
||||
e.enabled = static_cast<int8_t>(atoi(row[10]));
|
||||
e.min_expansion = static_cast<int8_t>(atoi(row[11]));
|
||||
e.max_expansion = static_cast<int8_t>(atoi(row[12]));
|
||||
e.content_flags = row[13] ? row[13] : "";
|
||||
e.content_flags_disabled = row[14] ? row[14] : "";
|
||||
e.learned_by_item_id = static_cast<int32_t>(atoi(row[9]));
|
||||
e.quest = static_cast<int8_t>(atoi(row[10]));
|
||||
e.enabled = static_cast<int8_t>(atoi(row[11]));
|
||||
e.min_expansion = static_cast<int8_t>(atoi(row[12]));
|
||||
e.max_expansion = static_cast<int8_t>(atoi(row[13]));
|
||||
e.content_flags = row[14] ? row[14] : "";
|
||||
e.content_flags_disabled = row[15] ? row[15] : "";
|
||||
|
||||
all_entries.push_back(e);
|
||||
}
|
||||
@@ -457,6 +468,92 @@ public:
|
||||
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 TradeskillRecipe &e
|
||||
)
|
||||
{
|
||||
std::vector<std::string> v;
|
||||
|
||||
v.push_back(std::to_string(e.id));
|
||||
v.push_back("'" + Strings::Escape(e.name) + "'");
|
||||
v.push_back(std::to_string(e.tradeskill));
|
||||
v.push_back(std::to_string(e.skillneeded));
|
||||
v.push_back(std::to_string(e.trivial));
|
||||
v.push_back(std::to_string(e.nofail));
|
||||
v.push_back(std::to_string(e.replace_container));
|
||||
v.push_back("'" + Strings::Escape(e.notes) + "'");
|
||||
v.push_back(std::to_string(e.must_learn));
|
||||
v.push_back(std::to_string(e.learned_by_item_id));
|
||||
v.push_back(std::to_string(e.quest));
|
||||
v.push_back(std::to_string(e.enabled));
|
||||
v.push_back(std::to_string(e.min_expansion));
|
||||
v.push_back(std::to_string(e.max_expansion));
|
||||
v.push_back("'" + Strings::Escape(e.content_flags) + "'");
|
||||
v.push_back("'" + Strings::Escape(e.content_flags_disabled) + "'");
|
||||
|
||||
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<TradeskillRecipe> &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("'" + Strings::Escape(e.name) + "'");
|
||||
v.push_back(std::to_string(e.tradeskill));
|
||||
v.push_back(std::to_string(e.skillneeded));
|
||||
v.push_back(std::to_string(e.trivial));
|
||||
v.push_back(std::to_string(e.nofail));
|
||||
v.push_back(std::to_string(e.replace_container));
|
||||
v.push_back("'" + Strings::Escape(e.notes) + "'");
|
||||
v.push_back(std::to_string(e.must_learn));
|
||||
v.push_back(std::to_string(e.learned_by_item_id));
|
||||
v.push_back(std::to_string(e.quest));
|
||||
v.push_back(std::to_string(e.enabled));
|
||||
v.push_back(std::to_string(e.min_expansion));
|
||||
v.push_back(std::to_string(e.max_expansion));
|
||||
v.push_back("'" + Strings::Escape(e.content_flags) + "'");
|
||||
v.push_back("'" + Strings::Escape(e.content_flags_disabled) + "'");
|
||||
|
||||
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_TRADESKILL_RECIPE_REPOSITORY_H
|
||||
|
||||
Reference in New Issue
Block a user