mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-31 04:56:20 +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_SPAWN2_REPOSITORY_H
|
||||
@@ -16,7 +16,6 @@
|
||||
#include "../../strings.h"
|
||||
#include <ctime>
|
||||
|
||||
|
||||
class BaseSpawn2Repository {
|
||||
public:
|
||||
struct Spawn2 {
|
||||
@@ -192,17 +191,17 @@ public:
|
||||
e.spawngroupID = static_cast<int32_t>(atoi(row[1]));
|
||||
e.zone = row[2] ? row[2] : "";
|
||||
e.version = static_cast<int16_t>(atoi(row[3]));
|
||||
e.x = strtof(row[4], nullptr);
|
||||
e.y = strtof(row[5], nullptr);
|
||||
e.z = strtof(row[6], nullptr);
|
||||
e.heading = strtof(row[7], nullptr);
|
||||
e.x = row[4] ? strtof(row[4], nullptr) : 0.000000;
|
||||
e.y = row[5] ? strtof(row[5], nullptr) : 0.000000;
|
||||
e.z = row[6] ? strtof(row[6], nullptr) : 0.000000;
|
||||
e.heading = row[7] ? strtof(row[7], nullptr) : 0.000000;
|
||||
e.respawntime = static_cast<int32_t>(atoi(row[8]));
|
||||
e.variance = static_cast<int32_t>(atoi(row[9]));
|
||||
e.pathgrid = static_cast<int32_t>(atoi(row[10]));
|
||||
e.path_when_zone_idle = static_cast<int8_t>(atoi(row[11]));
|
||||
e._condition = static_cast<uint32_t>(strtoul(row[12], nullptr, 10));
|
||||
e._condition = row[12] ? static_cast<uint32_t>(strtoul(row[12], nullptr, 10)) : 0;
|
||||
e.cond_value = static_cast<int32_t>(atoi(row[13]));
|
||||
e.animation = static_cast<uint8_t>(strtoul(row[14], nullptr, 10));
|
||||
e.animation = row[14] ? static_cast<uint8_t>(strtoul(row[14], nullptr, 10)) : 0;
|
||||
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] : "";
|
||||
@@ -383,17 +382,17 @@ public:
|
||||
e.spawngroupID = static_cast<int32_t>(atoi(row[1]));
|
||||
e.zone = row[2] ? row[2] : "";
|
||||
e.version = static_cast<int16_t>(atoi(row[3]));
|
||||
e.x = strtof(row[4], nullptr);
|
||||
e.y = strtof(row[5], nullptr);
|
||||
e.z = strtof(row[6], nullptr);
|
||||
e.heading = strtof(row[7], nullptr);
|
||||
e.x = row[4] ? strtof(row[4], nullptr) : 0.000000;
|
||||
e.y = row[5] ? strtof(row[5], nullptr) : 0.000000;
|
||||
e.z = row[6] ? strtof(row[6], nullptr) : 0.000000;
|
||||
e.heading = row[7] ? strtof(row[7], nullptr) : 0.000000;
|
||||
e.respawntime = static_cast<int32_t>(atoi(row[8]));
|
||||
e.variance = static_cast<int32_t>(atoi(row[9]));
|
||||
e.pathgrid = static_cast<int32_t>(atoi(row[10]));
|
||||
e.path_when_zone_idle = static_cast<int8_t>(atoi(row[11]));
|
||||
e._condition = static_cast<uint32_t>(strtoul(row[12], nullptr, 10));
|
||||
e._condition = row[12] ? static_cast<uint32_t>(strtoul(row[12], nullptr, 10)) : 0;
|
||||
e.cond_value = static_cast<int32_t>(atoi(row[13]));
|
||||
e.animation = static_cast<uint8_t>(strtoul(row[14], nullptr, 10));
|
||||
e.animation = row[14] ? static_cast<uint8_t>(strtoul(row[14], nullptr, 10)) : 0;
|
||||
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] : "";
|
||||
@@ -426,17 +425,17 @@ public:
|
||||
e.spawngroupID = static_cast<int32_t>(atoi(row[1]));
|
||||
e.zone = row[2] ? row[2] : "";
|
||||
e.version = static_cast<int16_t>(atoi(row[3]));
|
||||
e.x = strtof(row[4], nullptr);
|
||||
e.y = strtof(row[5], nullptr);
|
||||
e.z = strtof(row[6], nullptr);
|
||||
e.heading = strtof(row[7], nullptr);
|
||||
e.x = row[4] ? strtof(row[4], nullptr) : 0.000000;
|
||||
e.y = row[5] ? strtof(row[5], nullptr) : 0.000000;
|
||||
e.z = row[6] ? strtof(row[6], nullptr) : 0.000000;
|
||||
e.heading = row[7] ? strtof(row[7], nullptr) : 0.000000;
|
||||
e.respawntime = static_cast<int32_t>(atoi(row[8]));
|
||||
e.variance = static_cast<int32_t>(atoi(row[9]));
|
||||
e.pathgrid = static_cast<int32_t>(atoi(row[10]));
|
||||
e.path_when_zone_idle = static_cast<int8_t>(atoi(row[11]));
|
||||
e._condition = static_cast<uint32_t>(strtoul(row[12], nullptr, 10));
|
||||
e._condition = row[12] ? static_cast<uint32_t>(strtoul(row[12], nullptr, 10)) : 0;
|
||||
e.cond_value = static_cast<int32_t>(atoi(row[13]));
|
||||
e.animation = static_cast<uint8_t>(strtoul(row[14], nullptr, 10));
|
||||
e.animation = row[14] ? static_cast<uint8_t>(strtoul(row[14], nullptr, 10)) : 0;
|
||||
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] : "";
|
||||
@@ -499,6 +498,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 Spawn2 &e
|
||||
)
|
||||
{
|
||||
std::vector<std::string> v;
|
||||
|
||||
v.push_back(std::to_string(e.id));
|
||||
v.push_back(std::to_string(e.spawngroupID));
|
||||
v.push_back("'" + Strings::Escape(e.zone) + "'");
|
||||
v.push_back(std::to_string(e.version));
|
||||
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.respawntime));
|
||||
v.push_back(std::to_string(e.variance));
|
||||
v.push_back(std::to_string(e.pathgrid));
|
||||
v.push_back(std::to_string(e.path_when_zone_idle));
|
||||
v.push_back(std::to_string(e._condition));
|
||||
v.push_back(std::to_string(e.cond_value));
|
||||
v.push_back(std::to_string(e.animation));
|
||||
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<Spawn2> &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.spawngroupID));
|
||||
v.push_back("'" + Strings::Escape(e.zone) + "'");
|
||||
v.push_back(std::to_string(e.version));
|
||||
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.respawntime));
|
||||
v.push_back(std::to_string(e.variance));
|
||||
v.push_back(std::to_string(e.pathgrid));
|
||||
v.push_back(std::to_string(e.path_when_zone_idle));
|
||||
v.push_back(std::to_string(e._condition));
|
||||
v.push_back(std::to_string(e.cond_value));
|
||||
v.push_back(std::to_string(e.animation));
|
||||
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_SPAWN2_REPOSITORY_H
|
||||
|
||||
Reference in New Issue
Block a user