mirror of
https://github.com/EQEmu/Server.git
synced 2026-06-24 21:58:22 +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,29 +19,29 @@
|
||||
class BaseTrapsRepository {
|
||||
public:
|
||||
struct Traps {
|
||||
int id;
|
||||
int32_t id;
|
||||
std::string zone;
|
||||
int version;
|
||||
int x;
|
||||
int y;
|
||||
int z;
|
||||
int chance;
|
||||
uint16_t version;
|
||||
int32_t x;
|
||||
int32_t y;
|
||||
int32_t z;
|
||||
int8_t chance;
|
||||
float maxzdiff;
|
||||
float radius;
|
||||
int effect;
|
||||
int effectvalue;
|
||||
int effectvalue2;
|
||||
int32_t effect;
|
||||
int32_t effectvalue;
|
||||
int32_t effectvalue2;
|
||||
std::string message;
|
||||
int skill;
|
||||
int level;
|
||||
int respawn_time;
|
||||
int respawn_var;
|
||||
int triggered_number;
|
||||
int group;
|
||||
int despawn_when_triggered;
|
||||
int undetectable;
|
||||
int min_expansion;
|
||||
int max_expansion;
|
||||
int32_t skill;
|
||||
uint32_t level;
|
||||
uint32_t respawn_time;
|
||||
uint32_t respawn_var;
|
||||
int8_t triggered_number;
|
||||
int8_t group;
|
||||
int8_t despawn_when_triggered;
|
||||
int8_t undetectable;
|
||||
int8_t min_expansion;
|
||||
int8_t max_expansion;
|
||||
std::string content_flags;
|
||||
std::string content_flags_disabled;
|
||||
};
|
||||
@@ -210,29 +210,29 @@ public:
|
||||
if (results.RowCount() == 1) {
|
||||
Traps e{};
|
||||
|
||||
e.id = atoi(row[0]);
|
||||
e.id = static_cast<int32_t>(atoi(row[0]));
|
||||
e.zone = row[1] ? row[1] : "";
|
||||
e.version = atoi(row[2]);
|
||||
e.x = atoi(row[3]);
|
||||
e.y = atoi(row[4]);
|
||||
e.z = atoi(row[5]);
|
||||
e.chance = atoi(row[6]);
|
||||
e.maxzdiff = static_cast<float>(atof(row[7]));
|
||||
e.radius = static_cast<float>(atof(row[8]));
|
||||
e.effect = atoi(row[9]);
|
||||
e.effectvalue = atoi(row[10]);
|
||||
e.effectvalue2 = atoi(row[11]);
|
||||
e.version = static_cast<uint16_t>(strtoul(row[2], nullptr, 10));
|
||||
e.x = static_cast<int32_t>(atoi(row[3]));
|
||||
e.y = static_cast<int32_t>(atoi(row[4]));
|
||||
e.z = static_cast<int32_t>(atoi(row[5]));
|
||||
e.chance = static_cast<int8_t>(atoi(row[6]));
|
||||
e.maxzdiff = strtof(row[7], nullptr);
|
||||
e.radius = strtof(row[8], nullptr);
|
||||
e.effect = static_cast<int32_t>(atoi(row[9]));
|
||||
e.effectvalue = static_cast<int32_t>(atoi(row[10]));
|
||||
e.effectvalue2 = static_cast<int32_t>(atoi(row[11]));
|
||||
e.message = row[12] ? row[12] : "";
|
||||
e.skill = atoi(row[13]);
|
||||
e.level = atoi(row[14]);
|
||||
e.respawn_time = atoi(row[15]);
|
||||
e.respawn_var = atoi(row[16]);
|
||||
e.triggered_number = atoi(row[17]);
|
||||
e.group = atoi(row[18]);
|
||||
e.despawn_when_triggered = atoi(row[19]);
|
||||
e.undetectable = atoi(row[20]);
|
||||
e.min_expansion = atoi(row[21]);
|
||||
e.max_expansion = atoi(row[22]);
|
||||
e.skill = static_cast<int32_t>(atoi(row[13]));
|
||||
e.level = static_cast<uint32_t>(strtoul(row[14], nullptr, 10));
|
||||
e.respawn_time = static_cast<uint32_t>(strtoul(row[15], nullptr, 10));
|
||||
e.respawn_var = static_cast<uint32_t>(strtoul(row[16], nullptr, 10));
|
||||
e.triggered_number = static_cast<int8_t>(atoi(row[17]));
|
||||
e.group = static_cast<int8_t>(atoi(row[18]));
|
||||
e.despawn_when_triggered = static_cast<int8_t>(atoi(row[19]));
|
||||
e.undetectable = static_cast<int8_t>(atoi(row[20]));
|
||||
e.min_expansion = static_cast<int8_t>(atoi(row[21]));
|
||||
e.max_expansion = static_cast<int8_t>(atoi(row[22]));
|
||||
e.content_flags = row[23] ? row[23] : "";
|
||||
e.content_flags_disabled = row[24] ? row[24] : "";
|
||||
|
||||
@@ -425,29 +425,29 @@ public:
|
||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||
Traps e{};
|
||||
|
||||
e.id = atoi(row[0]);
|
||||
e.id = static_cast<int32_t>(atoi(row[0]));
|
||||
e.zone = row[1] ? row[1] : "";
|
||||
e.version = atoi(row[2]);
|
||||
e.x = atoi(row[3]);
|
||||
e.y = atoi(row[4]);
|
||||
e.z = atoi(row[5]);
|
||||
e.chance = atoi(row[6]);
|
||||
e.maxzdiff = static_cast<float>(atof(row[7]));
|
||||
e.radius = static_cast<float>(atof(row[8]));
|
||||
e.effect = atoi(row[9]);
|
||||
e.effectvalue = atoi(row[10]);
|
||||
e.effectvalue2 = atoi(row[11]);
|
||||
e.version = static_cast<uint16_t>(strtoul(row[2], nullptr, 10));
|
||||
e.x = static_cast<int32_t>(atoi(row[3]));
|
||||
e.y = static_cast<int32_t>(atoi(row[4]));
|
||||
e.z = static_cast<int32_t>(atoi(row[5]));
|
||||
e.chance = static_cast<int8_t>(atoi(row[6]));
|
||||
e.maxzdiff = strtof(row[7], nullptr);
|
||||
e.radius = strtof(row[8], nullptr);
|
||||
e.effect = static_cast<int32_t>(atoi(row[9]));
|
||||
e.effectvalue = static_cast<int32_t>(atoi(row[10]));
|
||||
e.effectvalue2 = static_cast<int32_t>(atoi(row[11]));
|
||||
e.message = row[12] ? row[12] : "";
|
||||
e.skill = atoi(row[13]);
|
||||
e.level = atoi(row[14]);
|
||||
e.respawn_time = atoi(row[15]);
|
||||
e.respawn_var = atoi(row[16]);
|
||||
e.triggered_number = atoi(row[17]);
|
||||
e.group = atoi(row[18]);
|
||||
e.despawn_when_triggered = atoi(row[19]);
|
||||
e.undetectable = atoi(row[20]);
|
||||
e.min_expansion = atoi(row[21]);
|
||||
e.max_expansion = atoi(row[22]);
|
||||
e.skill = static_cast<int32_t>(atoi(row[13]));
|
||||
e.level = static_cast<uint32_t>(strtoul(row[14], nullptr, 10));
|
||||
e.respawn_time = static_cast<uint32_t>(strtoul(row[15], nullptr, 10));
|
||||
e.respawn_var = static_cast<uint32_t>(strtoul(row[16], nullptr, 10));
|
||||
e.triggered_number = static_cast<int8_t>(atoi(row[17]));
|
||||
e.group = static_cast<int8_t>(atoi(row[18]));
|
||||
e.despawn_when_triggered = static_cast<int8_t>(atoi(row[19]));
|
||||
e.undetectable = static_cast<int8_t>(atoi(row[20]));
|
||||
e.min_expansion = static_cast<int8_t>(atoi(row[21]));
|
||||
e.max_expansion = static_cast<int8_t>(atoi(row[22]));
|
||||
e.content_flags = row[23] ? row[23] : "";
|
||||
e.content_flags_disabled = row[24] ? row[24] : "";
|
||||
|
||||
@@ -474,29 +474,29 @@ public:
|
||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||
Traps e{};
|
||||
|
||||
e.id = atoi(row[0]);
|
||||
e.id = static_cast<int32_t>(atoi(row[0]));
|
||||
e.zone = row[1] ? row[1] : "";
|
||||
e.version = atoi(row[2]);
|
||||
e.x = atoi(row[3]);
|
||||
e.y = atoi(row[4]);
|
||||
e.z = atoi(row[5]);
|
||||
e.chance = atoi(row[6]);
|
||||
e.maxzdiff = static_cast<float>(atof(row[7]));
|
||||
e.radius = static_cast<float>(atof(row[8]));
|
||||
e.effect = atoi(row[9]);
|
||||
e.effectvalue = atoi(row[10]);
|
||||
e.effectvalue2 = atoi(row[11]);
|
||||
e.version = static_cast<uint16_t>(strtoul(row[2], nullptr, 10));
|
||||
e.x = static_cast<int32_t>(atoi(row[3]));
|
||||
e.y = static_cast<int32_t>(atoi(row[4]));
|
||||
e.z = static_cast<int32_t>(atoi(row[5]));
|
||||
e.chance = static_cast<int8_t>(atoi(row[6]));
|
||||
e.maxzdiff = strtof(row[7], nullptr);
|
||||
e.radius = strtof(row[8], nullptr);
|
||||
e.effect = static_cast<int32_t>(atoi(row[9]));
|
||||
e.effectvalue = static_cast<int32_t>(atoi(row[10]));
|
||||
e.effectvalue2 = static_cast<int32_t>(atoi(row[11]));
|
||||
e.message = row[12] ? row[12] : "";
|
||||
e.skill = atoi(row[13]);
|
||||
e.level = atoi(row[14]);
|
||||
e.respawn_time = atoi(row[15]);
|
||||
e.respawn_var = atoi(row[16]);
|
||||
e.triggered_number = atoi(row[17]);
|
||||
e.group = atoi(row[18]);
|
||||
e.despawn_when_triggered = atoi(row[19]);
|
||||
e.undetectable = atoi(row[20]);
|
||||
e.min_expansion = atoi(row[21]);
|
||||
e.max_expansion = atoi(row[22]);
|
||||
e.skill = static_cast<int32_t>(atoi(row[13]));
|
||||
e.level = static_cast<uint32_t>(strtoul(row[14], nullptr, 10));
|
||||
e.respawn_time = static_cast<uint32_t>(strtoul(row[15], nullptr, 10));
|
||||
e.respawn_var = static_cast<uint32_t>(strtoul(row[16], nullptr, 10));
|
||||
e.triggered_number = static_cast<int8_t>(atoi(row[17]));
|
||||
e.group = static_cast<int8_t>(atoi(row[18]));
|
||||
e.despawn_when_triggered = static_cast<int8_t>(atoi(row[19]));
|
||||
e.undetectable = static_cast<int8_t>(atoi(row[20]));
|
||||
e.min_expansion = static_cast<int8_t>(atoi(row[21]));
|
||||
e.max_expansion = static_cast<int8_t>(atoi(row[22]));
|
||||
e.content_flags = row[23] ? row[23] : "";
|
||||
e.content_flags_disabled = row[24] ? row[24] : "";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user