mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-31 04:56:20 +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,34 +19,34 @@
|
||||
class BaseObjectRepository {
|
||||
public:
|
||||
struct Object {
|
||||
int id;
|
||||
int zoneid;
|
||||
int version;
|
||||
int32_t id;
|
||||
uint32_t zoneid;
|
||||
int16_t version;
|
||||
float xpos;
|
||||
float ypos;
|
||||
float zpos;
|
||||
float heading;
|
||||
int itemid;
|
||||
int charges;
|
||||
int32_t itemid;
|
||||
uint16_t charges;
|
||||
std::string objectname;
|
||||
int type;
|
||||
int icon;
|
||||
int unknown08;
|
||||
int unknown10;
|
||||
int unknown20;
|
||||
int unknown24;
|
||||
int unknown60;
|
||||
int unknown64;
|
||||
int unknown68;
|
||||
int unknown72;
|
||||
int unknown76;
|
||||
int unknown84;
|
||||
int32_t type;
|
||||
int32_t icon;
|
||||
int32_t unknown08;
|
||||
int32_t unknown10;
|
||||
int32_t unknown20;
|
||||
int32_t unknown24;
|
||||
int32_t unknown60;
|
||||
int32_t unknown64;
|
||||
int32_t unknown68;
|
||||
int32_t unknown72;
|
||||
int32_t unknown76;
|
||||
int32_t unknown84;
|
||||
float size;
|
||||
float tilt_x;
|
||||
float tilt_y;
|
||||
std::string display_name;
|
||||
int min_expansion;
|
||||
int max_expansion;
|
||||
int8_t min_expansion;
|
||||
int8_t max_expansion;
|
||||
std::string content_flags;
|
||||
std::string content_flags_disabled;
|
||||
};
|
||||
@@ -230,34 +230,34 @@ public:
|
||||
if (results.RowCount() == 1) {
|
||||
Object e{};
|
||||
|
||||
e.id = atoi(row[0]);
|
||||
e.zoneid = atoi(row[1]);
|
||||
e.version = atoi(row[2]);
|
||||
e.xpos = static_cast<float>(atof(row[3]));
|
||||
e.ypos = static_cast<float>(atof(row[4]));
|
||||
e.zpos = static_cast<float>(atof(row[5]));
|
||||
e.heading = static_cast<float>(atof(row[6]));
|
||||
e.itemid = atoi(row[7]);
|
||||
e.charges = atoi(row[8]);
|
||||
e.id = static_cast<int32_t>(atoi(row[0]));
|
||||
e.zoneid = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
|
||||
e.version = static_cast<int16_t>(atoi(row[2]));
|
||||
e.xpos = strtof(row[3], nullptr);
|
||||
e.ypos = strtof(row[4], nullptr);
|
||||
e.zpos = strtof(row[5], nullptr);
|
||||
e.heading = strtof(row[6], nullptr);
|
||||
e.itemid = static_cast<int32_t>(atoi(row[7]));
|
||||
e.charges = static_cast<uint16_t>(strtoul(row[8], nullptr, 10));
|
||||
e.objectname = row[9] ? row[9] : "";
|
||||
e.type = atoi(row[10]);
|
||||
e.icon = atoi(row[11]);
|
||||
e.unknown08 = atoi(row[12]);
|
||||
e.unknown10 = atoi(row[13]);
|
||||
e.unknown20 = atoi(row[14]);
|
||||
e.unknown24 = atoi(row[15]);
|
||||
e.unknown60 = atoi(row[16]);
|
||||
e.unknown64 = atoi(row[17]);
|
||||
e.unknown68 = atoi(row[18]);
|
||||
e.unknown72 = atoi(row[19]);
|
||||
e.unknown76 = atoi(row[20]);
|
||||
e.unknown84 = atoi(row[21]);
|
||||
e.size = static_cast<float>(atof(row[22]));
|
||||
e.tilt_x = static_cast<float>(atof(row[23]));
|
||||
e.tilt_y = static_cast<float>(atof(row[24]));
|
||||
e.type = static_cast<int32_t>(atoi(row[10]));
|
||||
e.icon = static_cast<int32_t>(atoi(row[11]));
|
||||
e.unknown08 = static_cast<int32_t>(atoi(row[12]));
|
||||
e.unknown10 = static_cast<int32_t>(atoi(row[13]));
|
||||
e.unknown20 = static_cast<int32_t>(atoi(row[14]));
|
||||
e.unknown24 = static_cast<int32_t>(atoi(row[15]));
|
||||
e.unknown60 = static_cast<int32_t>(atoi(row[16]));
|
||||
e.unknown64 = static_cast<int32_t>(atoi(row[17]));
|
||||
e.unknown68 = static_cast<int32_t>(atoi(row[18]));
|
||||
e.unknown72 = static_cast<int32_t>(atoi(row[19]));
|
||||
e.unknown76 = static_cast<int32_t>(atoi(row[20]));
|
||||
e.unknown84 = static_cast<int32_t>(atoi(row[21]));
|
||||
e.size = strtof(row[22], nullptr);
|
||||
e.tilt_x = strtof(row[23], nullptr);
|
||||
e.tilt_y = strtof(row[24], nullptr);
|
||||
e.display_name = row[25] ? row[25] : "";
|
||||
e.min_expansion = atoi(row[26]);
|
||||
e.max_expansion = atoi(row[27]);
|
||||
e.min_expansion = static_cast<int8_t>(atoi(row[26]));
|
||||
e.max_expansion = static_cast<int8_t>(atoi(row[27]));
|
||||
e.content_flags = row[28] ? row[28] : "";
|
||||
e.content_flags_disabled = row[29] ? row[29] : "";
|
||||
|
||||
@@ -465,34 +465,34 @@ public:
|
||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||
Object e{};
|
||||
|
||||
e.id = atoi(row[0]);
|
||||
e.zoneid = atoi(row[1]);
|
||||
e.version = atoi(row[2]);
|
||||
e.xpos = static_cast<float>(atof(row[3]));
|
||||
e.ypos = static_cast<float>(atof(row[4]));
|
||||
e.zpos = static_cast<float>(atof(row[5]));
|
||||
e.heading = static_cast<float>(atof(row[6]));
|
||||
e.itemid = atoi(row[7]);
|
||||
e.charges = atoi(row[8]);
|
||||
e.id = static_cast<int32_t>(atoi(row[0]));
|
||||
e.zoneid = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
|
||||
e.version = static_cast<int16_t>(atoi(row[2]));
|
||||
e.xpos = strtof(row[3], nullptr);
|
||||
e.ypos = strtof(row[4], nullptr);
|
||||
e.zpos = strtof(row[5], nullptr);
|
||||
e.heading = strtof(row[6], nullptr);
|
||||
e.itemid = static_cast<int32_t>(atoi(row[7]));
|
||||
e.charges = static_cast<uint16_t>(strtoul(row[8], nullptr, 10));
|
||||
e.objectname = row[9] ? row[9] : "";
|
||||
e.type = atoi(row[10]);
|
||||
e.icon = atoi(row[11]);
|
||||
e.unknown08 = atoi(row[12]);
|
||||
e.unknown10 = atoi(row[13]);
|
||||
e.unknown20 = atoi(row[14]);
|
||||
e.unknown24 = atoi(row[15]);
|
||||
e.unknown60 = atoi(row[16]);
|
||||
e.unknown64 = atoi(row[17]);
|
||||
e.unknown68 = atoi(row[18]);
|
||||
e.unknown72 = atoi(row[19]);
|
||||
e.unknown76 = atoi(row[20]);
|
||||
e.unknown84 = atoi(row[21]);
|
||||
e.size = static_cast<float>(atof(row[22]));
|
||||
e.tilt_x = static_cast<float>(atof(row[23]));
|
||||
e.tilt_y = static_cast<float>(atof(row[24]));
|
||||
e.type = static_cast<int32_t>(atoi(row[10]));
|
||||
e.icon = static_cast<int32_t>(atoi(row[11]));
|
||||
e.unknown08 = static_cast<int32_t>(atoi(row[12]));
|
||||
e.unknown10 = static_cast<int32_t>(atoi(row[13]));
|
||||
e.unknown20 = static_cast<int32_t>(atoi(row[14]));
|
||||
e.unknown24 = static_cast<int32_t>(atoi(row[15]));
|
||||
e.unknown60 = static_cast<int32_t>(atoi(row[16]));
|
||||
e.unknown64 = static_cast<int32_t>(atoi(row[17]));
|
||||
e.unknown68 = static_cast<int32_t>(atoi(row[18]));
|
||||
e.unknown72 = static_cast<int32_t>(atoi(row[19]));
|
||||
e.unknown76 = static_cast<int32_t>(atoi(row[20]));
|
||||
e.unknown84 = static_cast<int32_t>(atoi(row[21]));
|
||||
e.size = strtof(row[22], nullptr);
|
||||
e.tilt_x = strtof(row[23], nullptr);
|
||||
e.tilt_y = strtof(row[24], nullptr);
|
||||
e.display_name = row[25] ? row[25] : "";
|
||||
e.min_expansion = atoi(row[26]);
|
||||
e.max_expansion = atoi(row[27]);
|
||||
e.min_expansion = static_cast<int8_t>(atoi(row[26]));
|
||||
e.max_expansion = static_cast<int8_t>(atoi(row[27]));
|
||||
e.content_flags = row[28] ? row[28] : "";
|
||||
e.content_flags_disabled = row[29] ? row[29] : "";
|
||||
|
||||
@@ -519,34 +519,34 @@ public:
|
||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||
Object e{};
|
||||
|
||||
e.id = atoi(row[0]);
|
||||
e.zoneid = atoi(row[1]);
|
||||
e.version = atoi(row[2]);
|
||||
e.xpos = static_cast<float>(atof(row[3]));
|
||||
e.ypos = static_cast<float>(atof(row[4]));
|
||||
e.zpos = static_cast<float>(atof(row[5]));
|
||||
e.heading = static_cast<float>(atof(row[6]));
|
||||
e.itemid = atoi(row[7]);
|
||||
e.charges = atoi(row[8]);
|
||||
e.id = static_cast<int32_t>(atoi(row[0]));
|
||||
e.zoneid = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
|
||||
e.version = static_cast<int16_t>(atoi(row[2]));
|
||||
e.xpos = strtof(row[3], nullptr);
|
||||
e.ypos = strtof(row[4], nullptr);
|
||||
e.zpos = strtof(row[5], nullptr);
|
||||
e.heading = strtof(row[6], nullptr);
|
||||
e.itemid = static_cast<int32_t>(atoi(row[7]));
|
||||
e.charges = static_cast<uint16_t>(strtoul(row[8], nullptr, 10));
|
||||
e.objectname = row[9] ? row[9] : "";
|
||||
e.type = atoi(row[10]);
|
||||
e.icon = atoi(row[11]);
|
||||
e.unknown08 = atoi(row[12]);
|
||||
e.unknown10 = atoi(row[13]);
|
||||
e.unknown20 = atoi(row[14]);
|
||||
e.unknown24 = atoi(row[15]);
|
||||
e.unknown60 = atoi(row[16]);
|
||||
e.unknown64 = atoi(row[17]);
|
||||
e.unknown68 = atoi(row[18]);
|
||||
e.unknown72 = atoi(row[19]);
|
||||
e.unknown76 = atoi(row[20]);
|
||||
e.unknown84 = atoi(row[21]);
|
||||
e.size = static_cast<float>(atof(row[22]));
|
||||
e.tilt_x = static_cast<float>(atof(row[23]));
|
||||
e.tilt_y = static_cast<float>(atof(row[24]));
|
||||
e.type = static_cast<int32_t>(atoi(row[10]));
|
||||
e.icon = static_cast<int32_t>(atoi(row[11]));
|
||||
e.unknown08 = static_cast<int32_t>(atoi(row[12]));
|
||||
e.unknown10 = static_cast<int32_t>(atoi(row[13]));
|
||||
e.unknown20 = static_cast<int32_t>(atoi(row[14]));
|
||||
e.unknown24 = static_cast<int32_t>(atoi(row[15]));
|
||||
e.unknown60 = static_cast<int32_t>(atoi(row[16]));
|
||||
e.unknown64 = static_cast<int32_t>(atoi(row[17]));
|
||||
e.unknown68 = static_cast<int32_t>(atoi(row[18]));
|
||||
e.unknown72 = static_cast<int32_t>(atoi(row[19]));
|
||||
e.unknown76 = static_cast<int32_t>(atoi(row[20]));
|
||||
e.unknown84 = static_cast<int32_t>(atoi(row[21]));
|
||||
e.size = strtof(row[22], nullptr);
|
||||
e.tilt_x = strtof(row[23], nullptr);
|
||||
e.tilt_y = strtof(row[24], nullptr);
|
||||
e.display_name = row[25] ? row[25] : "";
|
||||
e.min_expansion = atoi(row[26]);
|
||||
e.max_expansion = atoi(row[27]);
|
||||
e.min_expansion = static_cast<int8_t>(atoi(row[26]));
|
||||
e.max_expansion = static_cast<int8_t>(atoi(row[27]));
|
||||
e.content_flags = row[28] ? row[28] : "";
|
||||
e.content_flags_disabled = row[29] ? row[29] : "";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user