mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-31 09:06:46 +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,39 +19,39 @@
|
||||
class BaseAdventureTemplateRepository {
|
||||
public:
|
||||
struct AdventureTemplate {
|
||||
int id;
|
||||
uint32_t id;
|
||||
std::string zone;
|
||||
int zone_version;
|
||||
int is_hard;
|
||||
int is_raid;
|
||||
int min_level;
|
||||
int max_level;
|
||||
int type;
|
||||
int type_data;
|
||||
int type_count;
|
||||
uint8_t zone_version;
|
||||
uint8_t is_hard;
|
||||
uint8_t is_raid;
|
||||
uint8_t min_level;
|
||||
uint8_t max_level;
|
||||
uint8_t type;
|
||||
uint32_t type_data;
|
||||
uint16_t type_count;
|
||||
float assa_x;
|
||||
float assa_y;
|
||||
float assa_z;
|
||||
float assa_h;
|
||||
std::string text;
|
||||
int duration;
|
||||
int zone_in_time;
|
||||
int win_points;
|
||||
int lose_points;
|
||||
int theme;
|
||||
int zone_in_zone_id;
|
||||
uint32_t duration;
|
||||
uint32_t zone_in_time;
|
||||
uint16_t win_points;
|
||||
uint16_t lose_points;
|
||||
uint8_t theme;
|
||||
uint16_t zone_in_zone_id;
|
||||
float zone_in_x;
|
||||
float zone_in_y;
|
||||
int zone_in_object_id;
|
||||
int16_t zone_in_object_id;
|
||||
float dest_x;
|
||||
float dest_y;
|
||||
float dest_z;
|
||||
float dest_h;
|
||||
int graveyard_zone_id;
|
||||
uint32_t graveyard_zone_id;
|
||||
float graveyard_x;
|
||||
float graveyard_y;
|
||||
float graveyard_z;
|
||||
float graveyard_radius;
|
||||
std::string graveyard_radius;
|
||||
};
|
||||
|
||||
static std::string PrimaryKey()
|
||||
@@ -242,39 +242,38 @@ public:
|
||||
if (results.RowCount() == 1) {
|
||||
AdventureTemplate e{};
|
||||
|
||||
e.id = atoi(row[0]);
|
||||
e.id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
|
||||
e.zone = row[1] ? row[1] : "";
|
||||
e.zone_version = atoi(row[2]);
|
||||
e.is_hard = atoi(row[3]);
|
||||
e.is_raid = atoi(row[4]);
|
||||
e.min_level = atoi(row[5]);
|
||||
e.max_level = atoi(row[6]);
|
||||
e.type = atoi(row[7]);
|
||||
e.type_data = atoi(row[8]);
|
||||
e.type_count = atoi(row[9]);
|
||||
e.assa_x = static_cast<float>(atof(row[10]));
|
||||
e.assa_y = static_cast<float>(atof(row[11]));
|
||||
e.assa_z = static_cast<float>(atof(row[12]));
|
||||
e.assa_h = static_cast<float>(atof(row[13]));
|
||||
e.zone_version = static_cast<uint8_t>(strtoul(row[2], nullptr, 10));
|
||||
e.is_hard = static_cast<uint8_t>(strtoul(row[3], nullptr, 10));
|
||||
e.is_raid = static_cast<uint8_t>(strtoul(row[4], nullptr, 10));
|
||||
e.min_level = static_cast<uint8_t>(strtoul(row[5], nullptr, 10));
|
||||
e.max_level = static_cast<uint8_t>(strtoul(row[6], nullptr, 10));
|
||||
e.type = static_cast<uint8_t>(strtoul(row[7], nullptr, 10));
|
||||
e.type_data = static_cast<uint32_t>(strtoul(row[8], nullptr, 10));
|
||||
e.type_count = static_cast<uint16_t>(strtoul(row[9], nullptr, 10));
|
||||
e.assa_x = strtof(row[10], nullptr);
|
||||
e.assa_y = strtof(row[11], nullptr);
|
||||
e.assa_z = strtof(row[12], nullptr);
|
||||
e.assa_h = strtof(row[13], nullptr);
|
||||
e.text = row[14] ? row[14] : "";
|
||||
e.duration = atoi(row[15]);
|
||||
e.zone_in_time = atoi(row[16]);
|
||||
e.win_points = atoi(row[17]);
|
||||
e.lose_points = atoi(row[18]);
|
||||
e.theme = atoi(row[19]);
|
||||
e.zone_in_zone_id = atoi(row[20]);
|
||||
e.zone_in_x = static_cast<float>(atof(row[21]));
|
||||
e.zone_in_y = static_cast<float>(atof(row[22]));
|
||||
e.zone_in_object_id = atoi(row[23]);
|
||||
e.dest_x = static_cast<float>(atof(row[24]));
|
||||
e.dest_y = static_cast<float>(atof(row[25]));
|
||||
e.dest_z = static_cast<float>(atof(row[26]));
|
||||
e.dest_h = static_cast<float>(atof(row[27]));
|
||||
e.graveyard_zone_id = atoi(row[28]);
|
||||
e.graveyard_x = static_cast<float>(atof(row[29]));
|
||||
e.graveyard_y = static_cast<float>(atof(row[30]));
|
||||
e.graveyard_z = static_cast<float>(atof(row[31]));
|
||||
e.graveyard_radius = static_cast<float>(atof(row[32]));
|
||||
e.duration = static_cast<uint32_t>(strtoul(row[15], nullptr, 10));
|
||||
e.zone_in_time = static_cast<uint32_t>(strtoul(row[16], nullptr, 10));
|
||||
e.win_points = static_cast<uint16_t>(strtoul(row[17], nullptr, 10));
|
||||
e.lose_points = static_cast<uint16_t>(strtoul(row[18], nullptr, 10));
|
||||
e.theme = static_cast<uint8_t>(strtoul(row[19], nullptr, 10));
|
||||
e.zone_in_zone_id = static_cast<uint16_t>(strtoul(row[20], nullptr, 10));
|
||||
e.zone_in_x = strtof(row[21], nullptr);
|
||||
e.zone_in_y = strtof(row[22], nullptr);
|
||||
e.zone_in_object_id = static_cast<int16_t>(atoi(row[23]));
|
||||
e.dest_x = strtof(row[24], nullptr);
|
||||
e.dest_y = strtof(row[25], nullptr);
|
||||
e.dest_z = strtof(row[26], nullptr);
|
||||
e.dest_h = strtof(row[27], nullptr);
|
||||
e.graveyard_zone_id = static_cast<uint32_t>(strtoul(row[28], nullptr, 10));
|
||||
e.graveyard_x = strtof(row[29], nullptr);
|
||||
e.graveyard_y = strtof(row[30], nullptr);
|
||||
e.graveyard_z = strtof(row[31], nullptr);
|
||||
|
||||
return e;
|
||||
}
|
||||
@@ -490,39 +489,38 @@ public:
|
||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||
AdventureTemplate e{};
|
||||
|
||||
e.id = atoi(row[0]);
|
||||
e.id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
|
||||
e.zone = row[1] ? row[1] : "";
|
||||
e.zone_version = atoi(row[2]);
|
||||
e.is_hard = atoi(row[3]);
|
||||
e.is_raid = atoi(row[4]);
|
||||
e.min_level = atoi(row[5]);
|
||||
e.max_level = atoi(row[6]);
|
||||
e.type = atoi(row[7]);
|
||||
e.type_data = atoi(row[8]);
|
||||
e.type_count = atoi(row[9]);
|
||||
e.assa_x = static_cast<float>(atof(row[10]));
|
||||
e.assa_y = static_cast<float>(atof(row[11]));
|
||||
e.assa_z = static_cast<float>(atof(row[12]));
|
||||
e.assa_h = static_cast<float>(atof(row[13]));
|
||||
e.zone_version = static_cast<uint8_t>(strtoul(row[2], nullptr, 10));
|
||||
e.is_hard = static_cast<uint8_t>(strtoul(row[3], nullptr, 10));
|
||||
e.is_raid = static_cast<uint8_t>(strtoul(row[4], nullptr, 10));
|
||||
e.min_level = static_cast<uint8_t>(strtoul(row[5], nullptr, 10));
|
||||
e.max_level = static_cast<uint8_t>(strtoul(row[6], nullptr, 10));
|
||||
e.type = static_cast<uint8_t>(strtoul(row[7], nullptr, 10));
|
||||
e.type_data = static_cast<uint32_t>(strtoul(row[8], nullptr, 10));
|
||||
e.type_count = static_cast<uint16_t>(strtoul(row[9], nullptr, 10));
|
||||
e.assa_x = strtof(row[10], nullptr);
|
||||
e.assa_y = strtof(row[11], nullptr);
|
||||
e.assa_z = strtof(row[12], nullptr);
|
||||
e.assa_h = strtof(row[13], nullptr);
|
||||
e.text = row[14] ? row[14] : "";
|
||||
e.duration = atoi(row[15]);
|
||||
e.zone_in_time = atoi(row[16]);
|
||||
e.win_points = atoi(row[17]);
|
||||
e.lose_points = atoi(row[18]);
|
||||
e.theme = atoi(row[19]);
|
||||
e.zone_in_zone_id = atoi(row[20]);
|
||||
e.zone_in_x = static_cast<float>(atof(row[21]));
|
||||
e.zone_in_y = static_cast<float>(atof(row[22]));
|
||||
e.zone_in_object_id = atoi(row[23]);
|
||||
e.dest_x = static_cast<float>(atof(row[24]));
|
||||
e.dest_y = static_cast<float>(atof(row[25]));
|
||||
e.dest_z = static_cast<float>(atof(row[26]));
|
||||
e.dest_h = static_cast<float>(atof(row[27]));
|
||||
e.graveyard_zone_id = atoi(row[28]);
|
||||
e.graveyard_x = static_cast<float>(atof(row[29]));
|
||||
e.graveyard_y = static_cast<float>(atof(row[30]));
|
||||
e.graveyard_z = static_cast<float>(atof(row[31]));
|
||||
e.graveyard_radius = static_cast<float>(atof(row[32]));
|
||||
e.duration = static_cast<uint32_t>(strtoul(row[15], nullptr, 10));
|
||||
e.zone_in_time = static_cast<uint32_t>(strtoul(row[16], nullptr, 10));
|
||||
e.win_points = static_cast<uint16_t>(strtoul(row[17], nullptr, 10));
|
||||
e.lose_points = static_cast<uint16_t>(strtoul(row[18], nullptr, 10));
|
||||
e.theme = static_cast<uint8_t>(strtoul(row[19], nullptr, 10));
|
||||
e.zone_in_zone_id = static_cast<uint16_t>(strtoul(row[20], nullptr, 10));
|
||||
e.zone_in_x = strtof(row[21], nullptr);
|
||||
e.zone_in_y = strtof(row[22], nullptr);
|
||||
e.zone_in_object_id = static_cast<int16_t>(atoi(row[23]));
|
||||
e.dest_x = strtof(row[24], nullptr);
|
||||
e.dest_y = strtof(row[25], nullptr);
|
||||
e.dest_z = strtof(row[26], nullptr);
|
||||
e.dest_h = strtof(row[27], nullptr);
|
||||
e.graveyard_zone_id = static_cast<uint32_t>(strtoul(row[28], nullptr, 10));
|
||||
e.graveyard_x = strtof(row[29], nullptr);
|
||||
e.graveyard_y = strtof(row[30], nullptr);
|
||||
e.graveyard_z = strtof(row[31], nullptr);
|
||||
|
||||
all_entries.push_back(e);
|
||||
}
|
||||
@@ -547,39 +545,38 @@ public:
|
||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||
AdventureTemplate e{};
|
||||
|
||||
e.id = atoi(row[0]);
|
||||
e.id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
|
||||
e.zone = row[1] ? row[1] : "";
|
||||
e.zone_version = atoi(row[2]);
|
||||
e.is_hard = atoi(row[3]);
|
||||
e.is_raid = atoi(row[4]);
|
||||
e.min_level = atoi(row[5]);
|
||||
e.max_level = atoi(row[6]);
|
||||
e.type = atoi(row[7]);
|
||||
e.type_data = atoi(row[8]);
|
||||
e.type_count = atoi(row[9]);
|
||||
e.assa_x = static_cast<float>(atof(row[10]));
|
||||
e.assa_y = static_cast<float>(atof(row[11]));
|
||||
e.assa_z = static_cast<float>(atof(row[12]));
|
||||
e.assa_h = static_cast<float>(atof(row[13]));
|
||||
e.zone_version = static_cast<uint8_t>(strtoul(row[2], nullptr, 10));
|
||||
e.is_hard = static_cast<uint8_t>(strtoul(row[3], nullptr, 10));
|
||||
e.is_raid = static_cast<uint8_t>(strtoul(row[4], nullptr, 10));
|
||||
e.min_level = static_cast<uint8_t>(strtoul(row[5], nullptr, 10));
|
||||
e.max_level = static_cast<uint8_t>(strtoul(row[6], nullptr, 10));
|
||||
e.type = static_cast<uint8_t>(strtoul(row[7], nullptr, 10));
|
||||
e.type_data = static_cast<uint32_t>(strtoul(row[8], nullptr, 10));
|
||||
e.type_count = static_cast<uint16_t>(strtoul(row[9], nullptr, 10));
|
||||
e.assa_x = strtof(row[10], nullptr);
|
||||
e.assa_y = strtof(row[11], nullptr);
|
||||
e.assa_z = strtof(row[12], nullptr);
|
||||
e.assa_h = strtof(row[13], nullptr);
|
||||
e.text = row[14] ? row[14] : "";
|
||||
e.duration = atoi(row[15]);
|
||||
e.zone_in_time = atoi(row[16]);
|
||||
e.win_points = atoi(row[17]);
|
||||
e.lose_points = atoi(row[18]);
|
||||
e.theme = atoi(row[19]);
|
||||
e.zone_in_zone_id = atoi(row[20]);
|
||||
e.zone_in_x = static_cast<float>(atof(row[21]));
|
||||
e.zone_in_y = static_cast<float>(atof(row[22]));
|
||||
e.zone_in_object_id = atoi(row[23]);
|
||||
e.dest_x = static_cast<float>(atof(row[24]));
|
||||
e.dest_y = static_cast<float>(atof(row[25]));
|
||||
e.dest_z = static_cast<float>(atof(row[26]));
|
||||
e.dest_h = static_cast<float>(atof(row[27]));
|
||||
e.graveyard_zone_id = atoi(row[28]);
|
||||
e.graveyard_x = static_cast<float>(atof(row[29]));
|
||||
e.graveyard_y = static_cast<float>(atof(row[30]));
|
||||
e.graveyard_z = static_cast<float>(atof(row[31]));
|
||||
e.graveyard_radius = static_cast<float>(atof(row[32]));
|
||||
e.duration = static_cast<uint32_t>(strtoul(row[15], nullptr, 10));
|
||||
e.zone_in_time = static_cast<uint32_t>(strtoul(row[16], nullptr, 10));
|
||||
e.win_points = static_cast<uint16_t>(strtoul(row[17], nullptr, 10));
|
||||
e.lose_points = static_cast<uint16_t>(strtoul(row[18], nullptr, 10));
|
||||
e.theme = static_cast<uint8_t>(strtoul(row[19], nullptr, 10));
|
||||
e.zone_in_zone_id = static_cast<uint16_t>(strtoul(row[20], nullptr, 10));
|
||||
e.zone_in_x = strtof(row[21], nullptr);
|
||||
e.zone_in_y = strtof(row[22], nullptr);
|
||||
e.zone_in_object_id = static_cast<int16_t>(atoi(row[23]));
|
||||
e.dest_x = strtof(row[24], nullptr);
|
||||
e.dest_y = strtof(row[25], nullptr);
|
||||
e.dest_z = strtof(row[26], nullptr);
|
||||
e.dest_h = strtof(row[27], nullptr);
|
||||
e.graveyard_zone_id = static_cast<uint32_t>(strtoul(row[28], nullptr, 10));
|
||||
e.graveyard_x = strtof(row[29], nullptr);
|
||||
e.graveyard_y = strtof(row[30], nullptr);
|
||||
e.graveyard_z = strtof(row[31], nullptr);
|
||||
|
||||
all_entries.push_back(e);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user