mirror of
https://github.com/EQEmu/Server.git
synced 2026-06-26 11:27:17 +00:00
[Repositories] Add more precise types to repository generator (#2391)
* Make utils/scripts/generators/repository-generator.pl aware of more datatypes This adds support for unsigned and more integer types. It also avoids using parsing functions that require casting (still needed in some cases) Having the data types in the Repository structs better map to the types in the database will allow us to avoid casting when we pull data out of them. And as a benefit, assume something is wrong if we do :) Hopefully clean up some warnings due to casting too. Co-authored-by: Akkadius <akkadius1@gmail.com>
This commit is contained in:
committed by
GitHub
parent
fcf01f6d87
commit
6f7fa98996
@@ -19,25 +19,25 @@
|
||||
class BaseAccountRepository {
|
||||
public:
|
||||
struct Account {
|
||||
int id;
|
||||
int32_t id;
|
||||
std::string name;
|
||||
std::string charname;
|
||||
int sharedplat;
|
||||
uint32_t sharedplat;
|
||||
std::string password;
|
||||
int status;
|
||||
int32_t status;
|
||||
std::string ls_id;
|
||||
int lsaccount_id;
|
||||
int gmspeed;
|
||||
int invulnerable;
|
||||
int flymode;
|
||||
int ignore_tells;
|
||||
int revoked;
|
||||
int karma;
|
||||
uint32_t lsaccount_id;
|
||||
uint8_t gmspeed;
|
||||
int8_t invulnerable;
|
||||
int8_t flymode;
|
||||
int8_t ignore_tells;
|
||||
uint8_t revoked;
|
||||
uint32_t karma;
|
||||
std::string minilogin_ip;
|
||||
int hideme;
|
||||
int rulesflag;
|
||||
int8_t hideme;
|
||||
uint8_t rulesflag;
|
||||
time_t suspendeduntil;
|
||||
int time_creation;
|
||||
uint32_t time_creation;
|
||||
std::string ban_reason;
|
||||
std::string suspend_reason;
|
||||
std::string crc_eqgame;
|
||||
@@ -206,25 +206,25 @@ public:
|
||||
if (results.RowCount() == 1) {
|
||||
Account e{};
|
||||
|
||||
e.id = atoi(row[0]);
|
||||
e.id = static_cast<int32_t>(atoi(row[0]));
|
||||
e.name = row[1] ? row[1] : "";
|
||||
e.charname = row[2] ? row[2] : "";
|
||||
e.sharedplat = atoi(row[3]);
|
||||
e.sharedplat = static_cast<uint32_t>(strtoul(row[3], nullptr, 10));
|
||||
e.password = row[4] ? row[4] : "";
|
||||
e.status = atoi(row[5]);
|
||||
e.status = static_cast<int32_t>(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.lsaccount_id = static_cast<uint32_t>(strtoul(row[7], nullptr, 10));
|
||||
e.gmspeed = static_cast<uint8_t>(strtoul(row[8], nullptr, 10));
|
||||
e.invulnerable = static_cast<int8_t>(atoi(row[9]));
|
||||
e.flymode = static_cast<int8_t>(atoi(row[10]));
|
||||
e.ignore_tells = static_cast<int8_t>(atoi(row[11]));
|
||||
e.revoked = static_cast<uint8_t>(strtoul(row[12], nullptr, 10));
|
||||
e.karma = static_cast<uint32_t>(strtoul(row[13], nullptr, 10));
|
||||
e.minilogin_ip = row[14] ? row[14] : "";
|
||||
e.hideme = atoi(row[15]);
|
||||
e.rulesflag = atoi(row[16]);
|
||||
e.hideme = static_cast<int8_t>(atoi(row[15]));
|
||||
e.rulesflag = static_cast<uint8_t>(strtoul(row[16], nullptr, 10));
|
||||
e.suspendeduntil = strtoll(row[17] ? row[17] : "-1", nullptr, 10);
|
||||
e.time_creation = atoi(row[18]);
|
||||
e.time_creation = static_cast<uint32_t>(strtoul(row[18], nullptr, 10));
|
||||
e.ban_reason = row[19] ? row[19] : "";
|
||||
e.suspend_reason = row[20] ? row[20] : "";
|
||||
e.crc_eqgame = row[21] ? row[21] : "";
|
||||
@@ -417,25 +417,25 @@ public:
|
||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||
Account e{};
|
||||
|
||||
e.id = atoi(row[0]);
|
||||
e.id = static_cast<int32_t>(atoi(row[0]));
|
||||
e.name = row[1] ? row[1] : "";
|
||||
e.charname = row[2] ? row[2] : "";
|
||||
e.sharedplat = atoi(row[3]);
|
||||
e.sharedplat = static_cast<uint32_t>(strtoul(row[3], nullptr, 10));
|
||||
e.password = row[4] ? row[4] : "";
|
||||
e.status = atoi(row[5]);
|
||||
e.status = static_cast<int32_t>(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.lsaccount_id = static_cast<uint32_t>(strtoul(row[7], nullptr, 10));
|
||||
e.gmspeed = static_cast<uint8_t>(strtoul(row[8], nullptr, 10));
|
||||
e.invulnerable = static_cast<int8_t>(atoi(row[9]));
|
||||
e.flymode = static_cast<int8_t>(atoi(row[10]));
|
||||
e.ignore_tells = static_cast<int8_t>(atoi(row[11]));
|
||||
e.revoked = static_cast<uint8_t>(strtoul(row[12], nullptr, 10));
|
||||
e.karma = static_cast<uint32_t>(strtoul(row[13], nullptr, 10));
|
||||
e.minilogin_ip = row[14] ? row[14] : "";
|
||||
e.hideme = atoi(row[15]);
|
||||
e.rulesflag = atoi(row[16]);
|
||||
e.hideme = static_cast<int8_t>(atoi(row[15]));
|
||||
e.rulesflag = static_cast<uint8_t>(strtoul(row[16], nullptr, 10));
|
||||
e.suspendeduntil = strtoll(row[17] ? row[17] : "-1", nullptr, 10);
|
||||
e.time_creation = atoi(row[18]);
|
||||
e.time_creation = static_cast<uint32_t>(strtoul(row[18], nullptr, 10));
|
||||
e.ban_reason = row[19] ? row[19] : "";
|
||||
e.suspend_reason = row[20] ? row[20] : "";
|
||||
e.crc_eqgame = row[21] ? row[21] : "";
|
||||
@@ -465,25 +465,25 @@ public:
|
||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||
Account e{};
|
||||
|
||||
e.id = atoi(row[0]);
|
||||
e.id = static_cast<int32_t>(atoi(row[0]));
|
||||
e.name = row[1] ? row[1] : "";
|
||||
e.charname = row[2] ? row[2] : "";
|
||||
e.sharedplat = atoi(row[3]);
|
||||
e.sharedplat = static_cast<uint32_t>(strtoul(row[3], nullptr, 10));
|
||||
e.password = row[4] ? row[4] : "";
|
||||
e.status = atoi(row[5]);
|
||||
e.status = static_cast<int32_t>(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.lsaccount_id = static_cast<uint32_t>(strtoul(row[7], nullptr, 10));
|
||||
e.gmspeed = static_cast<uint8_t>(strtoul(row[8], nullptr, 10));
|
||||
e.invulnerable = static_cast<int8_t>(atoi(row[9]));
|
||||
e.flymode = static_cast<int8_t>(atoi(row[10]));
|
||||
e.ignore_tells = static_cast<int8_t>(atoi(row[11]));
|
||||
e.revoked = static_cast<uint8_t>(strtoul(row[12], nullptr, 10));
|
||||
e.karma = static_cast<uint32_t>(strtoul(row[13], nullptr, 10));
|
||||
e.minilogin_ip = row[14] ? row[14] : "";
|
||||
e.hideme = atoi(row[15]);
|
||||
e.rulesflag = atoi(row[16]);
|
||||
e.hideme = static_cast<int8_t>(atoi(row[15]));
|
||||
e.rulesflag = static_cast<uint8_t>(strtoul(row[16], nullptr, 10));
|
||||
e.suspendeduntil = strtoll(row[17] ? row[17] : "-1", nullptr, 10);
|
||||
e.time_creation = atoi(row[18]);
|
||||
e.time_creation = static_cast<uint32_t>(strtoul(row[18], nullptr, 10));
|
||||
e.ban_reason = row[19] ? row[19] : "";
|
||||
e.suspend_reason = row[20] ? row[20] : "";
|
||||
e.crc_eqgame = row[21] ? row[21] : "";
|
||||
|
||||
Reference in New Issue
Block a user