[Tasks] Schema simplification (#2449)

* Combine task_activity item and npc fields

This will make tooling easier.

While denormalizing goallists may not be ideal, it decouples tasks from
rewards which share the table and removes a redundant column in favor
of a using the delimited string which better matches live packet data.

* [Tasks] Deprecate goallists table, migrate reward goal lists, simplify logic

* Update 2022_09_25_task_concat_matchlists.sql

* Update 2022_09_25_task_concat_matchlists.sql

* Tweaks

* Fix reward column name in conversion script

* Task reward stacking

* Update task_client_state.cpp

* Implement stack counts

* Fix reward item instance memory leak

* Validate reward item instance

* Fix item reward message

* Fix findtask

Co-authored-by: Akkadius <akkadius1@gmail.com>
This commit is contained in:
hg
2022-09-28 03:31:05 -04:00
committed by GitHub
parent d22fca7593
commit e883703b2f
23 changed files with 496 additions and 1111 deletions
-2
View File
@@ -207,7 +207,6 @@ SET(repositories
repositories/base/base_friends_repository.h
repositories/base/base_global_loot_repository.h
repositories/base/base_gm_ips_repository.h
repositories/base/base_goallists_repository.h
repositories/base/base_graveyard_repository.h
repositories/base/base_ground_spawns_repository.h
repositories/base/base_group_id_repository.h
@@ -384,7 +383,6 @@ SET(repositories
repositories/friends_repository.h
repositories/global_loot_repository.h
repositories/gm_ips_repository.h
repositories/goallists_repository.h
repositories/graveyard_repository.h
repositories/ground_spawns_repository.h
repositories/group_id_repository.h
-1
View File
@@ -197,7 +197,6 @@ namespace DatabaseSchema {
"fishing",
"forage",
"global_loot",
"goallists",
"graveyard",
"grid",
"grid_entries",
@@ -1,333 +0,0 @@
/**
* 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_GOALLISTS_REPOSITORY_H
#define EQEMU_BASE_GOALLISTS_REPOSITORY_H
#include "../../database.h"
#include "../../strings.h"
#include <ctime>
class BaseGoallistsRepository {
public:
struct Goallists {
uint32_t listid;
uint32_t entry;
};
static std::string PrimaryKey()
{
return std::string("listid");
}
static std::vector<std::string> Columns()
{
return {
"listid",
"entry",
};
}
static std::vector<std::string> SelectColumns()
{
return {
"listid",
"entry",
};
}
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("goallists");
}
static std::string BaseSelect()
{
return fmt::format(
"SELECT {} FROM {}",
SelectColumnsRaw(),
TableName()
);
}
static std::string BaseInsert()
{
return fmt::format(
"INSERT INTO {} ({}) ",
TableName(),
ColumnsRaw()
);
}
static Goallists NewEntity()
{
Goallists e{};
e.listid = 0;
e.entry = 0;
return e;
}
static Goallists GetGoallists(
const std::vector<Goallists> &goallistss,
int goallists_id
)
{
for (auto &goallists : goallistss) {
if (goallists.listid == goallists_id) {
return goallists;
}
}
return NewEntity();
}
static Goallists FindOne(
Database& db,
int goallists_id
)
{
auto results = db.QueryDatabase(
fmt::format(
"{} WHERE id = {} LIMIT 1",
BaseSelect(),
goallists_id
)
);
auto row = results.begin();
if (results.RowCount() == 1) {
Goallists e{};
e.listid = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.entry = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
return e;
}
return NewEntity();
}
static int DeleteOne(
Database& db,
int goallists_id
)
{
auto results = db.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {} = {}",
TableName(),
PrimaryKey(),
goallists_id
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int UpdateOne(
Database& db,
const Goallists &e
)
{
std::vector<std::string> v;
auto columns = Columns();
v.push_back(columns[0] + " = " + std::to_string(e.listid));
v.push_back(columns[1] + " = " + std::to_string(e.entry));
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", v),
PrimaryKey(),
e.listid
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static Goallists InsertOne(
Database& db,
Goallists e
)
{
std::vector<std::string> v;
v.push_back(std::to_string(e.listid));
v.push_back(std::to_string(e.entry));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", v)
)
);
if (results.Success()) {
e.listid = results.LastInsertedID();
return e;
}
e = NewEntity();
return e;
}
static int InsertMany(
Database& db,
const std::vector<Goallists> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &e: entries) {
std::vector<std::string> v;
v.push_back(std::to_string(e.listid));
v.push_back(std::to_string(e.entry));
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
Strings::Implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<Goallists> All(Database& db)
{
std::vector<Goallists> all_entries;
auto results = db.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
Goallists e{};
e.listid = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.entry = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<Goallists> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<Goallists> 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) {
Goallists e{};
e.listid = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.entry = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, const 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);
}
static int64 GetMaxId(Database& db)
{
auto results = db.QueryDatabase(
fmt::format(
"SELECT COALESCE(MAX({}), 0) FROM {}",
PrimaryKey(),
TableName()
)
);
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
}
static int64 Count(Database& db, const std::string &where_filter = "")
{
auto results = db.QueryDatabase(
fmt::format(
"SELECT COUNT(*) FROM {} {}",
TableName(),
(where_filter.empty() ? "" : "WHERE " + where_filter)
)
);
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
}
};
#endif //EQEMU_BASE_GOALLISTS_REPOSITORY_H
@@ -28,11 +28,7 @@ public:
uint32_t goalmethod;
int32_t goalcount;
std::string description_override;
uint32_t npc_id;
uint32_t npc_goal_id;
std::string npc_match_list;
uint32_t item_id;
uint32_t item_goal_id;
std::string item_id_list;
std::string item_list;
int32_t dz_switch_id;
@@ -66,11 +62,7 @@ public:
"goalmethod",
"goalcount",
"description_override",
"npc_id",
"npc_goal_id",
"npc_match_list",
"item_id",
"item_goal_id",
"item_id_list",
"item_list",
"dz_switch_id",
@@ -100,11 +92,7 @@ public:
"goalmethod",
"goalcount",
"description_override",
"npc_id",
"npc_goal_id",
"npc_match_list",
"item_id",
"item_goal_id",
"item_id_list",
"item_list",
"dz_switch_id",
@@ -168,11 +156,7 @@ public:
e.goalmethod = 0;
e.goalcount = 1;
e.description_override = "";
e.npc_id = 0;
e.npc_goal_id = 0;
e.npc_match_list = "";
e.item_id = 0;
e.item_goal_id = 0;
e.item_id_list = "";
e.item_list = "";
e.dz_switch_id = 0;
@@ -231,25 +215,21 @@ public:
e.goalmethod = static_cast<uint32_t>(strtoul(row[6], nullptr, 10));
e.goalcount = static_cast<int32_t>(atoi(row[7]));
e.description_override = row[8] ? row[8] : "";
e.npc_id = static_cast<uint32_t>(strtoul(row[9], nullptr, 10));
e.npc_goal_id = static_cast<uint32_t>(strtoul(row[10], nullptr, 10));
e.npc_match_list = row[11] ? row[11] : "";
e.item_id = static_cast<uint32_t>(strtoul(row[12], nullptr, 10));
e.item_goal_id = static_cast<uint32_t>(strtoul(row[13], nullptr, 10));
e.item_id_list = row[14] ? row[14] : "";
e.item_list = row[15] ? row[15] : "";
e.dz_switch_id = static_cast<int32_t>(atoi(row[16]));
e.min_x = strtof(row[17], nullptr);
e.min_y = strtof(row[18], nullptr);
e.min_z = strtof(row[19], nullptr);
e.max_x = strtof(row[20], nullptr);
e.max_y = strtof(row[21], nullptr);
e.max_z = strtof(row[22], nullptr);
e.skill_list = row[23] ? row[23] : "";
e.spell_list = row[24] ? row[24] : "";
e.zones = row[25] ? row[25] : "";
e.zone_version = static_cast<int32_t>(atoi(row[26]));
e.optional = static_cast<int8_t>(atoi(row[27]));
e.npc_match_list = row[9] ? row[9] : "";
e.item_id_list = row[10] ? row[10] : "";
e.item_list = row[11] ? row[11] : "";
e.dz_switch_id = static_cast<int32_t>(atoi(row[12]));
e.min_x = strtof(row[13], nullptr);
e.min_y = strtof(row[14], nullptr);
e.min_z = strtof(row[15], nullptr);
e.max_x = strtof(row[16], nullptr);
e.max_y = strtof(row[17], nullptr);
e.max_z = strtof(row[18], nullptr);
e.skill_list = row[19] ? row[19] : "";
e.spell_list = row[20] ? row[20] : "";
e.zones = row[21] ? row[21] : "";
e.zone_version = static_cast<int32_t>(atoi(row[22]));
e.optional = static_cast<int8_t>(atoi(row[23]));
return e;
}
@@ -292,25 +272,21 @@ public:
v.push_back(columns[6] + " = " + std::to_string(e.goalmethod));
v.push_back(columns[7] + " = " + std::to_string(e.goalcount));
v.push_back(columns[8] + " = '" + Strings::Escape(e.description_override) + "'");
v.push_back(columns[9] + " = " + std::to_string(e.npc_id));
v.push_back(columns[10] + " = " + std::to_string(e.npc_goal_id));
v.push_back(columns[11] + " = '" + Strings::Escape(e.npc_match_list) + "'");
v.push_back(columns[12] + " = " + std::to_string(e.item_id));
v.push_back(columns[13] + " = " + std::to_string(e.item_goal_id));
v.push_back(columns[14] + " = '" + Strings::Escape(e.item_id_list) + "'");
v.push_back(columns[15] + " = '" + Strings::Escape(e.item_list) + "'");
v.push_back(columns[16] + " = " + std::to_string(e.dz_switch_id));
v.push_back(columns[17] + " = " + std::to_string(e.min_x));
v.push_back(columns[18] + " = " + std::to_string(e.min_y));
v.push_back(columns[19] + " = " + std::to_string(e.min_z));
v.push_back(columns[20] + " = " + std::to_string(e.max_x));
v.push_back(columns[21] + " = " + std::to_string(e.max_y));
v.push_back(columns[22] + " = " + std::to_string(e.max_z));
v.push_back(columns[23] + " = '" + Strings::Escape(e.skill_list) + "'");
v.push_back(columns[24] + " = '" + Strings::Escape(e.spell_list) + "'");
v.push_back(columns[25] + " = '" + Strings::Escape(e.zones) + "'");
v.push_back(columns[26] + " = " + std::to_string(e.zone_version));
v.push_back(columns[27] + " = " + std::to_string(e.optional));
v.push_back(columns[9] + " = '" + Strings::Escape(e.npc_match_list) + "'");
v.push_back(columns[10] + " = '" + Strings::Escape(e.item_id_list) + "'");
v.push_back(columns[11] + " = '" + Strings::Escape(e.item_list) + "'");
v.push_back(columns[12] + " = " + std::to_string(e.dz_switch_id));
v.push_back(columns[13] + " = " + std::to_string(e.min_x));
v.push_back(columns[14] + " = " + std::to_string(e.min_y));
v.push_back(columns[15] + " = " + std::to_string(e.min_z));
v.push_back(columns[16] + " = " + std::to_string(e.max_x));
v.push_back(columns[17] + " = " + std::to_string(e.max_y));
v.push_back(columns[18] + " = " + std::to_string(e.max_z));
v.push_back(columns[19] + " = '" + Strings::Escape(e.skill_list) + "'");
v.push_back(columns[20] + " = '" + Strings::Escape(e.spell_list) + "'");
v.push_back(columns[21] + " = '" + Strings::Escape(e.zones) + "'");
v.push_back(columns[22] + " = " + std::to_string(e.zone_version));
v.push_back(columns[23] + " = " + std::to_string(e.optional));
auto results = db.QueryDatabase(
fmt::format(
@@ -341,11 +317,7 @@ public:
v.push_back(std::to_string(e.goalmethod));
v.push_back(std::to_string(e.goalcount));
v.push_back("'" + Strings::Escape(e.description_override) + "'");
v.push_back(std::to_string(e.npc_id));
v.push_back(std::to_string(e.npc_goal_id));
v.push_back("'" + Strings::Escape(e.npc_match_list) + "'");
v.push_back(std::to_string(e.item_id));
v.push_back(std::to_string(e.item_goal_id));
v.push_back("'" + Strings::Escape(e.item_id_list) + "'");
v.push_back("'" + Strings::Escape(e.item_list) + "'");
v.push_back(std::to_string(e.dz_switch_id));
@@ -398,11 +370,7 @@ public:
v.push_back(std::to_string(e.goalmethod));
v.push_back(std::to_string(e.goalcount));
v.push_back("'" + Strings::Escape(e.description_override) + "'");
v.push_back(std::to_string(e.npc_id));
v.push_back(std::to_string(e.npc_goal_id));
v.push_back("'" + Strings::Escape(e.npc_match_list) + "'");
v.push_back(std::to_string(e.item_id));
v.push_back(std::to_string(e.item_goal_id));
v.push_back("'" + Strings::Escape(e.item_id_list) + "'");
v.push_back("'" + Strings::Escape(e.item_list) + "'");
v.push_back(std::to_string(e.dz_switch_id));
@@ -459,25 +427,21 @@ public:
e.goalmethod = static_cast<uint32_t>(strtoul(row[6], nullptr, 10));
e.goalcount = static_cast<int32_t>(atoi(row[7]));
e.description_override = row[8] ? row[8] : "";
e.npc_id = static_cast<uint32_t>(strtoul(row[9], nullptr, 10));
e.npc_goal_id = static_cast<uint32_t>(strtoul(row[10], nullptr, 10));
e.npc_match_list = row[11] ? row[11] : "";
e.item_id = static_cast<uint32_t>(strtoul(row[12], nullptr, 10));
e.item_goal_id = static_cast<uint32_t>(strtoul(row[13], nullptr, 10));
e.item_id_list = row[14] ? row[14] : "";
e.item_list = row[15] ? row[15] : "";
e.dz_switch_id = static_cast<int32_t>(atoi(row[16]));
e.min_x = strtof(row[17], nullptr);
e.min_y = strtof(row[18], nullptr);
e.min_z = strtof(row[19], nullptr);
e.max_x = strtof(row[20], nullptr);
e.max_y = strtof(row[21], nullptr);
e.max_z = strtof(row[22], nullptr);
e.skill_list = row[23] ? row[23] : "";
e.spell_list = row[24] ? row[24] : "";
e.zones = row[25] ? row[25] : "";
e.zone_version = static_cast<int32_t>(atoi(row[26]));
e.optional = static_cast<int8_t>(atoi(row[27]));
e.npc_match_list = row[9] ? row[9] : "";
e.item_id_list = row[10] ? row[10] : "";
e.item_list = row[11] ? row[11] : "";
e.dz_switch_id = static_cast<int32_t>(atoi(row[12]));
e.min_x = strtof(row[13], nullptr);
e.min_y = strtof(row[14], nullptr);
e.min_z = strtof(row[15], nullptr);
e.max_x = strtof(row[16], nullptr);
e.max_y = strtof(row[17], nullptr);
e.max_z = strtof(row[18], nullptr);
e.skill_list = row[19] ? row[19] : "";
e.spell_list = row[20] ? row[20] : "";
e.zones = row[21] ? row[21] : "";
e.zone_version = static_cast<int32_t>(atoi(row[22]));
e.optional = static_cast<int8_t>(atoi(row[23]));
all_entries.push_back(e);
}
@@ -511,25 +475,21 @@ public:
e.goalmethod = static_cast<uint32_t>(strtoul(row[6], nullptr, 10));
e.goalcount = static_cast<int32_t>(atoi(row[7]));
e.description_override = row[8] ? row[8] : "";
e.npc_id = static_cast<uint32_t>(strtoul(row[9], nullptr, 10));
e.npc_goal_id = static_cast<uint32_t>(strtoul(row[10], nullptr, 10));
e.npc_match_list = row[11] ? row[11] : "";
e.item_id = static_cast<uint32_t>(strtoul(row[12], nullptr, 10));
e.item_goal_id = static_cast<uint32_t>(strtoul(row[13], nullptr, 10));
e.item_id_list = row[14] ? row[14] : "";
e.item_list = row[15] ? row[15] : "";
e.dz_switch_id = static_cast<int32_t>(atoi(row[16]));
e.min_x = strtof(row[17], nullptr);
e.min_y = strtof(row[18], nullptr);
e.min_z = strtof(row[19], nullptr);
e.max_x = strtof(row[20], nullptr);
e.max_y = strtof(row[21], nullptr);
e.max_z = strtof(row[22], nullptr);
e.skill_list = row[23] ? row[23] : "";
e.spell_list = row[24] ? row[24] : "";
e.zones = row[25] ? row[25] : "";
e.zone_version = static_cast<int32_t>(atoi(row[26]));
e.optional = static_cast<int8_t>(atoi(row[27]));
e.npc_match_list = row[9] ? row[9] : "";
e.item_id_list = row[10] ? row[10] : "";
e.item_list = row[11] ? row[11] : "";
e.dz_switch_id = static_cast<int32_t>(atoi(row[12]));
e.min_x = strtof(row[13], nullptr);
e.min_y = strtof(row[14], nullptr);
e.min_z = strtof(row[15], nullptr);
e.max_x = strtof(row[16], nullptr);
e.max_y = strtof(row[17], nullptr);
e.max_z = strtof(row[18], nullptr);
e.skill_list = row[19] ? row[19] : "";
e.spell_list = row[20] ? row[20] : "";
e.zones = row[21] ? row[21] : "";
e.zone_version = static_cast<int32_t>(atoi(row[22]));
e.optional = static_cast<int8_t>(atoi(row[23]));
all_entries.push_back(e);
}
@@ -25,15 +25,15 @@ public:
int8_t duration_code;
std::string title;
std::string description;
std::string reward;
uint32_t rewardid;
uint32_t cashreward;
int32_t xpreward;
uint8_t rewardmethod;
std::string reward_text;
std::string reward_id_list;
uint32_t cash_reward;
int32_t exp_reward;
uint8_t reward_method;
int32_t reward_points;
int32_t reward_point_type;
uint8_t minlevel;
uint8_t maxlevel;
uint8_t min_level;
uint8_t max_level;
uint32_t level_spread;
uint32_t min_players;
uint32_t max_players;
@@ -63,15 +63,15 @@ public:
"duration_code",
"title",
"description",
"reward",
"rewardid",
"cashreward",
"xpreward",
"rewardmethod",
"reward_text",
"reward_id_list",
"cash_reward",
"exp_reward",
"reward_method",
"reward_points",
"reward_point_type",
"minlevel",
"maxlevel",
"min_level",
"max_level",
"level_spread",
"min_players",
"max_players",
@@ -97,15 +97,15 @@ public:
"duration_code",
"title",
"description",
"reward",
"rewardid",
"cashreward",
"xpreward",
"rewardmethod",
"reward_text",
"reward_id_list",
"cash_reward",
"exp_reward",
"reward_method",
"reward_points",
"reward_point_type",
"minlevel",
"maxlevel",
"min_level",
"max_level",
"level_spread",
"min_players",
"max_players",
@@ -165,15 +165,15 @@ public:
e.duration_code = 0;
e.title = "";
e.description = "";
e.reward = "";
e.rewardid = 0;
e.cashreward = 0;
e.xpreward = 0;
e.rewardmethod = 2;
e.reward_text = "";
e.reward_id_list = "";
e.cash_reward = 0;
e.exp_reward = 0;
e.reward_method = 0;
e.reward_points = 0;
e.reward_point_type = 0;
e.minlevel = 0;
e.maxlevel = 0;
e.min_level = 0;
e.max_level = 0;
e.level_spread = 0;
e.min_players = 0;
e.max_players = 0;
@@ -228,15 +228,15 @@ public:
e.duration_code = static_cast<int8_t>(atoi(row[3]));
e.title = row[4] ? row[4] : "";
e.description = row[5] ? row[5] : "";
e.reward = row[6] ? row[6] : "";
e.rewardid = static_cast<uint32_t>(strtoul(row[7], nullptr, 10));
e.cashreward = static_cast<uint32_t>(strtoul(row[8], nullptr, 10));
e.xpreward = static_cast<int32_t>(atoi(row[9]));
e.rewardmethod = static_cast<uint8_t>(strtoul(row[10], nullptr, 10));
e.reward_text = row[6] ? row[6] : "";
e.reward_id_list = row[7] ? row[7] : "";
e.cash_reward = static_cast<uint32_t>(strtoul(row[8], nullptr, 10));
e.exp_reward = static_cast<int32_t>(atoi(row[9]));
e.reward_method = static_cast<uint8_t>(strtoul(row[10], nullptr, 10));
e.reward_points = static_cast<int32_t>(atoi(row[11]));
e.reward_point_type = static_cast<int32_t>(atoi(row[12]));
e.minlevel = static_cast<uint8_t>(strtoul(row[13], nullptr, 10));
e.maxlevel = static_cast<uint8_t>(strtoul(row[14], nullptr, 10));
e.min_level = static_cast<uint8_t>(strtoul(row[13], nullptr, 10));
e.max_level = static_cast<uint8_t>(strtoul(row[14], nullptr, 10));
e.level_spread = static_cast<uint32_t>(strtoul(row[15], nullptr, 10));
e.min_players = static_cast<uint32_t>(strtoul(row[16], nullptr, 10));
e.max_players = static_cast<uint32_t>(strtoul(row[17], nullptr, 10));
@@ -289,15 +289,15 @@ public:
v.push_back(columns[3] + " = " + std::to_string(e.duration_code));
v.push_back(columns[4] + " = '" + Strings::Escape(e.title) + "'");
v.push_back(columns[5] + " = '" + Strings::Escape(e.description) + "'");
v.push_back(columns[6] + " = '" + Strings::Escape(e.reward) + "'");
v.push_back(columns[7] + " = " + std::to_string(e.rewardid));
v.push_back(columns[8] + " = " + std::to_string(e.cashreward));
v.push_back(columns[9] + " = " + std::to_string(e.xpreward));
v.push_back(columns[10] + " = " + std::to_string(e.rewardmethod));
v.push_back(columns[6] + " = '" + Strings::Escape(e.reward_text) + "'");
v.push_back(columns[7] + " = '" + Strings::Escape(e.reward_id_list) + "'");
v.push_back(columns[8] + " = " + std::to_string(e.cash_reward));
v.push_back(columns[9] + " = " + std::to_string(e.exp_reward));
v.push_back(columns[10] + " = " + std::to_string(e.reward_method));
v.push_back(columns[11] + " = " + std::to_string(e.reward_points));
v.push_back(columns[12] + " = " + std::to_string(e.reward_point_type));
v.push_back(columns[13] + " = " + std::to_string(e.minlevel));
v.push_back(columns[14] + " = " + std::to_string(e.maxlevel));
v.push_back(columns[13] + " = " + std::to_string(e.min_level));
v.push_back(columns[14] + " = " + std::to_string(e.max_level));
v.push_back(columns[15] + " = " + std::to_string(e.level_spread));
v.push_back(columns[16] + " = " + std::to_string(e.min_players));
v.push_back(columns[17] + " = " + std::to_string(e.max_players));
@@ -338,15 +338,15 @@ public:
v.push_back(std::to_string(e.duration_code));
v.push_back("'" + Strings::Escape(e.title) + "'");
v.push_back("'" + Strings::Escape(e.description) + "'");
v.push_back("'" + Strings::Escape(e.reward) + "'");
v.push_back(std::to_string(e.rewardid));
v.push_back(std::to_string(e.cashreward));
v.push_back(std::to_string(e.xpreward));
v.push_back(std::to_string(e.rewardmethod));
v.push_back("'" + Strings::Escape(e.reward_text) + "'");
v.push_back("'" + Strings::Escape(e.reward_id_list) + "'");
v.push_back(std::to_string(e.cash_reward));
v.push_back(std::to_string(e.exp_reward));
v.push_back(std::to_string(e.reward_method));
v.push_back(std::to_string(e.reward_points));
v.push_back(std::to_string(e.reward_point_type));
v.push_back(std::to_string(e.minlevel));
v.push_back(std::to_string(e.maxlevel));
v.push_back(std::to_string(e.min_level));
v.push_back(std::to_string(e.max_level));
v.push_back(std::to_string(e.level_spread));
v.push_back(std::to_string(e.min_players));
v.push_back(std::to_string(e.max_players));
@@ -395,15 +395,15 @@ public:
v.push_back(std::to_string(e.duration_code));
v.push_back("'" + Strings::Escape(e.title) + "'");
v.push_back("'" + Strings::Escape(e.description) + "'");
v.push_back("'" + Strings::Escape(e.reward) + "'");
v.push_back(std::to_string(e.rewardid));
v.push_back(std::to_string(e.cashreward));
v.push_back(std::to_string(e.xpreward));
v.push_back(std::to_string(e.rewardmethod));
v.push_back("'" + Strings::Escape(e.reward_text) + "'");
v.push_back("'" + Strings::Escape(e.reward_id_list) + "'");
v.push_back(std::to_string(e.cash_reward));
v.push_back(std::to_string(e.exp_reward));
v.push_back(std::to_string(e.reward_method));
v.push_back(std::to_string(e.reward_points));
v.push_back(std::to_string(e.reward_point_type));
v.push_back(std::to_string(e.minlevel));
v.push_back(std::to_string(e.maxlevel));
v.push_back(std::to_string(e.min_level));
v.push_back(std::to_string(e.max_level));
v.push_back(std::to_string(e.level_spread));
v.push_back(std::to_string(e.min_players));
v.push_back(std::to_string(e.max_players));
@@ -456,15 +456,15 @@ public:
e.duration_code = static_cast<int8_t>(atoi(row[3]));
e.title = row[4] ? row[4] : "";
e.description = row[5] ? row[5] : "";
e.reward = row[6] ? row[6] : "";
e.rewardid = static_cast<uint32_t>(strtoul(row[7], nullptr, 10));
e.cashreward = static_cast<uint32_t>(strtoul(row[8], nullptr, 10));
e.xpreward = static_cast<int32_t>(atoi(row[9]));
e.rewardmethod = static_cast<uint8_t>(strtoul(row[10], nullptr, 10));
e.reward_text = row[6] ? row[6] : "";
e.reward_id_list = row[7] ? row[7] : "";
e.cash_reward = static_cast<uint32_t>(strtoul(row[8], nullptr, 10));
e.exp_reward = static_cast<int32_t>(atoi(row[9]));
e.reward_method = static_cast<uint8_t>(strtoul(row[10], nullptr, 10));
e.reward_points = static_cast<int32_t>(atoi(row[11]));
e.reward_point_type = static_cast<int32_t>(atoi(row[12]));
e.minlevel = static_cast<uint8_t>(strtoul(row[13], nullptr, 10));
e.maxlevel = static_cast<uint8_t>(strtoul(row[14], nullptr, 10));
e.min_level = static_cast<uint8_t>(strtoul(row[13], nullptr, 10));
e.max_level = static_cast<uint8_t>(strtoul(row[14], nullptr, 10));
e.level_spread = static_cast<uint32_t>(strtoul(row[15], nullptr, 10));
e.min_players = static_cast<uint32_t>(strtoul(row[16], nullptr, 10));
e.max_players = static_cast<uint32_t>(strtoul(row[17], nullptr, 10));
@@ -508,15 +508,15 @@ public:
e.duration_code = static_cast<int8_t>(atoi(row[3]));
e.title = row[4] ? row[4] : "";
e.description = row[5] ? row[5] : "";
e.reward = row[6] ? row[6] : "";
e.rewardid = static_cast<uint32_t>(strtoul(row[7], nullptr, 10));
e.cashreward = static_cast<uint32_t>(strtoul(row[8], nullptr, 10));
e.xpreward = static_cast<int32_t>(atoi(row[9]));
e.rewardmethod = static_cast<uint8_t>(strtoul(row[10], nullptr, 10));
e.reward_text = row[6] ? row[6] : "";
e.reward_id_list = row[7] ? row[7] : "";
e.cash_reward = static_cast<uint32_t>(strtoul(row[8], nullptr, 10));
e.exp_reward = static_cast<int32_t>(atoi(row[9]));
e.reward_method = static_cast<uint8_t>(strtoul(row[10], nullptr, 10));
e.reward_points = static_cast<int32_t>(atoi(row[11]));
e.reward_point_type = static_cast<int32_t>(atoi(row[12]));
e.minlevel = static_cast<uint8_t>(strtoul(row[13], nullptr, 10));
e.maxlevel = static_cast<uint8_t>(strtoul(row[14], nullptr, 10));
e.min_level = static_cast<uint8_t>(strtoul(row[13], nullptr, 10));
e.max_level = static_cast<uint8_t>(strtoul(row[14], nullptr, 10));
e.level_spread = static_cast<uint32_t>(strtoul(row[15], nullptr, 10));
e.min_players = static_cast<uint32_t>(strtoul(row[16], nullptr, 10));
e.max_players = static_cast<uint32_t>(strtoul(row[17], nullptr, 10));
@@ -1,50 +0,0 @@
#ifndef EQEMU_GOALLISTS_REPOSITORY_H
#define EQEMU_GOALLISTS_REPOSITORY_H
#include "../database.h"
#include "../strings.h"
#include "base/base_goallists_repository.h"
class GoallistsRepository: public BaseGoallistsRepository {
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
*
* GoallistsRepository::GetByZoneAndVersion(int zone_id, int zone_version)
* GoallistsRepository::GetWhereNeverExpires()
* GoallistsRepository::GetWhereXAndY()
* GoallistsRepository::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_GOALLISTS_REPOSITORY_H
+5 -1
View File
@@ -64,7 +64,7 @@ std::vector<std::string> Strings::Split(const std::string &str, const char delim
}
// this one takes delimiter length into consideration
std::vector<std::string> Strings::Split(std::string s, std::string delimiter)
std::vector<std::string> Strings::Split(const std::string& s, const std::string& delimiter)
{
size_t pos_start = 0, pos_end, delim_len = delimiter.length();
std::string token;
@@ -674,3 +674,7 @@ std::string Strings::ConvertToDigit(int n, std::string suffix)
return NUM_TO_ENGLISH_X[n] + suffix;
}
}
bool Strings::Contains(const std::string& subject, const std::string& search)
{
return subject.find(search) != std::string::npos;
}
+2 -1
View File
@@ -84,6 +84,7 @@ namespace EQ {
class Strings {
public:
static bool Contains(std::vector<std::string> container, std::string element);
static bool Contains(const std::string& subject, const std::string& search);
static bool IsNumber(const std::string &s);
static const std::string ToLower(std::string s);
static const std::string ToUpper(std::string s);
@@ -105,7 +106,7 @@ public:
static std::string SecondsToTime(int duration, bool is_milliseconds = false);
static std::string::size_type SearchDelim(const std::string &haystack, const std::string &needle, const char deliminator = ',');
static std::vector<std::string> Split(const std::string &s, const char delim = ',');
static std::vector<std::string> Split(std::string s, std::string delimiter);
static std::vector<std::string> Split(const std::string& s, const std::string& delimiter);
static std::vector<std::string> Wrap(std::vector<std::string> &src, std::string character);
static void FindReplace(std::string &string_subject, const std::string &search_string, const std::string &replace_string);
+36 -16
View File
@@ -1,6 +1,7 @@
#ifndef EQEMU_TASKS_H
#define EQEMU_TASKS_H
#include "../common/strings.h"
#include "serialize_buffer.h"
#include <algorithm>
#include <array>
@@ -16,12 +17,10 @@
// Command Codes for worldserver ServerOP_ReloadTasks
#define RELOADTASKS 0
#define RELOADTASKGOALLISTS 1
#define RELOADTASKSETS 2
typedef enum {
METHODSINGLEID = 0,
METHODLIST = 1,
METHODQUEST = 2
} TaskMethodType;
@@ -77,11 +76,7 @@ struct ActivityInformation {
int spell_id; // older clients, first id from above
TaskMethodType goal_method;
int goal_count;
uint32_t npc_id;
uint32_t npc_goal_id;
std::string npc_match_list; // delimited by '|' for partial name matches but also supports ids
uint32_t item_id;
uint32_t item_goal_id;
std::string item_id_list; // delimited by '|' to support multiple item ids
int dz_switch_id;
float min_x;
@@ -207,15 +202,15 @@ enum class DurationCode {
struct TaskInformation {
TaskType type;
int duration{};
uint32_t duration{};
DurationCode duration_code; // description for time investment for when duration == 0
std::string title{}; // max length 64
std::string description{}; // max length 4000, 2048 on Tit
std::string reward{};
std::string item_link{}; // max length 128 older clients, item link gets own string
std::string completion_emote{}; // emote after completing task, yellow. Maybe should make more generic ... but yellow for now!
int reward_id{};
int cash_reward{}; // Expressed in copper
std::string reward_id_list{};
uint32_t cash_reward{}; // Expressed in copper
int experience_reward{};
int faction_reward{}; // npc_faction_id if amount == 0, otherwise primary faction ID
int faction_amount{}; // faction hit value
@@ -225,14 +220,14 @@ struct TaskInformation {
int activity_count{};
uint8_t min_level{};
uint8_t max_level{};
int level_spread;
int min_players;
int max_players;
uint32_t level_spread;
uint32_t min_players;
uint32_t max_players;
bool repeatable{};
int replay_timer_group;
int replay_timer_seconds;
int request_timer_group;
int request_timer_seconds;
uint32_t replay_timer_group;
uint32_t replay_timer_seconds;
uint32_t request_timer_group;
uint32_t request_timer_seconds;
ActivityInformation activity_information[MAXACTIVITIESPERTASK];
void SerializeSelector(SerializeBuffer& out, EQ::versions::ClientVersion client_version) const
@@ -420,6 +415,31 @@ namespace Tasks {
return result;
}
static bool IsInMatchList(const std::string& match_list, const std::string& entry)
{
for (auto &s: Strings::Split(match_list, '|')) {
if (s == entry) {
return true;
}
}
return false;
}
static bool IsInMatchListPartial(const std::string &match_list, const std::string &entry)
{
std::string entry_match = Strings::ToLower(entry);
for (auto &s: Strings::Split(match_list, '|')) {
if (entry_match.find(Strings::ToLower(s)) != std::string::npos) {
return true;
}
}
return false;
}
}
namespace TaskStr {
+1 -1
View File
@@ -34,7 +34,7 @@
* Manifest: https://github.com/EQEmu/Server/blob/master/utils/sql/db_update_manifest.txt
*/
#define CURRENT_BINARY_DATABASE_VERSION 9207
#define CURRENT_BINARY_DATABASE_VERSION 9208
#ifdef BOTS
#define CURRENT_BINARY_BOTS_DATABASE_VERSION 9029