mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-17 03:08:26 +00:00
[Dynamic Zones] Implement dz templates (#2345)
This allows shared tasks to create dz instances automatically through the `dz_template_id` field instead of using quest scripts. Quest apis were also added to create expeditions from template ids.
This commit is contained in:
@@ -185,6 +185,7 @@ SET(repositories
|
||||
repositories/base/base_doors_repository.h
|
||||
repositories/base/base_dynamic_zones_repository.h
|
||||
repositories/base/base_dynamic_zone_members_repository.h
|
||||
repositories/base/base_dynamic_zone_templates_repository.h
|
||||
repositories/base/base_eventlog_repository.h
|
||||
repositories/base/base_expeditions_repository.h
|
||||
repositories/base/base_expedition_lockouts_repository.h
|
||||
@@ -358,6 +359,7 @@ SET(repositories
|
||||
repositories/doors_repository.h
|
||||
repositories/dynamic_zones_repository.h
|
||||
repositories/dynamic_zone_members_repository.h
|
||||
repositories/dynamic_zone_templates_repository.h
|
||||
repositories/eventlog_repository.h
|
||||
repositories/expeditions_repository.h
|
||||
repositories/expedition_lockouts_repository.h
|
||||
|
||||
@@ -189,6 +189,7 @@ namespace DatabaseSchema {
|
||||
"char_create_point_allocations",
|
||||
"damageshieldtypes",
|
||||
"doors",
|
||||
"dynamic_zone_templates",
|
||||
"faction_base_data",
|
||||
"faction_list",
|
||||
"faction_list_mod",
|
||||
|
||||
@@ -622,3 +622,28 @@ void DynamicZoneBase::LoadSerializedDzPacket(char* cereal_data, uint32_t cereal_
|
||||
cereal::BinaryInputArchive archive(ss);
|
||||
archive(*this);
|
||||
}
|
||||
|
||||
void DynamicZoneBase::LoadTemplate(const DynamicZoneTemplatesRepository::DynamicZoneTemplates& dz_template)
|
||||
{
|
||||
m_zone_id = dz_template.zone_id;
|
||||
m_zone_version = dz_template.zone_version;
|
||||
m_name = dz_template.name;
|
||||
m_min_players = dz_template.min_players;
|
||||
m_max_players = dz_template.max_players;
|
||||
m_duration = std::chrono::seconds(dz_template.duration_seconds);
|
||||
m_dz_switch_id = dz_template.dz_switch_id;
|
||||
m_compass.zone_id = dz_template.compass_zone_id;
|
||||
m_compass.x = dz_template.compass_x;
|
||||
m_compass.y = dz_template.compass_y;
|
||||
m_compass.z = dz_template.compass_z;
|
||||
m_safereturn.zone_id = dz_template.return_zone_id;
|
||||
m_safereturn.x = dz_template.return_x;
|
||||
m_safereturn.y = dz_template.return_y;
|
||||
m_safereturn.z = dz_template.return_z;
|
||||
m_safereturn.heading = dz_template.return_h;
|
||||
m_has_zonein = dz_template.override_zone_in;
|
||||
m_zonein.x = dz_template.zone_in_x;
|
||||
m_zonein.y = dz_template.zone_in_y;
|
||||
m_zonein.z = dz_template.zone_in_z;
|
||||
m_zonein.heading = dz_template.zone_in_h;
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "net/packet.h"
|
||||
#include "repositories/dynamic_zones_repository.h"
|
||||
#include "repositories/dynamic_zone_members_repository.h"
|
||||
#include "repositories/dynamic_zone_templates_repository.h"
|
||||
#include <algorithm>
|
||||
#include <chrono>
|
||||
#include <cstdint>
|
||||
@@ -74,6 +75,7 @@ public:
|
||||
|
||||
virtual void SetSecondsRemaining(uint32_t seconds_remaining) = 0;
|
||||
|
||||
int GetDuration() const { return static_cast<int>(m_duration.count()); }
|
||||
uint64_t GetExpireTime() const { return std::chrono::system_clock::to_time_t(m_expire_time); }
|
||||
uint32_t GetID() const { return m_id; }
|
||||
uint16_t GetInstanceID() const { return static_cast<uint16_t>(m_instance_id); }
|
||||
@@ -113,6 +115,7 @@ public:
|
||||
bool IsValid() const { return m_instance_id != 0; }
|
||||
bool IsSameDz(uint32_t zone_id, uint32_t instance_id) const { return zone_id == m_zone_id && instance_id == m_instance_id; }
|
||||
void LoadSerializedDzPacket(char* cereal_data, uint32_t cereal_size);
|
||||
void LoadTemplate(const DynamicZoneTemplatesRepository::DynamicZoneTemplates& dz_template);
|
||||
void RemoveAllMembers();
|
||||
bool RemoveMember(uint32_t character_id);
|
||||
bool RemoveMember(const std::string& character_name);
|
||||
|
||||
@@ -0,0 +1,506 @@
|
||||
/**
|
||||
* DO NOT MODIFY THIS FILE
|
||||
*
|
||||
* This repository was automatically generated 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
|
||||
*
|
||||
* @generator ./utils/scripts/generators/repository-generator.pl
|
||||
* @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories
|
||||
*/
|
||||
|
||||
#ifndef EQEMU_BASE_DYNAMIC_ZONE_TEMPLATES_REPOSITORY_H
|
||||
#define EQEMU_BASE_DYNAMIC_ZONE_TEMPLATES_REPOSITORY_H
|
||||
|
||||
#include "../../database.h"
|
||||
#include "../../strings.h"
|
||||
#include <ctime>
|
||||
|
||||
class BaseDynamicZoneTemplatesRepository {
|
||||
public:
|
||||
struct DynamicZoneTemplates {
|
||||
int id;
|
||||
int zone_id;
|
||||
int zone_version;
|
||||
std::string name;
|
||||
int min_players;
|
||||
int max_players;
|
||||
int duration_seconds;
|
||||
int dz_switch_id;
|
||||
int compass_zone_id;
|
||||
float compass_x;
|
||||
float compass_y;
|
||||
float compass_z;
|
||||
int return_zone_id;
|
||||
float return_x;
|
||||
float return_y;
|
||||
float return_z;
|
||||
float return_h;
|
||||
int override_zone_in;
|
||||
float zone_in_x;
|
||||
float zone_in_y;
|
||||
float zone_in_z;
|
||||
float zone_in_h;
|
||||
};
|
||||
|
||||
static std::string PrimaryKey()
|
||||
{
|
||||
return std::string("id");
|
||||
}
|
||||
|
||||
static std::vector<std::string> Columns()
|
||||
{
|
||||
return {
|
||||
"id",
|
||||
"zone_id",
|
||||
"zone_version",
|
||||
"name",
|
||||
"min_players",
|
||||
"max_players",
|
||||
"duration_seconds",
|
||||
"dz_switch_id",
|
||||
"compass_zone_id",
|
||||
"compass_x",
|
||||
"compass_y",
|
||||
"compass_z",
|
||||
"return_zone_id",
|
||||
"return_x",
|
||||
"return_y",
|
||||
"return_z",
|
||||
"return_h",
|
||||
"override_zone_in",
|
||||
"zone_in_x",
|
||||
"zone_in_y",
|
||||
"zone_in_z",
|
||||
"zone_in_h",
|
||||
};
|
||||
}
|
||||
|
||||
static std::vector<std::string> SelectColumns()
|
||||
{
|
||||
return {
|
||||
"id",
|
||||
"zone_id",
|
||||
"zone_version",
|
||||
"name",
|
||||
"min_players",
|
||||
"max_players",
|
||||
"duration_seconds",
|
||||
"dz_switch_id",
|
||||
"compass_zone_id",
|
||||
"compass_x",
|
||||
"compass_y",
|
||||
"compass_z",
|
||||
"return_zone_id",
|
||||
"return_x",
|
||||
"return_y",
|
||||
"return_z",
|
||||
"return_h",
|
||||
"override_zone_in",
|
||||
"zone_in_x",
|
||||
"zone_in_y",
|
||||
"zone_in_z",
|
||||
"zone_in_h",
|
||||
};
|
||||
}
|
||||
|
||||
static std::string ColumnsRaw()
|
||||
{
|
||||
return std::string(Strings::Implode(", ", Columns()));
|
||||
}
|
||||
|
||||
static std::string SelectColumnsRaw()
|
||||
{
|
||||
return std::string(Strings::Implode(", ", SelectColumns()));
|
||||
}
|
||||
|
||||
static std::string TableName()
|
||||
{
|
||||
return std::string("dynamic_zone_templates");
|
||||
}
|
||||
|
||||
static std::string BaseSelect()
|
||||
{
|
||||
return fmt::format(
|
||||
"SELECT {} FROM {}",
|
||||
SelectColumnsRaw(),
|
||||
TableName()
|
||||
);
|
||||
}
|
||||
|
||||
static std::string BaseInsert()
|
||||
{
|
||||
return fmt::format(
|
||||
"INSERT INTO {} ({}) ",
|
||||
TableName(),
|
||||
ColumnsRaw()
|
||||
);
|
||||
}
|
||||
|
||||
static DynamicZoneTemplates NewEntity()
|
||||
{
|
||||
DynamicZoneTemplates entry{};
|
||||
|
||||
entry.id = 0;
|
||||
entry.zone_id = 0;
|
||||
entry.zone_version = 0;
|
||||
entry.name = "";
|
||||
entry.min_players = 0;
|
||||
entry.max_players = 0;
|
||||
entry.duration_seconds = 0;
|
||||
entry.dz_switch_id = 0;
|
||||
entry.compass_zone_id = 0;
|
||||
entry.compass_x = 0;
|
||||
entry.compass_y = 0;
|
||||
entry.compass_z = 0;
|
||||
entry.return_zone_id = 0;
|
||||
entry.return_x = 0;
|
||||
entry.return_y = 0;
|
||||
entry.return_z = 0;
|
||||
entry.return_h = 0;
|
||||
entry.override_zone_in = 0;
|
||||
entry.zone_in_x = 0;
|
||||
entry.zone_in_y = 0;
|
||||
entry.zone_in_z = 0;
|
||||
entry.zone_in_h = 0;
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
static DynamicZoneTemplates GetDynamicZoneTemplatesEntry(
|
||||
const std::vector<DynamicZoneTemplates> &dynamic_zone_templatess,
|
||||
int dynamic_zone_templates_id
|
||||
)
|
||||
{
|
||||
for (auto &dynamic_zone_templates : dynamic_zone_templatess) {
|
||||
if (dynamic_zone_templates.id == dynamic_zone_templates_id) {
|
||||
return dynamic_zone_templates;
|
||||
}
|
||||
}
|
||||
|
||||
return NewEntity();
|
||||
}
|
||||
|
||||
static DynamicZoneTemplates FindOne(
|
||||
Database& db,
|
||||
int dynamic_zone_templates_id
|
||||
)
|
||||
{
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"{} WHERE id = {} LIMIT 1",
|
||||
BaseSelect(),
|
||||
dynamic_zone_templates_id
|
||||
)
|
||||
);
|
||||
|
||||
auto row = results.begin();
|
||||
if (results.RowCount() == 1) {
|
||||
DynamicZoneTemplates entry{};
|
||||
|
||||
entry.id = atoi(row[0]);
|
||||
entry.zone_id = atoi(row[1]);
|
||||
entry.zone_version = atoi(row[2]);
|
||||
entry.name = row[3] ? row[3] : "";
|
||||
entry.min_players = atoi(row[4]);
|
||||
entry.max_players = atoi(row[5]);
|
||||
entry.duration_seconds = atoi(row[6]);
|
||||
entry.dz_switch_id = atoi(row[7]);
|
||||
entry.compass_zone_id = atoi(row[8]);
|
||||
entry.compass_x = static_cast<float>(atof(row[9]));
|
||||
entry.compass_y = static_cast<float>(atof(row[10]));
|
||||
entry.compass_z = static_cast<float>(atof(row[11]));
|
||||
entry.return_zone_id = atoi(row[12]);
|
||||
entry.return_x = static_cast<float>(atof(row[13]));
|
||||
entry.return_y = static_cast<float>(atof(row[14]));
|
||||
entry.return_z = static_cast<float>(atof(row[15]));
|
||||
entry.return_h = static_cast<float>(atof(row[16]));
|
||||
entry.override_zone_in = atoi(row[17]);
|
||||
entry.zone_in_x = static_cast<float>(atof(row[18]));
|
||||
entry.zone_in_y = static_cast<float>(atof(row[19]));
|
||||
entry.zone_in_z = static_cast<float>(atof(row[20]));
|
||||
entry.zone_in_h = static_cast<float>(atof(row[21]));
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
return NewEntity();
|
||||
}
|
||||
|
||||
static int DeleteOne(
|
||||
Database& db,
|
||||
int dynamic_zone_templates_id
|
||||
)
|
||||
{
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"DELETE FROM {} WHERE {} = {}",
|
||||
TableName(),
|
||||
PrimaryKey(),
|
||||
dynamic_zone_templates_id
|
||||
)
|
||||
);
|
||||
|
||||
return (results.Success() ? results.RowsAffected() : 0);
|
||||
}
|
||||
|
||||
static int UpdateOne(
|
||||
Database& db,
|
||||
DynamicZoneTemplates dynamic_zone_templates_entry
|
||||
)
|
||||
{
|
||||
std::vector<std::string> update_values;
|
||||
|
||||
auto columns = Columns();
|
||||
|
||||
update_values.push_back(columns[1] + " = " + std::to_string(dynamic_zone_templates_entry.zone_id));
|
||||
update_values.push_back(columns[2] + " = " + std::to_string(dynamic_zone_templates_entry.zone_version));
|
||||
update_values.push_back(columns[3] + " = '" + Strings::Escape(dynamic_zone_templates_entry.name) + "'");
|
||||
update_values.push_back(columns[4] + " = " + std::to_string(dynamic_zone_templates_entry.min_players));
|
||||
update_values.push_back(columns[5] + " = " + std::to_string(dynamic_zone_templates_entry.max_players));
|
||||
update_values.push_back(columns[6] + " = " + std::to_string(dynamic_zone_templates_entry.duration_seconds));
|
||||
update_values.push_back(columns[7] + " = " + std::to_string(dynamic_zone_templates_entry.dz_switch_id));
|
||||
update_values.push_back(columns[8] + " = " + std::to_string(dynamic_zone_templates_entry.compass_zone_id));
|
||||
update_values.push_back(columns[9] + " = " + std::to_string(dynamic_zone_templates_entry.compass_x));
|
||||
update_values.push_back(columns[10] + " = " + std::to_string(dynamic_zone_templates_entry.compass_y));
|
||||
update_values.push_back(columns[11] + " = " + std::to_string(dynamic_zone_templates_entry.compass_z));
|
||||
update_values.push_back(columns[12] + " = " + std::to_string(dynamic_zone_templates_entry.return_zone_id));
|
||||
update_values.push_back(columns[13] + " = " + std::to_string(dynamic_zone_templates_entry.return_x));
|
||||
update_values.push_back(columns[14] + " = " + std::to_string(dynamic_zone_templates_entry.return_y));
|
||||
update_values.push_back(columns[15] + " = " + std::to_string(dynamic_zone_templates_entry.return_z));
|
||||
update_values.push_back(columns[16] + " = " + std::to_string(dynamic_zone_templates_entry.return_h));
|
||||
update_values.push_back(columns[17] + " = " + std::to_string(dynamic_zone_templates_entry.override_zone_in));
|
||||
update_values.push_back(columns[18] + " = " + std::to_string(dynamic_zone_templates_entry.zone_in_x));
|
||||
update_values.push_back(columns[19] + " = " + std::to_string(dynamic_zone_templates_entry.zone_in_y));
|
||||
update_values.push_back(columns[20] + " = " + std::to_string(dynamic_zone_templates_entry.zone_in_z));
|
||||
update_values.push_back(columns[21] + " = " + std::to_string(dynamic_zone_templates_entry.zone_in_h));
|
||||
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"UPDATE {} SET {} WHERE {} = {}",
|
||||
TableName(),
|
||||
Strings::Implode(", ", update_values),
|
||||
PrimaryKey(),
|
||||
dynamic_zone_templates_entry.id
|
||||
)
|
||||
);
|
||||
|
||||
return (results.Success() ? results.RowsAffected() : 0);
|
||||
}
|
||||
|
||||
static DynamicZoneTemplates InsertOne(
|
||||
Database& db,
|
||||
DynamicZoneTemplates dynamic_zone_templates_entry
|
||||
)
|
||||
{
|
||||
std::vector<std::string> insert_values;
|
||||
|
||||
insert_values.push_back(std::to_string(dynamic_zone_templates_entry.id));
|
||||
insert_values.push_back(std::to_string(dynamic_zone_templates_entry.zone_id));
|
||||
insert_values.push_back(std::to_string(dynamic_zone_templates_entry.zone_version));
|
||||
insert_values.push_back("'" + Strings::Escape(dynamic_zone_templates_entry.name) + "'");
|
||||
insert_values.push_back(std::to_string(dynamic_zone_templates_entry.min_players));
|
||||
insert_values.push_back(std::to_string(dynamic_zone_templates_entry.max_players));
|
||||
insert_values.push_back(std::to_string(dynamic_zone_templates_entry.duration_seconds));
|
||||
insert_values.push_back(std::to_string(dynamic_zone_templates_entry.dz_switch_id));
|
||||
insert_values.push_back(std::to_string(dynamic_zone_templates_entry.compass_zone_id));
|
||||
insert_values.push_back(std::to_string(dynamic_zone_templates_entry.compass_x));
|
||||
insert_values.push_back(std::to_string(dynamic_zone_templates_entry.compass_y));
|
||||
insert_values.push_back(std::to_string(dynamic_zone_templates_entry.compass_z));
|
||||
insert_values.push_back(std::to_string(dynamic_zone_templates_entry.return_zone_id));
|
||||
insert_values.push_back(std::to_string(dynamic_zone_templates_entry.return_x));
|
||||
insert_values.push_back(std::to_string(dynamic_zone_templates_entry.return_y));
|
||||
insert_values.push_back(std::to_string(dynamic_zone_templates_entry.return_z));
|
||||
insert_values.push_back(std::to_string(dynamic_zone_templates_entry.return_h));
|
||||
insert_values.push_back(std::to_string(dynamic_zone_templates_entry.override_zone_in));
|
||||
insert_values.push_back(std::to_string(dynamic_zone_templates_entry.zone_in_x));
|
||||
insert_values.push_back(std::to_string(dynamic_zone_templates_entry.zone_in_y));
|
||||
insert_values.push_back(std::to_string(dynamic_zone_templates_entry.zone_in_z));
|
||||
insert_values.push_back(std::to_string(dynamic_zone_templates_entry.zone_in_h));
|
||||
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"{} VALUES ({})",
|
||||
BaseInsert(),
|
||||
Strings::Implode(",", insert_values)
|
||||
)
|
||||
);
|
||||
|
||||
if (results.Success()) {
|
||||
dynamic_zone_templates_entry.id = results.LastInsertedID();
|
||||
return dynamic_zone_templates_entry;
|
||||
}
|
||||
|
||||
dynamic_zone_templates_entry = NewEntity();
|
||||
|
||||
return dynamic_zone_templates_entry;
|
||||
}
|
||||
|
||||
static int InsertMany(
|
||||
Database& db,
|
||||
std::vector<DynamicZoneTemplates> dynamic_zone_templates_entries
|
||||
)
|
||||
{
|
||||
std::vector<std::string> insert_chunks;
|
||||
|
||||
for (auto &dynamic_zone_templates_entry: dynamic_zone_templates_entries) {
|
||||
std::vector<std::string> insert_values;
|
||||
|
||||
insert_values.push_back(std::to_string(dynamic_zone_templates_entry.id));
|
||||
insert_values.push_back(std::to_string(dynamic_zone_templates_entry.zone_id));
|
||||
insert_values.push_back(std::to_string(dynamic_zone_templates_entry.zone_version));
|
||||
insert_values.push_back("'" + Strings::Escape(dynamic_zone_templates_entry.name) + "'");
|
||||
insert_values.push_back(std::to_string(dynamic_zone_templates_entry.min_players));
|
||||
insert_values.push_back(std::to_string(dynamic_zone_templates_entry.max_players));
|
||||
insert_values.push_back(std::to_string(dynamic_zone_templates_entry.duration_seconds));
|
||||
insert_values.push_back(std::to_string(dynamic_zone_templates_entry.dz_switch_id));
|
||||
insert_values.push_back(std::to_string(dynamic_zone_templates_entry.compass_zone_id));
|
||||
insert_values.push_back(std::to_string(dynamic_zone_templates_entry.compass_x));
|
||||
insert_values.push_back(std::to_string(dynamic_zone_templates_entry.compass_y));
|
||||
insert_values.push_back(std::to_string(dynamic_zone_templates_entry.compass_z));
|
||||
insert_values.push_back(std::to_string(dynamic_zone_templates_entry.return_zone_id));
|
||||
insert_values.push_back(std::to_string(dynamic_zone_templates_entry.return_x));
|
||||
insert_values.push_back(std::to_string(dynamic_zone_templates_entry.return_y));
|
||||
insert_values.push_back(std::to_string(dynamic_zone_templates_entry.return_z));
|
||||
insert_values.push_back(std::to_string(dynamic_zone_templates_entry.return_h));
|
||||
insert_values.push_back(std::to_string(dynamic_zone_templates_entry.override_zone_in));
|
||||
insert_values.push_back(std::to_string(dynamic_zone_templates_entry.zone_in_x));
|
||||
insert_values.push_back(std::to_string(dynamic_zone_templates_entry.zone_in_y));
|
||||
insert_values.push_back(std::to_string(dynamic_zone_templates_entry.zone_in_z));
|
||||
insert_values.push_back(std::to_string(dynamic_zone_templates_entry.zone_in_h));
|
||||
|
||||
insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")");
|
||||
}
|
||||
|
||||
std::vector<std::string> insert_values;
|
||||
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"{} VALUES {}",
|
||||
BaseInsert(),
|
||||
Strings::Implode(",", insert_chunks)
|
||||
)
|
||||
);
|
||||
|
||||
return (results.Success() ? results.RowsAffected() : 0);
|
||||
}
|
||||
|
||||
static std::vector<DynamicZoneTemplates> All(Database& db)
|
||||
{
|
||||
std::vector<DynamicZoneTemplates> all_entries;
|
||||
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"{}",
|
||||
BaseSelect()
|
||||
)
|
||||
);
|
||||
|
||||
all_entries.reserve(results.RowCount());
|
||||
|
||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||
DynamicZoneTemplates entry{};
|
||||
|
||||
entry.id = atoi(row[0]);
|
||||
entry.zone_id = atoi(row[1]);
|
||||
entry.zone_version = atoi(row[2]);
|
||||
entry.name = row[3] ? row[3] : "";
|
||||
entry.min_players = atoi(row[4]);
|
||||
entry.max_players = atoi(row[5]);
|
||||
entry.duration_seconds = atoi(row[6]);
|
||||
entry.dz_switch_id = atoi(row[7]);
|
||||
entry.compass_zone_id = atoi(row[8]);
|
||||
entry.compass_x = static_cast<float>(atof(row[9]));
|
||||
entry.compass_y = static_cast<float>(atof(row[10]));
|
||||
entry.compass_z = static_cast<float>(atof(row[11]));
|
||||
entry.return_zone_id = atoi(row[12]);
|
||||
entry.return_x = static_cast<float>(atof(row[13]));
|
||||
entry.return_y = static_cast<float>(atof(row[14]));
|
||||
entry.return_z = static_cast<float>(atof(row[15]));
|
||||
entry.return_h = static_cast<float>(atof(row[16]));
|
||||
entry.override_zone_in = atoi(row[17]);
|
||||
entry.zone_in_x = static_cast<float>(atof(row[18]));
|
||||
entry.zone_in_y = static_cast<float>(atof(row[19]));
|
||||
entry.zone_in_z = static_cast<float>(atof(row[20]));
|
||||
entry.zone_in_h = static_cast<float>(atof(row[21]));
|
||||
|
||||
all_entries.push_back(entry);
|
||||
}
|
||||
|
||||
return all_entries;
|
||||
}
|
||||
|
||||
static std::vector<DynamicZoneTemplates> GetWhere(Database& db, std::string where_filter)
|
||||
{
|
||||
std::vector<DynamicZoneTemplates> all_entries;
|
||||
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"{} WHERE {}",
|
||||
BaseSelect(),
|
||||
where_filter
|
||||
)
|
||||
);
|
||||
|
||||
all_entries.reserve(results.RowCount());
|
||||
|
||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||
DynamicZoneTemplates entry{};
|
||||
|
||||
entry.id = atoi(row[0]);
|
||||
entry.zone_id = atoi(row[1]);
|
||||
entry.zone_version = atoi(row[2]);
|
||||
entry.name = row[3] ? row[3] : "";
|
||||
entry.min_players = atoi(row[4]);
|
||||
entry.max_players = atoi(row[5]);
|
||||
entry.duration_seconds = atoi(row[6]);
|
||||
entry.dz_switch_id = atoi(row[7]);
|
||||
entry.compass_zone_id = atoi(row[8]);
|
||||
entry.compass_x = static_cast<float>(atof(row[9]));
|
||||
entry.compass_y = static_cast<float>(atof(row[10]));
|
||||
entry.compass_z = static_cast<float>(atof(row[11]));
|
||||
entry.return_zone_id = atoi(row[12]);
|
||||
entry.return_x = static_cast<float>(atof(row[13]));
|
||||
entry.return_y = static_cast<float>(atof(row[14]));
|
||||
entry.return_z = static_cast<float>(atof(row[15]));
|
||||
entry.return_h = static_cast<float>(atof(row[16]));
|
||||
entry.override_zone_in = atoi(row[17]);
|
||||
entry.zone_in_x = static_cast<float>(atof(row[18]));
|
||||
entry.zone_in_y = static_cast<float>(atof(row[19]));
|
||||
entry.zone_in_z = static_cast<float>(atof(row[20]));
|
||||
entry.zone_in_h = static_cast<float>(atof(row[21]));
|
||||
|
||||
all_entries.push_back(entry);
|
||||
}
|
||||
|
||||
return all_entries;
|
||||
}
|
||||
|
||||
static int DeleteWhere(Database& db, std::string where_filter)
|
||||
{
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"DELETE FROM {} WHERE {}",
|
||||
TableName(),
|
||||
where_filter
|
||||
)
|
||||
);
|
||||
|
||||
return (results.Success() ? results.RowsAffected() : 0);
|
||||
}
|
||||
|
||||
static int Truncate(Database& db)
|
||||
{
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"TRUNCATE TABLE {}",
|
||||
TableName()
|
||||
)
|
||||
);
|
||||
|
||||
return (results.Success() ? results.RowsAffected() : 0);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif //EQEMU_BASE_DYNAMIC_ZONE_TEMPLATES_REPOSITORY_H
|
||||
@@ -44,6 +44,7 @@ public:
|
||||
int replay_timer_seconds;
|
||||
int request_timer_group;
|
||||
int request_timer_seconds;
|
||||
int dz_template_id;
|
||||
int lock_activity_id;
|
||||
};
|
||||
|
||||
@@ -80,6 +81,7 @@ public:
|
||||
"replay_timer_seconds",
|
||||
"request_timer_group",
|
||||
"request_timer_seconds",
|
||||
"dz_template_id",
|
||||
"lock_activity_id",
|
||||
};
|
||||
}
|
||||
@@ -112,6 +114,7 @@ public:
|
||||
"replay_timer_seconds",
|
||||
"request_timer_group",
|
||||
"request_timer_seconds",
|
||||
"dz_template_id",
|
||||
"lock_activity_id",
|
||||
};
|
||||
}
|
||||
@@ -178,6 +181,7 @@ public:
|
||||
entry.replay_timer_seconds = 0;
|
||||
entry.request_timer_group = 0;
|
||||
entry.request_timer_seconds = 0;
|
||||
entry.dz_template_id = 0;
|
||||
entry.lock_activity_id = -1;
|
||||
|
||||
return entry;
|
||||
@@ -239,7 +243,8 @@ public:
|
||||
entry.replay_timer_seconds = atoi(row[22]);
|
||||
entry.request_timer_group = atoi(row[23]);
|
||||
entry.request_timer_seconds = atoi(row[24]);
|
||||
entry.lock_activity_id = atoi(row[25]);
|
||||
entry.dz_template_id = atoi(row[25]);
|
||||
entry.lock_activity_id = atoi(row[26]);
|
||||
|
||||
return entry;
|
||||
}
|
||||
@@ -298,7 +303,8 @@ public:
|
||||
update_values.push_back(columns[22] + " = " + std::to_string(tasks_entry.replay_timer_seconds));
|
||||
update_values.push_back(columns[23] + " = " + std::to_string(tasks_entry.request_timer_group));
|
||||
update_values.push_back(columns[24] + " = " + std::to_string(tasks_entry.request_timer_seconds));
|
||||
update_values.push_back(columns[25] + " = " + std::to_string(tasks_entry.lock_activity_id));
|
||||
update_values.push_back(columns[25] + " = " + std::to_string(tasks_entry.dz_template_id));
|
||||
update_values.push_back(columns[26] + " = " + std::to_string(tasks_entry.lock_activity_id));
|
||||
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
@@ -345,6 +351,7 @@ public:
|
||||
insert_values.push_back(std::to_string(tasks_entry.replay_timer_seconds));
|
||||
insert_values.push_back(std::to_string(tasks_entry.request_timer_group));
|
||||
insert_values.push_back(std::to_string(tasks_entry.request_timer_seconds));
|
||||
insert_values.push_back(std::to_string(tasks_entry.dz_template_id));
|
||||
insert_values.push_back(std::to_string(tasks_entry.lock_activity_id));
|
||||
|
||||
auto results = db.QueryDatabase(
|
||||
@@ -400,6 +407,7 @@ public:
|
||||
insert_values.push_back(std::to_string(tasks_entry.replay_timer_seconds));
|
||||
insert_values.push_back(std::to_string(tasks_entry.request_timer_group));
|
||||
insert_values.push_back(std::to_string(tasks_entry.request_timer_seconds));
|
||||
insert_values.push_back(std::to_string(tasks_entry.dz_template_id));
|
||||
insert_values.push_back(std::to_string(tasks_entry.lock_activity_id));
|
||||
|
||||
insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")");
|
||||
@@ -459,7 +467,8 @@ public:
|
||||
entry.replay_timer_seconds = atoi(row[22]);
|
||||
entry.request_timer_group = atoi(row[23]);
|
||||
entry.request_timer_seconds = atoi(row[24]);
|
||||
entry.lock_activity_id = atoi(row[25]);
|
||||
entry.dz_template_id = atoi(row[25]);
|
||||
entry.lock_activity_id = atoi(row[26]);
|
||||
|
||||
all_entries.push_back(entry);
|
||||
}
|
||||
@@ -509,7 +518,8 @@ public:
|
||||
entry.replay_timer_seconds = atoi(row[22]);
|
||||
entry.request_timer_group = atoi(row[23]);
|
||||
entry.request_timer_seconds = atoi(row[24]);
|
||||
entry.lock_activity_id = atoi(row[25]);
|
||||
entry.dz_template_id = atoi(row[25]);
|
||||
entry.lock_activity_id = atoi(row[26]);
|
||||
|
||||
all_entries.push_back(entry);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef EQEMU_DYNAMIC_ZONE_TEMPLATES_REPOSITORY_H
|
||||
#define EQEMU_DYNAMIC_ZONE_TEMPLATES_REPOSITORY_H
|
||||
|
||||
#include "../database.h"
|
||||
#include "../strings.h"
|
||||
#include "base/base_dynamic_zone_templates_repository.h"
|
||||
|
||||
class DynamicZoneTemplatesRepository: public BaseDynamicZoneTemplatesRepository {
|
||||
public:
|
||||
|
||||
/**
|
||||
* This file was auto generated and can be modified and extended upon
|
||||
*
|
||||
* Base repository methods are automatically
|
||||
* generated in the "base" version of this repository. The base repository
|
||||
* is immutable and to be left untouched, while methods in this class
|
||||
* are used as extension methods for more specific persistence-layer
|
||||
* accessors or mutators.
|
||||
*
|
||||
* Base Methods (Subject to be expanded upon in time)
|
||||
*
|
||||
* Note: Not all tables are designed appropriately to fit functionality with all base methods
|
||||
*
|
||||
* InsertOne
|
||||
* UpdateOne
|
||||
* DeleteOne
|
||||
* FindOne
|
||||
* GetWhere(std::string where_filter)
|
||||
* DeleteWhere(std::string where_filter)
|
||||
* InsertMany
|
||||
* All
|
||||
*
|
||||
* Example custom methods in a repository
|
||||
*
|
||||
* DynamicZoneTemplatesRepository::GetByZoneAndVersion(int zone_id, int zone_version)
|
||||
* DynamicZoneTemplatesRepository::GetWhereNeverExpires()
|
||||
* DynamicZoneTemplatesRepository::GetWhereXAndY()
|
||||
* DynamicZoneTemplatesRepository::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
|
||||
*/
|
||||
|
||||
// Custom extended repository methods here
|
||||
|
||||
};
|
||||
|
||||
#endif //EQEMU_DYNAMIC_ZONE_TEMPLATES_REPOSITORY_H
|
||||
@@ -244,6 +244,7 @@
|
||||
#define ServerOP_ReloadVeteranRewards 0x4118
|
||||
#define ServerOP_ReloadWorld 0x4119
|
||||
#define ServerOP_ReloadZonePoints 0x4120
|
||||
#define ServerOP_ReloadDzTemplates 0x4121
|
||||
|
||||
#define ServerOP_CZDialogueWindow 0x4500
|
||||
#define ServerOP_CZLDoNUpdate 0x4501
|
||||
|
||||
+1
-1
@@ -34,7 +34,7 @@
|
||||
* Manifest: https://github.com/EQEmu/Server/blob/master/utils/sql/db_update_manifest.txt
|
||||
*/
|
||||
|
||||
#define CURRENT_BINARY_DATABASE_VERSION 9194
|
||||
#define CURRENT_BINARY_DATABASE_VERSION 9195
|
||||
|
||||
#ifdef BOTS
|
||||
#define CURRENT_BINARY_BOTS_DATABASE_VERSION 9029
|
||||
|
||||
Reference in New Issue
Block a user