[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
@@ -19,17 +19,17 @@
class BaseAurasRepository {
public:
struct Auras {
int type;
int npc_type;
int32_t type;
int32_t npc_type;
std::string name;
int spell_id;
int distance;
int aura_type;
int spawn_type;
int movement;
int duration;
int icon;
int cast_time;
int32_t spell_id;
int32_t distance;
int32_t aura_type;
int32_t spawn_type;
int32_t movement;
int32_t duration;
int32_t icon;
int32_t cast_time;
};
static std::string PrimaryKey()
@@ -154,17 +154,17 @@ public:
if (results.RowCount() == 1) {
Auras e{};
e.type = atoi(row[0]);
e.npc_type = atoi(row[1]);
e.type = static_cast<int32_t>(atoi(row[0]));
e.npc_type = static_cast<int32_t>(atoi(row[1]));
e.name = row[2] ? row[2] : "";
e.spell_id = atoi(row[3]);
e.distance = atoi(row[4]);
e.aura_type = atoi(row[5]);
e.spawn_type = atoi(row[6]);
e.movement = atoi(row[7]);
e.duration = atoi(row[8]);
e.icon = atoi(row[9]);
e.cast_time = atoi(row[10]);
e.spell_id = static_cast<int32_t>(atoi(row[3]));
e.distance = static_cast<int32_t>(atoi(row[4]));
e.aura_type = static_cast<int32_t>(atoi(row[5]));
e.spawn_type = static_cast<int32_t>(atoi(row[6]));
e.movement = static_cast<int32_t>(atoi(row[7]));
e.duration = static_cast<int32_t>(atoi(row[8]));
e.icon = static_cast<int32_t>(atoi(row[9]));
e.cast_time = static_cast<int32_t>(atoi(row[10]));
return e;
}
@@ -314,17 +314,17 @@ public:
for (auto row = results.begin(); row != results.end(); ++row) {
Auras e{};
e.type = atoi(row[0]);
e.npc_type = atoi(row[1]);
e.type = static_cast<int32_t>(atoi(row[0]));
e.npc_type = static_cast<int32_t>(atoi(row[1]));
e.name = row[2] ? row[2] : "";
e.spell_id = atoi(row[3]);
e.distance = atoi(row[4]);
e.aura_type = atoi(row[5]);
e.spawn_type = atoi(row[6]);
e.movement = atoi(row[7]);
e.duration = atoi(row[8]);
e.icon = atoi(row[9]);
e.cast_time = atoi(row[10]);
e.spell_id = static_cast<int32_t>(atoi(row[3]));
e.distance = static_cast<int32_t>(atoi(row[4]));
e.aura_type = static_cast<int32_t>(atoi(row[5]));
e.spawn_type = static_cast<int32_t>(atoi(row[6]));
e.movement = static_cast<int32_t>(atoi(row[7]));
e.duration = static_cast<int32_t>(atoi(row[8]));
e.icon = static_cast<int32_t>(atoi(row[9]));
e.cast_time = static_cast<int32_t>(atoi(row[10]));
all_entries.push_back(e);
}
@@ -349,17 +349,17 @@ public:
for (auto row = results.begin(); row != results.end(); ++row) {
Auras e{};
e.type = atoi(row[0]);
e.npc_type = atoi(row[1]);
e.type = static_cast<int32_t>(atoi(row[0]));
e.npc_type = static_cast<int32_t>(atoi(row[1]));
e.name = row[2] ? row[2] : "";
e.spell_id = atoi(row[3]);
e.distance = atoi(row[4]);
e.aura_type = atoi(row[5]);
e.spawn_type = atoi(row[6]);
e.movement = atoi(row[7]);
e.duration = atoi(row[8]);
e.icon = atoi(row[9]);
e.cast_time = atoi(row[10]);
e.spell_id = static_cast<int32_t>(atoi(row[3]));
e.distance = static_cast<int32_t>(atoi(row[4]));
e.aura_type = static_cast<int32_t>(atoi(row[5]));
e.spawn_type = static_cast<int32_t>(atoi(row[6]));
e.movement = static_cast<int32_t>(atoi(row[7]));
e.duration = static_cast<int32_t>(atoi(row[8]));
e.icon = static_cast<int32_t>(atoi(row[9]));
e.cast_time = static_cast<int32_t>(atoi(row[10]));
all_entries.push_back(e);
}