mirror of
https://github.com/EQEmu/Server.git
synced 2026-06-01 10:11:37 +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,10 +19,10 @@
|
||||
class BaseExpeditionsRepository {
|
||||
public:
|
||||
struct Expeditions {
|
||||
int id;
|
||||
int dynamic_zone_id;
|
||||
int add_replay_on_join;
|
||||
int is_locked;
|
||||
uint32_t id;
|
||||
uint32_t dynamic_zone_id;
|
||||
uint8_t add_replay_on_join;
|
||||
uint8_t is_locked;
|
||||
};
|
||||
|
||||
static std::string PrimaryKey()
|
||||
@@ -126,10 +126,10 @@ public:
|
||||
if (results.RowCount() == 1) {
|
||||
Expeditions e{};
|
||||
|
||||
e.id = atoi(row[0]);
|
||||
e.dynamic_zone_id = atoi(row[1]);
|
||||
e.add_replay_on_join = atoi(row[2]);
|
||||
e.is_locked = atoi(row[3]);
|
||||
e.id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
|
||||
e.dynamic_zone_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
|
||||
e.add_replay_on_join = static_cast<uint8_t>(strtoul(row[2], nullptr, 10));
|
||||
e.is_locked = static_cast<uint8_t>(strtoul(row[3], nullptr, 10));
|
||||
|
||||
return e;
|
||||
}
|
||||
@@ -257,10 +257,10 @@ public:
|
||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||
Expeditions e{};
|
||||
|
||||
e.id = atoi(row[0]);
|
||||
e.dynamic_zone_id = atoi(row[1]);
|
||||
e.add_replay_on_join = atoi(row[2]);
|
||||
e.is_locked = atoi(row[3]);
|
||||
e.id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
|
||||
e.dynamic_zone_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
|
||||
e.add_replay_on_join = static_cast<uint8_t>(strtoul(row[2], nullptr, 10));
|
||||
e.is_locked = static_cast<uint8_t>(strtoul(row[3], nullptr, 10));
|
||||
|
||||
all_entries.push_back(e);
|
||||
}
|
||||
@@ -285,10 +285,10 @@ public:
|
||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||
Expeditions e{};
|
||||
|
||||
e.id = atoi(row[0]);
|
||||
e.dynamic_zone_id = atoi(row[1]);
|
||||
e.add_replay_on_join = atoi(row[2]);
|
||||
e.is_locked = atoi(row[3]);
|
||||
e.id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
|
||||
e.dynamic_zone_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
|
||||
e.add_replay_on_join = static_cast<uint8_t>(strtoul(row[2], nullptr, 10));
|
||||
e.is_locked = static_cast<uint8_t>(strtoul(row[3], nullptr, 10));
|
||||
|
||||
all_entries.push_back(e);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user