[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
+194 -81
View File
@@ -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_OBJECT_REPOSITORY_H
@@ -16,7 +16,6 @@
#include "../../strings.h"
#include <ctime>
class BaseObjectRepository {
public:
struct Object {
@@ -33,8 +32,6 @@ public:
int32_t type;
int32_t icon;
float size_percentage;
int32_t solid_type;
int32_t incline;
int32_t unknown24;
int32_t unknown60;
int32_t unknown64;
@@ -43,6 +40,8 @@ public:
int32_t unknown76;
int32_t unknown84;
float size;
int32_t solid_type;
int32_t incline;
float tilt_x;
float tilt_y;
std::string display_name;
@@ -73,8 +72,6 @@ public:
"type",
"icon",
"size_percentage",
"solid_type",
"incline",
"unknown24",
"unknown60",
"unknown64",
@@ -83,6 +80,8 @@ public:
"unknown76",
"unknown84",
"size",
"solid_type",
"incline",
"tilt_x",
"tilt_y",
"display_name",
@@ -109,8 +108,6 @@ public:
"type",
"icon",
"size_percentage",
"solid_type",
"incline",
"unknown24",
"unknown60",
"unknown64",
@@ -119,6 +116,8 @@ public:
"unknown76",
"unknown84",
"size",
"solid_type",
"incline",
"tilt_x",
"tilt_y",
"display_name",
@@ -179,8 +178,6 @@ public:
e.type = 0;
e.icon = 0;
e.size_percentage = 0;
e.solid_type = 0;
e.incline = 0;
e.unknown24 = 0;
e.unknown60 = 0;
e.unknown64 = 0;
@@ -189,6 +186,8 @@ public:
e.unknown76 = 0;
e.unknown84 = 0;
e.size = 100;
e.solid_type = 0;
e.incline = 0;
e.tilt_x = 0;
e.tilt_y = 0;
e.display_name = "";
@@ -233,30 +232,30 @@ public:
Object e{};
e.id = static_cast<int32_t>(atoi(row[0]));
e.zoneid = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
e.zoneid = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
e.version = static_cast<int16_t>(atoi(row[2]));
e.xpos = strtof(row[3], nullptr);
e.ypos = strtof(row[4], nullptr);
e.zpos = strtof(row[5], nullptr);
e.heading = strtof(row[6], nullptr);
e.xpos = row[3] ? strtof(row[3], nullptr) : 0;
e.ypos = row[4] ? strtof(row[4], nullptr) : 0;
e.zpos = row[5] ? strtof(row[5], nullptr) : 0;
e.heading = row[6] ? strtof(row[6], nullptr) : 0;
e.itemid = static_cast<int32_t>(atoi(row[7]));
e.charges = static_cast<uint16_t>(strtoul(row[8], nullptr, 10));
e.charges = row[8] ? static_cast<uint16_t>(strtoul(row[8], nullptr, 10)) : 0;
e.objectname = row[9] ? row[9] : "";
e.type = static_cast<int32_t>(atoi(row[10]));
e.icon = static_cast<int32_t>(atoi(row[11]));
e.size_percentage = strtof(row[12], nullptr);
e.solid_type = static_cast<int32_t>(atoi(row[13]));
e.incline = static_cast<int32_t>(atoi(row[14]));
e.unknown24 = static_cast<int32_t>(atoi(row[15]));
e.unknown60 = static_cast<int32_t>(atoi(row[16]));
e.unknown64 = static_cast<int32_t>(atoi(row[17]));
e.unknown68 = static_cast<int32_t>(atoi(row[18]));
e.unknown72 = static_cast<int32_t>(atoi(row[19]));
e.unknown76 = static_cast<int32_t>(atoi(row[20]));
e.unknown84 = static_cast<int32_t>(atoi(row[21]));
e.size = strtof(row[22], nullptr);
e.tilt_x = strtof(row[23], nullptr);
e.tilt_y = strtof(row[24], nullptr);
e.size_percentage = row[12] ? strtof(row[12], nullptr) : 0;
e.unknown24 = static_cast<int32_t>(atoi(row[13]));
e.unknown60 = static_cast<int32_t>(atoi(row[14]));
e.unknown64 = static_cast<int32_t>(atoi(row[15]));
e.unknown68 = static_cast<int32_t>(atoi(row[16]));
e.unknown72 = static_cast<int32_t>(atoi(row[17]));
e.unknown76 = static_cast<int32_t>(atoi(row[18]));
e.unknown84 = static_cast<int32_t>(atoi(row[19]));
e.size = row[20] ? strtof(row[20], nullptr) : 100;
e.solid_type = static_cast<int32_t>(atoi(row[21]));
e.incline = static_cast<int32_t>(atoi(row[22]));
e.tilt_x = row[23] ? strtof(row[23], nullptr) : 0;
e.tilt_y = row[24] ? strtof(row[24], nullptr) : 0;
e.display_name = row[25] ? row[25] : "";
e.min_expansion = static_cast<int8_t>(atoi(row[26]));
e.max_expansion = static_cast<int8_t>(atoi(row[27]));
@@ -307,16 +306,16 @@ public:
v.push_back(columns[10] + " = " + std::to_string(e.type));
v.push_back(columns[11] + " = " + std::to_string(e.icon));
v.push_back(columns[12] + " = " + std::to_string(e.size_percentage));
v.push_back(columns[13] + " = " + std::to_string(e.solid_type));
v.push_back(columns[14] + " = " + std::to_string(e.incline));
v.push_back(columns[15] + " = " + std::to_string(e.unknown24));
v.push_back(columns[16] + " = " + std::to_string(e.unknown60));
v.push_back(columns[17] + " = " + std::to_string(e.unknown64));
v.push_back(columns[18] + " = " + std::to_string(e.unknown68));
v.push_back(columns[19] + " = " + std::to_string(e.unknown72));
v.push_back(columns[20] + " = " + std::to_string(e.unknown76));
v.push_back(columns[21] + " = " + std::to_string(e.unknown84));
v.push_back(columns[22] + " = " + std::to_string(e.size));
v.push_back(columns[13] + " = " + std::to_string(e.unknown24));
v.push_back(columns[14] + " = " + std::to_string(e.unknown60));
v.push_back(columns[15] + " = " + std::to_string(e.unknown64));
v.push_back(columns[16] + " = " + std::to_string(e.unknown68));
v.push_back(columns[17] + " = " + std::to_string(e.unknown72));
v.push_back(columns[18] + " = " + std::to_string(e.unknown76));
v.push_back(columns[19] + " = " + std::to_string(e.unknown84));
v.push_back(columns[20] + " = " + std::to_string(e.size));
v.push_back(columns[21] + " = " + std::to_string(e.solid_type));
v.push_back(columns[22] + " = " + std::to_string(e.incline));
v.push_back(columns[23] + " = " + std::to_string(e.tilt_x));
v.push_back(columns[24] + " = " + std::to_string(e.tilt_y));
v.push_back(columns[25] + " = '" + Strings::Escape(e.display_name) + "'");
@@ -358,8 +357,6 @@ public:
v.push_back(std::to_string(e.type));
v.push_back(std::to_string(e.icon));
v.push_back(std::to_string(e.size_percentage));
v.push_back(std::to_string(e.solid_type));
v.push_back(std::to_string(e.incline));
v.push_back(std::to_string(e.unknown24));
v.push_back(std::to_string(e.unknown60));
v.push_back(std::to_string(e.unknown64));
@@ -368,6 +365,8 @@ public:
v.push_back(std::to_string(e.unknown76));
v.push_back(std::to_string(e.unknown84));
v.push_back(std::to_string(e.size));
v.push_back(std::to_string(e.solid_type));
v.push_back(std::to_string(e.incline));
v.push_back(std::to_string(e.tilt_x));
v.push_back(std::to_string(e.tilt_y));
v.push_back("'" + Strings::Escape(e.display_name) + "'");
@@ -417,8 +416,6 @@ public:
v.push_back(std::to_string(e.type));
v.push_back(std::to_string(e.icon));
v.push_back(std::to_string(e.size_percentage));
v.push_back(std::to_string(e.solid_type));
v.push_back(std::to_string(e.incline));
v.push_back(std::to_string(e.unknown24));
v.push_back(std::to_string(e.unknown60));
v.push_back(std::to_string(e.unknown64));
@@ -427,6 +424,8 @@ public:
v.push_back(std::to_string(e.unknown76));
v.push_back(std::to_string(e.unknown84));
v.push_back(std::to_string(e.size));
v.push_back(std::to_string(e.solid_type));
v.push_back(std::to_string(e.incline));
v.push_back(std::to_string(e.tilt_x));
v.push_back(std::to_string(e.tilt_y));
v.push_back("'" + Strings::Escape(e.display_name) + "'");
@@ -468,30 +467,30 @@ public:
Object e{};
e.id = static_cast<int32_t>(atoi(row[0]));
e.zoneid = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
e.zoneid = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
e.version = static_cast<int16_t>(atoi(row[2]));
e.xpos = strtof(row[3], nullptr);
e.ypos = strtof(row[4], nullptr);
e.zpos = strtof(row[5], nullptr);
e.heading = strtof(row[6], nullptr);
e.xpos = row[3] ? strtof(row[3], nullptr) : 0;
e.ypos = row[4] ? strtof(row[4], nullptr) : 0;
e.zpos = row[5] ? strtof(row[5], nullptr) : 0;
e.heading = row[6] ? strtof(row[6], nullptr) : 0;
e.itemid = static_cast<int32_t>(atoi(row[7]));
e.charges = static_cast<uint16_t>(strtoul(row[8], nullptr, 10));
e.charges = row[8] ? static_cast<uint16_t>(strtoul(row[8], nullptr, 10)) : 0;
e.objectname = row[9] ? row[9] : "";
e.type = static_cast<int32_t>(atoi(row[10]));
e.icon = static_cast<int32_t>(atoi(row[11]));
e.size_percentage = strtof(row[12], nullptr);
e.solid_type = static_cast<int32_t>(atoi(row[13]));
e.incline = static_cast<int32_t>(atoi(row[14]));
e.unknown24 = static_cast<int32_t>(atoi(row[15]));
e.unknown60 = static_cast<int32_t>(atoi(row[16]));
e.unknown64 = static_cast<int32_t>(atoi(row[17]));
e.unknown68 = static_cast<int32_t>(atoi(row[18]));
e.unknown72 = static_cast<int32_t>(atoi(row[19]));
e.unknown76 = static_cast<int32_t>(atoi(row[20]));
e.unknown84 = static_cast<int32_t>(atoi(row[21]));
e.size = strtof(row[22], nullptr);
e.tilt_x = strtof(row[23], nullptr);
e.tilt_y = strtof(row[24], nullptr);
e.size_percentage = row[12] ? strtof(row[12], nullptr) : 0;
e.unknown24 = static_cast<int32_t>(atoi(row[13]));
e.unknown60 = static_cast<int32_t>(atoi(row[14]));
e.unknown64 = static_cast<int32_t>(atoi(row[15]));
e.unknown68 = static_cast<int32_t>(atoi(row[16]));
e.unknown72 = static_cast<int32_t>(atoi(row[17]));
e.unknown76 = static_cast<int32_t>(atoi(row[18]));
e.unknown84 = static_cast<int32_t>(atoi(row[19]));
e.size = row[20] ? strtof(row[20], nullptr) : 100;
e.solid_type = static_cast<int32_t>(atoi(row[21]));
e.incline = static_cast<int32_t>(atoi(row[22]));
e.tilt_x = row[23] ? strtof(row[23], nullptr) : 0;
e.tilt_y = row[24] ? strtof(row[24], nullptr) : 0;
e.display_name = row[25] ? row[25] : "";
e.min_expansion = static_cast<int8_t>(atoi(row[26]));
e.max_expansion = static_cast<int8_t>(atoi(row[27]));
@@ -522,30 +521,30 @@ public:
Object e{};
e.id = static_cast<int32_t>(atoi(row[0]));
e.zoneid = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
e.zoneid = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
e.version = static_cast<int16_t>(atoi(row[2]));
e.xpos = strtof(row[3], nullptr);
e.ypos = strtof(row[4], nullptr);
e.zpos = strtof(row[5], nullptr);
e.heading = strtof(row[6], nullptr);
e.xpos = row[3] ? strtof(row[3], nullptr) : 0;
e.ypos = row[4] ? strtof(row[4], nullptr) : 0;
e.zpos = row[5] ? strtof(row[5], nullptr) : 0;
e.heading = row[6] ? strtof(row[6], nullptr) : 0;
e.itemid = static_cast<int32_t>(atoi(row[7]));
e.charges = static_cast<uint16_t>(strtoul(row[8], nullptr, 10));
e.charges = row[8] ? static_cast<uint16_t>(strtoul(row[8], nullptr, 10)) : 0;
e.objectname = row[9] ? row[9] : "";
e.type = static_cast<int32_t>(atoi(row[10]));
e.icon = static_cast<int32_t>(atoi(row[11]));
e.size_percentage = strtof(row[12], nullptr);
e.solid_type = static_cast<int32_t>(atoi(row[13]));
e.incline = static_cast<int32_t>(atoi(row[14]));
e.unknown24 = static_cast<int32_t>(atoi(row[15]));
e.unknown60 = static_cast<int32_t>(atoi(row[16]));
e.unknown64 = static_cast<int32_t>(atoi(row[17]));
e.unknown68 = static_cast<int32_t>(atoi(row[18]));
e.unknown72 = static_cast<int32_t>(atoi(row[19]));
e.unknown76 = static_cast<int32_t>(atoi(row[20]));
e.unknown84 = static_cast<int32_t>(atoi(row[21]));
e.size = strtof(row[22], nullptr);
e.tilt_x = strtof(row[23], nullptr);
e.tilt_y = strtof(row[24], nullptr);
e.size_percentage = row[12] ? strtof(row[12], nullptr) : 0;
e.unknown24 = static_cast<int32_t>(atoi(row[13]));
e.unknown60 = static_cast<int32_t>(atoi(row[14]));
e.unknown64 = static_cast<int32_t>(atoi(row[15]));
e.unknown68 = static_cast<int32_t>(atoi(row[16]));
e.unknown72 = static_cast<int32_t>(atoi(row[17]));
e.unknown76 = static_cast<int32_t>(atoi(row[18]));
e.unknown84 = static_cast<int32_t>(atoi(row[19]));
e.size = row[20] ? strtof(row[20], nullptr) : 100;
e.solid_type = static_cast<int32_t>(atoi(row[21]));
e.incline = static_cast<int32_t>(atoi(row[22]));
e.tilt_x = row[23] ? strtof(row[23], nullptr) : 0;
e.tilt_y = row[24] ? strtof(row[24], nullptr) : 0;
e.display_name = row[25] ? row[25] : "";
e.min_expansion = static_cast<int8_t>(atoi(row[26]));
e.max_expansion = static_cast<int8_t>(atoi(row[27]));
@@ -609,6 +608,120 @@ 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 Object &e
)
{
std::vector<std::string> v;
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.zoneid));
v.push_back(std::to_string(e.version));
v.push_back(std::to_string(e.xpos));
v.push_back(std::to_string(e.ypos));
v.push_back(std::to_string(e.zpos));
v.push_back(std::to_string(e.heading));
v.push_back(std::to_string(e.itemid));
v.push_back(std::to_string(e.charges));
v.push_back("'" + Strings::Escape(e.objectname) + "'");
v.push_back(std::to_string(e.type));
v.push_back(std::to_string(e.icon));
v.push_back(std::to_string(e.size_percentage));
v.push_back(std::to_string(e.unknown24));
v.push_back(std::to_string(e.unknown60));
v.push_back(std::to_string(e.unknown64));
v.push_back(std::to_string(e.unknown68));
v.push_back(std::to_string(e.unknown72));
v.push_back(std::to_string(e.unknown76));
v.push_back(std::to_string(e.unknown84));
v.push_back(std::to_string(e.size));
v.push_back(std::to_string(e.solid_type));
v.push_back(std::to_string(e.incline));
v.push_back(std::to_string(e.tilt_x));
v.push_back(std::to_string(e.tilt_y));
v.push_back("'" + Strings::Escape(e.display_name) + "'");
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<Object> &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.zoneid));
v.push_back(std::to_string(e.version));
v.push_back(std::to_string(e.xpos));
v.push_back(std::to_string(e.ypos));
v.push_back(std::to_string(e.zpos));
v.push_back(std::to_string(e.heading));
v.push_back(std::to_string(e.itemid));
v.push_back(std::to_string(e.charges));
v.push_back("'" + Strings::Escape(e.objectname) + "'");
v.push_back(std::to_string(e.type));
v.push_back(std::to_string(e.icon));
v.push_back(std::to_string(e.size_percentage));
v.push_back(std::to_string(e.unknown24));
v.push_back(std::to_string(e.unknown60));
v.push_back(std::to_string(e.unknown64));
v.push_back(std::to_string(e.unknown68));
v.push_back(std::to_string(e.unknown72));
v.push_back(std::to_string(e.unknown76));
v.push_back(std::to_string(e.unknown84));
v.push_back(std::to_string(e.size));
v.push_back(std::to_string(e.solid_type));
v.push_back(std::to_string(e.incline));
v.push_back(std::to_string(e.tilt_x));
v.push_back(std::to_string(e.tilt_y));
v.push_back("'" + Strings::Escape(e.display_name) + "'");
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_OBJECT_REPOSITORY_H