mirror of
https://github.com/EQEmu/Server.git
synced 2026-06-24 05:18:40 +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:
@@ -145,37 +145,37 @@ public:
|
||||
|
||||
static Account NewEntity()
|
||||
{
|
||||
Account entry{};
|
||||
Account e{};
|
||||
|
||||
entry.id = 0;
|
||||
entry.name = "";
|
||||
entry.charname = "";
|
||||
entry.sharedplat = 0;
|
||||
entry.password = "";
|
||||
entry.status = 0;
|
||||
entry.ls_id = "eqemu";
|
||||
entry.lsaccount_id = 0;
|
||||
entry.gmspeed = 0;
|
||||
entry.invulnerable = 0;
|
||||
entry.flymode = 0;
|
||||
entry.ignore_tells = 0;
|
||||
entry.revoked = 0;
|
||||
entry.karma = 0;
|
||||
entry.minilogin_ip = "";
|
||||
entry.hideme = 0;
|
||||
entry.rulesflag = 0;
|
||||
entry.suspendeduntil = 0;
|
||||
entry.time_creation = 0;
|
||||
entry.ban_reason = "";
|
||||
entry.suspend_reason = "";
|
||||
entry.crc_eqgame = "";
|
||||
entry.crc_skillcaps = "";
|
||||
entry.crc_basedata = "";
|
||||
e.id = 0;
|
||||
e.name = "";
|
||||
e.charname = "";
|
||||
e.sharedplat = 0;
|
||||
e.password = "";
|
||||
e.status = 0;
|
||||
e.ls_id = "eqemu";
|
||||
e.lsaccount_id = 0;
|
||||
e.gmspeed = 0;
|
||||
e.invulnerable = 0;
|
||||
e.flymode = 0;
|
||||
e.ignore_tells = 0;
|
||||
e.revoked = 0;
|
||||
e.karma = 0;
|
||||
e.minilogin_ip = "";
|
||||
e.hideme = 0;
|
||||
e.rulesflag = 0;
|
||||
e.suspendeduntil = 0;
|
||||
e.time_creation = 0;
|
||||
e.ban_reason = "";
|
||||
e.suspend_reason = "";
|
||||
e.crc_eqgame = "";
|
||||
e.crc_skillcaps = "";
|
||||
e.crc_basedata = "";
|
||||
|
||||
return entry;
|
||||
return e;
|
||||
}
|
||||
|
||||
static Account GetAccountEntry(
|
||||
static Account GetAccount(
|
||||
const std::vector<Account> &accounts,
|
||||
int account_id
|
||||
)
|
||||
@@ -204,34 +204,34 @@ public:
|
||||
|
||||
auto row = results.begin();
|
||||
if (results.RowCount() == 1) {
|
||||
Account entry{};
|
||||
Account e{};
|
||||
|
||||
entry.id = atoi(row[0]);
|
||||
entry.name = row[1] ? row[1] : "";
|
||||
entry.charname = row[2] ? row[2] : "";
|
||||
entry.sharedplat = atoi(row[3]);
|
||||
entry.password = row[4] ? row[4] : "";
|
||||
entry.status = atoi(row[5]);
|
||||
entry.ls_id = row[6] ? row[6] : "";
|
||||
entry.lsaccount_id = atoi(row[7]);
|
||||
entry.gmspeed = atoi(row[8]);
|
||||
entry.invulnerable = atoi(row[9]);
|
||||
entry.flymode = atoi(row[10]);
|
||||
entry.ignore_tells = atoi(row[11]);
|
||||
entry.revoked = atoi(row[12]);
|
||||
entry.karma = atoi(row[13]);
|
||||
entry.minilogin_ip = row[14] ? row[14] : "";
|
||||
entry.hideme = atoi(row[15]);
|
||||
entry.rulesflag = atoi(row[16]);
|
||||
entry.suspendeduntil = strtoll(row[17] ? row[17] : "-1", nullptr, 10);
|
||||
entry.time_creation = atoi(row[18]);
|
||||
entry.ban_reason = row[19] ? row[19] : "";
|
||||
entry.suspend_reason = row[20] ? row[20] : "";
|
||||
entry.crc_eqgame = row[21] ? row[21] : "";
|
||||
entry.crc_skillcaps = row[22] ? row[22] : "";
|
||||
entry.crc_basedata = row[23] ? row[23] : "";
|
||||
e.id = atoi(row[0]);
|
||||
e.name = row[1] ? row[1] : "";
|
||||
e.charname = row[2] ? row[2] : "";
|
||||
e.sharedplat = atoi(row[3]);
|
||||
e.password = row[4] ? row[4] : "";
|
||||
e.status = atoi(row[5]);
|
||||
e.ls_id = row[6] ? row[6] : "";
|
||||
e.lsaccount_id = atoi(row[7]);
|
||||
e.gmspeed = atoi(row[8]);
|
||||
e.invulnerable = atoi(row[9]);
|
||||
e.flymode = atoi(row[10]);
|
||||
e.ignore_tells = atoi(row[11]);
|
||||
e.revoked = atoi(row[12]);
|
||||
e.karma = atoi(row[13]);
|
||||
e.minilogin_ip = row[14] ? row[14] : "";
|
||||
e.hideme = atoi(row[15]);
|
||||
e.rulesflag = atoi(row[16]);
|
||||
e.suspendeduntil = strtoll(row[17] ? row[17] : "-1", nullptr, 10);
|
||||
e.time_creation = atoi(row[18]);
|
||||
e.ban_reason = row[19] ? row[19] : "";
|
||||
e.suspend_reason = row[20] ? row[20] : "";
|
||||
e.crc_eqgame = row[21] ? row[21] : "";
|
||||
e.crc_skillcaps = row[22] ? row[22] : "";
|
||||
e.crc_basedata = row[23] ? row[23] : "";
|
||||
|
||||
return entry;
|
||||
return e;
|
||||
}
|
||||
|
||||
return NewEntity();
|
||||
@@ -256,44 +256,44 @@ public:
|
||||
|
||||
static int UpdateOne(
|
||||
Database& db,
|
||||
Account account_entry
|
||||
const Account &e
|
||||
)
|
||||
{
|
||||
std::vector<std::string> update_values;
|
||||
std::vector<std::string> v;
|
||||
|
||||
auto columns = Columns();
|
||||
|
||||
update_values.push_back(columns[1] + " = '" + Strings::Escape(account_entry.name) + "'");
|
||||
update_values.push_back(columns[2] + " = '" + Strings::Escape(account_entry.charname) + "'");
|
||||
update_values.push_back(columns[3] + " = " + std::to_string(account_entry.sharedplat));
|
||||
update_values.push_back(columns[4] + " = '" + Strings::Escape(account_entry.password) + "'");
|
||||
update_values.push_back(columns[5] + " = " + std::to_string(account_entry.status));
|
||||
update_values.push_back(columns[6] + " = '" + Strings::Escape(account_entry.ls_id) + "'");
|
||||
update_values.push_back(columns[7] + " = " + std::to_string(account_entry.lsaccount_id));
|
||||
update_values.push_back(columns[8] + " = " + std::to_string(account_entry.gmspeed));
|
||||
update_values.push_back(columns[9] + " = " + std::to_string(account_entry.invulnerable));
|
||||
update_values.push_back(columns[10] + " = " + std::to_string(account_entry.flymode));
|
||||
update_values.push_back(columns[11] + " = " + std::to_string(account_entry.ignore_tells));
|
||||
update_values.push_back(columns[12] + " = " + std::to_string(account_entry.revoked));
|
||||
update_values.push_back(columns[13] + " = " + std::to_string(account_entry.karma));
|
||||
update_values.push_back(columns[14] + " = '" + Strings::Escape(account_entry.minilogin_ip) + "'");
|
||||
update_values.push_back(columns[15] + " = " + std::to_string(account_entry.hideme));
|
||||
update_values.push_back(columns[16] + " = " + std::to_string(account_entry.rulesflag));
|
||||
update_values.push_back(columns[17] + " = FROM_UNIXTIME(" + (account_entry.suspendeduntil > 0 ? std::to_string(account_entry.suspendeduntil) : "null") + ")");
|
||||
update_values.push_back(columns[18] + " = " + std::to_string(account_entry.time_creation));
|
||||
update_values.push_back(columns[19] + " = '" + Strings::Escape(account_entry.ban_reason) + "'");
|
||||
update_values.push_back(columns[20] + " = '" + Strings::Escape(account_entry.suspend_reason) + "'");
|
||||
update_values.push_back(columns[21] + " = '" + Strings::Escape(account_entry.crc_eqgame) + "'");
|
||||
update_values.push_back(columns[22] + " = '" + Strings::Escape(account_entry.crc_skillcaps) + "'");
|
||||
update_values.push_back(columns[23] + " = '" + Strings::Escape(account_entry.crc_basedata) + "'");
|
||||
v.push_back(columns[1] + " = '" + Strings::Escape(e.name) + "'");
|
||||
v.push_back(columns[2] + " = '" + Strings::Escape(e.charname) + "'");
|
||||
v.push_back(columns[3] + " = " + std::to_string(e.sharedplat));
|
||||
v.push_back(columns[4] + " = '" + Strings::Escape(e.password) + "'");
|
||||
v.push_back(columns[5] + " = " + std::to_string(e.status));
|
||||
v.push_back(columns[6] + " = '" + Strings::Escape(e.ls_id) + "'");
|
||||
v.push_back(columns[7] + " = " + std::to_string(e.lsaccount_id));
|
||||
v.push_back(columns[8] + " = " + std::to_string(e.gmspeed));
|
||||
v.push_back(columns[9] + " = " + std::to_string(e.invulnerable));
|
||||
v.push_back(columns[10] + " = " + std::to_string(e.flymode));
|
||||
v.push_back(columns[11] + " = " + std::to_string(e.ignore_tells));
|
||||
v.push_back(columns[12] + " = " + std::to_string(e.revoked));
|
||||
v.push_back(columns[13] + " = " + std::to_string(e.karma));
|
||||
v.push_back(columns[14] + " = '" + Strings::Escape(e.minilogin_ip) + "'");
|
||||
v.push_back(columns[15] + " = " + std::to_string(e.hideme));
|
||||
v.push_back(columns[16] + " = " + std::to_string(e.rulesflag));
|
||||
v.push_back(columns[17] + " = FROM_UNIXTIME(" + (e.suspendeduntil > 0 ? std::to_string(e.suspendeduntil) : "null") + ")");
|
||||
v.push_back(columns[18] + " = " + std::to_string(e.time_creation));
|
||||
v.push_back(columns[19] + " = '" + Strings::Escape(e.ban_reason) + "'");
|
||||
v.push_back(columns[20] + " = '" + Strings::Escape(e.suspend_reason) + "'");
|
||||
v.push_back(columns[21] + " = '" + Strings::Escape(e.crc_eqgame) + "'");
|
||||
v.push_back(columns[22] + " = '" + Strings::Escape(e.crc_skillcaps) + "'");
|
||||
v.push_back(columns[23] + " = '" + Strings::Escape(e.crc_basedata) + "'");
|
||||
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"UPDATE {} SET {} WHERE {} = {}",
|
||||
TableName(),
|
||||
Strings::Implode(", ", update_values),
|
||||
Strings::Implode(", ", v),
|
||||
PrimaryKey(),
|
||||
account_entry.id
|
||||
e.id
|
||||
)
|
||||
);
|
||||
|
||||
@@ -302,93 +302,93 @@ public:
|
||||
|
||||
static Account InsertOne(
|
||||
Database& db,
|
||||
Account account_entry
|
||||
Account e
|
||||
)
|
||||
{
|
||||
std::vector<std::string> insert_values;
|
||||
std::vector<std::string> v;
|
||||
|
||||
insert_values.push_back(std::to_string(account_entry.id));
|
||||
insert_values.push_back("'" + Strings::Escape(account_entry.name) + "'");
|
||||
insert_values.push_back("'" + Strings::Escape(account_entry.charname) + "'");
|
||||
insert_values.push_back(std::to_string(account_entry.sharedplat));
|
||||
insert_values.push_back("'" + Strings::Escape(account_entry.password) + "'");
|
||||
insert_values.push_back(std::to_string(account_entry.status));
|
||||
insert_values.push_back("'" + Strings::Escape(account_entry.ls_id) + "'");
|
||||
insert_values.push_back(std::to_string(account_entry.lsaccount_id));
|
||||
insert_values.push_back(std::to_string(account_entry.gmspeed));
|
||||
insert_values.push_back(std::to_string(account_entry.invulnerable));
|
||||
insert_values.push_back(std::to_string(account_entry.flymode));
|
||||
insert_values.push_back(std::to_string(account_entry.ignore_tells));
|
||||
insert_values.push_back(std::to_string(account_entry.revoked));
|
||||
insert_values.push_back(std::to_string(account_entry.karma));
|
||||
insert_values.push_back("'" + Strings::Escape(account_entry.minilogin_ip) + "'");
|
||||
insert_values.push_back(std::to_string(account_entry.hideme));
|
||||
insert_values.push_back(std::to_string(account_entry.rulesflag));
|
||||
insert_values.push_back("FROM_UNIXTIME(" + (account_entry.suspendeduntil > 0 ? std::to_string(account_entry.suspendeduntil) : "null") + ")");
|
||||
insert_values.push_back(std::to_string(account_entry.time_creation));
|
||||
insert_values.push_back("'" + Strings::Escape(account_entry.ban_reason) + "'");
|
||||
insert_values.push_back("'" + Strings::Escape(account_entry.suspend_reason) + "'");
|
||||
insert_values.push_back("'" + Strings::Escape(account_entry.crc_eqgame) + "'");
|
||||
insert_values.push_back("'" + Strings::Escape(account_entry.crc_skillcaps) + "'");
|
||||
insert_values.push_back("'" + Strings::Escape(account_entry.crc_basedata) + "'");
|
||||
v.push_back(std::to_string(e.id));
|
||||
v.push_back("'" + Strings::Escape(e.name) + "'");
|
||||
v.push_back("'" + Strings::Escape(e.charname) + "'");
|
||||
v.push_back(std::to_string(e.sharedplat));
|
||||
v.push_back("'" + Strings::Escape(e.password) + "'");
|
||||
v.push_back(std::to_string(e.status));
|
||||
v.push_back("'" + Strings::Escape(e.ls_id) + "'");
|
||||
v.push_back(std::to_string(e.lsaccount_id));
|
||||
v.push_back(std::to_string(e.gmspeed));
|
||||
v.push_back(std::to_string(e.invulnerable));
|
||||
v.push_back(std::to_string(e.flymode));
|
||||
v.push_back(std::to_string(e.ignore_tells));
|
||||
v.push_back(std::to_string(e.revoked));
|
||||
v.push_back(std::to_string(e.karma));
|
||||
v.push_back("'" + Strings::Escape(e.minilogin_ip) + "'");
|
||||
v.push_back(std::to_string(e.hideme));
|
||||
v.push_back(std::to_string(e.rulesflag));
|
||||
v.push_back("FROM_UNIXTIME(" + (e.suspendeduntil > 0 ? std::to_string(e.suspendeduntil) : "null") + ")");
|
||||
v.push_back(std::to_string(e.time_creation));
|
||||
v.push_back("'" + Strings::Escape(e.ban_reason) + "'");
|
||||
v.push_back("'" + Strings::Escape(e.suspend_reason) + "'");
|
||||
v.push_back("'" + Strings::Escape(e.crc_eqgame) + "'");
|
||||
v.push_back("'" + Strings::Escape(e.crc_skillcaps) + "'");
|
||||
v.push_back("'" + Strings::Escape(e.crc_basedata) + "'");
|
||||
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"{} VALUES ({})",
|
||||
BaseInsert(),
|
||||
Strings::Implode(",", insert_values)
|
||||
Strings::Implode(",", v)
|
||||
)
|
||||
);
|
||||
|
||||
if (results.Success()) {
|
||||
account_entry.id = results.LastInsertedID();
|
||||
return account_entry;
|
||||
e.id = results.LastInsertedID();
|
||||
return e;
|
||||
}
|
||||
|
||||
account_entry = NewEntity();
|
||||
e = NewEntity();
|
||||
|
||||
return account_entry;
|
||||
return e;
|
||||
}
|
||||
|
||||
static int InsertMany(
|
||||
Database& db,
|
||||
std::vector<Account> account_entries
|
||||
const std::vector<Account> &entries
|
||||
)
|
||||
{
|
||||
std::vector<std::string> insert_chunks;
|
||||
|
||||
for (auto &account_entry: account_entries) {
|
||||
std::vector<std::string> insert_values;
|
||||
for (auto &e: entries) {
|
||||
std::vector<std::string> v;
|
||||
|
||||
insert_values.push_back(std::to_string(account_entry.id));
|
||||
insert_values.push_back("'" + Strings::Escape(account_entry.name) + "'");
|
||||
insert_values.push_back("'" + Strings::Escape(account_entry.charname) + "'");
|
||||
insert_values.push_back(std::to_string(account_entry.sharedplat));
|
||||
insert_values.push_back("'" + Strings::Escape(account_entry.password) + "'");
|
||||
insert_values.push_back(std::to_string(account_entry.status));
|
||||
insert_values.push_back("'" + Strings::Escape(account_entry.ls_id) + "'");
|
||||
insert_values.push_back(std::to_string(account_entry.lsaccount_id));
|
||||
insert_values.push_back(std::to_string(account_entry.gmspeed));
|
||||
insert_values.push_back(std::to_string(account_entry.invulnerable));
|
||||
insert_values.push_back(std::to_string(account_entry.flymode));
|
||||
insert_values.push_back(std::to_string(account_entry.ignore_tells));
|
||||
insert_values.push_back(std::to_string(account_entry.revoked));
|
||||
insert_values.push_back(std::to_string(account_entry.karma));
|
||||
insert_values.push_back("'" + Strings::Escape(account_entry.minilogin_ip) + "'");
|
||||
insert_values.push_back(std::to_string(account_entry.hideme));
|
||||
insert_values.push_back(std::to_string(account_entry.rulesflag));
|
||||
insert_values.push_back("FROM_UNIXTIME(" + (account_entry.suspendeduntil > 0 ? std::to_string(account_entry.suspendeduntil) : "null") + ")");
|
||||
insert_values.push_back(std::to_string(account_entry.time_creation));
|
||||
insert_values.push_back("'" + Strings::Escape(account_entry.ban_reason) + "'");
|
||||
insert_values.push_back("'" + Strings::Escape(account_entry.suspend_reason) + "'");
|
||||
insert_values.push_back("'" + Strings::Escape(account_entry.crc_eqgame) + "'");
|
||||
insert_values.push_back("'" + Strings::Escape(account_entry.crc_skillcaps) + "'");
|
||||
insert_values.push_back("'" + Strings::Escape(account_entry.crc_basedata) + "'");
|
||||
v.push_back(std::to_string(e.id));
|
||||
v.push_back("'" + Strings::Escape(e.name) + "'");
|
||||
v.push_back("'" + Strings::Escape(e.charname) + "'");
|
||||
v.push_back(std::to_string(e.sharedplat));
|
||||
v.push_back("'" + Strings::Escape(e.password) + "'");
|
||||
v.push_back(std::to_string(e.status));
|
||||
v.push_back("'" + Strings::Escape(e.ls_id) + "'");
|
||||
v.push_back(std::to_string(e.lsaccount_id));
|
||||
v.push_back(std::to_string(e.gmspeed));
|
||||
v.push_back(std::to_string(e.invulnerable));
|
||||
v.push_back(std::to_string(e.flymode));
|
||||
v.push_back(std::to_string(e.ignore_tells));
|
||||
v.push_back(std::to_string(e.revoked));
|
||||
v.push_back(std::to_string(e.karma));
|
||||
v.push_back("'" + Strings::Escape(e.minilogin_ip) + "'");
|
||||
v.push_back(std::to_string(e.hideme));
|
||||
v.push_back(std::to_string(e.rulesflag));
|
||||
v.push_back("FROM_UNIXTIME(" + (e.suspendeduntil > 0 ? std::to_string(e.suspendeduntil) : "null") + ")");
|
||||
v.push_back(std::to_string(e.time_creation));
|
||||
v.push_back("'" + Strings::Escape(e.ban_reason) + "'");
|
||||
v.push_back("'" + Strings::Escape(e.suspend_reason) + "'");
|
||||
v.push_back("'" + Strings::Escape(e.crc_eqgame) + "'");
|
||||
v.push_back("'" + Strings::Escape(e.crc_skillcaps) + "'");
|
||||
v.push_back("'" + Strings::Escape(e.crc_basedata) + "'");
|
||||
|
||||
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(
|
||||
@@ -415,40 +415,40 @@ public:
|
||||
all_entries.reserve(results.RowCount());
|
||||
|
||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||
Account entry{};
|
||||
Account e{};
|
||||
|
||||
entry.id = atoi(row[0]);
|
||||
entry.name = row[1] ? row[1] : "";
|
||||
entry.charname = row[2] ? row[2] : "";
|
||||
entry.sharedplat = atoi(row[3]);
|
||||
entry.password = row[4] ? row[4] : "";
|
||||
entry.status = atoi(row[5]);
|
||||
entry.ls_id = row[6] ? row[6] : "";
|
||||
entry.lsaccount_id = atoi(row[7]);
|
||||
entry.gmspeed = atoi(row[8]);
|
||||
entry.invulnerable = atoi(row[9]);
|
||||
entry.flymode = atoi(row[10]);
|
||||
entry.ignore_tells = atoi(row[11]);
|
||||
entry.revoked = atoi(row[12]);
|
||||
entry.karma = atoi(row[13]);
|
||||
entry.minilogin_ip = row[14] ? row[14] : "";
|
||||
entry.hideme = atoi(row[15]);
|
||||
entry.rulesflag = atoi(row[16]);
|
||||
entry.suspendeduntil = strtoll(row[17] ? row[17] : "-1", nullptr, 10);
|
||||
entry.time_creation = atoi(row[18]);
|
||||
entry.ban_reason = row[19] ? row[19] : "";
|
||||
entry.suspend_reason = row[20] ? row[20] : "";
|
||||
entry.crc_eqgame = row[21] ? row[21] : "";
|
||||
entry.crc_skillcaps = row[22] ? row[22] : "";
|
||||
entry.crc_basedata = row[23] ? row[23] : "";
|
||||
e.id = atoi(row[0]);
|
||||
e.name = row[1] ? row[1] : "";
|
||||
e.charname = row[2] ? row[2] : "";
|
||||
e.sharedplat = atoi(row[3]);
|
||||
e.password = row[4] ? row[4] : "";
|
||||
e.status = atoi(row[5]);
|
||||
e.ls_id = row[6] ? row[6] : "";
|
||||
e.lsaccount_id = atoi(row[7]);
|
||||
e.gmspeed = atoi(row[8]);
|
||||
e.invulnerable = atoi(row[9]);
|
||||
e.flymode = atoi(row[10]);
|
||||
e.ignore_tells = atoi(row[11]);
|
||||
e.revoked = atoi(row[12]);
|
||||
e.karma = atoi(row[13]);
|
||||
e.minilogin_ip = row[14] ? row[14] : "";
|
||||
e.hideme = atoi(row[15]);
|
||||
e.rulesflag = atoi(row[16]);
|
||||
e.suspendeduntil = strtoll(row[17] ? row[17] : "-1", nullptr, 10);
|
||||
e.time_creation = atoi(row[18]);
|
||||
e.ban_reason = row[19] ? row[19] : "";
|
||||
e.suspend_reason = row[20] ? row[20] : "";
|
||||
e.crc_eqgame = row[21] ? row[21] : "";
|
||||
e.crc_skillcaps = row[22] ? row[22] : "";
|
||||
e.crc_basedata = row[23] ? row[23] : "";
|
||||
|
||||
all_entries.push_back(entry);
|
||||
all_entries.push_back(e);
|
||||
}
|
||||
|
||||
return all_entries;
|
||||
}
|
||||
|
||||
static std::vector<Account> GetWhere(Database& db, std::string where_filter)
|
||||
static std::vector<Account> GetWhere(Database& db, const std::string &where_filter)
|
||||
{
|
||||
std::vector<Account> all_entries;
|
||||
|
||||
@@ -463,40 +463,40 @@ public:
|
||||
all_entries.reserve(results.RowCount());
|
||||
|
||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||
Account entry{};
|
||||
Account e{};
|
||||
|
||||
entry.id = atoi(row[0]);
|
||||
entry.name = row[1] ? row[1] : "";
|
||||
entry.charname = row[2] ? row[2] : "";
|
||||
entry.sharedplat = atoi(row[3]);
|
||||
entry.password = row[4] ? row[4] : "";
|
||||
entry.status = atoi(row[5]);
|
||||
entry.ls_id = row[6] ? row[6] : "";
|
||||
entry.lsaccount_id = atoi(row[7]);
|
||||
entry.gmspeed = atoi(row[8]);
|
||||
entry.invulnerable = atoi(row[9]);
|
||||
entry.flymode = atoi(row[10]);
|
||||
entry.ignore_tells = atoi(row[11]);
|
||||
entry.revoked = atoi(row[12]);
|
||||
entry.karma = atoi(row[13]);
|
||||
entry.minilogin_ip = row[14] ? row[14] : "";
|
||||
entry.hideme = atoi(row[15]);
|
||||
entry.rulesflag = atoi(row[16]);
|
||||
entry.suspendeduntil = strtoll(row[17] ? row[17] : "-1", nullptr, 10);
|
||||
entry.time_creation = atoi(row[18]);
|
||||
entry.ban_reason = row[19] ? row[19] : "";
|
||||
entry.suspend_reason = row[20] ? row[20] : "";
|
||||
entry.crc_eqgame = row[21] ? row[21] : "";
|
||||
entry.crc_skillcaps = row[22] ? row[22] : "";
|
||||
entry.crc_basedata = row[23] ? row[23] : "";
|
||||
e.id = atoi(row[0]);
|
||||
e.name = row[1] ? row[1] : "";
|
||||
e.charname = row[2] ? row[2] : "";
|
||||
e.sharedplat = atoi(row[3]);
|
||||
e.password = row[4] ? row[4] : "";
|
||||
e.status = atoi(row[5]);
|
||||
e.ls_id = row[6] ? row[6] : "";
|
||||
e.lsaccount_id = atoi(row[7]);
|
||||
e.gmspeed = atoi(row[8]);
|
||||
e.invulnerable = atoi(row[9]);
|
||||
e.flymode = atoi(row[10]);
|
||||
e.ignore_tells = atoi(row[11]);
|
||||
e.revoked = atoi(row[12]);
|
||||
e.karma = atoi(row[13]);
|
||||
e.minilogin_ip = row[14] ? row[14] : "";
|
||||
e.hideme = atoi(row[15]);
|
||||
e.rulesflag = atoi(row[16]);
|
||||
e.suspendeduntil = strtoll(row[17] ? row[17] : "-1", nullptr, 10);
|
||||
e.time_creation = atoi(row[18]);
|
||||
e.ban_reason = row[19] ? row[19] : "";
|
||||
e.suspend_reason = row[20] ? row[20] : "";
|
||||
e.crc_eqgame = row[21] ? row[21] : "";
|
||||
e.crc_skillcaps = row[22] ? row[22] : "";
|
||||
e.crc_basedata = row[23] ? row[23] : "";
|
||||
|
||||
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(
|
||||
@@ -521,6 +521,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_ACCOUNT_REPOSITORY_H
|
||||
|
||||
Reference in New Issue
Block a user