mirror of
https://github.com/EQEmu/Server.git
synced 2026-06-01 01:52:02 +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,40 +19,40 @@
|
||||
class BaseDoorsRepository {
|
||||
public:
|
||||
struct Doors {
|
||||
int id;
|
||||
int doorid;
|
||||
int32_t id;
|
||||
int16_t doorid;
|
||||
std::string zone;
|
||||
int version;
|
||||
int16_t version;
|
||||
std::string name;
|
||||
float pos_y;
|
||||
float pos_x;
|
||||
float pos_z;
|
||||
float heading;
|
||||
int opentype;
|
||||
int guild;
|
||||
int lockpick;
|
||||
int keyitem;
|
||||
int nokeyring;
|
||||
int triggerdoor;
|
||||
int triggertype;
|
||||
int disable_timer;
|
||||
int doorisopen;
|
||||
int door_param;
|
||||
int16_t opentype;
|
||||
int16_t guild;
|
||||
int16_t lockpick;
|
||||
int32_t keyitem;
|
||||
uint8_t nokeyring;
|
||||
int16_t triggerdoor;
|
||||
int16_t triggertype;
|
||||
int8_t disable_timer;
|
||||
int16_t doorisopen;
|
||||
int32_t door_param;
|
||||
std::string dest_zone;
|
||||
int dest_instance;
|
||||
uint32_t dest_instance;
|
||||
float dest_x;
|
||||
float dest_y;
|
||||
float dest_z;
|
||||
float dest_heading;
|
||||
int invert_state;
|
||||
int incline;
|
||||
int size;
|
||||
int32_t invert_state;
|
||||
int32_t incline;
|
||||
uint16_t size;
|
||||
float buffer;
|
||||
int client_version_mask;
|
||||
int is_ldon_door;
|
||||
int dz_switch_id;
|
||||
int min_expansion;
|
||||
int max_expansion;
|
||||
uint32_t client_version_mask;
|
||||
int16_t is_ldon_door;
|
||||
int32_t dz_switch_id;
|
||||
int8_t min_expansion;
|
||||
int8_t max_expansion;
|
||||
std::string content_flags;
|
||||
std::string content_flags_disabled;
|
||||
};
|
||||
@@ -254,40 +254,40 @@ public:
|
||||
if (results.RowCount() == 1) {
|
||||
Doors e{};
|
||||
|
||||
e.id = atoi(row[0]);
|
||||
e.doorid = atoi(row[1]);
|
||||
e.id = static_cast<int32_t>(atoi(row[0]));
|
||||
e.doorid = static_cast<int16_t>(atoi(row[1]));
|
||||
e.zone = row[2] ? row[2] : "";
|
||||
e.version = atoi(row[3]);
|
||||
e.version = static_cast<int16_t>(atoi(row[3]));
|
||||
e.name = row[4] ? row[4] : "";
|
||||
e.pos_y = static_cast<float>(atof(row[5]));
|
||||
e.pos_x = static_cast<float>(atof(row[6]));
|
||||
e.pos_z = static_cast<float>(atof(row[7]));
|
||||
e.heading = static_cast<float>(atof(row[8]));
|
||||
e.opentype = atoi(row[9]);
|
||||
e.guild = atoi(row[10]);
|
||||
e.lockpick = atoi(row[11]);
|
||||
e.keyitem = atoi(row[12]);
|
||||
e.nokeyring = atoi(row[13]);
|
||||
e.triggerdoor = atoi(row[14]);
|
||||
e.triggertype = atoi(row[15]);
|
||||
e.disable_timer = atoi(row[16]);
|
||||
e.doorisopen = atoi(row[17]);
|
||||
e.door_param = atoi(row[18]);
|
||||
e.pos_y = strtof(row[5], nullptr);
|
||||
e.pos_x = strtof(row[6], nullptr);
|
||||
e.pos_z = strtof(row[7], nullptr);
|
||||
e.heading = strtof(row[8], nullptr);
|
||||
e.opentype = static_cast<int16_t>(atoi(row[9]));
|
||||
e.guild = static_cast<int16_t>(atoi(row[10]));
|
||||
e.lockpick = static_cast<int16_t>(atoi(row[11]));
|
||||
e.keyitem = static_cast<int32_t>(atoi(row[12]));
|
||||
e.nokeyring = static_cast<uint8_t>(strtoul(row[13], nullptr, 10));
|
||||
e.triggerdoor = static_cast<int16_t>(atoi(row[14]));
|
||||
e.triggertype = static_cast<int16_t>(atoi(row[15]));
|
||||
e.disable_timer = static_cast<int8_t>(atoi(row[16]));
|
||||
e.doorisopen = static_cast<int16_t>(atoi(row[17]));
|
||||
e.door_param = static_cast<int32_t>(atoi(row[18]));
|
||||
e.dest_zone = row[19] ? row[19] : "";
|
||||
e.dest_instance = atoi(row[20]);
|
||||
e.dest_x = static_cast<float>(atof(row[21]));
|
||||
e.dest_y = static_cast<float>(atof(row[22]));
|
||||
e.dest_z = static_cast<float>(atof(row[23]));
|
||||
e.dest_heading = static_cast<float>(atof(row[24]));
|
||||
e.invert_state = atoi(row[25]);
|
||||
e.incline = atoi(row[26]);
|
||||
e.size = atoi(row[27]);
|
||||
e.buffer = static_cast<float>(atof(row[28]));
|
||||
e.client_version_mask = atoi(row[29]);
|
||||
e.is_ldon_door = atoi(row[30]);
|
||||
e.dz_switch_id = atoi(row[31]);
|
||||
e.min_expansion = atoi(row[32]);
|
||||
e.max_expansion = atoi(row[33]);
|
||||
e.dest_instance = static_cast<uint32_t>(strtoul(row[20], nullptr, 10));
|
||||
e.dest_x = strtof(row[21], nullptr);
|
||||
e.dest_y = strtof(row[22], nullptr);
|
||||
e.dest_z = strtof(row[23], nullptr);
|
||||
e.dest_heading = strtof(row[24], nullptr);
|
||||
e.invert_state = static_cast<int32_t>(atoi(row[25]));
|
||||
e.incline = static_cast<int32_t>(atoi(row[26]));
|
||||
e.size = static_cast<uint16_t>(strtoul(row[27], nullptr, 10));
|
||||
e.buffer = strtof(row[28], nullptr);
|
||||
e.client_version_mask = static_cast<uint32_t>(strtoul(row[29], nullptr, 10));
|
||||
e.is_ldon_door = static_cast<int16_t>(atoi(row[30]));
|
||||
e.dz_switch_id = static_cast<int32_t>(atoi(row[31]));
|
||||
e.min_expansion = static_cast<int8_t>(atoi(row[32]));
|
||||
e.max_expansion = static_cast<int8_t>(atoi(row[33]));
|
||||
e.content_flags = row[34] ? row[34] : "";
|
||||
e.content_flags_disabled = row[35] ? row[35] : "";
|
||||
|
||||
@@ -513,40 +513,40 @@ public:
|
||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||
Doors e{};
|
||||
|
||||
e.id = atoi(row[0]);
|
||||
e.doorid = atoi(row[1]);
|
||||
e.id = static_cast<int32_t>(atoi(row[0]));
|
||||
e.doorid = static_cast<int16_t>(atoi(row[1]));
|
||||
e.zone = row[2] ? row[2] : "";
|
||||
e.version = atoi(row[3]);
|
||||
e.version = static_cast<int16_t>(atoi(row[3]));
|
||||
e.name = row[4] ? row[4] : "";
|
||||
e.pos_y = static_cast<float>(atof(row[5]));
|
||||
e.pos_x = static_cast<float>(atof(row[6]));
|
||||
e.pos_z = static_cast<float>(atof(row[7]));
|
||||
e.heading = static_cast<float>(atof(row[8]));
|
||||
e.opentype = atoi(row[9]);
|
||||
e.guild = atoi(row[10]);
|
||||
e.lockpick = atoi(row[11]);
|
||||
e.keyitem = atoi(row[12]);
|
||||
e.nokeyring = atoi(row[13]);
|
||||
e.triggerdoor = atoi(row[14]);
|
||||
e.triggertype = atoi(row[15]);
|
||||
e.disable_timer = atoi(row[16]);
|
||||
e.doorisopen = atoi(row[17]);
|
||||
e.door_param = atoi(row[18]);
|
||||
e.pos_y = strtof(row[5], nullptr);
|
||||
e.pos_x = strtof(row[6], nullptr);
|
||||
e.pos_z = strtof(row[7], nullptr);
|
||||
e.heading = strtof(row[8], nullptr);
|
||||
e.opentype = static_cast<int16_t>(atoi(row[9]));
|
||||
e.guild = static_cast<int16_t>(atoi(row[10]));
|
||||
e.lockpick = static_cast<int16_t>(atoi(row[11]));
|
||||
e.keyitem = static_cast<int32_t>(atoi(row[12]));
|
||||
e.nokeyring = static_cast<uint8_t>(strtoul(row[13], nullptr, 10));
|
||||
e.triggerdoor = static_cast<int16_t>(atoi(row[14]));
|
||||
e.triggertype = static_cast<int16_t>(atoi(row[15]));
|
||||
e.disable_timer = static_cast<int8_t>(atoi(row[16]));
|
||||
e.doorisopen = static_cast<int16_t>(atoi(row[17]));
|
||||
e.door_param = static_cast<int32_t>(atoi(row[18]));
|
||||
e.dest_zone = row[19] ? row[19] : "";
|
||||
e.dest_instance = atoi(row[20]);
|
||||
e.dest_x = static_cast<float>(atof(row[21]));
|
||||
e.dest_y = static_cast<float>(atof(row[22]));
|
||||
e.dest_z = static_cast<float>(atof(row[23]));
|
||||
e.dest_heading = static_cast<float>(atof(row[24]));
|
||||
e.invert_state = atoi(row[25]);
|
||||
e.incline = atoi(row[26]);
|
||||
e.size = atoi(row[27]);
|
||||
e.buffer = static_cast<float>(atof(row[28]));
|
||||
e.client_version_mask = atoi(row[29]);
|
||||
e.is_ldon_door = atoi(row[30]);
|
||||
e.dz_switch_id = atoi(row[31]);
|
||||
e.min_expansion = atoi(row[32]);
|
||||
e.max_expansion = atoi(row[33]);
|
||||
e.dest_instance = static_cast<uint32_t>(strtoul(row[20], nullptr, 10));
|
||||
e.dest_x = strtof(row[21], nullptr);
|
||||
e.dest_y = strtof(row[22], nullptr);
|
||||
e.dest_z = strtof(row[23], nullptr);
|
||||
e.dest_heading = strtof(row[24], nullptr);
|
||||
e.invert_state = static_cast<int32_t>(atoi(row[25]));
|
||||
e.incline = static_cast<int32_t>(atoi(row[26]));
|
||||
e.size = static_cast<uint16_t>(strtoul(row[27], nullptr, 10));
|
||||
e.buffer = strtof(row[28], nullptr);
|
||||
e.client_version_mask = static_cast<uint32_t>(strtoul(row[29], nullptr, 10));
|
||||
e.is_ldon_door = static_cast<int16_t>(atoi(row[30]));
|
||||
e.dz_switch_id = static_cast<int32_t>(atoi(row[31]));
|
||||
e.min_expansion = static_cast<int8_t>(atoi(row[32]));
|
||||
e.max_expansion = static_cast<int8_t>(atoi(row[33]));
|
||||
e.content_flags = row[34] ? row[34] : "";
|
||||
e.content_flags_disabled = row[35] ? row[35] : "";
|
||||
|
||||
@@ -573,40 +573,40 @@ public:
|
||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||
Doors e{};
|
||||
|
||||
e.id = atoi(row[0]);
|
||||
e.doorid = atoi(row[1]);
|
||||
e.id = static_cast<int32_t>(atoi(row[0]));
|
||||
e.doorid = static_cast<int16_t>(atoi(row[1]));
|
||||
e.zone = row[2] ? row[2] : "";
|
||||
e.version = atoi(row[3]);
|
||||
e.version = static_cast<int16_t>(atoi(row[3]));
|
||||
e.name = row[4] ? row[4] : "";
|
||||
e.pos_y = static_cast<float>(atof(row[5]));
|
||||
e.pos_x = static_cast<float>(atof(row[6]));
|
||||
e.pos_z = static_cast<float>(atof(row[7]));
|
||||
e.heading = static_cast<float>(atof(row[8]));
|
||||
e.opentype = atoi(row[9]);
|
||||
e.guild = atoi(row[10]);
|
||||
e.lockpick = atoi(row[11]);
|
||||
e.keyitem = atoi(row[12]);
|
||||
e.nokeyring = atoi(row[13]);
|
||||
e.triggerdoor = atoi(row[14]);
|
||||
e.triggertype = atoi(row[15]);
|
||||
e.disable_timer = atoi(row[16]);
|
||||
e.doorisopen = atoi(row[17]);
|
||||
e.door_param = atoi(row[18]);
|
||||
e.pos_y = strtof(row[5], nullptr);
|
||||
e.pos_x = strtof(row[6], nullptr);
|
||||
e.pos_z = strtof(row[7], nullptr);
|
||||
e.heading = strtof(row[8], nullptr);
|
||||
e.opentype = static_cast<int16_t>(atoi(row[9]));
|
||||
e.guild = static_cast<int16_t>(atoi(row[10]));
|
||||
e.lockpick = static_cast<int16_t>(atoi(row[11]));
|
||||
e.keyitem = static_cast<int32_t>(atoi(row[12]));
|
||||
e.nokeyring = static_cast<uint8_t>(strtoul(row[13], nullptr, 10));
|
||||
e.triggerdoor = static_cast<int16_t>(atoi(row[14]));
|
||||
e.triggertype = static_cast<int16_t>(atoi(row[15]));
|
||||
e.disable_timer = static_cast<int8_t>(atoi(row[16]));
|
||||
e.doorisopen = static_cast<int16_t>(atoi(row[17]));
|
||||
e.door_param = static_cast<int32_t>(atoi(row[18]));
|
||||
e.dest_zone = row[19] ? row[19] : "";
|
||||
e.dest_instance = atoi(row[20]);
|
||||
e.dest_x = static_cast<float>(atof(row[21]));
|
||||
e.dest_y = static_cast<float>(atof(row[22]));
|
||||
e.dest_z = static_cast<float>(atof(row[23]));
|
||||
e.dest_heading = static_cast<float>(atof(row[24]));
|
||||
e.invert_state = atoi(row[25]);
|
||||
e.incline = atoi(row[26]);
|
||||
e.size = atoi(row[27]);
|
||||
e.buffer = static_cast<float>(atof(row[28]));
|
||||
e.client_version_mask = atoi(row[29]);
|
||||
e.is_ldon_door = atoi(row[30]);
|
||||
e.dz_switch_id = atoi(row[31]);
|
||||
e.min_expansion = atoi(row[32]);
|
||||
e.max_expansion = atoi(row[33]);
|
||||
e.dest_instance = static_cast<uint32_t>(strtoul(row[20], nullptr, 10));
|
||||
e.dest_x = strtof(row[21], nullptr);
|
||||
e.dest_y = strtof(row[22], nullptr);
|
||||
e.dest_z = strtof(row[23], nullptr);
|
||||
e.dest_heading = strtof(row[24], nullptr);
|
||||
e.invert_state = static_cast<int32_t>(atoi(row[25]));
|
||||
e.incline = static_cast<int32_t>(atoi(row[26]));
|
||||
e.size = static_cast<uint16_t>(strtoul(row[27], nullptr, 10));
|
||||
e.buffer = strtof(row[28], nullptr);
|
||||
e.client_version_mask = static_cast<uint32_t>(strtoul(row[29], nullptr, 10));
|
||||
e.is_ldon_door = static_cast<int16_t>(atoi(row[30]));
|
||||
e.dz_switch_id = static_cast<int32_t>(atoi(row[31]));
|
||||
e.min_expansion = static_cast<int8_t>(atoi(row[32]));
|
||||
e.max_expansion = static_cast<int8_t>(atoi(row[33]));
|
||||
e.content_flags = row[34] ? row[34] : "";
|
||||
e.content_flags_disabled = row[35] ? row[35] : "";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user