[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
@@ -23,19 +23,19 @@ public:
float y;
float z;
float heading;
int zone_id;
int bind_id;
int player_choice;
int player_class;
int player_deity;
int player_race;
int start_zone;
int32_t zone_id;
int32_t bind_id;
int32_t player_choice;
int32_t player_class;
int32_t player_deity;
int32_t player_race;
int32_t start_zone;
float bind_x;
float bind_y;
float bind_z;
int select_rank;
int min_expansion;
int max_expansion;
uint8_t select_rank;
int8_t min_expansion;
int8_t max_expansion;
std::string content_flags;
std::string content_flags_disabled;
};
@@ -186,23 +186,23 @@ public:
if (results.RowCount() == 1) {
StartZones e{};
e.x = static_cast<float>(atof(row[0]));
e.y = static_cast<float>(atof(row[1]));
e.z = static_cast<float>(atof(row[2]));
e.heading = static_cast<float>(atof(row[3]));
e.zone_id = atoi(row[4]);
e.bind_id = atoi(row[5]);
e.player_choice = atoi(row[6]);
e.player_class = atoi(row[7]);
e.player_deity = atoi(row[8]);
e.player_race = atoi(row[9]);
e.start_zone = atoi(row[10]);
e.bind_x = static_cast<float>(atof(row[11]));
e.bind_y = static_cast<float>(atof(row[12]));
e.bind_z = static_cast<float>(atof(row[13]));
e.select_rank = atoi(row[14]);
e.min_expansion = atoi(row[15]);
e.max_expansion = atoi(row[16]);
e.x = strtof(row[0], nullptr);
e.y = strtof(row[1], nullptr);
e.z = strtof(row[2], nullptr);
e.heading = strtof(row[3], nullptr);
e.zone_id = static_cast<int32_t>(atoi(row[4]));
e.bind_id = static_cast<int32_t>(atoi(row[5]));
e.player_choice = static_cast<int32_t>(atoi(row[6]));
e.player_class = static_cast<int32_t>(atoi(row[7]));
e.player_deity = static_cast<int32_t>(atoi(row[8]));
e.player_race = static_cast<int32_t>(atoi(row[9]));
e.start_zone = static_cast<int32_t>(atoi(row[10]));
e.bind_x = strtof(row[11], nullptr);
e.bind_y = strtof(row[12], nullptr);
e.bind_z = strtof(row[13], nullptr);
e.select_rank = static_cast<uint8_t>(strtoul(row[14], nullptr, 10));
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] : "";
e.content_flags_disabled = row[18] ? row[18] : "";
@@ -378,23 +378,23 @@ public:
for (auto row = results.begin(); row != results.end(); ++row) {
StartZones e{};
e.x = static_cast<float>(atof(row[0]));
e.y = static_cast<float>(atof(row[1]));
e.z = static_cast<float>(atof(row[2]));
e.heading = static_cast<float>(atof(row[3]));
e.zone_id = atoi(row[4]);
e.bind_id = atoi(row[5]);
e.player_choice = atoi(row[6]);
e.player_class = atoi(row[7]);
e.player_deity = atoi(row[8]);
e.player_race = atoi(row[9]);
e.start_zone = atoi(row[10]);
e.bind_x = static_cast<float>(atof(row[11]));
e.bind_y = static_cast<float>(atof(row[12]));
e.bind_z = static_cast<float>(atof(row[13]));
e.select_rank = atoi(row[14]);
e.min_expansion = atoi(row[15]);
e.max_expansion = atoi(row[16]);
e.x = strtof(row[0], nullptr);
e.y = strtof(row[1], nullptr);
e.z = strtof(row[2], nullptr);
e.heading = strtof(row[3], nullptr);
e.zone_id = static_cast<int32_t>(atoi(row[4]));
e.bind_id = static_cast<int32_t>(atoi(row[5]));
e.player_choice = static_cast<int32_t>(atoi(row[6]));
e.player_class = static_cast<int32_t>(atoi(row[7]));
e.player_deity = static_cast<int32_t>(atoi(row[8]));
e.player_race = static_cast<int32_t>(atoi(row[9]));
e.start_zone = static_cast<int32_t>(atoi(row[10]));
e.bind_x = strtof(row[11], nullptr);
e.bind_y = strtof(row[12], nullptr);
e.bind_z = strtof(row[13], nullptr);
e.select_rank = static_cast<uint8_t>(strtoul(row[14], nullptr, 10));
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] : "";
e.content_flags_disabled = row[18] ? row[18] : "";
@@ -421,23 +421,23 @@ public:
for (auto row = results.begin(); row != results.end(); ++row) {
StartZones e{};
e.x = static_cast<float>(atof(row[0]));
e.y = static_cast<float>(atof(row[1]));
e.z = static_cast<float>(atof(row[2]));
e.heading = static_cast<float>(atof(row[3]));
e.zone_id = atoi(row[4]);
e.bind_id = atoi(row[5]);
e.player_choice = atoi(row[6]);
e.player_class = atoi(row[7]);
e.player_deity = atoi(row[8]);
e.player_race = atoi(row[9]);
e.start_zone = atoi(row[10]);
e.bind_x = static_cast<float>(atof(row[11]));
e.bind_y = static_cast<float>(atof(row[12]));
e.bind_z = static_cast<float>(atof(row[13]));
e.select_rank = atoi(row[14]);
e.min_expansion = atoi(row[15]);
e.max_expansion = atoi(row[16]);
e.x = strtof(row[0], nullptr);
e.y = strtof(row[1], nullptr);
e.z = strtof(row[2], nullptr);
e.heading = strtof(row[3], nullptr);
e.zone_id = static_cast<int32_t>(atoi(row[4]));
e.bind_id = static_cast<int32_t>(atoi(row[5]));
e.player_choice = static_cast<int32_t>(atoi(row[6]));
e.player_class = static_cast<int32_t>(atoi(row[7]));
e.player_deity = static_cast<int32_t>(atoi(row[8]));
e.player_race = static_cast<int32_t>(atoi(row[9]));
e.start_zone = static_cast<int32_t>(atoi(row[10]));
e.bind_x = strtof(row[11], nullptr);
e.bind_y = strtof(row[12], nullptr);
e.bind_z = strtof(row[13], nullptr);
e.select_rank = static_cast<uint8_t>(strtoul(row[14], nullptr, 10));
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] : "";
e.content_flags_disabled = row[18] ? row[18] : "";