mirror of
https://github.com/EQEmu/Server.git
synced 2026-06-01 06:01:38 +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:
@@ -181,49 +181,49 @@ public:
|
||||
|
||||
static Doors NewEntity()
|
||||
{
|
||||
Doors entry{};
|
||||
Doors e{};
|
||||
|
||||
entry.id = 0;
|
||||
entry.doorid = 0;
|
||||
entry.zone = "";
|
||||
entry.version = 0;
|
||||
entry.name = "";
|
||||
entry.pos_y = 0;
|
||||
entry.pos_x = 0;
|
||||
entry.pos_z = 0;
|
||||
entry.heading = 0;
|
||||
entry.opentype = 0;
|
||||
entry.guild = 0;
|
||||
entry.lockpick = 0;
|
||||
entry.keyitem = 0;
|
||||
entry.nokeyring = 0;
|
||||
entry.triggerdoor = 0;
|
||||
entry.triggertype = 0;
|
||||
entry.disable_timer = 0;
|
||||
entry.doorisopen = 0;
|
||||
entry.door_param = 0;
|
||||
entry.dest_zone = "NONE";
|
||||
entry.dest_instance = 0;
|
||||
entry.dest_x = 0;
|
||||
entry.dest_y = 0;
|
||||
entry.dest_z = 0;
|
||||
entry.dest_heading = 0;
|
||||
entry.invert_state = 0;
|
||||
entry.incline = 0;
|
||||
entry.size = 100;
|
||||
entry.buffer = 0;
|
||||
entry.client_version_mask = 4294967295;
|
||||
entry.is_ldon_door = 0;
|
||||
entry.dz_switch_id = 0;
|
||||
entry.min_expansion = -1;
|
||||
entry.max_expansion = -1;
|
||||
entry.content_flags = "";
|
||||
entry.content_flags_disabled = "";
|
||||
e.id = 0;
|
||||
e.doorid = 0;
|
||||
e.zone = "";
|
||||
e.version = 0;
|
||||
e.name = "";
|
||||
e.pos_y = 0;
|
||||
e.pos_x = 0;
|
||||
e.pos_z = 0;
|
||||
e.heading = 0;
|
||||
e.opentype = 0;
|
||||
e.guild = 0;
|
||||
e.lockpick = 0;
|
||||
e.keyitem = 0;
|
||||
e.nokeyring = 0;
|
||||
e.triggerdoor = 0;
|
||||
e.triggertype = 0;
|
||||
e.disable_timer = 0;
|
||||
e.doorisopen = 0;
|
||||
e.door_param = 0;
|
||||
e.dest_zone = "NONE";
|
||||
e.dest_instance = 0;
|
||||
e.dest_x = 0;
|
||||
e.dest_y = 0;
|
||||
e.dest_z = 0;
|
||||
e.dest_heading = 0;
|
||||
e.invert_state = 0;
|
||||
e.incline = 0;
|
||||
e.size = 100;
|
||||
e.buffer = 0;
|
||||
e.client_version_mask = 4294967295;
|
||||
e.is_ldon_door = 0;
|
||||
e.dz_switch_id = 0;
|
||||
e.min_expansion = -1;
|
||||
e.max_expansion = -1;
|
||||
e.content_flags = "";
|
||||
e.content_flags_disabled = "";
|
||||
|
||||
return entry;
|
||||
return e;
|
||||
}
|
||||
|
||||
static Doors GetDoorsEntry(
|
||||
static Doors GetDoors(
|
||||
const std::vector<Doors> &doorss,
|
||||
int doors_id
|
||||
)
|
||||
@@ -252,46 +252,46 @@ public:
|
||||
|
||||
auto row = results.begin();
|
||||
if (results.RowCount() == 1) {
|
||||
Doors entry{};
|
||||
Doors e{};
|
||||
|
||||
entry.id = atoi(row[0]);
|
||||
entry.doorid = atoi(row[1]);
|
||||
entry.zone = row[2] ? row[2] : "";
|
||||
entry.version = atoi(row[3]);
|
||||
entry.name = row[4] ? row[4] : "";
|
||||
entry.pos_y = static_cast<float>(atof(row[5]));
|
||||
entry.pos_x = static_cast<float>(atof(row[6]));
|
||||
entry.pos_z = static_cast<float>(atof(row[7]));
|
||||
entry.heading = static_cast<float>(atof(row[8]));
|
||||
entry.opentype = atoi(row[9]);
|
||||
entry.guild = atoi(row[10]);
|
||||
entry.lockpick = atoi(row[11]);
|
||||
entry.keyitem = atoi(row[12]);
|
||||
entry.nokeyring = atoi(row[13]);
|
||||
entry.triggerdoor = atoi(row[14]);
|
||||
entry.triggertype = atoi(row[15]);
|
||||
entry.disable_timer = atoi(row[16]);
|
||||
entry.doorisopen = atoi(row[17]);
|
||||
entry.door_param = atoi(row[18]);
|
||||
entry.dest_zone = row[19] ? row[19] : "";
|
||||
entry.dest_instance = atoi(row[20]);
|
||||
entry.dest_x = static_cast<float>(atof(row[21]));
|
||||
entry.dest_y = static_cast<float>(atof(row[22]));
|
||||
entry.dest_z = static_cast<float>(atof(row[23]));
|
||||
entry.dest_heading = static_cast<float>(atof(row[24]));
|
||||
entry.invert_state = atoi(row[25]);
|
||||
entry.incline = atoi(row[26]);
|
||||
entry.size = atoi(row[27]);
|
||||
entry.buffer = static_cast<float>(atof(row[28]));
|
||||
entry.client_version_mask = atoi(row[29]);
|
||||
entry.is_ldon_door = atoi(row[30]);
|
||||
entry.dz_switch_id = atoi(row[31]);
|
||||
entry.min_expansion = atoi(row[32]);
|
||||
entry.max_expansion = atoi(row[33]);
|
||||
entry.content_flags = row[34] ? row[34] : "";
|
||||
entry.content_flags_disabled = row[35] ? row[35] : "";
|
||||
e.id = atoi(row[0]);
|
||||
e.doorid = atoi(row[1]);
|
||||
e.zone = row[2] ? row[2] : "";
|
||||
e.version = atoi(row[3]);
|
||||
e.name = row[4] ? row[4] : "";
|
||||
e.pos_y = static_cast<float>(atof(row[5]));
|
||||
e.pos_x = static_cast<float>(atof(row[6]));
|
||||
e.pos_z = static_cast<float>(atof(row[7]));
|
||||
e.heading = static_cast<float>(atof(row[8]));
|
||||
e.opentype = atoi(row[9]);
|
||||
e.guild = atoi(row[10]);
|
||||
e.lockpick = atoi(row[11]);
|
||||
e.keyitem = atoi(row[12]);
|
||||
e.nokeyring = atoi(row[13]);
|
||||
e.triggerdoor = atoi(row[14]);
|
||||
e.triggertype = atoi(row[15]);
|
||||
e.disable_timer = atoi(row[16]);
|
||||
e.doorisopen = atoi(row[17]);
|
||||
e.door_param = atoi(row[18]);
|
||||
e.dest_zone = row[19] ? row[19] : "";
|
||||
e.dest_instance = atoi(row[20]);
|
||||
e.dest_x = static_cast<float>(atof(row[21]));
|
||||
e.dest_y = static_cast<float>(atof(row[22]));
|
||||
e.dest_z = static_cast<float>(atof(row[23]));
|
||||
e.dest_heading = static_cast<float>(atof(row[24]));
|
||||
e.invert_state = atoi(row[25]);
|
||||
e.incline = atoi(row[26]);
|
||||
e.size = atoi(row[27]);
|
||||
e.buffer = static_cast<float>(atof(row[28]));
|
||||
e.client_version_mask = atoi(row[29]);
|
||||
e.is_ldon_door = atoi(row[30]);
|
||||
e.dz_switch_id = atoi(row[31]);
|
||||
e.min_expansion = atoi(row[32]);
|
||||
e.max_expansion = atoi(row[33]);
|
||||
e.content_flags = row[34] ? row[34] : "";
|
||||
e.content_flags_disabled = row[35] ? row[35] : "";
|
||||
|
||||
return entry;
|
||||
return e;
|
||||
}
|
||||
|
||||
return NewEntity();
|
||||
@@ -316,56 +316,56 @@ public:
|
||||
|
||||
static int UpdateOne(
|
||||
Database& db,
|
||||
Doors doors_entry
|
||||
const Doors &e
|
||||
)
|
||||
{
|
||||
std::vector<std::string> update_values;
|
||||
std::vector<std::string> v;
|
||||
|
||||
auto columns = Columns();
|
||||
|
||||
update_values.push_back(columns[1] + " = " + std::to_string(doors_entry.doorid));
|
||||
update_values.push_back(columns[2] + " = '" + Strings::Escape(doors_entry.zone) + "'");
|
||||
update_values.push_back(columns[3] + " = " + std::to_string(doors_entry.version));
|
||||
update_values.push_back(columns[4] + " = '" + Strings::Escape(doors_entry.name) + "'");
|
||||
update_values.push_back(columns[5] + " = " + std::to_string(doors_entry.pos_y));
|
||||
update_values.push_back(columns[6] + " = " + std::to_string(doors_entry.pos_x));
|
||||
update_values.push_back(columns[7] + " = " + std::to_string(doors_entry.pos_z));
|
||||
update_values.push_back(columns[8] + " = " + std::to_string(doors_entry.heading));
|
||||
update_values.push_back(columns[9] + " = " + std::to_string(doors_entry.opentype));
|
||||
update_values.push_back(columns[10] + " = " + std::to_string(doors_entry.guild));
|
||||
update_values.push_back(columns[11] + " = " + std::to_string(doors_entry.lockpick));
|
||||
update_values.push_back(columns[12] + " = " + std::to_string(doors_entry.keyitem));
|
||||
update_values.push_back(columns[13] + " = " + std::to_string(doors_entry.nokeyring));
|
||||
update_values.push_back(columns[14] + " = " + std::to_string(doors_entry.triggerdoor));
|
||||
update_values.push_back(columns[15] + " = " + std::to_string(doors_entry.triggertype));
|
||||
update_values.push_back(columns[16] + " = " + std::to_string(doors_entry.disable_timer));
|
||||
update_values.push_back(columns[17] + " = " + std::to_string(doors_entry.doorisopen));
|
||||
update_values.push_back(columns[18] + " = " + std::to_string(doors_entry.door_param));
|
||||
update_values.push_back(columns[19] + " = '" + Strings::Escape(doors_entry.dest_zone) + "'");
|
||||
update_values.push_back(columns[20] + " = " + std::to_string(doors_entry.dest_instance));
|
||||
update_values.push_back(columns[21] + " = " + std::to_string(doors_entry.dest_x));
|
||||
update_values.push_back(columns[22] + " = " + std::to_string(doors_entry.dest_y));
|
||||
update_values.push_back(columns[23] + " = " + std::to_string(doors_entry.dest_z));
|
||||
update_values.push_back(columns[24] + " = " + std::to_string(doors_entry.dest_heading));
|
||||
update_values.push_back(columns[25] + " = " + std::to_string(doors_entry.invert_state));
|
||||
update_values.push_back(columns[26] + " = " + std::to_string(doors_entry.incline));
|
||||
update_values.push_back(columns[27] + " = " + std::to_string(doors_entry.size));
|
||||
update_values.push_back(columns[28] + " = " + std::to_string(doors_entry.buffer));
|
||||
update_values.push_back(columns[29] + " = " + std::to_string(doors_entry.client_version_mask));
|
||||
update_values.push_back(columns[30] + " = " + std::to_string(doors_entry.is_ldon_door));
|
||||
update_values.push_back(columns[31] + " = " + std::to_string(doors_entry.dz_switch_id));
|
||||
update_values.push_back(columns[32] + " = " + std::to_string(doors_entry.min_expansion));
|
||||
update_values.push_back(columns[33] + " = " + std::to_string(doors_entry.max_expansion));
|
||||
update_values.push_back(columns[34] + " = '" + Strings::Escape(doors_entry.content_flags) + "'");
|
||||
update_values.push_back(columns[35] + " = '" + Strings::Escape(doors_entry.content_flags_disabled) + "'");
|
||||
v.push_back(columns[1] + " = " + std::to_string(e.doorid));
|
||||
v.push_back(columns[2] + " = '" + Strings::Escape(e.zone) + "'");
|
||||
v.push_back(columns[3] + " = " + std::to_string(e.version));
|
||||
v.push_back(columns[4] + " = '" + Strings::Escape(e.name) + "'");
|
||||
v.push_back(columns[5] + " = " + std::to_string(e.pos_y));
|
||||
v.push_back(columns[6] + " = " + std::to_string(e.pos_x));
|
||||
v.push_back(columns[7] + " = " + std::to_string(e.pos_z));
|
||||
v.push_back(columns[8] + " = " + std::to_string(e.heading));
|
||||
v.push_back(columns[9] + " = " + std::to_string(e.opentype));
|
||||
v.push_back(columns[10] + " = " + std::to_string(e.guild));
|
||||
v.push_back(columns[11] + " = " + std::to_string(e.lockpick));
|
||||
v.push_back(columns[12] + " = " + std::to_string(e.keyitem));
|
||||
v.push_back(columns[13] + " = " + std::to_string(e.nokeyring));
|
||||
v.push_back(columns[14] + " = " + std::to_string(e.triggerdoor));
|
||||
v.push_back(columns[15] + " = " + std::to_string(e.triggertype));
|
||||
v.push_back(columns[16] + " = " + std::to_string(e.disable_timer));
|
||||
v.push_back(columns[17] + " = " + std::to_string(e.doorisopen));
|
||||
v.push_back(columns[18] + " = " + std::to_string(e.door_param));
|
||||
v.push_back(columns[19] + " = '" + Strings::Escape(e.dest_zone) + "'");
|
||||
v.push_back(columns[20] + " = " + std::to_string(e.dest_instance));
|
||||
v.push_back(columns[21] + " = " + std::to_string(e.dest_x));
|
||||
v.push_back(columns[22] + " = " + std::to_string(e.dest_y));
|
||||
v.push_back(columns[23] + " = " + std::to_string(e.dest_z));
|
||||
v.push_back(columns[24] + " = " + std::to_string(e.dest_heading));
|
||||
v.push_back(columns[25] + " = " + std::to_string(e.invert_state));
|
||||
v.push_back(columns[26] + " = " + std::to_string(e.incline));
|
||||
v.push_back(columns[27] + " = " + std::to_string(e.size));
|
||||
v.push_back(columns[28] + " = " + std::to_string(e.buffer));
|
||||
v.push_back(columns[29] + " = " + std::to_string(e.client_version_mask));
|
||||
v.push_back(columns[30] + " = " + std::to_string(e.is_ldon_door));
|
||||
v.push_back(columns[31] + " = " + std::to_string(e.dz_switch_id));
|
||||
v.push_back(columns[32] + " = " + std::to_string(e.min_expansion));
|
||||
v.push_back(columns[33] + " = " + std::to_string(e.max_expansion));
|
||||
v.push_back(columns[34] + " = '" + Strings::Escape(e.content_flags) + "'");
|
||||
v.push_back(columns[35] + " = '" + Strings::Escape(e.content_flags_disabled) + "'");
|
||||
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"UPDATE {} SET {} WHERE {} = {}",
|
||||
TableName(),
|
||||
Strings::Implode(", ", update_values),
|
||||
Strings::Implode(", ", v),
|
||||
PrimaryKey(),
|
||||
doors_entry.id
|
||||
e.id
|
||||
)
|
||||
);
|
||||
|
||||
@@ -374,117 +374,117 @@ public:
|
||||
|
||||
static Doors InsertOne(
|
||||
Database& db,
|
||||
Doors doors_entry
|
||||
Doors e
|
||||
)
|
||||
{
|
||||
std::vector<std::string> insert_values;
|
||||
std::vector<std::string> v;
|
||||
|
||||
insert_values.push_back(std::to_string(doors_entry.id));
|
||||
insert_values.push_back(std::to_string(doors_entry.doorid));
|
||||
insert_values.push_back("'" + Strings::Escape(doors_entry.zone) + "'");
|
||||
insert_values.push_back(std::to_string(doors_entry.version));
|
||||
insert_values.push_back("'" + Strings::Escape(doors_entry.name) + "'");
|
||||
insert_values.push_back(std::to_string(doors_entry.pos_y));
|
||||
insert_values.push_back(std::to_string(doors_entry.pos_x));
|
||||
insert_values.push_back(std::to_string(doors_entry.pos_z));
|
||||
insert_values.push_back(std::to_string(doors_entry.heading));
|
||||
insert_values.push_back(std::to_string(doors_entry.opentype));
|
||||
insert_values.push_back(std::to_string(doors_entry.guild));
|
||||
insert_values.push_back(std::to_string(doors_entry.lockpick));
|
||||
insert_values.push_back(std::to_string(doors_entry.keyitem));
|
||||
insert_values.push_back(std::to_string(doors_entry.nokeyring));
|
||||
insert_values.push_back(std::to_string(doors_entry.triggerdoor));
|
||||
insert_values.push_back(std::to_string(doors_entry.triggertype));
|
||||
insert_values.push_back(std::to_string(doors_entry.disable_timer));
|
||||
insert_values.push_back(std::to_string(doors_entry.doorisopen));
|
||||
insert_values.push_back(std::to_string(doors_entry.door_param));
|
||||
insert_values.push_back("'" + Strings::Escape(doors_entry.dest_zone) + "'");
|
||||
insert_values.push_back(std::to_string(doors_entry.dest_instance));
|
||||
insert_values.push_back(std::to_string(doors_entry.dest_x));
|
||||
insert_values.push_back(std::to_string(doors_entry.dest_y));
|
||||
insert_values.push_back(std::to_string(doors_entry.dest_z));
|
||||
insert_values.push_back(std::to_string(doors_entry.dest_heading));
|
||||
insert_values.push_back(std::to_string(doors_entry.invert_state));
|
||||
insert_values.push_back(std::to_string(doors_entry.incline));
|
||||
insert_values.push_back(std::to_string(doors_entry.size));
|
||||
insert_values.push_back(std::to_string(doors_entry.buffer));
|
||||
insert_values.push_back(std::to_string(doors_entry.client_version_mask));
|
||||
insert_values.push_back(std::to_string(doors_entry.is_ldon_door));
|
||||
insert_values.push_back(std::to_string(doors_entry.dz_switch_id));
|
||||
insert_values.push_back(std::to_string(doors_entry.min_expansion));
|
||||
insert_values.push_back(std::to_string(doors_entry.max_expansion));
|
||||
insert_values.push_back("'" + Strings::Escape(doors_entry.content_flags) + "'");
|
||||
insert_values.push_back("'" + Strings::Escape(doors_entry.content_flags_disabled) + "'");
|
||||
v.push_back(std::to_string(e.id));
|
||||
v.push_back(std::to_string(e.doorid));
|
||||
v.push_back("'" + Strings::Escape(e.zone) + "'");
|
||||
v.push_back(std::to_string(e.version));
|
||||
v.push_back("'" + Strings::Escape(e.name) + "'");
|
||||
v.push_back(std::to_string(e.pos_y));
|
||||
v.push_back(std::to_string(e.pos_x));
|
||||
v.push_back(std::to_string(e.pos_z));
|
||||
v.push_back(std::to_string(e.heading));
|
||||
v.push_back(std::to_string(e.opentype));
|
||||
v.push_back(std::to_string(e.guild));
|
||||
v.push_back(std::to_string(e.lockpick));
|
||||
v.push_back(std::to_string(e.keyitem));
|
||||
v.push_back(std::to_string(e.nokeyring));
|
||||
v.push_back(std::to_string(e.triggerdoor));
|
||||
v.push_back(std::to_string(e.triggertype));
|
||||
v.push_back(std::to_string(e.disable_timer));
|
||||
v.push_back(std::to_string(e.doorisopen));
|
||||
v.push_back(std::to_string(e.door_param));
|
||||
v.push_back("'" + Strings::Escape(e.dest_zone) + "'");
|
||||
v.push_back(std::to_string(e.dest_instance));
|
||||
v.push_back(std::to_string(e.dest_x));
|
||||
v.push_back(std::to_string(e.dest_y));
|
||||
v.push_back(std::to_string(e.dest_z));
|
||||
v.push_back(std::to_string(e.dest_heading));
|
||||
v.push_back(std::to_string(e.invert_state));
|
||||
v.push_back(std::to_string(e.incline));
|
||||
v.push_back(std::to_string(e.size));
|
||||
v.push_back(std::to_string(e.buffer));
|
||||
v.push_back(std::to_string(e.client_version_mask));
|
||||
v.push_back(std::to_string(e.is_ldon_door));
|
||||
v.push_back(std::to_string(e.dz_switch_id));
|
||||
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 ({})",
|
||||
BaseInsert(),
|
||||
Strings::Implode(",", insert_values)
|
||||
Strings::Implode(",", v)
|
||||
)
|
||||
);
|
||||
|
||||
if (results.Success()) {
|
||||
doors_entry.id = results.LastInsertedID();
|
||||
return doors_entry;
|
||||
e.id = results.LastInsertedID();
|
||||
return e;
|
||||
}
|
||||
|
||||
doors_entry = NewEntity();
|
||||
e = NewEntity();
|
||||
|
||||
return doors_entry;
|
||||
return e;
|
||||
}
|
||||
|
||||
static int InsertMany(
|
||||
Database& db,
|
||||
std::vector<Doors> doors_entries
|
||||
const std::vector<Doors> &entries
|
||||
)
|
||||
{
|
||||
std::vector<std::string> insert_chunks;
|
||||
|
||||
for (auto &doors_entry: doors_entries) {
|
||||
std::vector<std::string> insert_values;
|
||||
for (auto &e: entries) {
|
||||
std::vector<std::string> v;
|
||||
|
||||
insert_values.push_back(std::to_string(doors_entry.id));
|
||||
insert_values.push_back(std::to_string(doors_entry.doorid));
|
||||
insert_values.push_back("'" + Strings::Escape(doors_entry.zone) + "'");
|
||||
insert_values.push_back(std::to_string(doors_entry.version));
|
||||
insert_values.push_back("'" + Strings::Escape(doors_entry.name) + "'");
|
||||
insert_values.push_back(std::to_string(doors_entry.pos_y));
|
||||
insert_values.push_back(std::to_string(doors_entry.pos_x));
|
||||
insert_values.push_back(std::to_string(doors_entry.pos_z));
|
||||
insert_values.push_back(std::to_string(doors_entry.heading));
|
||||
insert_values.push_back(std::to_string(doors_entry.opentype));
|
||||
insert_values.push_back(std::to_string(doors_entry.guild));
|
||||
insert_values.push_back(std::to_string(doors_entry.lockpick));
|
||||
insert_values.push_back(std::to_string(doors_entry.keyitem));
|
||||
insert_values.push_back(std::to_string(doors_entry.nokeyring));
|
||||
insert_values.push_back(std::to_string(doors_entry.triggerdoor));
|
||||
insert_values.push_back(std::to_string(doors_entry.triggertype));
|
||||
insert_values.push_back(std::to_string(doors_entry.disable_timer));
|
||||
insert_values.push_back(std::to_string(doors_entry.doorisopen));
|
||||
insert_values.push_back(std::to_string(doors_entry.door_param));
|
||||
insert_values.push_back("'" + Strings::Escape(doors_entry.dest_zone) + "'");
|
||||
insert_values.push_back(std::to_string(doors_entry.dest_instance));
|
||||
insert_values.push_back(std::to_string(doors_entry.dest_x));
|
||||
insert_values.push_back(std::to_string(doors_entry.dest_y));
|
||||
insert_values.push_back(std::to_string(doors_entry.dest_z));
|
||||
insert_values.push_back(std::to_string(doors_entry.dest_heading));
|
||||
insert_values.push_back(std::to_string(doors_entry.invert_state));
|
||||
insert_values.push_back(std::to_string(doors_entry.incline));
|
||||
insert_values.push_back(std::to_string(doors_entry.size));
|
||||
insert_values.push_back(std::to_string(doors_entry.buffer));
|
||||
insert_values.push_back(std::to_string(doors_entry.client_version_mask));
|
||||
insert_values.push_back(std::to_string(doors_entry.is_ldon_door));
|
||||
insert_values.push_back(std::to_string(doors_entry.dz_switch_id));
|
||||
insert_values.push_back(std::to_string(doors_entry.min_expansion));
|
||||
insert_values.push_back(std::to_string(doors_entry.max_expansion));
|
||||
insert_values.push_back("'" + Strings::Escape(doors_entry.content_flags) + "'");
|
||||
insert_values.push_back("'" + Strings::Escape(doors_entry.content_flags_disabled) + "'");
|
||||
v.push_back(std::to_string(e.id));
|
||||
v.push_back(std::to_string(e.doorid));
|
||||
v.push_back("'" + Strings::Escape(e.zone) + "'");
|
||||
v.push_back(std::to_string(e.version));
|
||||
v.push_back("'" + Strings::Escape(e.name) + "'");
|
||||
v.push_back(std::to_string(e.pos_y));
|
||||
v.push_back(std::to_string(e.pos_x));
|
||||
v.push_back(std::to_string(e.pos_z));
|
||||
v.push_back(std::to_string(e.heading));
|
||||
v.push_back(std::to_string(e.opentype));
|
||||
v.push_back(std::to_string(e.guild));
|
||||
v.push_back(std::to_string(e.lockpick));
|
||||
v.push_back(std::to_string(e.keyitem));
|
||||
v.push_back(std::to_string(e.nokeyring));
|
||||
v.push_back(std::to_string(e.triggerdoor));
|
||||
v.push_back(std::to_string(e.triggertype));
|
||||
v.push_back(std::to_string(e.disable_timer));
|
||||
v.push_back(std::to_string(e.doorisopen));
|
||||
v.push_back(std::to_string(e.door_param));
|
||||
v.push_back("'" + Strings::Escape(e.dest_zone) + "'");
|
||||
v.push_back(std::to_string(e.dest_instance));
|
||||
v.push_back(std::to_string(e.dest_x));
|
||||
v.push_back(std::to_string(e.dest_y));
|
||||
v.push_back(std::to_string(e.dest_z));
|
||||
v.push_back(std::to_string(e.dest_heading));
|
||||
v.push_back(std::to_string(e.invert_state));
|
||||
v.push_back(std::to_string(e.incline));
|
||||
v.push_back(std::to_string(e.size));
|
||||
v.push_back(std::to_string(e.buffer));
|
||||
v.push_back(std::to_string(e.client_version_mask));
|
||||
v.push_back(std::to_string(e.is_ldon_door));
|
||||
v.push_back(std::to_string(e.dz_switch_id));
|
||||
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(",", 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(
|
||||
@@ -511,52 +511,52 @@ public:
|
||||
all_entries.reserve(results.RowCount());
|
||||
|
||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||
Doors entry{};
|
||||
Doors e{};
|
||||
|
||||
entry.id = atoi(row[0]);
|
||||
entry.doorid = atoi(row[1]);
|
||||
entry.zone = row[2] ? row[2] : "";
|
||||
entry.version = atoi(row[3]);
|
||||
entry.name = row[4] ? row[4] : "";
|
||||
entry.pos_y = static_cast<float>(atof(row[5]));
|
||||
entry.pos_x = static_cast<float>(atof(row[6]));
|
||||
entry.pos_z = static_cast<float>(atof(row[7]));
|
||||
entry.heading = static_cast<float>(atof(row[8]));
|
||||
entry.opentype = atoi(row[9]);
|
||||
entry.guild = atoi(row[10]);
|
||||
entry.lockpick = atoi(row[11]);
|
||||
entry.keyitem = atoi(row[12]);
|
||||
entry.nokeyring = atoi(row[13]);
|
||||
entry.triggerdoor = atoi(row[14]);
|
||||
entry.triggertype = atoi(row[15]);
|
||||
entry.disable_timer = atoi(row[16]);
|
||||
entry.doorisopen = atoi(row[17]);
|
||||
entry.door_param = atoi(row[18]);
|
||||
entry.dest_zone = row[19] ? row[19] : "";
|
||||
entry.dest_instance = atoi(row[20]);
|
||||
entry.dest_x = static_cast<float>(atof(row[21]));
|
||||
entry.dest_y = static_cast<float>(atof(row[22]));
|
||||
entry.dest_z = static_cast<float>(atof(row[23]));
|
||||
entry.dest_heading = static_cast<float>(atof(row[24]));
|
||||
entry.invert_state = atoi(row[25]);
|
||||
entry.incline = atoi(row[26]);
|
||||
entry.size = atoi(row[27]);
|
||||
entry.buffer = static_cast<float>(atof(row[28]));
|
||||
entry.client_version_mask = atoi(row[29]);
|
||||
entry.is_ldon_door = atoi(row[30]);
|
||||
entry.dz_switch_id = atoi(row[31]);
|
||||
entry.min_expansion = atoi(row[32]);
|
||||
entry.max_expansion = atoi(row[33]);
|
||||
entry.content_flags = row[34] ? row[34] : "";
|
||||
entry.content_flags_disabled = row[35] ? row[35] : "";
|
||||
e.id = atoi(row[0]);
|
||||
e.doorid = atoi(row[1]);
|
||||
e.zone = row[2] ? row[2] : "";
|
||||
e.version = atoi(row[3]);
|
||||
e.name = row[4] ? row[4] : "";
|
||||
e.pos_y = static_cast<float>(atof(row[5]));
|
||||
e.pos_x = static_cast<float>(atof(row[6]));
|
||||
e.pos_z = static_cast<float>(atof(row[7]));
|
||||
e.heading = static_cast<float>(atof(row[8]));
|
||||
e.opentype = atoi(row[9]);
|
||||
e.guild = atoi(row[10]);
|
||||
e.lockpick = atoi(row[11]);
|
||||
e.keyitem = atoi(row[12]);
|
||||
e.nokeyring = atoi(row[13]);
|
||||
e.triggerdoor = atoi(row[14]);
|
||||
e.triggertype = atoi(row[15]);
|
||||
e.disable_timer = atoi(row[16]);
|
||||
e.doorisopen = atoi(row[17]);
|
||||
e.door_param = atoi(row[18]);
|
||||
e.dest_zone = row[19] ? row[19] : "";
|
||||
e.dest_instance = atoi(row[20]);
|
||||
e.dest_x = static_cast<float>(atof(row[21]));
|
||||
e.dest_y = static_cast<float>(atof(row[22]));
|
||||
e.dest_z = static_cast<float>(atof(row[23]));
|
||||
e.dest_heading = static_cast<float>(atof(row[24]));
|
||||
e.invert_state = atoi(row[25]);
|
||||
e.incline = atoi(row[26]);
|
||||
e.size = atoi(row[27]);
|
||||
e.buffer = static_cast<float>(atof(row[28]));
|
||||
e.client_version_mask = atoi(row[29]);
|
||||
e.is_ldon_door = atoi(row[30]);
|
||||
e.dz_switch_id = atoi(row[31]);
|
||||
e.min_expansion = atoi(row[32]);
|
||||
e.max_expansion = atoi(row[33]);
|
||||
e.content_flags = row[34] ? row[34] : "";
|
||||
e.content_flags_disabled = row[35] ? row[35] : "";
|
||||
|
||||
all_entries.push_back(entry);
|
||||
all_entries.push_back(e);
|
||||
}
|
||||
|
||||
return all_entries;
|
||||
}
|
||||
|
||||
static std::vector<Doors> GetWhere(Database& db, std::string where_filter)
|
||||
static std::vector<Doors> GetWhere(Database& db, const std::string &where_filter)
|
||||
{
|
||||
std::vector<Doors> all_entries;
|
||||
|
||||
@@ -571,52 +571,52 @@ public:
|
||||
all_entries.reserve(results.RowCount());
|
||||
|
||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||
Doors entry{};
|
||||
Doors e{};
|
||||
|
||||
entry.id = atoi(row[0]);
|
||||
entry.doorid = atoi(row[1]);
|
||||
entry.zone = row[2] ? row[2] : "";
|
||||
entry.version = atoi(row[3]);
|
||||
entry.name = row[4] ? row[4] : "";
|
||||
entry.pos_y = static_cast<float>(atof(row[5]));
|
||||
entry.pos_x = static_cast<float>(atof(row[6]));
|
||||
entry.pos_z = static_cast<float>(atof(row[7]));
|
||||
entry.heading = static_cast<float>(atof(row[8]));
|
||||
entry.opentype = atoi(row[9]);
|
||||
entry.guild = atoi(row[10]);
|
||||
entry.lockpick = atoi(row[11]);
|
||||
entry.keyitem = atoi(row[12]);
|
||||
entry.nokeyring = atoi(row[13]);
|
||||
entry.triggerdoor = atoi(row[14]);
|
||||
entry.triggertype = atoi(row[15]);
|
||||
entry.disable_timer = atoi(row[16]);
|
||||
entry.doorisopen = atoi(row[17]);
|
||||
entry.door_param = atoi(row[18]);
|
||||
entry.dest_zone = row[19] ? row[19] : "";
|
||||
entry.dest_instance = atoi(row[20]);
|
||||
entry.dest_x = static_cast<float>(atof(row[21]));
|
||||
entry.dest_y = static_cast<float>(atof(row[22]));
|
||||
entry.dest_z = static_cast<float>(atof(row[23]));
|
||||
entry.dest_heading = static_cast<float>(atof(row[24]));
|
||||
entry.invert_state = atoi(row[25]);
|
||||
entry.incline = atoi(row[26]);
|
||||
entry.size = atoi(row[27]);
|
||||
entry.buffer = static_cast<float>(atof(row[28]));
|
||||
entry.client_version_mask = atoi(row[29]);
|
||||
entry.is_ldon_door = atoi(row[30]);
|
||||
entry.dz_switch_id = atoi(row[31]);
|
||||
entry.min_expansion = atoi(row[32]);
|
||||
entry.max_expansion = atoi(row[33]);
|
||||
entry.content_flags = row[34] ? row[34] : "";
|
||||
entry.content_flags_disabled = row[35] ? row[35] : "";
|
||||
e.id = atoi(row[0]);
|
||||
e.doorid = atoi(row[1]);
|
||||
e.zone = row[2] ? row[2] : "";
|
||||
e.version = atoi(row[3]);
|
||||
e.name = row[4] ? row[4] : "";
|
||||
e.pos_y = static_cast<float>(atof(row[5]));
|
||||
e.pos_x = static_cast<float>(atof(row[6]));
|
||||
e.pos_z = static_cast<float>(atof(row[7]));
|
||||
e.heading = static_cast<float>(atof(row[8]));
|
||||
e.opentype = atoi(row[9]);
|
||||
e.guild = atoi(row[10]);
|
||||
e.lockpick = atoi(row[11]);
|
||||
e.keyitem = atoi(row[12]);
|
||||
e.nokeyring = atoi(row[13]);
|
||||
e.triggerdoor = atoi(row[14]);
|
||||
e.triggertype = atoi(row[15]);
|
||||
e.disable_timer = atoi(row[16]);
|
||||
e.doorisopen = atoi(row[17]);
|
||||
e.door_param = atoi(row[18]);
|
||||
e.dest_zone = row[19] ? row[19] : "";
|
||||
e.dest_instance = atoi(row[20]);
|
||||
e.dest_x = static_cast<float>(atof(row[21]));
|
||||
e.dest_y = static_cast<float>(atof(row[22]));
|
||||
e.dest_z = static_cast<float>(atof(row[23]));
|
||||
e.dest_heading = static_cast<float>(atof(row[24]));
|
||||
e.invert_state = atoi(row[25]);
|
||||
e.incline = atoi(row[26]);
|
||||
e.size = atoi(row[27]);
|
||||
e.buffer = static_cast<float>(atof(row[28]));
|
||||
e.client_version_mask = atoi(row[29]);
|
||||
e.is_ldon_door = atoi(row[30]);
|
||||
e.dz_switch_id = atoi(row[31]);
|
||||
e.min_expansion = atoi(row[32]);
|
||||
e.max_expansion = atoi(row[33]);
|
||||
e.content_flags = row[34] ? row[34] : "";
|
||||
e.content_flags_disabled = row[35] ? row[35] : "";
|
||||
|
||||
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(
|
||||
@@ -641,6 +641,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_DOORS_REPOSITORY_H
|
||||
|
||||
Reference in New Issue
Block a user