[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:
Michael Cook (mackal)
2022-08-31 01:04:27 -04:00
committed by GitHub
parent fcf01f6d87
commit 6f7fa98996
183 changed files with 7849 additions and 7818 deletions
+32 -32
View File
@@ -19,15 +19,15 @@
class BasePetsRepository {
public:
struct Pets {
int id;
int32_t id;
std::string type;
int petpower;
int npcID;
int temp;
int petcontrol;
int petnaming;
int monsterflag;
int equipmentset;
int32_t petpower;
int32_t npcID;
int8_t temp;
int8_t petcontrol;
int8_t petnaming;
int8_t monsterflag;
int32_t equipmentset;
};
static std::string PrimaryKey()
@@ -146,15 +146,15 @@ public:
if (results.RowCount() == 1) {
Pets e{};
e.id = atoi(row[0]);
e.id = static_cast<int32_t>(atoi(row[0]));
e.type = row[1] ? row[1] : "";
e.petpower = atoi(row[2]);
e.npcID = atoi(row[3]);
e.temp = atoi(row[4]);
e.petcontrol = atoi(row[5]);
e.petnaming = atoi(row[6]);
e.monsterflag = atoi(row[7]);
e.equipmentset = atoi(row[8]);
e.petpower = static_cast<int32_t>(atoi(row[2]));
e.npcID = static_cast<int32_t>(atoi(row[3]));
e.temp = static_cast<int8_t>(atoi(row[4]));
e.petcontrol = static_cast<int8_t>(atoi(row[5]));
e.petnaming = static_cast<int8_t>(atoi(row[6]));
e.monsterflag = static_cast<int8_t>(atoi(row[7]));
e.equipmentset = static_cast<int32_t>(atoi(row[8]));
return e;
}
@@ -297,15 +297,15 @@ public:
for (auto row = results.begin(); row != results.end(); ++row) {
Pets e{};
e.id = atoi(row[0]);
e.id = static_cast<int32_t>(atoi(row[0]));
e.type = row[1] ? row[1] : "";
e.petpower = atoi(row[2]);
e.npcID = atoi(row[3]);
e.temp = atoi(row[4]);
e.petcontrol = atoi(row[5]);
e.petnaming = atoi(row[6]);
e.monsterflag = atoi(row[7]);
e.equipmentset = atoi(row[8]);
e.petpower = static_cast<int32_t>(atoi(row[2]));
e.npcID = static_cast<int32_t>(atoi(row[3]));
e.temp = static_cast<int8_t>(atoi(row[4]));
e.petcontrol = static_cast<int8_t>(atoi(row[5]));
e.petnaming = static_cast<int8_t>(atoi(row[6]));
e.monsterflag = static_cast<int8_t>(atoi(row[7]));
e.equipmentset = static_cast<int32_t>(atoi(row[8]));
all_entries.push_back(e);
}
@@ -330,15 +330,15 @@ public:
for (auto row = results.begin(); row != results.end(); ++row) {
Pets e{};
e.id = atoi(row[0]);
e.id = static_cast<int32_t>(atoi(row[0]));
e.type = row[1] ? row[1] : "";
e.petpower = atoi(row[2]);
e.npcID = atoi(row[3]);
e.temp = atoi(row[4]);
e.petcontrol = atoi(row[5]);
e.petnaming = atoi(row[6]);
e.monsterflag = atoi(row[7]);
e.equipmentset = atoi(row[8]);
e.petpower = static_cast<int32_t>(atoi(row[2]));
e.npcID = static_cast<int32_t>(atoi(row[3]));
e.temp = static_cast<int8_t>(atoi(row[4]));
e.petcontrol = static_cast<int8_t>(atoi(row[5]));
e.petnaming = static_cast<int8_t>(atoi(row[6]));
e.monsterflag = static_cast<int8_t>(atoi(row[7]));
e.equipmentset = static_cast<int32_t>(atoi(row[8]));
all_entries.push_back(e);
}