mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-16 05:11:29 +00:00
More repository comb-throughs [skip ci]
This commit is contained in:
parent
826f0418f7
commit
80fb204f39
@ -17,30 +17,36 @@
|
|||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef EQEMU_SPAWNGROUP_REPOSITORY_H
|
#ifndef EQEMU_SPAWNGROUP_REPOSITORY_H
|
||||||
#define EQEMU_SPAWNGROUP_REPOSITORY_H
|
#define EQEMU_SPAWNGROUP_REPOSITORY_H
|
||||||
|
|
||||||
#include "../database.h"
|
#include "../database.h"
|
||||||
#include "../string_util.h"
|
#include "../string_util.h"
|
||||||
|
|
||||||
class SpawnGroupRepository {
|
class SpawngroupRepository {
|
||||||
public:
|
public:
|
||||||
struct SpawnGroup {
|
struct Spawngroup {
|
||||||
int id;
|
int id;
|
||||||
std::string name;
|
std::string name;
|
||||||
int8 spawn_limit;
|
int8 spawn_limit;
|
||||||
int dist;
|
float dist;
|
||||||
float max_x;
|
float max_x;
|
||||||
float min_x;
|
float min_x;
|
||||||
float max_y;
|
float max_y;
|
||||||
float min_y;
|
float min_y;
|
||||||
int delay;
|
int delay;
|
||||||
int mindelay;
|
int mindelay;
|
||||||
int despawn;
|
int8 despawn;
|
||||||
int despawn_timer;
|
int despawn_timer;
|
||||||
int wp_spawns;
|
int8 wp_spawns;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static std::string PrimaryKey()
|
||||||
|
{
|
||||||
|
return std::string("id");
|
||||||
|
}
|
||||||
|
|
||||||
static std::vector<std::string> Columns()
|
static std::vector<std::string> Columns()
|
||||||
{
|
{
|
||||||
return {
|
return {
|
||||||
@ -65,6 +71,21 @@ public:
|
|||||||
return std::string(implode(", ", Columns()));
|
return std::string(implode(", ", Columns()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static std::string InsertColumnsRaw()
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_columns;
|
||||||
|
|
||||||
|
for (auto &column : Columns()) {
|
||||||
|
if (column == PrimaryKey()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
insert_columns.push_back(column);
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::string(implode(", ", insert_columns));
|
||||||
|
}
|
||||||
|
|
||||||
static std::string TableName()
|
static std::string TableName()
|
||||||
{
|
{
|
||||||
return std::string("spawngroup");
|
return std::string("spawngroup");
|
||||||
@ -72,18 +93,25 @@ public:
|
|||||||
|
|
||||||
static std::string BaseSelect()
|
static std::string BaseSelect()
|
||||||
{
|
{
|
||||||
return std::string(
|
return fmt::format(
|
||||||
fmt::format(
|
"SELECT {} FROM {}",
|
||||||
"SELECT {} FROM {}",
|
ColumnsRaw(),
|
||||||
ColumnsRaw(),
|
TableName()
|
||||||
TableName()
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static SpawnGroup NewEntity()
|
static std::string BaseInsert()
|
||||||
{
|
{
|
||||||
SpawnGroup entry;
|
return fmt::format(
|
||||||
|
"INSERT INTO {} ({}) ",
|
||||||
|
TableName(),
|
||||||
|
InsertColumnsRaw()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Spawngroup NewEntity()
|
||||||
|
{
|
||||||
|
Spawngroup entry{};
|
||||||
|
|
||||||
entry.id = 0;
|
entry.id = 0;
|
||||||
entry.name = "";
|
entry.name = "";
|
||||||
@ -93,36 +121,44 @@ public:
|
|||||||
entry.min_x = 0;
|
entry.min_x = 0;
|
||||||
entry.max_y = 0;
|
entry.max_y = 0;
|
||||||
entry.min_y = 0;
|
entry.min_y = 0;
|
||||||
entry.delay = 0;
|
entry.delay = 45000;
|
||||||
entry.mindelay = 0;
|
entry.mindelay = 15000;
|
||||||
entry.despawn = 0;
|
entry.despawn = 0;
|
||||||
entry.despawn_timer = 0;
|
entry.despawn_timer = 100;
|
||||||
entry.wp_spawns = 0;
|
entry.wp_spawns = 0;
|
||||||
|
|
||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::vector<SpawnGroup> GetZoneSpawnGroups(
|
static Spawngroup GetSpawngroupEntry(
|
||||||
const std::string &zone_short_name,
|
const std::vector<Spawngroup> &spawngroups,
|
||||||
int zone_version
|
int spawngroup_id
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
std::vector<SpawnGroup> spawn_groups;
|
for (auto &spawngroup : spawngroups) {
|
||||||
|
if (spawngroup.id == spawngroup_id) {
|
||||||
|
return spawngroup;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static Spawngroup FindOne(
|
||||||
|
int spawngroup_id
|
||||||
|
)
|
||||||
|
{
|
||||||
auto results = content_db.QueryDatabase(
|
auto results = content_db.QueryDatabase(
|
||||||
fmt::format(
|
fmt::format(
|
||||||
SQL (
|
"{} WHERE id = {} LIMIT 1",
|
||||||
{} INNER JOIN spawn2 ON spawn2.spawngroupID = spawngroup.id
|
|
||||||
WHERE spawn2.zone = '{}' and spawn2.version = {}
|
|
||||||
),
|
|
||||||
BaseSelect(),
|
BaseSelect(),
|
||||||
zone_short_name,
|
spawngroup_id
|
||||||
zone_version
|
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
auto row = results.begin();
|
||||||
SpawnGroup entry{};
|
if (results.RowCount() == 1) {
|
||||||
|
Spawngroup entry{};
|
||||||
|
|
||||||
entry.id = atoi(row[0]);
|
entry.id = atoi(row[0]);
|
||||||
entry.name = row[1];
|
entry.name = row[1];
|
||||||
@ -138,27 +174,173 @@ public:
|
|||||||
entry.despawn_timer = atoi(row[11]);
|
entry.despawn_timer = atoi(row[11]);
|
||||||
entry.wp_spawns = atoi(row[12]);
|
entry.wp_spawns = atoi(row[12]);
|
||||||
|
|
||||||
spawn_groups.push_back(entry);
|
return entry;
|
||||||
}
|
|
||||||
|
|
||||||
return spawn_groups;
|
|
||||||
}
|
|
||||||
|
|
||||||
static SpawnGroup GetGrid(
|
|
||||||
const std::vector<SpawnGroup> &spawn_groups,
|
|
||||||
int spawn_group_id
|
|
||||||
)
|
|
||||||
{
|
|
||||||
for (auto &row : spawn_groups) {
|
|
||||||
if (row.id == spawn_group_id) {
|
|
||||||
return row;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return NewEntity();
|
return NewEntity();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int DeleteOne(
|
||||||
|
int spawngroup_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
PrimaryKey(),
|
||||||
|
spawngroup_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int UpdateOne(
|
||||||
|
Spawngroup spawngroup_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> update_values;
|
||||||
|
|
||||||
|
auto columns = Columns();
|
||||||
|
|
||||||
|
update_values.push_back(columns[1] + " = '" + EscapeString(spawngroup_entry.name) + "'");
|
||||||
|
update_values.push_back(columns[2] + " = " + std::to_string(spawngroup_entry.spawn_limit));
|
||||||
|
update_values.push_back(columns[3] + " = '" + EscapeString(spawngroup_entry.dist) + "'");
|
||||||
|
update_values.push_back(columns[4] + " = '" + EscapeString(spawngroup_entry.max_x) + "'");
|
||||||
|
update_values.push_back(columns[5] + " = '" + EscapeString(spawngroup_entry.min_x) + "'");
|
||||||
|
update_values.push_back(columns[6] + " = '" + EscapeString(spawngroup_entry.max_y) + "'");
|
||||||
|
update_values.push_back(columns[7] + " = '" + EscapeString(spawngroup_entry.min_y) + "'");
|
||||||
|
update_values.push_back(columns[8] + " = " + std::to_string(spawngroup_entry.delay));
|
||||||
|
update_values.push_back(columns[9] + " = " + std::to_string(spawngroup_entry.mindelay));
|
||||||
|
update_values.push_back(columns[10] + " = " + std::to_string(spawngroup_entry.despawn));
|
||||||
|
update_values.push_back(columns[11] + " = " + std::to_string(spawngroup_entry.despawn_timer));
|
||||||
|
update_values.push_back(columns[12] + " = " + std::to_string(spawngroup_entry.wp_spawns));
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"UPDATE {} SET {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
implode(", ", update_values),
|
||||||
|
PrimaryKey(),
|
||||||
|
spawngroup_entry.id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Spawngroup InsertOne(
|
||||||
|
Spawngroup spawngroup_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back("'" + EscapeString(spawngroup_entry.name) + "'");
|
||||||
|
insert_values.push_back(std::to_string(spawngroup_entry.spawn_limit));
|
||||||
|
insert_values.push_back("'" + EscapeString(spawngroup_entry.dist) + "'");
|
||||||
|
insert_values.push_back("'" + EscapeString(spawngroup_entry.max_x) + "'");
|
||||||
|
insert_values.push_back("'" + EscapeString(spawngroup_entry.min_x) + "'");
|
||||||
|
insert_values.push_back("'" + EscapeString(spawngroup_entry.max_y) + "'");
|
||||||
|
insert_values.push_back("'" + EscapeString(spawngroup_entry.min_y) + "'");
|
||||||
|
insert_values.push_back(std::to_string(spawngroup_entry.delay));
|
||||||
|
insert_values.push_back(std::to_string(spawngroup_entry.mindelay));
|
||||||
|
insert_values.push_back(std::to_string(spawngroup_entry.despawn));
|
||||||
|
insert_values.push_back(std::to_string(spawngroup_entry.despawn_timer));
|
||||||
|
insert_values.push_back(std::to_string(spawngroup_entry.wp_spawns));
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES ({})",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_values)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (results.Success()) {
|
||||||
|
spawngroup_entry.id = results.LastInsertedID();
|
||||||
|
return spawngroup_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
spawngroup_entry = InstanceListRepository::NewEntity();
|
||||||
|
|
||||||
|
return spawngroup_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int InsertMany(
|
||||||
|
std::vector<Spawngroup> spawngroup_entries
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_chunks;
|
||||||
|
|
||||||
|
for (auto &spawngroup_entry: spawngroup_entries) {
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back("'" + EscapeString(spawngroup_entry.name) + "'");
|
||||||
|
insert_values.push_back(std::to_string(spawngroup_entry.spawn_limit));
|
||||||
|
insert_values.push_back("'" + EscapeString(spawngroup_entry.dist) + "'");
|
||||||
|
insert_values.push_back("'" + EscapeString(spawngroup_entry.max_x) + "'");
|
||||||
|
insert_values.push_back("'" + EscapeString(spawngroup_entry.min_x) + "'");
|
||||||
|
insert_values.push_back("'" + EscapeString(spawngroup_entry.max_y) + "'");
|
||||||
|
insert_values.push_back("'" + EscapeString(spawngroup_entry.min_y) + "'");
|
||||||
|
insert_values.push_back(std::to_string(spawngroup_entry.delay));
|
||||||
|
insert_values.push_back(std::to_string(spawngroup_entry.mindelay));
|
||||||
|
insert_values.push_back(std::to_string(spawngroup_entry.despawn));
|
||||||
|
insert_values.push_back(std::to_string(spawngroup_entry.despawn_timer));
|
||||||
|
insert_values.push_back(std::to_string(spawngroup_entry.wp_spawns));
|
||||||
|
|
||||||
|
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES {}",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_chunks)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<Spawngroup> All()
|
||||||
|
{
|
||||||
|
std::vector<Spawngroup> all_entries;
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{}",
|
||||||
|
BaseSelect()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
Spawngroup entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.name = row[1];
|
||||||
|
entry.spawn_limit = atoi(row[2]);
|
||||||
|
entry.dist = atof(row[3]);
|
||||||
|
entry.max_x = atof(row[4]);
|
||||||
|
entry.min_x = atof(row[5]);
|
||||||
|
entry.max_y = atof(row[6]);
|
||||||
|
entry.min_y = atof(row[7]);
|
||||||
|
entry.delay = atoi(row[8]);
|
||||||
|
entry.mindelay = atoi(row[9]);
|
||||||
|
entry.despawn = atoi(row[10]);
|
||||||
|
entry.despawn_timer = atoi(row[11]);
|
||||||
|
entry.wp_spawns = atoi(row[12]);
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif //EQEMU_SPAWNGROUP_REPOSITORY_H
|
#endif //EQEMU_SPAWNGROUP_REPOSITORY_H
|
||||||
|
|||||||
@ -29,22 +29,17 @@ public:
|
|||||||
struct TradeskillRecipe {
|
struct TradeskillRecipe {
|
||||||
int id;
|
int id;
|
||||||
std::string name;
|
std::string name;
|
||||||
int16 tradeskill;
|
int tradeskill;
|
||||||
int16 skillneeded;
|
int skillneeded;
|
||||||
int16 trivial;
|
int trivial;
|
||||||
int8 nofail;
|
uint8 nofail;
|
||||||
int8 replace_container;
|
int replace_container;
|
||||||
std::string notes;
|
std::string notes;
|
||||||
int8 must_learn;
|
uint8 must_learn;
|
||||||
int8 quest;
|
uint8 quest;
|
||||||
int8 enabled;
|
uint8 enabled;
|
||||||
};
|
};
|
||||||
|
|
||||||
static std::string PrimaryKey()
|
|
||||||
{
|
|
||||||
return std::string("id");
|
|
||||||
}
|
|
||||||
|
|
||||||
static std::vector<std::string> Columns()
|
static std::vector<std::string> Columns()
|
||||||
{
|
{
|
||||||
return {
|
return {
|
||||||
@ -67,21 +62,6 @@ public:
|
|||||||
return std::string(implode(", ", Columns()));
|
return std::string(implode(", ", Columns()));
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::string InsertColumnsRaw()
|
|
||||||
{
|
|
||||||
std::vector<std::string> insert_columns;
|
|
||||||
|
|
||||||
for (auto &column : Columns()) {
|
|
||||||
if (column == PrimaryKey()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
insert_columns.push_back(column);
|
|
||||||
}
|
|
||||||
|
|
||||||
return std::string(implode(", ", insert_columns));
|
|
||||||
}
|
|
||||||
|
|
||||||
static std::string TableName()
|
static std::string TableName()
|
||||||
{
|
{
|
||||||
return std::string("tradeskill_recipe");
|
return std::string("tradeskill_recipe");
|
||||||
@ -89,25 +69,18 @@ public:
|
|||||||
|
|
||||||
static std::string BaseSelect()
|
static std::string BaseSelect()
|
||||||
{
|
{
|
||||||
return fmt::format(
|
return std::string(
|
||||||
"SELECT {} FROM {}",
|
fmt::format(
|
||||||
ColumnsRaw(),
|
"SELECT {} FROM {}",
|
||||||
TableName()
|
ColumnsRaw(),
|
||||||
);
|
TableName()
|
||||||
}
|
)
|
||||||
|
|
||||||
static std::string BaseInsert()
|
|
||||||
{
|
|
||||||
return fmt::format(
|
|
||||||
"INSERT INTO {} ({}) ",
|
|
||||||
TableName(),
|
|
||||||
InsertColumnsRaw()
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static TradeskillRecipe NewEntity()
|
static TradeskillRecipe NewEntity()
|
||||||
{
|
{
|
||||||
TradeskillRecipe entry{};
|
TradeskillRecipe entry;
|
||||||
|
|
||||||
entry.id = 0;
|
entry.id = 0;
|
||||||
entry.name = "";
|
entry.name = "";
|
||||||
@ -116,215 +89,46 @@ public:
|
|||||||
entry.trivial = 0;
|
entry.trivial = 0;
|
||||||
entry.nofail = 0;
|
entry.nofail = 0;
|
||||||
entry.replace_container = 0;
|
entry.replace_container = 0;
|
||||||
entry.notes = 0;
|
entry.notes = "";
|
||||||
entry.must_learn = 0;
|
entry.must_learn = 0;
|
||||||
entry.quest = 0;
|
entry.quest = 0;
|
||||||
entry.enabled = 1;
|
entry.enabled = 0;
|
||||||
|
|
||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
static TradeskillRecipe GetTradeskillRecipeEntry(
|
static TradeskillRecipe GetRecipe(int recipe_id)
|
||||||
const std::vector<TradeskillRecipe> &tradeskill_recipes,
|
|
||||||
int tradeskill_recipe_id
|
|
||||||
)
|
|
||||||
{
|
|
||||||
for (auto &tradeskill_recipe : tradeskill_recipes) {
|
|
||||||
if (tradeskill_recipe.id == tradeskill_recipe_id) {
|
|
||||||
return tradeskill_recipe;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return NewEntity();
|
|
||||||
}
|
|
||||||
|
|
||||||
static TradeskillRecipe FindOne(
|
|
||||||
int tradeskill_recipe_id
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
auto results = content_db.QueryDatabase(
|
auto results = content_db.QueryDatabase(
|
||||||
fmt::format(
|
fmt::format(
|
||||||
"{} WHERE id = {} LIMIT 1",
|
"{} WHERE id = {}",
|
||||||
BaseSelect(),
|
BaseSelect(),
|
||||||
tradeskill_recipe_id
|
recipe_id
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
TradeskillRecipe tradeskill_recipe = NewEntity();
|
||||||
|
|
||||||
auto row = results.begin();
|
auto row = results.begin();
|
||||||
if (results.RowCount() == 1) {
|
if (results.RowCount() == 0) {
|
||||||
TradeskillRecipe entry{};
|
return tradeskill_recipe;
|
||||||
|
|
||||||
entry.id = atoi(row[0]);
|
|
||||||
entry.name = row[1];
|
|
||||||
entry.tradeskill = atoi(row[2]);
|
|
||||||
entry.skillneeded = atoi(row[3]);
|
|
||||||
entry.trivial = atoi(row[4]);
|
|
||||||
entry.nofail = atoi(row[5]);
|
|
||||||
entry.replace_container = atoi(row[6]);
|
|
||||||
entry.notes = row[7];
|
|
||||||
entry.must_learn = atoi(row[8]);
|
|
||||||
entry.quest = atoi(row[9]);
|
|
||||||
entry.enabled = atoi(row[10]);
|
|
||||||
|
|
||||||
return entry;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return NewEntity();
|
tradeskill_recipe.id = atoi(row[0]);
|
||||||
}
|
tradeskill_recipe.name = (row[1] ? row[1] : "");
|
||||||
|
tradeskill_recipe.tradeskill = atoi(row[2]);
|
||||||
|
tradeskill_recipe.skillneeded = atoi(row[3]);
|
||||||
|
tradeskill_recipe.trivial = atoi(row[4]);
|
||||||
|
tradeskill_recipe.nofail = atoi(row[5]);
|
||||||
|
tradeskill_recipe.replace_container = atoi(row[6]);
|
||||||
|
tradeskill_recipe.notes = (row[7] ? row[7] : "");
|
||||||
|
tradeskill_recipe.must_learn = atoi(row[8]);
|
||||||
|
tradeskill_recipe.quest = atoi(row[9]);
|
||||||
|
tradeskill_recipe.enabled = atoi(row[10]);
|
||||||
|
|
||||||
static int DeleteOne(
|
return tradeskill_recipe;
|
||||||
int tradeskill_recipe_id
|
|
||||||
)
|
|
||||||
{
|
|
||||||
auto results = content_db.QueryDatabase(
|
|
||||||
fmt::format(
|
|
||||||
"DELETE FROM {} WHERE {} = {}",
|
|
||||||
TableName(),
|
|
||||||
PrimaryKey(),
|
|
||||||
tradeskill_recipe_id
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
return (results.Success() ? results.RowsAffected() : 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int UpdateOne(
|
|
||||||
TradeskillRecipe tradeskill_recipe_entry
|
|
||||||
)
|
|
||||||
{
|
|
||||||
std::vector<std::string> update_values;
|
|
||||||
|
|
||||||
auto columns = Columns();
|
|
||||||
|
|
||||||
update_values.push_back(columns[1] + " = '" + EscapeString(tradeskill_recipe_entry.name) + "'");
|
|
||||||
update_values.push_back(columns[2] + " = " + std::to_string(tradeskill_recipe_entry.tradeskill));
|
|
||||||
update_values.push_back(columns[3] + " = " + std::to_string(tradeskill_recipe_entry.skillneeded));
|
|
||||||
update_values.push_back(columns[4] + " = " + std::to_string(tradeskill_recipe_entry.trivial));
|
|
||||||
update_values.push_back(columns[5] + " = " + std::to_string(tradeskill_recipe_entry.nofail));
|
|
||||||
update_values.push_back(columns[6] + " = " + std::to_string(tradeskill_recipe_entry.replace_container));
|
|
||||||
update_values.push_back(columns[7] + " = '" + EscapeString(tradeskill_recipe_entry.notes) + "'");
|
|
||||||
update_values.push_back(columns[8] + " = " + std::to_string(tradeskill_recipe_entry.must_learn));
|
|
||||||
update_values.push_back(columns[9] + " = " + std::to_string(tradeskill_recipe_entry.quest));
|
|
||||||
update_values.push_back(columns[10] + " = " + std::to_string(tradeskill_recipe_entry.enabled));
|
|
||||||
|
|
||||||
auto results = content_db.QueryDatabase(
|
|
||||||
fmt::format(
|
|
||||||
"UPDATE {} SET {} WHERE {} = {}",
|
|
||||||
TableName(),
|
|
||||||
implode(", ", update_values),
|
|
||||||
PrimaryKey(),
|
|
||||||
tradeskill_recipe_entry.id
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
return (results.Success() ? results.RowsAffected() : 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static TradeskillRecipe InsertOne(
|
|
||||||
TradeskillRecipe tradeskill_recipe_entry
|
|
||||||
)
|
|
||||||
{
|
|
||||||
std::vector<std::string> insert_values;
|
|
||||||
|
|
||||||
insert_values.push_back("'" + EscapeString(tradeskill_recipe_entry.name) + "'");
|
|
||||||
insert_values.push_back(std::to_string(tradeskill_recipe_entry.tradeskill));
|
|
||||||
insert_values.push_back(std::to_string(tradeskill_recipe_entry.skillneeded));
|
|
||||||
insert_values.push_back(std::to_string(tradeskill_recipe_entry.trivial));
|
|
||||||
insert_values.push_back(std::to_string(tradeskill_recipe_entry.nofail));
|
|
||||||
insert_values.push_back(std::to_string(tradeskill_recipe_entry.replace_container));
|
|
||||||
insert_values.push_back("'" + EscapeString(tradeskill_recipe_entry.notes) + "'");
|
|
||||||
insert_values.push_back(std::to_string(tradeskill_recipe_entry.must_learn));
|
|
||||||
insert_values.push_back(std::to_string(tradeskill_recipe_entry.quest));
|
|
||||||
insert_values.push_back(std::to_string(tradeskill_recipe_entry.enabled));
|
|
||||||
|
|
||||||
auto results = content_db.QueryDatabase(
|
|
||||||
fmt::format(
|
|
||||||
"{} VALUES ({})",
|
|
||||||
BaseInsert(),
|
|
||||||
implode(",", insert_values)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (results.Success()) {
|
|
||||||
tradeskill_recipe_entry.id = results.LastInsertedID();
|
|
||||||
return tradeskill_recipe_entry;
|
|
||||||
}
|
|
||||||
|
|
||||||
tradeskill_recipe_entry = InstanceListRepository::NewEntity();
|
|
||||||
|
|
||||||
return tradeskill_recipe_entry;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int InsertMany(
|
|
||||||
std::vector<TradeskillRecipe> tradeskill_recipe_entries
|
|
||||||
)
|
|
||||||
{
|
|
||||||
std::vector<std::string> insert_chunks;
|
|
||||||
|
|
||||||
for (auto &tradeskill_recipe_entry: tradeskill_recipe_entries) {
|
|
||||||
std::vector<std::string> insert_values;
|
|
||||||
|
|
||||||
insert_values.push_back("'" + EscapeString(tradeskill_recipe_entry.name) + "'");
|
|
||||||
insert_values.push_back(std::to_string(tradeskill_recipe_entry.tradeskill));
|
|
||||||
insert_values.push_back(std::to_string(tradeskill_recipe_entry.skillneeded));
|
|
||||||
insert_values.push_back(std::to_string(tradeskill_recipe_entry.trivial));
|
|
||||||
insert_values.push_back(std::to_string(tradeskill_recipe_entry.nofail));
|
|
||||||
insert_values.push_back(std::to_string(tradeskill_recipe_entry.replace_container));
|
|
||||||
insert_values.push_back("'" + EscapeString(tradeskill_recipe_entry.notes) + "'");
|
|
||||||
insert_values.push_back(std::to_string(tradeskill_recipe_entry.must_learn));
|
|
||||||
insert_values.push_back(std::to_string(tradeskill_recipe_entry.quest));
|
|
||||||
insert_values.push_back(std::to_string(tradeskill_recipe_entry.enabled));
|
|
||||||
|
|
||||||
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<std::string> insert_values;
|
|
||||||
|
|
||||||
auto results = content_db.QueryDatabase(
|
|
||||||
fmt::format(
|
|
||||||
"{} VALUES {}",
|
|
||||||
BaseInsert(),
|
|
||||||
implode(",", insert_chunks)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
return (results.Success() ? results.RowsAffected() : 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static std::vector<TradeskillRecipe> All()
|
|
||||||
{
|
|
||||||
std::vector<TradeskillRecipe> all_entries;
|
|
||||||
|
|
||||||
auto results = content_db.QueryDatabase(
|
|
||||||
fmt::format(
|
|
||||||
"{}",
|
|
||||||
BaseSelect()
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
all_entries.reserve(results.RowCount());
|
|
||||||
|
|
||||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
|
||||||
TradeskillRecipe entry{};
|
|
||||||
|
|
||||||
entry.id = atoi(row[0]);
|
|
||||||
entry.name = row[1];
|
|
||||||
entry.tradeskill = atoi(row[2]);
|
|
||||||
entry.skillneeded = atoi(row[3]);
|
|
||||||
entry.trivial = atoi(row[4]);
|
|
||||||
entry.nofail = atoi(row[5]);
|
|
||||||
entry.replace_container = atoi(row[6]);
|
|
||||||
entry.notes = row[7];
|
|
||||||
entry.must_learn = atoi(row[8]);
|
|
||||||
entry.quest = atoi(row[9]);
|
|
||||||
entry.enabled = atoi(row[10]);
|
|
||||||
|
|
||||||
all_entries.push_back(entry);
|
|
||||||
}
|
|
||||||
|
|
||||||
return all_entries;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //EQEMU_TRADESKILL_RECIPE_REPOSITORY_H
|
#endif
|
||||||
|
|||||||
@ -117,6 +117,10 @@ foreach my $table_to_generate (@tables) {
|
|||||||
# These tables don't have a typical schema
|
# These tables don't have a typical schema
|
||||||
my @table_ignore_list = (
|
my @table_ignore_list = (
|
||||||
"character_enabledtasks",
|
"character_enabledtasks",
|
||||||
|
"grid", # Manually created
|
||||||
|
"grid_entries", # Manually created
|
||||||
|
"tradeskill_recipe", # Manually created
|
||||||
|
"character_recipe_list", # Manually created
|
||||||
"eqtime",
|
"eqtime",
|
||||||
"db_version",
|
"db_version",
|
||||||
"keyring",
|
"keyring",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user