mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-20 17:31:30 +00:00
More adjustments [skip ci[
This commit is contained in:
parent
725ad9ddf5
commit
be57c57029
@ -186,6 +186,8 @@ SET(repositories
|
|||||||
repositories/base/base_gm_ips_repository.h
|
repositories/base/base_gm_ips_repository.h
|
||||||
repositories/base/base_goallists_repository.h
|
repositories/base/base_goallists_repository.h
|
||||||
repositories/base/base_graveyard_repository.h
|
repositories/base/base_graveyard_repository.h
|
||||||
|
repositories/base/base_grid_repository.h
|
||||||
|
repositories/base/base_grid_entries_repository.h
|
||||||
repositories/base/base_ground_spawns_repository.h
|
repositories/base/base_ground_spawns_repository.h
|
||||||
repositories/base/base_group_id_repository.h
|
repositories/base/base_group_id_repository.h
|
||||||
repositories/base/base_group_leaders_repository.h
|
repositories/base/base_group_leaders_repository.h
|
||||||
@ -267,6 +269,7 @@ SET(repositories
|
|||||||
repositories/base/base_timers_repository.h
|
repositories/base/base_timers_repository.h
|
||||||
repositories/base/base_titles_repository.h
|
repositories/base/base_titles_repository.h
|
||||||
repositories/base/base_trader_repository.h
|
repositories/base/base_trader_repository.h
|
||||||
|
repositories/base/base_tradeskill_recipe_repository.h
|
||||||
repositories/base/base_tradeskill_recipe_entries_repository.h
|
repositories/base/base_tradeskill_recipe_entries_repository.h
|
||||||
repositories/base/base_traps_repository.h
|
repositories/base/base_traps_repository.h
|
||||||
repositories/base/base_tributes_repository.h
|
repositories/base/base_tributes_repository.h
|
||||||
@ -348,6 +351,8 @@ SET(repositories
|
|||||||
repositories/gm_ips_repository.h
|
repositories/gm_ips_repository.h
|
||||||
repositories/goallists_repository.h
|
repositories/goallists_repository.h
|
||||||
repositories/graveyard_repository.h
|
repositories/graveyard_repository.h
|
||||||
|
repositories/grid_repository.h
|
||||||
|
repositories/grid_entries_repository.h
|
||||||
repositories/ground_spawns_repository.h
|
repositories/ground_spawns_repository.h
|
||||||
repositories/group_id_repository.h
|
repositories/group_id_repository.h
|
||||||
repositories/group_leaders_repository.h
|
repositories/group_leaders_repository.h
|
||||||
@ -429,6 +434,7 @@ SET(repositories
|
|||||||
repositories/timers_repository.h
|
repositories/timers_repository.h
|
||||||
repositories/titles_repository.h
|
repositories/titles_repository.h
|
||||||
repositories/trader_repository.h
|
repositories/trader_repository.h
|
||||||
|
repositories/tradeskill_recipe_repository.h
|
||||||
repositories/tradeskill_recipe_entries_repository.h
|
repositories/tradeskill_recipe_entries_repository.h
|
||||||
repositories/traps_repository.h
|
repositories/traps_repository.h
|
||||||
repositories/tributes_repository.h
|
repositories/tributes_repository.h
|
||||||
@ -437,10 +443,6 @@ SET(repositories
|
|||||||
repositories/veteran_reward_templates_repository.h
|
repositories/veteran_reward_templates_repository.h
|
||||||
repositories/zone_repository.h
|
repositories/zone_repository.h
|
||||||
repositories/zone_points_repository.h
|
repositories/zone_points_repository.h
|
||||||
|
|
||||||
repositories/grid_repository.h
|
|
||||||
repositories/grid_entries_repository.h
|
|
||||||
repositories/tradeskill_recipe_repository.h
|
|
||||||
)
|
)
|
||||||
|
|
||||||
SET(common_headers
|
SET(common_headers
|
||||||
|
|||||||
363
common/repositories/base/base_grid_entries_repository.h
Normal file
363
common/repositories/base/base_grid_entries_repository.h
Normal file
@ -0,0 +1,363 @@
|
|||||||
|
/**
|
||||||
|
* EQEmulator: Everquest Server Emulator
|
||||||
|
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; version 2 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||||
|
* are required to give you total support for your newly bought product;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This repository was automatically generated on Apr 5, 2020 and is NOT
|
||||||
|
* to be modified directly. Any repository modifications are meant to be made to
|
||||||
|
* the repository extending the base. Any modifications to base repositories are to
|
||||||
|
* be made by the generator only
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_BASE_GRID_ENTRIES_REPOSITORY_H
|
||||||
|
#define EQEMU_BASE_GRID_ENTRIES_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../../database.h"
|
||||||
|
#include "../../string_util.h"
|
||||||
|
|
||||||
|
class BaseGridEntriesRepository {
|
||||||
|
public:
|
||||||
|
struct GridEntries {
|
||||||
|
int gridid;
|
||||||
|
int zoneid;
|
||||||
|
int number;
|
||||||
|
float x;
|
||||||
|
float y;
|
||||||
|
float z;
|
||||||
|
float heading;
|
||||||
|
int pause;
|
||||||
|
int8 centerpoint;
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::string PrimaryKey()
|
||||||
|
{
|
||||||
|
return std::string("number");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> Columns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"gridid",
|
||||||
|
"zoneid",
|
||||||
|
"number",
|
||||||
|
"x",
|
||||||
|
"y",
|
||||||
|
"z",
|
||||||
|
"heading",
|
||||||
|
"pause",
|
||||||
|
"centerpoint",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string ColumnsRaw()
|
||||||
|
{
|
||||||
|
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()
|
||||||
|
{
|
||||||
|
return std::string("grid_entries");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseSelect()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"SELECT {} FROM {}",
|
||||||
|
ColumnsRaw(),
|
||||||
|
TableName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseInsert()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"INSERT INTO {} ({}) ",
|
||||||
|
TableName(),
|
||||||
|
InsertColumnsRaw()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static GridEntries NewEntity()
|
||||||
|
{
|
||||||
|
GridEntries entry{};
|
||||||
|
|
||||||
|
entry.gridid = 0;
|
||||||
|
entry.zoneid = 0;
|
||||||
|
entry.number = 0;
|
||||||
|
entry.x = 0;
|
||||||
|
entry.y = 0;
|
||||||
|
entry.z = 0;
|
||||||
|
entry.heading = 0;
|
||||||
|
entry.pause = 0;
|
||||||
|
entry.centerpoint = 0;
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static GridEntries GetGridEntriesEntry(
|
||||||
|
const std::vector<GridEntries> &grid_entriess,
|
||||||
|
int grid_entries_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
for (auto &grid_entries : grid_entriess) {
|
||||||
|
if (grid_entries.number == grid_entries_id) {
|
||||||
|
return grid_entries;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static GridEntries FindOne(
|
||||||
|
int grid_entries_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE id = {} LIMIT 1",
|
||||||
|
BaseSelect(),
|
||||||
|
grid_entries_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
auto row = results.begin();
|
||||||
|
if (results.RowCount() == 1) {
|
||||||
|
GridEntries entry{};
|
||||||
|
|
||||||
|
entry.gridid = atoi(row[0]);
|
||||||
|
entry.zoneid = atoi(row[1]);
|
||||||
|
entry.number = atoi(row[2]);
|
||||||
|
entry.x = atof(row[3]);
|
||||||
|
entry.y = atof(row[4]);
|
||||||
|
entry.z = atof(row[5]);
|
||||||
|
entry.heading = atof(row[6]);
|
||||||
|
entry.pause = atoi(row[7]);
|
||||||
|
entry.centerpoint = atoi(row[8]);
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteOne(
|
||||||
|
int grid_entries_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
PrimaryKey(),
|
||||||
|
grid_entries_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int UpdateOne(
|
||||||
|
GridEntries grid_entries_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> update_values;
|
||||||
|
|
||||||
|
auto columns = Columns();
|
||||||
|
|
||||||
|
update_values.push_back(columns[3] + " = " + std::to_string(grid_entries_entry.x));
|
||||||
|
update_values.push_back(columns[4] + " = " + std::to_string(grid_entries_entry.y));
|
||||||
|
update_values.push_back(columns[5] + " = " + std::to_string(grid_entries_entry.z));
|
||||||
|
update_values.push_back(columns[6] + " = " + std::to_string(grid_entries_entry.heading));
|
||||||
|
update_values.push_back(columns[7] + " = " + std::to_string(grid_entries_entry.pause));
|
||||||
|
update_values.push_back(columns[8] + " = " + std::to_string(grid_entries_entry.centerpoint));
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"UPDATE {} SET {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
implode(", ", update_values),
|
||||||
|
PrimaryKey(),
|
||||||
|
grid_entries_entry.number
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static GridEntries InsertOne(
|
||||||
|
GridEntries grid_entries_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(grid_entries_entry.x));
|
||||||
|
insert_values.push_back(std::to_string(grid_entries_entry.y));
|
||||||
|
insert_values.push_back(std::to_string(grid_entries_entry.z));
|
||||||
|
insert_values.push_back(std::to_string(grid_entries_entry.heading));
|
||||||
|
insert_values.push_back(std::to_string(grid_entries_entry.pause));
|
||||||
|
insert_values.push_back(std::to_string(grid_entries_entry.centerpoint));
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES ({})",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_values)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (results.Success()) {
|
||||||
|
grid_entries_entry.id = results.LastInsertedID();
|
||||||
|
return grid_entries_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
grid_entries_entry = NewEntity();
|
||||||
|
|
||||||
|
return grid_entries_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int InsertMany(
|
||||||
|
std::vector<GridEntries> grid_entries_entries
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_chunks;
|
||||||
|
|
||||||
|
for (auto &grid_entries_entry: grid_entries_entries) {
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(grid_entries_entry.x));
|
||||||
|
insert_values.push_back(std::to_string(grid_entries_entry.y));
|
||||||
|
insert_values.push_back(std::to_string(grid_entries_entry.z));
|
||||||
|
insert_values.push_back(std::to_string(grid_entries_entry.heading));
|
||||||
|
insert_values.push_back(std::to_string(grid_entries_entry.pause));
|
||||||
|
insert_values.push_back(std::to_string(grid_entries_entry.centerpoint));
|
||||||
|
|
||||||
|
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<GridEntries> All()
|
||||||
|
{
|
||||||
|
std::vector<GridEntries> all_entries;
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{}",
|
||||||
|
BaseSelect()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
GridEntries entry{};
|
||||||
|
|
||||||
|
entry.gridid = atoi(row[0]);
|
||||||
|
entry.zoneid = atoi(row[1]);
|
||||||
|
entry.number = atoi(row[2]);
|
||||||
|
entry.x = atof(row[3]);
|
||||||
|
entry.y = atof(row[4]);
|
||||||
|
entry.z = atof(row[5]);
|
||||||
|
entry.heading = atof(row[6]);
|
||||||
|
entry.pause = atoi(row[7]);
|
||||||
|
entry.centerpoint = atoi(row[8]);
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<GridEntries> GetWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
std::vector<GridEntries> all_entries;
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {}",
|
||||||
|
BaseSelect(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
GridEntries entry{};
|
||||||
|
|
||||||
|
entry.gridid = atoi(row[0]);
|
||||||
|
entry.zoneid = atoi(row[1]);
|
||||||
|
entry.number = atoi(row[2]);
|
||||||
|
entry.x = atof(row[3]);
|
||||||
|
entry.y = atof(row[4]);
|
||||||
|
entry.z = atof(row[5]);
|
||||||
|
entry.heading = atof(row[6]);
|
||||||
|
entry.pause = atoi(row[7]);
|
||||||
|
entry.centerpoint = atoi(row[8]);
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {}",
|
||||||
|
TableName(),
|
||||||
|
PrimaryKey(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_BASE_GRID_ENTRIES_REPOSITORY_H
|
||||||
321
common/repositories/base/base_grid_repository.h
Normal file
321
common/repositories/base/base_grid_repository.h
Normal file
@ -0,0 +1,321 @@
|
|||||||
|
/**
|
||||||
|
* EQEmulator: Everquest Server Emulator
|
||||||
|
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; version 2 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||||
|
* are required to give you total support for your newly bought product;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This repository was automatically generated on Apr 5, 2020 and is NOT
|
||||||
|
* to be modified directly. Any repository modifications are meant to be made to
|
||||||
|
* the repository extending the base. Any modifications to base repositories are to
|
||||||
|
* be made by the generator only
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_BASE_GRID_REPOSITORY_H
|
||||||
|
#define EQEMU_BASE_GRID_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../../database.h"
|
||||||
|
#include "../../string_util.h"
|
||||||
|
|
||||||
|
class BaseGridRepository {
|
||||||
|
public:
|
||||||
|
struct Grid {
|
||||||
|
int id;
|
||||||
|
int zoneid;
|
||||||
|
int type;
|
||||||
|
int type2;
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::string PrimaryKey()
|
||||||
|
{
|
||||||
|
return std::string("zoneid");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> Columns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"id",
|
||||||
|
"zoneid",
|
||||||
|
"type",
|
||||||
|
"type2",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string ColumnsRaw()
|
||||||
|
{
|
||||||
|
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()
|
||||||
|
{
|
||||||
|
return std::string("grid");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseSelect()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"SELECT {} FROM {}",
|
||||||
|
ColumnsRaw(),
|
||||||
|
TableName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseInsert()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"INSERT INTO {} ({}) ",
|
||||||
|
TableName(),
|
||||||
|
InsertColumnsRaw()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Grid NewEntity()
|
||||||
|
{
|
||||||
|
Grid entry{};
|
||||||
|
|
||||||
|
entry.id = 0;
|
||||||
|
entry.zoneid = 0;
|
||||||
|
entry.type = 0;
|
||||||
|
entry.type2 = 0;
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Grid GetGridEntry(
|
||||||
|
const std::vector<Grid> &grids,
|
||||||
|
int grid_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
for (auto &grid : grids) {
|
||||||
|
if (grid.zoneid == grid_id) {
|
||||||
|
return grid;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static Grid FindOne(
|
||||||
|
int grid_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE id = {} LIMIT 1",
|
||||||
|
BaseSelect(),
|
||||||
|
grid_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
auto row = results.begin();
|
||||||
|
if (results.RowCount() == 1) {
|
||||||
|
Grid entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.zoneid = atoi(row[1]);
|
||||||
|
entry.type = atoi(row[2]);
|
||||||
|
entry.type2 = atoi(row[3]);
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteOne(
|
||||||
|
int grid_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
PrimaryKey(),
|
||||||
|
grid_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int UpdateOne(
|
||||||
|
Grid grid_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> update_values;
|
||||||
|
|
||||||
|
auto columns = Columns();
|
||||||
|
|
||||||
|
update_values.push_back(columns[2] + " = " + std::to_string(grid_entry.type));
|
||||||
|
update_values.push_back(columns[3] + " = " + std::to_string(grid_entry.type2));
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"UPDATE {} SET {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
implode(", ", update_values),
|
||||||
|
PrimaryKey(),
|
||||||
|
grid_entry.zoneid
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Grid InsertOne(
|
||||||
|
Grid grid_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(grid_entry.type));
|
||||||
|
insert_values.push_back(std::to_string(grid_entry.type2));
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES ({})",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_values)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (results.Success()) {
|
||||||
|
grid_entry.id = results.LastInsertedID();
|
||||||
|
return grid_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
grid_entry = NewEntity();
|
||||||
|
|
||||||
|
return grid_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int InsertMany(
|
||||||
|
std::vector<Grid> grid_entries
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_chunks;
|
||||||
|
|
||||||
|
for (auto &grid_entry: grid_entries) {
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(grid_entry.type));
|
||||||
|
insert_values.push_back(std::to_string(grid_entry.type2));
|
||||||
|
|
||||||
|
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<Grid> All()
|
||||||
|
{
|
||||||
|
std::vector<Grid> all_entries;
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{}",
|
||||||
|
BaseSelect()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
Grid entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.zoneid = atoi(row[1]);
|
||||||
|
entry.type = atoi(row[2]);
|
||||||
|
entry.type2 = atoi(row[3]);
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<Grid> GetWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
std::vector<Grid> all_entries;
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {}",
|
||||||
|
BaseSelect(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
Grid entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.zoneid = atoi(row[1]);
|
||||||
|
entry.type = atoi(row[2]);
|
||||||
|
entry.type2 = atoi(row[3]);
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {}",
|
||||||
|
TableName(),
|
||||||
|
PrimaryKey(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_BASE_GRID_REPOSITORY_H
|
||||||
414
common/repositories/base/base_tradeskill_recipe_repository.h
Normal file
414
common/repositories/base/base_tradeskill_recipe_repository.h
Normal file
@ -0,0 +1,414 @@
|
|||||||
|
/**
|
||||||
|
* EQEmulator: Everquest Server Emulator
|
||||||
|
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; version 2 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||||
|
* are required to give you total support for your newly bought product;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This repository was automatically generated on Apr 5, 2020 and is NOT
|
||||||
|
* to be modified directly. Any repository modifications are meant to be made to
|
||||||
|
* the repository extending the base. Any modifications to base repositories are to
|
||||||
|
* be made by the generator only
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_BASE_TRADESKILL_RECIPE_REPOSITORY_H
|
||||||
|
#define EQEMU_BASE_TRADESKILL_RECIPE_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../../database.h"
|
||||||
|
#include "../../string_util.h"
|
||||||
|
|
||||||
|
class BaseTradeskillRecipeRepository {
|
||||||
|
public:
|
||||||
|
struct TradeskillRecipe {
|
||||||
|
int id;
|
||||||
|
std::string name;
|
||||||
|
int16 tradeskill;
|
||||||
|
int16 skillneeded;
|
||||||
|
int16 trivial;
|
||||||
|
int8 nofail;
|
||||||
|
int8 replace_container;
|
||||||
|
std::string notes;
|
||||||
|
int8 must_learn;
|
||||||
|
int8 quest;
|
||||||
|
int8 enabled;
|
||||||
|
int8 min_expansion;
|
||||||
|
int8 max_expansion;
|
||||||
|
std::string content_flags;
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::string PrimaryKey()
|
||||||
|
{
|
||||||
|
return std::string("id");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> Columns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"id",
|
||||||
|
"name",
|
||||||
|
"tradeskill",
|
||||||
|
"skillneeded",
|
||||||
|
"trivial",
|
||||||
|
"nofail",
|
||||||
|
"replace_container",
|
||||||
|
"notes",
|
||||||
|
"must_learn",
|
||||||
|
"quest",
|
||||||
|
"enabled",
|
||||||
|
"min_expansion",
|
||||||
|
"max_expansion",
|
||||||
|
"content_flags",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string ColumnsRaw()
|
||||||
|
{
|
||||||
|
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()
|
||||||
|
{
|
||||||
|
return std::string("tradeskill_recipe");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseSelect()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"SELECT {} FROM {}",
|
||||||
|
ColumnsRaw(),
|
||||||
|
TableName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseInsert()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"INSERT INTO {} ({}) ",
|
||||||
|
TableName(),
|
||||||
|
InsertColumnsRaw()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static TradeskillRecipe NewEntity()
|
||||||
|
{
|
||||||
|
TradeskillRecipe entry{};
|
||||||
|
|
||||||
|
entry.id = 0;
|
||||||
|
entry.name = "";
|
||||||
|
entry.tradeskill = 0;
|
||||||
|
entry.skillneeded = 0;
|
||||||
|
entry.trivial = 0;
|
||||||
|
entry.nofail = 0;
|
||||||
|
entry.replace_container = 0;
|
||||||
|
entry.notes = "";
|
||||||
|
entry.must_learn = 0;
|
||||||
|
entry.quest = 0;
|
||||||
|
entry.enabled = 1;
|
||||||
|
entry.min_expansion = 0;
|
||||||
|
entry.max_expansion = 0;
|
||||||
|
entry.content_flags = "";
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static TradeskillRecipe GetTradeskillRecipeEntry(
|
||||||
|
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(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE id = {} LIMIT 1",
|
||||||
|
BaseSelect(),
|
||||||
|
tradeskill_recipe_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
auto row = results.begin();
|
||||||
|
if (results.RowCount() == 1) {
|
||||||
|
TradeskillRecipe entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.name = row[1] ? 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] ? row[7] : "";
|
||||||
|
entry.must_learn = atoi(row[8]);
|
||||||
|
entry.quest = atoi(row[9]);
|
||||||
|
entry.enabled = atoi(row[10]);
|
||||||
|
entry.min_expansion = atoi(row[11]);
|
||||||
|
entry.max_expansion = atoi(row[12]);
|
||||||
|
entry.content_flags = row[13] ? row[13] : "";
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteOne(
|
||||||
|
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));
|
||||||
|
update_values.push_back(columns[11] + " = " + std::to_string(tradeskill_recipe_entry.min_expansion));
|
||||||
|
update_values.push_back(columns[12] + " = " + std::to_string(tradeskill_recipe_entry.max_expansion));
|
||||||
|
update_values.push_back(columns[13] + " = '" + EscapeString(tradeskill_recipe_entry.content_flags) + "'");
|
||||||
|
|
||||||
|
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));
|
||||||
|
insert_values.push_back(std::to_string(tradeskill_recipe_entry.min_expansion));
|
||||||
|
insert_values.push_back(std::to_string(tradeskill_recipe_entry.max_expansion));
|
||||||
|
insert_values.push_back("'" + EscapeString(tradeskill_recipe_entry.content_flags) + "'");
|
||||||
|
|
||||||
|
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 = 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_values.push_back(std::to_string(tradeskill_recipe_entry.min_expansion));
|
||||||
|
insert_values.push_back(std::to_string(tradeskill_recipe_entry.max_expansion));
|
||||||
|
insert_values.push_back("'" + EscapeString(tradeskill_recipe_entry.content_flags) + "'");
|
||||||
|
|
||||||
|
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] ? 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] ? row[7] : "";
|
||||||
|
entry.must_learn = atoi(row[8]);
|
||||||
|
entry.quest = atoi(row[9]);
|
||||||
|
entry.enabled = atoi(row[10]);
|
||||||
|
entry.min_expansion = atoi(row[11]);
|
||||||
|
entry.max_expansion = atoi(row[12]);
|
||||||
|
entry.content_flags = row[13] ? row[13] : "";
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<TradeskillRecipe> GetWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
std::vector<TradeskillRecipe> all_entries;
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {}",
|
||||||
|
BaseSelect(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
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] ? 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] ? row[7] : "";
|
||||||
|
entry.must_learn = atoi(row[8]);
|
||||||
|
entry.quest = atoi(row[9]);
|
||||||
|
entry.enabled = atoi(row[10]);
|
||||||
|
entry.min_expansion = atoi(row[11]);
|
||||||
|
entry.max_expansion = atoi(row[12]);
|
||||||
|
entry.content_flags = row[13] ? row[13] : "";
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {}",
|
||||||
|
TableName(),
|
||||||
|
PrimaryKey(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_BASE_TRADESKILL_RECIPE_REPOSITORY_H
|
||||||
@ -23,58 +23,45 @@
|
|||||||
|
|
||||||
#include "../database.h"
|
#include "../database.h"
|
||||||
#include "../string_util.h"
|
#include "../string_util.h"
|
||||||
|
#include "base/base_grid_repository.h"
|
||||||
|
|
||||||
class GridRepository {
|
class GridRepository : public BaseGridRepository {
|
||||||
public:
|
public:
|
||||||
struct Grid {
|
|
||||||
int id;
|
|
||||||
int zoneid;
|
|
||||||
int type;
|
|
||||||
int type2;
|
|
||||||
};
|
|
||||||
|
|
||||||
static std::vector<std::string> Columns()
|
/**
|
||||||
{
|
* This file was auto generated on Apr 5, 2020 and can be modified and extended upon
|
||||||
return {
|
*
|
||||||
"id",
|
* Base repository methods are automatically
|
||||||
"zoneid",
|
* generated in the "base" version of this repository. The base repository
|
||||||
"type",
|
* is immutable and to be left untouched, while methods in this class
|
||||||
"type2",
|
* are used as extension methods for more specific persistence-layer
|
||||||
};
|
* accessors or mutators
|
||||||
}
|
*
|
||||||
|
* Base Methods (Subject to be expanded upon in time)
|
||||||
|
*
|
||||||
|
* InsertOne
|
||||||
|
* UpdateOne
|
||||||
|
* DeleteOne
|
||||||
|
* FindOne
|
||||||
|
* GetWhere(std::string where_filter)
|
||||||
|
* DeleteWhere(std::string where_filter)
|
||||||
|
* InsertMany
|
||||||
|
* All
|
||||||
|
*
|
||||||
|
* Example custom methods in a repository
|
||||||
|
*
|
||||||
|
* GridRepository::GetByZoneAndVersion(int zone_id, int zone_version)
|
||||||
|
* GridRepository::GetWhereNeverExpires()
|
||||||
|
* GridRepository::GetWhereXAndY()
|
||||||
|
* GridRepository::DeleteWhereXAndY()
|
||||||
|
*
|
||||||
|
* Most of the above could be covered by base methods, but if you as a developer
|
||||||
|
* find yourself re-using logic for other parts of the code, its best to just make a
|
||||||
|
* method that can be re-used easily elsewhere especially if it can use a base repository
|
||||||
|
* method and encapsulate filters there
|
||||||
|
*/
|
||||||
|
|
||||||
static std::string ColumnsRaw()
|
// Custom extended repository methods here
|
||||||
{
|
|
||||||
return std::string(implode(", ", Columns()));
|
|
||||||
}
|
|
||||||
|
|
||||||
static std::string TableName()
|
|
||||||
{
|
|
||||||
return std::string("grid");
|
|
||||||
}
|
|
||||||
|
|
||||||
static std::string BaseSelect()
|
|
||||||
{
|
|
||||||
return std::string(
|
|
||||||
fmt::format(
|
|
||||||
"SELECT {} FROM {}",
|
|
||||||
ColumnsRaw(),
|
|
||||||
TableName()
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
static Grid NewEntity()
|
|
||||||
{
|
|
||||||
Grid entry{};
|
|
||||||
|
|
||||||
entry.id = 0;
|
|
||||||
entry.zoneid = 0;
|
|
||||||
entry.type = 0;
|
|
||||||
entry.type2 = 0;
|
|
||||||
|
|
||||||
return entry;
|
|
||||||
}
|
|
||||||
|
|
||||||
static std::vector<Grid> GetZoneGrids(int zone_id)
|
static std::vector<Grid> GetZoneGrids(int zone_id)
|
||||||
{
|
{
|
||||||
@ -118,4 +105,4 @@ public:
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif //EQEMU_GRID_REPOSITORY_H
|
||||||
|
|||||||
@ -23,112 +23,48 @@
|
|||||||
|
|
||||||
#include "../database.h"
|
#include "../database.h"
|
||||||
#include "../string_util.h"
|
#include "../string_util.h"
|
||||||
|
#include "base/base_tradeskill_recipe_repository.h"
|
||||||
|
|
||||||
class TradeskillRecipeRepository {
|
class TradeskillRecipeRepository: public BaseTradeskillRecipeRepository {
|
||||||
public:
|
public:
|
||||||
struct TradeskillRecipe {
|
|
||||||
int id;
|
|
||||||
std::string name;
|
|
||||||
int tradeskill;
|
|
||||||
int skillneeded;
|
|
||||||
int trivial;
|
|
||||||
uint8 nofail;
|
|
||||||
int replace_container;
|
|
||||||
std::string notes;
|
|
||||||
uint8 must_learn;
|
|
||||||
uint8 quest;
|
|
||||||
uint8 enabled;
|
|
||||||
};
|
|
||||||
|
|
||||||
static std::vector<std::string> Columns()
|
/**
|
||||||
{
|
* This file was auto generated on Apr 5, 2020 and can be modified and extended upon
|
||||||
return {
|
*
|
||||||
"id",
|
* Base repository methods are automatically
|
||||||
"name",
|
* generated in the "base" version of this repository. The base repository
|
||||||
"tradeskill",
|
* is immutable and to be left untouched, while methods in this class
|
||||||
"skillneeded",
|
* are used as extension methods for more specific persistence-layer
|
||||||
"trivial",
|
* accessors or mutators
|
||||||
"nofail",
|
*
|
||||||
"replace_container",
|
* Base Methods (Subject to be expanded upon in time)
|
||||||
"notes",
|
*
|
||||||
"must_learn",
|
* InsertOne
|
||||||
"quest",
|
* UpdateOne
|
||||||
"enabled",
|
* DeleteOne
|
||||||
};
|
* FindOne
|
||||||
}
|
* GetWhere(std::string where_filter)
|
||||||
|
* DeleteWhere(std::string where_filter)
|
||||||
|
* InsertMany
|
||||||
|
* All
|
||||||
|
*
|
||||||
|
* Example custom methods in a repository
|
||||||
|
*
|
||||||
|
* TradeskillRecipeRepository::GetByZoneAndVersion(int zone_id, int zone_version)
|
||||||
|
* TradeskillRecipeRepository::GetWhereNeverExpires()
|
||||||
|
* TradeskillRecipeRepository::GetWhereXAndY()
|
||||||
|
* TradeskillRecipeRepository::DeleteWhereXAndY()
|
||||||
|
*
|
||||||
|
* Most of the above could be covered by base methods, but if you as a developer
|
||||||
|
* find yourself re-using logic for other parts of the code, its best to just make a
|
||||||
|
* method that can be re-used easily elsewhere especially if it can use a base repository
|
||||||
|
* method and encapsulate filters there
|
||||||
|
*/
|
||||||
|
|
||||||
static std::string ColumnsRaw()
|
// Custom extended repository methods here
|
||||||
{
|
|
||||||
return std::string(implode(", ", Columns()));
|
|
||||||
}
|
|
||||||
|
|
||||||
static std::string TableName()
|
|
||||||
{
|
|
||||||
return std::string("tradeskill_recipe");
|
|
||||||
}
|
|
||||||
|
|
||||||
static std::string BaseSelect()
|
|
||||||
{
|
|
||||||
return std::string(
|
|
||||||
fmt::format(
|
|
||||||
"SELECT {} FROM {}",
|
|
||||||
ColumnsRaw(),
|
|
||||||
TableName()
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
static TradeskillRecipe NewEntity()
|
|
||||||
{
|
|
||||||
TradeskillRecipe entry;
|
|
||||||
|
|
||||||
entry.id = 0;
|
|
||||||
entry.name = "";
|
|
||||||
entry.tradeskill = 0;
|
|
||||||
entry.skillneeded = 0;
|
|
||||||
entry.trivial = 0;
|
|
||||||
entry.nofail = 0;
|
|
||||||
entry.replace_container = 0;
|
|
||||||
entry.notes = "";
|
|
||||||
entry.must_learn = 0;
|
|
||||||
entry.quest = 0;
|
|
||||||
entry.enabled = 0;
|
|
||||||
|
|
||||||
return entry;
|
|
||||||
}
|
|
||||||
|
|
||||||
static TradeskillRecipe GetRecipe(int recipe_id)
|
|
||||||
{
|
|
||||||
auto results = content_db.QueryDatabase(
|
|
||||||
fmt::format(
|
|
||||||
"{} WHERE id = {}",
|
|
||||||
BaseSelect(),
|
|
||||||
recipe_id
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
TradeskillRecipe tradeskill_recipe = NewEntity();
|
|
||||||
|
|
||||||
auto row = results.begin();
|
|
||||||
if (results.RowCount() == 0) {
|
|
||||||
return tradeskill_recipe;
|
|
||||||
}
|
|
||||||
|
|
||||||
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]);
|
|
||||||
|
|
||||||
return tradeskill_recipe;
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif //EQEMU_TRADESKILL_RECIPE_REPOSITORY_H
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
# Author: Akkadius
|
# Author: Akkadius
|
||||||
# @file: repository-generator.pl
|
# @file: repository-generator.pl
|
||||||
# @description: Script used to generate database repositories
|
# @description: Script used to generate database repositories
|
||||||
# @example perl ~/code/utils/scripts/generators/repository-generator.pl ~/server/
|
# @example perl ~/code/utils/scripts/generators/repository-generator.pl ~/server/ [table|all] [base|extended|all]
|
||||||
|
|
||||||
#############################################
|
#############################################
|
||||||
# modules
|
# modules
|
||||||
@ -20,9 +20,10 @@ my $json = new JSON();
|
|||||||
#############################################
|
#############################################
|
||||||
# args
|
# args
|
||||||
#############################################
|
#############################################
|
||||||
my $server_path = $ARGV[0];
|
my $server_path = $ARGV[0];
|
||||||
my $config_path = $server_path . "/eqemu_config.json";
|
my $config_path = $server_path . "/eqemu_config.json";
|
||||||
my $requested_table_to_generate = $ARGV[1] ? $ARGV[1] : "";
|
my $requested_table_to_generate = $ARGV[1] ? $ARGV[1] : "all";
|
||||||
|
my $repository_generation_option = $ARGV[2] ? $ARGV[2] : "all";
|
||||||
|
|
||||||
#############################################
|
#############################################
|
||||||
# world path
|
# world path
|
||||||
@ -118,10 +119,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", # Manually created
|
||||||
"grid_entries", # Manually created
|
"grid_entries", # Manually created
|
||||||
"tradeskill_recipe", # Manually created
|
# "tradeskill_recipe", # Manually created
|
||||||
"character_recipe_list", # Manually created
|
# "character_recipe_list", # Manually created
|
||||||
"guild_bank",
|
"guild_bank",
|
||||||
"inventory_versions",
|
"inventory_versions",
|
||||||
"raid_leaders",
|
"raid_leaders",
|
||||||
@ -388,39 +389,48 @@ foreach my $table_to_generate (@tables) {
|
|||||||
$new_repository =~ s/\{\{ALL_ENTRIES}}/$all_entries/g;
|
$new_repository =~ s/\{\{ALL_ENTRIES}}/$all_entries/g;
|
||||||
$new_repository =~ s/\{\{GENERATED_DATE}}/$generated_date/g;
|
$new_repository =~ s/\{\{GENERATED_DATE}}/$generated_date/g;
|
||||||
|
|
||||||
print $new_base_repository;
|
if ($repository_generation_option eq "all" || $repository_generation_option eq "base") {
|
||||||
print $new_repository;
|
print $new_base_repository;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($repository_generation_option eq "all" || $repository_generation_option eq "extended") {
|
||||||
|
print $new_repository;
|
||||||
|
}
|
||||||
|
|
||||||
#############################################
|
#############################################
|
||||||
# write base repository
|
# write base repository
|
||||||
#############################################
|
#############################################
|
||||||
my $generated_base_repository = './common/repositories/base/base_' . $table_to_generate . '_repository.h';
|
if ($repository_generation_option eq "all" || $repository_generation_option eq "base") {
|
||||||
my $cmake_generated_base_reference = $generated_base_repository;
|
my $generated_base_repository = './common/repositories/base/base_' . $table_to_generate . '_repository.h';
|
||||||
$cmake_generated_base_reference =~ s/.\/common\///g;
|
my $cmake_generated_base_reference = $generated_base_repository;
|
||||||
$generated_base_repository_files .= $cmake_generated_base_reference . "\n";
|
$cmake_generated_base_reference =~ s/.\/common\///g;
|
||||||
open(FH, '>', $generated_base_repository) or die $!;
|
$generated_base_repository_files .= $cmake_generated_base_reference . "\n";
|
||||||
print FH $new_base_repository;
|
open(FH, '>', $generated_base_repository) or die $!;
|
||||||
close(FH);
|
print FH $new_base_repository;
|
||||||
|
close(FH);
|
||||||
|
}
|
||||||
|
|
||||||
#############################################
|
#############################################
|
||||||
# write repository
|
# write extended repository
|
||||||
#############################################
|
#############################################
|
||||||
my $generated_repository = './common/repositories/' . $table_to_generate . '_repository.h';
|
if ($repository_generation_option eq "all" || $repository_generation_option eq "extended") {
|
||||||
my $cmake_generated_reference = $generated_repository;
|
my $generated_repository = './common/repositories/' . $table_to_generate . '_repository.h';
|
||||||
$cmake_generated_reference =~ s/.\/common\///g;
|
my $cmake_generated_reference = $generated_repository;
|
||||||
$generated_repository_files .= $cmake_generated_reference . "\n";
|
$cmake_generated_reference =~ s/.\/common\///g;
|
||||||
open(FH, '>', $generated_repository) or die $!;
|
$generated_repository_files .= $cmake_generated_reference . "\n";
|
||||||
print FH $new_repository;
|
open(FH, '>', $generated_repository) or die $!;
|
||||||
close(FH);
|
print FH $new_repository;
|
||||||
|
close(FH);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
print "\n# Make sure to add generated repositories to common/CMakeLists.txt under the repositories section\n\n";
|
print "\n# Make sure to add generated repositories to common/CMakeLists.txt under the repositories section\n\n";
|
||||||
|
|
||||||
print "\n#Base repository files\n";
|
print "\n#Base Repositories\n";
|
||||||
print $generated_base_repository_files . "\n";
|
print $generated_base_repository_files . "\n";
|
||||||
|
|
||||||
print "\n#repository files\n";
|
print "\n#Extended Repositories\n";
|
||||||
print $generated_repository_files . "\n";
|
print $generated_repository_files . "\n";
|
||||||
|
|
||||||
sub trim {
|
sub trim {
|
||||||
|
|||||||
@ -993,7 +993,7 @@ bool Client::TradeskillExecute(DBTradeskillRecipe_Struct *spec) {
|
|||||||
aa_chance = spellbonuses.ReduceTradeskillFail[spec->tradeskill] + itembonuses.ReduceTradeskillFail[spec->tradeskill] + aabonuses.ReduceTradeskillFail[spec->tradeskill];
|
aa_chance = spellbonuses.ReduceTradeskillFail[spec->tradeskill] + itembonuses.ReduceTradeskillFail[spec->tradeskill] + aabonuses.ReduceTradeskillFail[spec->tradeskill];
|
||||||
|
|
||||||
const EQEmu::ItemData* item = nullptr;
|
const EQEmu::ItemData* item = nullptr;
|
||||||
|
|
||||||
chance = mod_tradeskill_chance(chance, spec);
|
chance = mod_tradeskill_chance(chance, spec);
|
||||||
|
|
||||||
if (((spec->tradeskill==75) || GetGM() || (chance > res)) || zone->random.Roll(aa_chance)) {
|
if (((spec->tradeskill==75) || GetGM() || (chance > res)) || zone->random.Roll(aa_chance)) {
|
||||||
@ -1497,7 +1497,7 @@ void Client::LearnRecipe(uint32 recipe_id)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto tradeskill_recipe = TradeskillRecipeRepository::GetRecipe(recipe_id);
|
auto tradeskill_recipe = TradeskillRecipeRepository::FindOne(recipe_id);
|
||||||
if (tradeskill_recipe.id == 0) {
|
if (tradeskill_recipe.id == 0) {
|
||||||
LogError("Invalid recipe [{}]", recipe_id);
|
LogError("Invalid recipe [{}]", recipe_id);
|
||||||
return;
|
return;
|
||||||
@ -1542,8 +1542,8 @@ bool Client::CanIncreaseTradeskill(EQEmu::skills::SkillType tradeskill) {
|
|||||||
uint8 Tailoring = (GetRawSkill(EQEmu::skills::SkillTailoring) > 200) ? 1 : 0;
|
uint8 Tailoring = (GetRawSkill(EQEmu::skills::SkillTailoring) > 200) ? 1 : 0;
|
||||||
uint8 SkillTotal = Baking + Smithing + Brewing + Fletching + Jewelry + Pottery + Tailoring; //Tradeskills above 200
|
uint8 SkillTotal = Baking + Smithing + Brewing + Fletching + Jewelry + Pottery + Tailoring; //Tradeskills above 200
|
||||||
//New Tanaan AA: Each level allows an additional tradeskill above 200 (first one is free)
|
//New Tanaan AA: Each level allows an additional tradeskill above 200 (first one is free)
|
||||||
uint8 aaLevel = spellbonuses.TradeSkillMastery + itembonuses.TradeSkillMastery + aabonuses.TradeSkillMastery;
|
uint8 aaLevel = spellbonuses.TradeSkillMastery + itembonuses.TradeSkillMastery + aabonuses.TradeSkillMastery;
|
||||||
|
|
||||||
switch (tradeskill) {
|
switch (tradeskill) {
|
||||||
case EQEmu::skills::SkillBaking:
|
case EQEmu::skills::SkillBaking:
|
||||||
case EQEmu::skills::SkillBlacksmithing:
|
case EQEmu::skills::SkillBlacksmithing:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user