[Expansion] Content Filtering Adjustments (#1910)

* Change default expansion values for ALL to -1 from 0

* Adjust content_filter_criteria

* Refactor content filtering logic

* Allow flag strings to also just be empty instead of null

* Formatting

* Editor oops
This commit is contained in:
Chris Miles 2022-01-02 20:52:29 -06:00 committed by GitHub
parent c0f57bed1f
commit 9815f50efa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
23 changed files with 365 additions and 121 deletions

View File

@ -35,8 +35,12 @@ int WorldContentService::GetCurrentExpansion() const
return current_expansion;
}
void WorldContentService::SetExpansionContext()
WorldContentService *WorldContentService::SetExpansionContext()
{
// do a rule manager reload until where we store expansion is changed to somewhere else
RuleManager::Instance()->LoadRules(GetDatabase(), "default", true);
// pull expansion from rules
int expansion = RuleI(Expansion, CurrentExpansion);
if (expansion >= Expansion::Classic && expansion <= Expansion::MaxId) {
content_service.SetCurrentExpansion(expansion);
@ -47,6 +51,8 @@ void WorldContentService::SetExpansionContext()
GetCurrentExpansion(),
GetCurrentExpansionName()
);
return this;
}
std::string WorldContentService::GetCurrentExpansionName()
@ -73,15 +79,47 @@ void WorldContentService::SetCurrentExpansion(int current_expansion)
/**
* @return
*/
const std::vector<std::string> &WorldContentService::GetContentFlags() const
const std::vector<ContentFlagsRepository::ContentFlags> &WorldContentService::GetContentFlags() const
{
return content_flags;
}
/**
* @return
*/
std::vector<std::string> WorldContentService::GetContentFlagsEnabled()
{
std::vector<std::string> enabled_flags;
for (auto &f: GetContentFlags()) {
if (f.enabled) {
enabled_flags.emplace_back(f.flag_name);
}
}
return enabled_flags;
}
/**
* @return
*/
std::vector<std::string> WorldContentService::GetContentFlagsDisabled()
{
std::vector<std::string> disabled_flags;
for (auto &f: GetContentFlags()) {
if (!f.enabled) {
disabled_flags.emplace_back(f.flag_name);
}
}
return disabled_flags;
}
/**
* @param content_flags
*/
void WorldContentService::SetContentFlags(std::vector<std::string> content_flags)
void WorldContentService::SetContentFlags(std::vector<ContentFlagsRepository::ContentFlags> content_flags)
{
WorldContentService::content_flags = content_flags;
}
@ -90,10 +128,10 @@ void WorldContentService::SetContentFlags(std::vector<std::string> content_flags
* @param content_flag
* @return
*/
bool WorldContentService::IsContentFlagEnabled(const std::string& content_flag)
bool WorldContentService::IsContentFlagEnabled(const std::string &content_flag)
{
for (auto &flag : GetContentFlags()) {
if (flag == content_flag) {
for (auto &f: GetContentFlags()) {
if (f.flag_name == content_flag) {
return true;
}
}
@ -101,20 +139,58 @@ bool WorldContentService::IsContentFlagEnabled(const std::string& content_flag)
return false;
}
void WorldContentService::ReloadContentFlags(Database &db)
void WorldContentService::ReloadContentFlags()
{
std::vector<std::string> set_content_flags;
auto content_flags = ContentFlagsRepository::GetWhere(db, "enabled = 1");
std::vector<ContentFlagsRepository::ContentFlags> set_content_flags;
auto flags = ContentFlagsRepository::All(*GetDatabase());
set_content_flags.reserve(content_flags.size());
for (auto &flags: content_flags) {
set_content_flags.push_back(flags.flag_name);
set_content_flags.reserve(flags.size());
for (auto &f: flags) {
set_content_flags.push_back(f);
LogInfo(
"Loaded content flag [{}] [{}]",
f.flag_name,
(f.enabled ? "Enabled" : "Disabled")
);
}
LogInfo(
"Enabled content flags [{}]",
implode(", ", set_content_flags)
);
SetContentFlags(set_content_flags);
}
Database *WorldContentService::GetDatabase() const
{
return m_database;
}
WorldContentService *WorldContentService::SetDatabase(Database *database)
{
WorldContentService::m_database = database;
return this;
}
void WorldContentService::SetContentFlag(const std::string &content_flag_name, bool enabled)
{
auto flags = ContentFlagsRepository::GetWhere(
*GetDatabase(),
fmt::format("flag_name = '{}'", content_flag_name)
);
auto f = ContentFlagsRepository::NewEntity();
if (!flags.empty()) {
f = flags.front();
}
f.enabled = enabled ? 1 : 0;
f.flag_name = content_flag_name;
if (!flags.empty()) {
ContentFlagsRepository::UpdateOne(*GetDatabase(), f);
}
else {
ContentFlagsRepository::InsertOne(*GetDatabase(), f);
}
ReloadContentFlags();
}

View File

@ -23,6 +23,7 @@
#include <string>
#include <vector>
#include "../repositories/content_flags_repository.h"
class Database;
@ -160,15 +161,25 @@ public:
bool IsCurrentExpansionTheBurningLands() { return current_expansion == Expansion::ExpansionNumber::TheBurningLands; }
bool IsCurrentExpansionTormentOfVelious() { return current_expansion == Expansion::ExpansionNumber::TormentOfVelious; }
const std::vector<ContentFlagsRepository::ContentFlags> &GetContentFlags() const;
std::vector<std::string> GetContentFlagsEnabled();
std::vector<std::string> GetContentFlagsDisabled();
bool IsContentFlagEnabled(const std::string& content_flag);
void SetContentFlags(std::vector<ContentFlagsRepository::ContentFlags> content_flags);
void ReloadContentFlags();
WorldContentService * SetExpansionContext();
WorldContentService * SetDatabase(Database *database);
Database *GetDatabase() const;
void SetContentFlag(const std::string &content_flag_name, bool enabled);
private:
int current_expansion{};
std::vector<std::string> content_flags;
public:
const std::vector<std::string> &GetContentFlags() const;
bool IsContentFlagEnabled(const std::string& content_flag);
void SetContentFlags(std::vector<std::string> content_flags);
void ReloadContentFlags(Database &db);
void SetExpansionContext();
std::vector<ContentFlagsRepository::ContentFlags> content_flags;
// reference to database
Database *m_database;
};
extern WorldContentService content_service;

View File

@ -40,43 +40,48 @@ namespace ContentFilterCriteria {
}
criteria += fmt::format(
" AND ({}min_expansion <= {} OR {}min_expansion = 0)",
" AND ({}min_expansion <= {} OR {}min_expansion = -1)",
table_prefix,
current_expansion_filter_criteria,
table_prefix
);
criteria += fmt::format(
" AND ({}max_expansion >= {} OR {}max_expansion = 0)",
" AND ({}max_expansion >= {} OR {}max_expansion = -1)",
table_prefix,
current_expansion_filter_criteria,
table_prefix
);
std::vector<std::string> flags = content_service.GetContentFlags();
std::vector<std::string> flags_disabled = content_service.GetContentFlagsDisabled();
std::vector<std::string> flags_enabled = content_service.GetContentFlagsEnabled();
std::string flags_in_filter_enabled;
std::string flags_in_filter_disabled;
if (!flags.empty()) {
if (!flags_enabled.empty()) {
flags_in_filter_enabled = fmt::format(
" OR CONCAT(',', {}content_flags, ',') REGEXP ',({}),' ",
table_prefix,
implode("|", flags)
implode("|", flags_enabled)
);
}
if (!flags_disabled.empty()) {
flags_in_filter_disabled = fmt::format(
" OR CONCAT(',', {}content_flags_disabled, ',') NOT REGEXP ',({}),' ",
" OR CONCAT(',', {}content_flags_disabled, ',') REGEXP ',({}),' ",
table_prefix,
implode("|", flags)
implode("|", flags_disabled)
);
}
criteria += fmt::format(
" AND ({}content_flags IS NULL{}) ",
" AND (({}content_flags IS NULL OR {}content_flags = ''){}) ",
table_prefix,
table_prefix,
flags_in_filter_enabled
);
criteria += fmt::format(
" AND ({}content_flags_disabled IS NULL{}) ",
" AND (({}content_flags_disabled IS NULL OR {}content_flags_disabled = ''){}) ",
table_prefix,
table_prefix,
flags_in_filter_disabled
);

View File

@ -226,6 +226,7 @@
#define ServerOP_UCSServerStatusReply 0x4010
#define ServerOP_HotReloadQuests 0x4011
#define ServerOP_UpdateSchedulerEvents 0x4012
#define ServerOP_ReloadContentFlags 0x4013
#define ServerOP_CZDialogueWindow 0x4500
#define ServerOP_CZLDoNUpdate 0x4501

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 9174
#define CURRENT_BINARY_DATABASE_VERSION 9175
#ifdef BOTS
#define CURRENT_BINARY_BOTS_DATABASE_VERSION 9028

View File

@ -428,6 +428,7 @@
9172|2021_05_21_shared_tasks.sql|SHOW TABLES LIKE 'shared_tasks'|empty|
9173|2021_09_14_zone_lava_damage.sql|SHOW COLUMNS FROM `zone` LIKE 'lava_damage'|empty|
9174|2021_10_09_not_null_door_columns.sql|SELECT * FROM db_version WHERE version >= 9174|empty|
9175|2022_01_02_expansion_default_value_all.sql|SHOW COLUMNS FROM `forage` LIKE 'min_expansion'|contains|unsigned
# Upgrade conditions:
# This won't be needed after this system is implemented, but it is used database that are not

View File

@ -0,0 +1,117 @@
-- forage
ALTER TABLE `forage` CHANGE `max_expansion` `max_expansion` tinyint(4) NOT NULL DEFAULT -1 COMMENT '';
ALTER TABLE `forage` CHANGE `min_expansion` `min_expansion` tinyint(4) NOT NULL DEFAULT -1 COMMENT '';
UPDATE forage set min_expansion = -1 where min_expansion = 0;
UPDATE forage set max_expansion = -1 where max_expansion = 0;
-- tradeskill_recipe
ALTER TABLE `tradeskill_recipe` CHANGE `max_expansion` `max_expansion` tinyint(4) NOT NULL DEFAULT -1 COMMENT '';
ALTER TABLE `tradeskill_recipe` CHANGE `min_expansion` `min_expansion` tinyint(4) NOT NULL DEFAULT -1 COMMENT '';
UPDATE tradeskill_recipe set min_expansion = -1 where min_expansion = 0;
UPDATE tradeskill_recipe set max_expansion = -1 where max_expansion = 0;
-- fishing
ALTER TABLE `fishing` CHANGE `max_expansion` `max_expansion` tinyint(4) NOT NULL DEFAULT -1 COMMENT '';
ALTER TABLE `fishing` CHANGE `min_expansion` `min_expansion` tinyint(4) NOT NULL DEFAULT -1 COMMENT '';
UPDATE fishing set min_expansion = -1 where min_expansion = 0;
UPDATE fishing set max_expansion = -1 where max_expansion = 0;
-- zone
ALTER TABLE `zone` CHANGE `max_expansion` `max_expansion` tinyint(4) NOT NULL DEFAULT -1 COMMENT '';
ALTER TABLE `zone` CHANGE `min_expansion` `min_expansion` tinyint(4) NOT NULL DEFAULT -1 COMMENT '';
UPDATE zone set min_expansion = -1 where min_expansion = 0;
UPDATE zone set max_expansion = -1 where max_expansion = 0;
-- traps
ALTER TABLE `traps` CHANGE `max_expansion` `max_expansion` tinyint(4) NOT NULL DEFAULT -1 COMMENT '';
ALTER TABLE `traps` CHANGE `min_expansion` `min_expansion` tinyint(4) NOT NULL DEFAULT -1 COMMENT '';
UPDATE traps set min_expansion = -1 where min_expansion = 0;
UPDATE traps set max_expansion = -1 where max_expansion = 0;
-- loottable
ALTER TABLE `loottable` CHANGE `max_expansion` `max_expansion` tinyint(4) NOT NULL DEFAULT -1 COMMENT '';
ALTER TABLE `loottable` CHANGE `min_expansion` `min_expansion` tinyint(4) NOT NULL DEFAULT -1 COMMENT '';
UPDATE loottable set min_expansion = -1 where min_expansion = 0;
UPDATE loottable set max_expansion = -1 where max_expansion = 0;
-- ground_spawns
ALTER TABLE `ground_spawns` CHANGE `max_expansion` `max_expansion` tinyint(4) NOT NULL DEFAULT -1 COMMENT '';
ALTER TABLE `ground_spawns` CHANGE `min_expansion` `min_expansion` tinyint(4) NOT NULL DEFAULT -1 COMMENT '';
UPDATE ground_spawns set min_expansion = -1 where min_expansion = 0;
UPDATE ground_spawns set max_expansion = -1 where max_expansion = 0;
-- starting_items
ALTER TABLE `starting_items` CHANGE `max_expansion` `max_expansion` tinyint(4) NOT NULL DEFAULT -1 COMMENT '';
ALTER TABLE `starting_items` CHANGE `min_expansion` `min_expansion` tinyint(4) NOT NULL DEFAULT -1 COMMENT '';
UPDATE starting_items set min_expansion = -1 where min_expansion = 0;
UPDATE starting_items set max_expansion = -1 where max_expansion = 0;
-- spawn2
ALTER TABLE `spawn2` CHANGE `max_expansion` `max_expansion` tinyint(4) NOT NULL DEFAULT -1 COMMENT '';
ALTER TABLE `spawn2` CHANGE `min_expansion` `min_expansion` tinyint(4) NOT NULL DEFAULT -1 COMMENT '';
UPDATE spawn2 set min_expansion = -1 where min_expansion = 0;
UPDATE spawn2 set max_expansion = -1 where max_expansion = 0;
-- zone_points
ALTER TABLE `zone_points` CHANGE `max_expansion` `max_expansion` tinyint(4) NOT NULL DEFAULT -1 COMMENT '';
ALTER TABLE `zone_points` CHANGE `min_expansion` `min_expansion` tinyint(4) NOT NULL DEFAULT -1 COMMENT '';
UPDATE zone_points set min_expansion = -1 where min_expansion = 0;
UPDATE zone_points set max_expansion = -1 where max_expansion = 0;
-- lootdrop
ALTER TABLE `lootdrop` CHANGE `max_expansion` `max_expansion` tinyint(4) NOT NULL DEFAULT -1 COMMENT '';
ALTER TABLE `lootdrop` CHANGE `min_expansion` `min_expansion` tinyint(4) NOT NULL DEFAULT -1 COMMENT '';
UPDATE lootdrop set min_expansion = -1 where min_expansion = 0;
UPDATE lootdrop set max_expansion = -1 where max_expansion = 0;
-- global_loot
ALTER TABLE `global_loot` CHANGE `max_expansion` `max_expansion` tinyint(4) NOT NULL DEFAULT -1 COMMENT '';
ALTER TABLE `global_loot` CHANGE `min_expansion` `min_expansion` tinyint(4) NOT NULL DEFAULT -1 COMMENT '';
UPDATE global_loot set min_expansion = -1 where min_expansion = 0;
UPDATE global_loot set max_expansion = -1 where max_expansion = 0;
-- doors
ALTER TABLE `doors` CHANGE `max_expansion` `max_expansion` tinyint(4) NOT NULL DEFAULT -1 COMMENT '';
ALTER TABLE `doors` CHANGE `min_expansion` `min_expansion` tinyint(4) NOT NULL DEFAULT -1 COMMENT '';
UPDATE doors set min_expansion = -1 where min_expansion = 0;
UPDATE doors set max_expansion = -1 where max_expansion = 0;
-- object
ALTER TABLE `object` CHANGE `max_expansion` `max_expansion` tinyint(4) NOT NULL DEFAULT -1 COMMENT '';
ALTER TABLE `object` CHANGE `min_expansion` `min_expansion` tinyint(4) NOT NULL DEFAULT -1 COMMENT '';
UPDATE object set min_expansion = -1 where min_expansion = 0;
UPDATE object set max_expansion = -1 where max_expansion = 0;
-- start_zones
ALTER TABLE `start_zones` CHANGE `max_expansion` `max_expansion` tinyint(4) NOT NULL DEFAULT -1 COMMENT '';
ALTER TABLE `start_zones` CHANGE `min_expansion` `min_expansion` tinyint(4) NOT NULL DEFAULT -1 COMMENT '';
UPDATE start_zones set min_expansion = -1 where min_expansion = 0;
UPDATE start_zones set max_expansion = -1 where max_expansion = 0;
-- merchantlist
ALTER TABLE `merchantlist` CHANGE `max_expansion` `max_expansion` tinyint(4) NOT NULL DEFAULT -1 COMMENT '';
ALTER TABLE `merchantlist` CHANGE `min_expansion` `min_expansion` tinyint(4) NOT NULL DEFAULT -1 COMMENT '';
UPDATE merchantlist set min_expansion = -1 where min_expansion = 0;
UPDATE merchantlist set max_expansion = -1 where max_expansion = 0;
-- spawnentry
ALTER TABLE `spawnentry` ADD `min_expansion` tinyint(4) NOT NULL DEFAULT -1;
ALTER TABLE `spawnentry` ADD `max_expansion` tinyint(4) NOT NULL DEFAULT -1;
ALTER TABLE `spawnentry` ADD `content_flags` varchar(100) NULL;
ALTER TABLE `spawnentry` ADD `content_flags_disabled` varchar(100) NULL;

View File

@ -503,6 +503,11 @@ int main(int argc, char **argv)
LogInfo("Initializing [EventScheduler]");
event_scheduler.SetDatabase(&database)->LoadScheduledEvents();
LogInfo("Initializing [WorldContentService]");
content_service.SetDatabase(&database)
->SetExpansionContext()
->ReloadContentFlags();
LogInfo("Initializing [SharedTaskManager]");
shared_task_manager.SetDatabase(&database)
->SetContentDatabase(&content_db)

View File

@ -165,37 +165,37 @@ namespace WorldserverCommandHandler {
Json::Value player_tables_json;
std::vector<std::string> player_tables = DatabaseSchema::GetPlayerTables();
for (const auto &table : player_tables) {
for (const auto &table: player_tables) {
player_tables_json.append(table);
}
Json::Value content_tables_json;
std::vector<std::string> content_tables = DatabaseSchema::GetContentTables();
for (const auto &table : content_tables) {
for (const auto &table: content_tables) {
content_tables_json.append(table);
}
Json::Value server_tables_json;
std::vector<std::string> server_tables = DatabaseSchema::GetServerTables();
for (const auto &table : server_tables) {
for (const auto &table: server_tables) {
server_tables_json.append(table);
}
Json::Value login_tables_json;
std::vector<std::string> login_tables = DatabaseSchema::GetLoginTables();
for (const auto &table : login_tables) {
for (const auto &table: login_tables) {
login_tables_json.append(table);
}
Json::Value state_tables_json;
std::vector<std::string> state_tables = DatabaseSchema::GetStateTables();
for (const auto &table : state_tables) {
for (const auto &table: state_tables) {
state_tables_json.append(table);
}
Json::Value version_tables_json;
std::vector<std::string> version_tables = DatabaseSchema::GetVersionTables();
for (const auto &table : version_tables) {
for (const auto &table: version_tables) {
version_tables_json.append(table);
}
@ -313,11 +313,20 @@ namespace WorldserverCommandHandler {
content_service.SetCurrentExpansion(RuleI(Expansion, CurrentExpansion));
std::vector<std::string> flags = {
std::vector<ContentFlagsRepository::ContentFlags> flags = {};
auto f = ContentFlagsRepository::NewEntity();
f.enabled = 1;
std::vector<std::string> flag_names = {
"hateplane_enabled",
"patch_nerf_7077",
};
for (auto &name: flag_names) {
f.flag_name = name;
flags.push_back(f);
}
content_service.SetContentFlags(flags);
LogInfo(

View File

@ -41,6 +41,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include "shared_task_world_messaging.h"
#include "../common/shared_tasks.h"
#include "shared_task_manager.h"
#include "../common/content/world_content_service.h"
extern ClientList client_list;
extern GroupLFPList LFPGroupList;
@ -868,6 +869,11 @@ void ZoneServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) {
RuleManager::Instance()->LoadRules(&database, "default", true);
break;
}
case ServerOP_ReloadContentFlags: {
zoneserver_list.SendPacket(pack);
content_service.SetExpansionContext()->ReloadContentFlags();
break;
}
case ServerOP_ReloadRulesWorld:
{
RuleManager::Instance()->LoadRules(&database, "default", true);

View File

@ -459,6 +459,7 @@ SET(gm_commands
gm_commands/refreshgroup.cpp
gm_commands/reloadaa.cpp
gm_commands/reloadallrules.cpp
gm_commands/reloadcontentflags.cpp
gm_commands/reloademote.cpp
gm_commands/reloadlevelmods.cpp
gm_commands/reloadmerchants.cpp

View File

@ -295,6 +295,7 @@ int command_init(void)
command_add("refreshgroup", "- Refreshes Group.", AccountStatus::Player, command_refreshgroup) ||
command_add("reloadaa", "Reloads AA data", AccountStatus::GMMgmt, command_reloadaa) ||
command_add("reloadallrules", "Executes a reload of all rules.", AccountStatus::QuestTroupe, command_reloadallrules) ||
command_add("reloadcontentflags", "Executes a reload of all expansion and content flags", AccountStatus::QuestTroupe, command_reloadcontentflags) ||
command_add("reloademote", "Reloads NPC Emotes", AccountStatus::QuestTroupe, command_reloademote) ||
command_add("reloadlevelmods", nullptr, AccountStatus::Max, command_reloadlevelmods) ||
command_add("reloadmerchants", nullptr, AccountStatus::Max, command_reloadmerchants) ||

View File

@ -216,6 +216,7 @@ void command_randomfeatures(Client *c, const Seperator *sep);
void command_refreshgroup(Client *c, const Seperator *sep);
void command_reloadaa(Client *c, const Seperator *sep);
void command_reloadallrules(Client *c, const Seperator *sep);
void command_reloadcontentflags(Client *c, const Seperator *sep);
void command_reloademote(Client *c, const Seperator *sep);
void command_reloadlevelmods(Client *c, const Seperator *sep);
void command_reloadmerchants(Client *c, const Seperator *sep);

View File

@ -4802,7 +4802,8 @@ XS(XS__SetContentFlag)
std::string flag_name = (std::string) SvPV_nolen(ST(0));
bool enabled = (int) SvIV(ST(1)) != 0;
ZoneStore::SetContentFlag(flag_name, enabled);
content_service.SetContentFlag(flag_name, enabled);
XSRETURN_EMPTY;
}
@ -5141,7 +5142,7 @@ XS(XS__gethexcolorcode) {
sv_setpv(TARG, hex_color_code.c_str());
XSprePUSH;
PUSHTARG;
XSRETURN(1);
XSRETURN(1);
}
XS(XS__getaaexpmodifierbycharid);
@ -5149,7 +5150,7 @@ XS(XS__getaaexpmodifierbycharid) {
dXSARGS;
if (items != 2)
Perl_croak(aTHX_ "Usage: quest::getaaexpmodifierbycharid(uint32 character_id, uint32 zone_id)");
dXSTARG;
double aa_modifier;
uint32 character_id = (uint32) SvUV(ST(0));
@ -5165,7 +5166,7 @@ XS(XS__getexpmodifierbycharid) {
dXSARGS;
if (items != 2)
Perl_croak(aTHX_ "Usage: quest::getexpmodifierbycharid(uint32 character_id, uint32 zone_id)");
dXSTARG;
double exp_modifier;
uint32 character_id = (uint32) SvUV(ST(0));
@ -5313,7 +5314,7 @@ XS(XS__getspellstat) {
uint8 slot = 0;
if (items == 3)
slot = (uint8) SvUV(ST(2));
stat_value = quest_manager.getspellstat(spell_id, stat_identifier, slot);
XSprePUSH;
@ -7551,7 +7552,7 @@ XS(XS__worldwideassigntask) {
if (items == 3)
max_status = (uint8) SvUV(ST(2));
quest_manager.WorldWideTaskUpdate(update_type, task_identifier, task_subidentifier, update_count, enforce_level_requirement, min_status, max_status);
}
XSRETURN_EMPTY;
@ -7616,7 +7617,7 @@ XS(XS__worldwidedisabletask) {
if (items == 3)
max_status = (uint8) SvUV(ST(2));
quest_manager.WorldWideTaskUpdate(update_type, task_identifier, task_subidentifier, update_count, enforce_level_requirement, min_status, max_status);
}
XSRETURN_EMPTY;
@ -7640,7 +7641,7 @@ XS(XS__worldwideenabletask) {
if (items == 3)
max_status = (uint8) SvUV(ST(2));
quest_manager.WorldWideTaskUpdate(update_type, task_identifier, task_subidentifier, update_count, enforce_level_requirement, min_status, max_status);
}
XSRETURN_EMPTY;
@ -7664,7 +7665,7 @@ XS(XS__worldwidefailtask) {
if (items == 3)
max_status = (uint8) SvUV(ST(2));
quest_manager.WorldWideTaskUpdate(update_type, task_identifier, task_subidentifier, update_count, enforce_level_requirement, min_status, max_status);
}
XSRETURN_EMPTY;

View File

@ -0,0 +1,15 @@
#include "../client.h"
#include "../worldserver.h"
extern WorldServer worldserver;
void command_reloadcontentflags(Client *c, const Seperator *sep)
{
if (c) {
auto pack = new ServerPacket(ServerOP_ReloadContentFlags, 0);
worldserver.SendPacket(pack);
c->Message(Chat::Red, "Successfully sent the packet to world to reload content flags globally.");
safe_delete(pack);
}
}

View File

@ -1410,7 +1410,7 @@ void lua_add_spawn_point(luabind::adl::object table) {
lua_remove_spawn_point(spawn2_id);
auto t = new Spawn2(spawn2_id, spawngroup_id, x, y, z, heading, respawn,
variance, timeleft, grid, path_when_zone_idle, condition_id,
variance, timeleft, grid, path_when_zone_idle, condition_id,
condition_min_value, enabled, static_cast<EmuAppearance>(animation));
zone->spawn2_list.Insert(t);
@ -1743,7 +1743,7 @@ bool lua_is_content_flag_enabled(std::string content_flag){
}
void lua_set_content_flag(std::string flag_name, bool enabled){
ZoneStore::SetContentFlag(flag_name, enabled);
content_service.SetContentFlag(flag_name, enabled);
}
Lua_Expedition lua_get_expedition() {

View File

@ -386,9 +386,9 @@ int main(int argc, char** argv) {
LogInfo("Initialized dynamic dictionary entries");
}
content_service.SetExpansionContext();
ZoneStore::LoadContentFlags();
content_service.SetDatabase(&database)
->SetExpansionContext()
->ReloadContentFlags();
event_scheduler.SetDatabase(&database)->LoadScheduledEvents();

View File

@ -244,8 +244,11 @@ bool ZoneDatabase::LoadSpawnGroups(const char *zone_name, uint16 version, SpawnG
AND
spawnentry.spawngroupID = spawn2.spawngroupID
AND
zone = '{}'),
zone_name
zone = '{}'
{}
),
zone_name,
ContentFilterCriteria::apply("spawnentry")
);
results = QueryDatabase(query);

View File

@ -1977,6 +1977,34 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p)
RuleManager::Instance()->LoadRules(&database, RuleManager::Instance()->GetActiveRuleset(), true);
break;
}
case ServerOP_ReloadContentFlags: {
if (zone) {
worldserver.SendEmoteMessage(
0,
0,
AccountStatus::GMAdmin,
Chat::Yellow,
fmt::format(
"Content flags (and expansion) reloaded for {}.",
fmt::format(
"{} ({})",
zone->GetLongName(),
zone->GetZoneID()
),
(
zone->GetInstanceID() ?
fmt::format(
"Instance ID: {}",
zone->GetInstanceID()
) :
""
)
).c_str()
);
}
content_service.SetExpansionContext()->ReloadContentFlags();
break;
}
case ServerOP_ReloadLogs: {
LogSys.LoadLogDatabaseSettings();
break;
@ -2069,7 +2097,7 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p)
}
}
} else if (update_type == CZUpdateType_Expedition) {
for (auto &client: entity_list.GetClientList()) {
for (auto &client: entity_list.GetClientList()) {
if (client.second->GetExpedition() && client.second->GetExpedition()->GetID() == update_identifier) {
DialogueWindow::Render(client.second, message);
}
@ -2243,7 +2271,7 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p)
}
}
break;
}
}
break;
}
case ServerOP_CZMarquee:
@ -2290,7 +2318,7 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p)
}
}
} else if (update_type == CZUpdateType_Expedition) {
for (auto &client: entity_list.GetClientList()) {
for (auto &client: entity_list.GetClientList()) {
if (client.second->GetExpedition() && client.second->GetExpedition()->GetID() == update_identifier) {
client.second->SendMarqueeMessage(type, priority, fade_in, fade_out, duration, message);
}
@ -2343,7 +2371,7 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p)
}
}
} else if (update_type == CZUpdateType_Expedition) {
for (auto &client: entity_list.GetClientList()) {
for (auto &client: entity_list.GetClientList()) {
if (client.second->GetExpedition() && client.second->GetExpedition()->GetID() == update_identifier) {
client.second->Message(type, message);
}
@ -2425,7 +2453,7 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p)
}
}
} else if (update_type == CZUpdateType_Expedition) {
for (auto &client: entity_list.GetClientList()) {
for (auto &client: entity_list.GetClientList()) {
if (client.second->GetExpedition() && client.second->GetExpedition()->GetID() == update_identifier) {
switch (update_subtype) {
case CZMoveUpdateSubtype_MoveZone:
@ -2492,7 +2520,7 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p)
}
}
} else if (update_type == CZUpdateType_Expedition) {
for (auto &client: entity_list.GetClientList()) {
for (auto &client: entity_list.GetClientList()) {
if (client.second->GetExpedition() && client.second->GetExpedition()->GetID() == update_identifier) {
client.second->SetEntityVariable(variable_name, variable_value);
}
@ -2549,7 +2577,7 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p)
}
}
} else if (update_type == CZUpdateType_Expedition) {
for (auto &client: entity_list.GetClientList()) {
for (auto &client: entity_list.GetClientList()) {
if (client.second->GetExpedition() && client.second->GetExpedition()->GetID() == update_identifier) {
client.second->Signal(signal);
}
@ -2609,7 +2637,7 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p)
if (client_raid) {
for (int member_index = 0; member_index < MAX_RAID_MEMBERS; member_index++) {
if (client_raid->members[member_index].member && client_raid->members[member_index].member->IsClient()) {
auto raid_member = client_raid->members[member_index].member->CastToClient();
auto raid_member = client_raid->members[member_index].member->CastToClient();
switch (update_subtype) {
case CZSpellUpdateSubtype_Cast:
raid_member->SpellFinished(spell_id, raid_member);
@ -2635,7 +2663,7 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p)
}
}
} else if (update_type == CZUpdateType_Expedition) {
for (auto &client: entity_list.GetClientList()) {
for (auto &client: entity_list.GetClientList()) {
if (client.second->GetExpedition() && client.second->GetExpedition()->GetID() == update_identifier) {
switch (update_subtype) {
case CZSpellUpdateSubtype_Cast:
@ -2792,9 +2820,9 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p)
break;
}
}
}
}
} else if (update_type == CZUpdateType_Expedition) {
for (auto &client: entity_list.GetClientList()) {
for (auto &client: entity_list.GetClientList()) {
if (client.second->GetExpedition() && client.second->GetExpedition()->GetID() == update_identifier) {
switch (update_subtype) {
case CZTaskUpdateSubtype_ActivityReset:
@ -2968,7 +2996,7 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p)
uint8 min_status = WWSEV->min_status;
uint8 max_status = WWSEV->max_status;
if (update_type == WWSetEntityVariableUpdateType_Character) {
for (auto &client : entity_list.GetClientList()) {
for (auto &client : entity_list.GetClientList()) {
if (client.second->Admin() >= min_status && (client.second->Admin() <= max_status || max_status == AccountStatus::Player)) {
client.second->SetEntityVariable(variable_name, variable_value);
}
@ -2988,7 +3016,7 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p)
uint8 min_status = WWS->min_status;
uint8 max_status = WWS->max_status;
if (update_type == WWSignalUpdateType_Character) {
for (auto &client : entity_list.GetClientList()) {
for (auto &client : entity_list.GetClientList()) {
if (client.second->Admin() >= min_status && (client.second->Admin() <= max_status || max_status == AccountStatus::Player)) {
client.second->Signal(signal);
}
@ -3008,13 +3036,13 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p)
uint8 min_status = WWS->min_status;
uint8 max_status = WWS->max_status;
if (update_type == WWSpellUpdateType_Cast) {
for (auto &client : entity_list.GetClientList()) {
for (auto &client : entity_list.GetClientList()) {
if (client.second->Admin() >= min_status && (client.second->Admin() <= max_status || max_status == AccountStatus::Player)) {
client.second->SpellFinished(spell_id, client.second);
}
}
} else if (update_type == WWSpellUpdateType_Remove) {
for (auto &client : entity_list.GetClientList()) {
for (auto &client : entity_list.GetClientList()) {
if (client.second->Admin() >= min_status && (client.second->Admin() <= max_status || max_status == AccountStatus::Player)) {
client.second->BuffFadeBySpellID(spell_id);
}
@ -3031,8 +3059,8 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p)
int update_count = WWTU->update_count;
bool enforce_level_requirement = WWTU->enforce_level_requirement;
uint8 min_status = WWTU->min_status;
uint8 max_status = WWTU->max_status;
for (auto &client : entity_list.GetClientList()) {
uint8 max_status = WWTU->max_status;
for (auto &client : entity_list.GetClientList()) {
if (client.second->Admin() >= min_status && (client.second->Admin() <= max_status || max_status == AccountStatus::Player)) {
switch (update_type) {
case WWTaskUpdateType_ActivityReset:

View File

@ -1255,9 +1255,8 @@ void Zone::ReloadStaticData() {
);
} // if that fails, try the file name, then load defaults
content_service.SetExpansionContext();
content_service.SetExpansionContext()->ReloadContentFlags();
ZoneStore::LoadContentFlags();
LogInfo("Zone Static Data Reloaded");
}
@ -2749,7 +2748,7 @@ uint32 Zone::GetCurrencyID(uint32 item_id)
if (!item_id) {
return 0;
}
for (const auto& alternate_currency : AlternateCurrencies) {
if (item_id == alternate_currency.item_id) {
return alternate_currency.id;
@ -2772,4 +2771,4 @@ uint32 Zone::GetCurrencyItemID(uint32 currency_id)
}
return 0;
}
}

View File

@ -54,7 +54,7 @@ void ZoneEventScheduler::Process(Zone *zone, WorldContentService *content_servic
auto flag_name = e.event_data;
if (!flag_name.empty()) {
LogScheduler("Deactivating event [{}] resetting content flags", e.description);
content_service->ReloadContentFlags(*m_database);
content_service->ReloadContentFlags();
}
// force active events clear and reapply all active events because we reset the entire state
@ -117,8 +117,13 @@ void ZoneEventScheduler::Process(Zone *zone, WorldContentService *content_servic
flag_name
);
// add new flag entity to stack
auto flags = content_service->GetContentFlags();
flags.push_back(flag_name);
auto f = ContentFlagsRepository::NewEntity();
f.flag_name = flag_name;
f.enabled = 1;
flags.push_back(f);
content_service->SetContentFlags(flags);
m_active_events.push_back(e);
}

View File

@ -160,41 +160,3 @@ ZoneRepository::Zone ZoneStore::GetZone(const char *in_zone_name)
return ZoneRepository::Zone();
}
/**
* @return
*/
void ZoneStore::LoadContentFlags()
{
content_service.ReloadContentFlags(database);
}
/**
* Sets the value in the database and proceeds to load content flags into the server context again
*
* @param content_flag_name
* @param enabled
*/
void ZoneStore::SetContentFlag(const std::string &content_flag_name, bool enabled)
{
auto content_flags = ContentFlagsRepository::GetWhere(database,
fmt::format("flag_name = '{}'", content_flag_name)
);
auto content_flag = ContentFlagsRepository::NewEntity();
if (!content_flags.empty()) {
content_flag = content_flags.front();
}
content_flag.enabled = enabled ? 1 : 0;
content_flag.flag_name = content_flag_name;
if (!content_flags.empty()) {
ContentFlagsRepository::UpdateOne(database, content_flag);
}
else {
ContentFlagsRepository::InsertOne(database, content_flag);
}
LoadContentFlags();
}

View File

@ -42,9 +42,6 @@ public:
std::string GetZoneLongName(uint32 zone_id);
const char *GetZoneName(uint32 zone_id, bool error_unknown = false);
const char *GetZoneLongName(uint32 zone_id, bool error_unknown = false);
static void LoadContentFlags();
static void SetContentFlag(const std::string& content_flag_name, bool enabled);
};
extern ZoneStore zone_store;