[Repository] Add null integer column support, instance_list notes migration, regenerate repositories (#3969)

This commit is contained in:
Chris Miles
2024-01-12 22:23:55 -06:00
committed by GitHub
parent 1238a6ca68
commit 818f833d04
189 changed files with 17218 additions and 3604 deletions
@@ -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_START_ZONES_REPOSITORY_H
@@ -176,8 +176,9 @@ public:
{
auto results = db.QueryDatabase(
fmt::format(
"{} WHERE id = {} LIMIT 1",
"{} WHERE {} = {} LIMIT 1",
BaseSelect(),
PrimaryKey(),
start_zones_id
)
);
@@ -186,10 +187,10 @@ public:
if (results.RowCount() == 1) {
StartZones e{};
e.x = strtof(row[0], nullptr);
e.y = strtof(row[1], nullptr);
e.z = strtof(row[2], nullptr);
e.heading = strtof(row[3], nullptr);
e.x = row[0] ? strtof(row[0], nullptr) : 0;
e.y = row[1] ? strtof(row[1], nullptr) : 0;
e.z = row[2] ? strtof(row[2], nullptr) : 0;
e.heading = row[3] ? strtof(row[3], nullptr) : 0;
e.zone_id = static_cast<int32_t>(atoi(row[4]));
e.bind_id = static_cast<int32_t>(atoi(row[5]));
e.player_choice = static_cast<int32_t>(atoi(row[6]));
@@ -197,10 +198,10 @@ public:
e.player_deity = static_cast<int32_t>(atoi(row[8]));
e.player_race = static_cast<int32_t>(atoi(row[9]));
e.start_zone = static_cast<int32_t>(atoi(row[10]));
e.bind_x = strtof(row[11], nullptr);
e.bind_y = strtof(row[12], nullptr);
e.bind_z = strtof(row[13], nullptr);
e.select_rank = static_cast<uint8_t>(strtoul(row[14], nullptr, 10));
e.bind_x = row[11] ? strtof(row[11], nullptr) : 0;
e.bind_y = row[12] ? strtof(row[12], nullptr) : 0;
e.bind_z = row[13] ? strtof(row[13], nullptr) : 0;
e.select_rank = row[14] ? static_cast<uint8_t>(strtoul(row[14], nullptr, 10)) : 50;
e.min_expansion = static_cast<int8_t>(atoi(row[15]));
e.max_expansion = static_cast<int8_t>(atoi(row[16]));
e.content_flags = row[17] ? row[17] : "";
@@ -378,10 +379,10 @@ public:
for (auto row = results.begin(); row != results.end(); ++row) {
StartZones e{};
e.x = strtof(row[0], nullptr);
e.y = strtof(row[1], nullptr);
e.z = strtof(row[2], nullptr);
e.heading = strtof(row[3], nullptr);
e.x = row[0] ? strtof(row[0], nullptr) : 0;
e.y = row[1] ? strtof(row[1], nullptr) : 0;
e.z = row[2] ? strtof(row[2], nullptr) : 0;
e.heading = row[3] ? strtof(row[3], nullptr) : 0;
e.zone_id = static_cast<int32_t>(atoi(row[4]));
e.bind_id = static_cast<int32_t>(atoi(row[5]));
e.player_choice = static_cast<int32_t>(atoi(row[6]));
@@ -389,10 +390,10 @@ public:
e.player_deity = static_cast<int32_t>(atoi(row[8]));
e.player_race = static_cast<int32_t>(atoi(row[9]));
e.start_zone = static_cast<int32_t>(atoi(row[10]));
e.bind_x = strtof(row[11], nullptr);
e.bind_y = strtof(row[12], nullptr);
e.bind_z = strtof(row[13], nullptr);
e.select_rank = static_cast<uint8_t>(strtoul(row[14], nullptr, 10));
e.bind_x = row[11] ? strtof(row[11], nullptr) : 0;
e.bind_y = row[12] ? strtof(row[12], nullptr) : 0;
e.bind_z = row[13] ? strtof(row[13], nullptr) : 0;
e.select_rank = row[14] ? static_cast<uint8_t>(strtoul(row[14], nullptr, 10)) : 50;
e.min_expansion = static_cast<int8_t>(atoi(row[15]));
e.max_expansion = static_cast<int8_t>(atoi(row[16]));
e.content_flags = row[17] ? row[17] : "";
@@ -421,10 +422,10 @@ public:
for (auto row = results.begin(); row != results.end(); ++row) {
StartZones e{};
e.x = strtof(row[0], nullptr);
e.y = strtof(row[1], nullptr);
e.z = strtof(row[2], nullptr);
e.heading = strtof(row[3], nullptr);
e.x = row[0] ? strtof(row[0], nullptr) : 0;
e.y = row[1] ? strtof(row[1], nullptr) : 0;
e.z = row[2] ? strtof(row[2], nullptr) : 0;
e.heading = row[3] ? strtof(row[3], nullptr) : 0;
e.zone_id = static_cast<int32_t>(atoi(row[4]));
e.bind_id = static_cast<int32_t>(atoi(row[5]));
e.player_choice = static_cast<int32_t>(atoi(row[6]));
@@ -432,10 +433,10 @@ public:
e.player_deity = static_cast<int32_t>(atoi(row[8]));
e.player_race = static_cast<int32_t>(atoi(row[9]));
e.start_zone = static_cast<int32_t>(atoi(row[10]));
e.bind_x = strtof(row[11], nullptr);
e.bind_y = strtof(row[12], nullptr);
e.bind_z = strtof(row[13], nullptr);
e.select_rank = static_cast<uint8_t>(strtoul(row[14], nullptr, 10));
e.bind_x = row[11] ? strtof(row[11], nullptr) : 0;
e.bind_y = row[12] ? strtof(row[12], nullptr) : 0;
e.bind_z = row[13] ? strtof(row[13], nullptr) : 0;
e.select_rank = row[14] ? static_cast<uint8_t>(strtoul(row[14], nullptr, 10)) : 50;
e.min_expansion = static_cast<int8_t>(atoi(row[15]));
e.max_expansion = static_cast<int8_t>(atoi(row[16]));
e.content_flags = row[17] ? row[17] : "";
@@ -498,6 +499,98 @@ 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 StartZones &e
)
{
std::vector<std::string> v;
v.push_back(std::to_string(e.x));
v.push_back(std::to_string(e.y));
v.push_back(std::to_string(e.z));
v.push_back(std::to_string(e.heading));
v.push_back(std::to_string(e.zone_id));
v.push_back(std::to_string(e.bind_id));
v.push_back(std::to_string(e.player_choice));
v.push_back(std::to_string(e.player_class));
v.push_back(std::to_string(e.player_deity));
v.push_back(std::to_string(e.player_race));
v.push_back(std::to_string(e.start_zone));
v.push_back(std::to_string(e.bind_x));
v.push_back(std::to_string(e.bind_y));
v.push_back(std::to_string(e.bind_z));
v.push_back(std::to_string(e.select_rank));
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<StartZones> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &e: entries) {
std::vector<std::string> v;
v.push_back(std::to_string(e.x));
v.push_back(std::to_string(e.y));
v.push_back(std::to_string(e.z));
v.push_back(std::to_string(e.heading));
v.push_back(std::to_string(e.zone_id));
v.push_back(std::to_string(e.bind_id));
v.push_back(std::to_string(e.player_choice));
v.push_back(std::to_string(e.player_class));
v.push_back(std::to_string(e.player_deity));
v.push_back(std::to_string(e.player_race));
v.push_back(std::to_string(e.start_zone));
v.push_back(std::to_string(e.bind_x));
v.push_back(std::to_string(e.bind_y));
v.push_back(std::to_string(e.bind_z));
v.push_back(std::to_string(e.select_rank));
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_START_ZONES_REPOSITORY_H