diff --git a/CMakeLists.txt b/CMakeLists.txt index f93cabb22..e53a05bef 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,6 +42,7 @@ IF(USE_MAP_MMFS) ENDIF (USE_MAP_MMFS) IF(MSVC) + add_compile_options(/bigobj) ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS) ADD_DEFINITIONS(-DNOMINMAX) ADD_DEFINITIONS(-DCRASH_LOGGING) diff --git a/README.md b/README.md index 1a2ae2b3a..033fcccab 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@

-EverQuest Emulator (EQEmu) - A Fan-Made Project Honoring the Legendary MMORPG +EQEmulator - A Fan-Made Project Honoring a Legendary MMORPG

@@ -26,19 +26,19 @@ ***

-EQEmulator is a passion-driven, open source server emulator project dedicated to preserving and celebrating the groundbreaking world of EverQuest, the massively multiplayer online role-playing game originally developed by Verant Interactive and Sony Online Entertainment (now Daybreak Game Company). +EQEmulator is a passion-driven, open source server emulator project dedicated to preserving and celebrating the legacy of a groundbreaking classic MMORPG.

-For over two decades and continuing, EQEmulator has served as a fan tribute, providing tools and technology that allow players to explore, customize, and experience EverQuest’s iconic gameplay in new ways. This project exists solely out of deep admiration for the original developers, artists, designers, and visionaries who created one of the most influential online worlds of all time. +For over two decades and continuing, EQEmulator has served as a fan tribute, providing tools and technology that allow players to explore, customize, and experience the legendary game's iconic gameplay in new ways. This project exists solely out of deep admiration for the original developers, artists, designers, and visionaries who created one of the most influential online worlds of all time.

-We do not claim ownership of EverQuest or its assets. All credit and respect belong to the original creators and Daybreak Game Company, whose work continues to inspire generations of players and developers alike. +We do not claim ownership of the original game or its assets. All credit and respect belong to the original creators and Daybreak Game Company, whose work continues to inspire generations of players and developers alike.

-EQEmulator has for over 20 years and always will be a fan-based, non-commercial open-source effort made by players, for players—preserving the legacy of EverQuest while empowering community-driven creativity, learning and joy that the game and its creators has so strongly inspired in us all. +EQEmulator has for over 20 years and always will be a fan-based, non-commercial open-source effort made by players, for players—preserving the legacy of the game while empowering community-driven creativity, learning and joy that the game and its creators has so strongly inspired in us all.

*** @@ -47,7 +47,7 @@ EQEmulator has for over 20 years and always will be a fan-based, non-com Technical Overview & Reverse Engineering Effort -

EQEmulator represents over two decades of collaborative reverse engineering, rebuilding the EverQuest server from the ground up without access to the original source code. This effort was achieved entirely through community-driven analysis, network protocol decoding, and in-game behavioral research.

+

EQEmulator represents over two decades of collaborative reverse engineering, building the server from the ground up without access to the original source code. This effort was achieved entirely through community-driven analysis, network protocol decoding, and in-game behavioral research.

💡 How We Did It @@ -104,10 +104,10 @@ Every system, packet, opcode, and game mechanic has been reconstructed through c 🚀 Why It Matters

-

🧬 EQEmulator stands as a technical preservation project, ensuring that the magic of classic and custom EverQuest servers lives on for future generations of players, tinkerers, and game designers. +

🧬 EQEmulator stands as a technical preservation project, ensuring that the magic of classic and custom servers lives on for future generations of players, tinkerers, and game designers.

-> We humbly acknowledge and thank the original developers at **Verant Interactive** and **Sony Online Entertainment (now Daybreak Game Company)** for creating one of the most influential online experiences in gaming history. +> We humbly acknowledge and thank the original developers for creating one of the most influential online experiences in gaming history.

🧑‍💻🖥️ Supported Clients @@ -148,4 +148,3 @@ If you want to set up your own EQEmulator server, please refer to the current [s - diff --git a/client_files/export/main.cpp b/client_files/export/main.cpp index a930d5404..3e66e259d 100644 --- a/client_files/export/main.cpp +++ b/client_files/export/main.cpp @@ -38,10 +38,7 @@ #include "../../common/skill_caps.h" #include "../../common/evolving_items.h" -EQEmuLogSys LogSys; WorldContentService content_service; -ZoneStore zone_store; -PathManager path; PlayerEventLogs player_event_logs; EvolvingItemsManager evolving_items_manager; @@ -53,10 +50,10 @@ void ExportDBStrings(SharedDatabase *db); int main(int argc, char **argv) { RegisterExecutablePlatform(ExePlatformClientExport); - LogSys.LoadLogSettingsDefaults(); + EQEmuLogSys::Instance()->LoadLogSettingsDefaults(); set_exception_handler(); - path.LoadPaths(); + PathManager::Instance()->Init(); LogInfo("Client Files Export Utility"); if (!EQEmuConfig::LoadConfig()) { @@ -99,8 +96,8 @@ int main(int argc, char **argv) content_db.SetMySQL(database); } - LogSys.SetDatabase(&database) - ->SetLogPath(path.GetLogPath()) + EQEmuLogSys::Instance()->SetDatabase(&database) + ->SetLogPath(PathManager::Instance()->GetLogPath()) ->LoadLogDatabaseSettings() ->StartFileLogs(); @@ -129,14 +126,14 @@ int main(int argc, char **argv) ExportBaseData(&content_db); ExportDBStrings(&database); - LogSys.CloseFileLogs(); + EQEmuLogSys::Instance()->CloseFileLogs(); return 0; } void ExportSpells(SharedDatabase* db) { - std::ofstream file(fmt::format("{}/export/spells_us.txt", path.GetServerPath())); + std::ofstream file(fmt::format("{}/export/spells_us.txt", PathManager::Instance()->GetServerPath())); if (!file || !file.is_open()) { LogError("Unable to open export/spells_us.txt to write, skipping."); return; @@ -155,7 +152,7 @@ void ExportSpells(SharedDatabase* db) void ExportSkillCaps(SharedDatabase* db) { - std::ofstream file(fmt::format("{}/export/SkillCaps.txt", path.GetServerPath())); + std::ofstream file(fmt::format("{}/export/SkillCaps.txt", PathManager::Instance()->GetServerPath())); if (!file || !file.is_open()) { LogError("Unable to open export/SkillCaps.txt to write, skipping."); return; @@ -174,7 +171,7 @@ void ExportSkillCaps(SharedDatabase* db) void ExportBaseData(SharedDatabase *db) { - std::ofstream file(fmt::format("{}/export/BaseData.txt", path.GetServerPath())); + std::ofstream file(fmt::format("{}/export/BaseData.txt", PathManager::Instance()->GetServerPath())); if (!file || !file.is_open()) { LogError("Unable to open export/BaseData.txt to write, skipping."); return; @@ -193,7 +190,7 @@ void ExportBaseData(SharedDatabase *db) void ExportDBStrings(SharedDatabase *db) { - std::ofstream file(fmt::format("{}/export/dbstr_us.txt", path.GetServerPath())); + std::ofstream file(fmt::format("{}/export/dbstr_us.txt", PathManager::Instance()->GetServerPath())); if (!file || !file.is_open()) { LogError("Unable to open export/dbstr_us.txt to write, skipping."); return; diff --git a/client_files/import/main.cpp b/client_files/import/main.cpp index 74f447a23..312a8a5d4 100644 --- a/client_files/import/main.cpp +++ b/client_files/import/main.cpp @@ -32,10 +32,7 @@ #include "../../common/events/player_event_logs.h" #include "../../common/evolving_items.h" -EQEmuLogSys LogSys; WorldContentService content_service; -ZoneStore zone_store; -PathManager path; PlayerEventLogs player_event_logs; EvolvingItemsManager evolving_items_manager; @@ -46,10 +43,10 @@ void ImportDBStrings(SharedDatabase *db); int main(int argc, char **argv) { RegisterExecutablePlatform(ExePlatformClientImport); - LogSys.LoadLogSettingsDefaults(); + EQEmuLogSys::Instance()->LoadLogSettingsDefaults(); set_exception_handler(); - path.LoadPaths(); + PathManager::Instance()->Init(); LogInfo("Client Files Import Utility"); if(!EQEmuConfig::LoadConfig()) { @@ -92,8 +89,8 @@ int main(int argc, char **argv) { content_db.SetMySQL(database); } - LogSys.SetDatabase(&database) - ->SetLogPath(path.GetLogPath()) + EQEmuLogSys::Instance()->SetDatabase(&database) + ->SetLogPath(PathManager::Instance()->GetLogPath()) ->LoadLogDatabaseSettings() ->StartFileLogs(); @@ -102,7 +99,7 @@ int main(int argc, char **argv) { ImportBaseData(&content_db); ImportDBStrings(&database); - LogSys.CloseFileLogs(); + EQEmuLogSys::Instance()->CloseFileLogs(); return 0; } @@ -138,7 +135,7 @@ bool IsStringField(int i) { void ImportSpells(SharedDatabase *db) { LogInfo("Importing Spells"); - std::string file = fmt::format("{}/import/spells_us.txt", path.GetServerPath()); + std::string file = fmt::format("{}/import/spells_us.txt", PathManager::Instance()->GetServerPath()); FILE *f = fopen(file.c_str(), "r"); if(!f) { LogError("Unable to open {} to read, skipping.", file); @@ -228,7 +225,7 @@ void ImportSpells(SharedDatabase *db) { void ImportSkillCaps(SharedDatabase *db) { LogInfo("Importing Skill Caps"); - std::string file = fmt::format("{}/import/SkillCaps.txt", path.GetServerPath()); + std::string file = fmt::format("{}/import/SkillCaps.txt", PathManager::Instance()->GetServerPath()); FILE *f = fopen(file.c_str(), "r"); if(!f) { LogError("Unable to open {} to read, skipping.", file); @@ -265,7 +262,7 @@ void ImportBaseData(SharedDatabase *db) { LogInfo("Importing Base Data"); - const std::string& file_name = fmt::format("{}/import/BaseData.txt", path.GetServerPath()); + const std::string& file_name = fmt::format("{}/import/BaseData.txt", PathManager::Instance()->GetServerPath()); const auto& file_contents = File::GetContents(file_name); if (!file_contents.error.empty()) { @@ -305,7 +302,7 @@ void ImportBaseData(SharedDatabase *db) void ImportDBStrings(SharedDatabase *db) { LogInfo("Importing DB Strings"); - std::string file = fmt::format("{}/import/dbstr_us.txt", path.GetServerPath()); + std::string file = fmt::format("{}/import/dbstr_us.txt", PathManager::Instance()->GetServerPath()); FILE *f = fopen(file.c_str(), "r"); if(!f) { LogError("Unable to open {} to read, skipping.", file); diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 0350cb6d4..787cd299c 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -842,7 +842,7 @@ IF (UNIX) ENDIF (UNIX) IF (WIN32 AND EQEMU_BUILD_PCH) - TARGET_PRECOMPILE_HEADERS(common PRIVATE pch/pch.h) + TARGET_PRECOMPILE_HEADERS(common PRIVATE pch/std-pch.h) ENDIF () SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin) diff --git a/common/content/world_content_service.cpp b/common/content/world_content_service.cpp index 7d23c9d13..b54dd7032 100644 --- a/common/content/world_content_service.cpp +++ b/common/content/world_content_service.cpp @@ -185,7 +185,7 @@ void WorldContentService::ReloadContentFlags() SetContentFlags(set_content_flags); LoadStaticGlobalZoneInstances(); - zone_store.LoadZones(*m_content_database); + ZoneStore::Instance()->LoadZones(*m_content_database); } Database *WorldContentService::GetDatabase() const @@ -291,7 +291,7 @@ WorldContentService *WorldContentService::LoadStaticGlobalZoneInstances() // instance_list table entry for lavastorm has version = 1, is_global = 1, never_expires = 1 WorldContentService::FindZoneResult WorldContentService::FindZone(uint32 zone_id, uint32 instance_id) { - for (const auto &z: zone_store.GetZones()) { + for (const auto &z: ZoneStore::Instance()->GetZones()) { for (auto &i: m_zone_static_instances) { if ( z.zoneidnumber == zone_id && diff --git a/common/crash.cpp b/common/crash.cpp index 3828a9af0..968a7c5ff 100644 --- a/common/crash.cpp +++ b/common/crash.cpp @@ -27,6 +27,8 @@ void SendCrashReport(const std::string &crash_report) // "http://localhost:3010/api/v1/analytics/server-crash-report", // development }; + EQEmuLogSys* log = EQEmuLogSys::Instance(); + auto config = EQEmuConfig::get(); for (auto &e: endpoints) { uri u(e); @@ -68,12 +70,12 @@ void SendCrashReport(const std::string &crash_report) p["cpus"] = cpus.size(); p["origination_info"] = ""; - if (!LogSys.origination_info.zone_short_name.empty()) { + if (!log->origination_info.zone_short_name.empty()) { p["origination_info"] = fmt::format( "{} ({}) instance_id [{}]", - LogSys.origination_info.zone_short_name, - LogSys.origination_info.zone_long_name, - LogSys.origination_info.instance_id + log->origination_info.zone_short_name, + log->origination_info.zone_long_name, + log->origination_info.instance_id ); } @@ -294,7 +296,7 @@ void print_trace() SendCrashReport(crash_report); } - LogSys.CloseFileLogs(); + EQEmuLogSys::Instance()->CloseFileLogs(); exit(1); } diff --git a/common/data_bucket.cpp b/common/data_bucket.cpp index d0ad01b7e..166100549 100644 --- a/common/data_bucket.cpp +++ b/common/data_bucket.cpp @@ -19,6 +19,37 @@ extern WorldDatabase database; #error "You must define either ZONE or WORLD" #endif +// Key: compound cache key (e.g., account_id|character_id|zone_id|instance_id|top_key|full_key) +// Value: resolved DataBuckets with extracted nested value +static std::unordered_map g_nested_bucket_cache; + +static std::string MakeNestedCacheKey(const DataBucketKey &k, const std::string &full_key) { + return fmt::format( + "account_id:{}|character_id:{}|npc_id:{}|bot_id:{}|zone_id:{}|instance_id:{}|top_key:{}|full_key:{}", + k.account_id, k.character_id, k.npc_id, k.bot_id, k.zone_id, k.instance_id, + Strings::Split(full_key, NESTED_KEY_DELIMITER).front(), + full_key + ); +} + +static std::string MakeNestedCacheKeyPrefix(const DataBucketKey &k, const std::string &top_key) { + return fmt::format( + "account_id:{}|character_id:{}|npc_id:{}|bot_id:{}|zone_id:{}|instance_id:{}|top_key:{}|", + k.account_id, k.character_id, k.npc_id, k.bot_id, k.zone_id, k.instance_id, top_key + ); +} + +static void InvalidateNestedCacheForKey(const DataBucketKey &k, const std::string &top_key) { + std::string prefix = MakeNestedCacheKeyPrefix(k, top_key); + for (auto it = g_nested_bucket_cache.begin(); it != g_nested_bucket_cache.end(); ) { + if (it->first.find(prefix) == 0) { + it = g_nested_bucket_cache.erase(it); + } else { + ++it; + } + } +} + void DataBucket::SetData(const std::string &bucket_key, const std::string &bucket_value, std::string expires_time) { auto k = DataBucketKey{ @@ -136,6 +167,15 @@ void DataBucket::SetData(const DataBucketKey &k_) // Serialize JSON back to string b.value = json_value.dump(); b.key_ = top_key; // Use the top-level key + + if (CanCache(k_)) { + InvalidateNestedCacheForKey(k_, top_key); + std::string nested_cache_key = MakeNestedCacheKey(k_, k_.key); + auto extracted = ExtractNestedValue(b, k_.key); + if (extracted.id > 0) { + g_nested_bucket_cache[nested_cache_key] = extracted; + } + } } if (bucket_id) { @@ -251,12 +291,27 @@ DataBucketsRepository::DataBuckets DataBucket::GetData(const DataBucketKey &k_, LogDataBuckets("Returning key [{}] value [{}] from cache", e.key_, e.value); if (is_nested_key && !k_.key.empty()) { - return ExtractNestedValue(e, k_.key); + std::string nested_cache_key = MakeNestedCacheKey(k_, k.key); + + auto it = g_nested_bucket_cache.find(nested_cache_key); + if (it != g_nested_bucket_cache.end()) { + LogDataBucketsDetail("Nested cache hit for key [{}]", nested_cache_key); + return it->second; + } + + auto extracted = ExtractNestedValue(e, k_.key); + if (extracted.id > 0) { + g_nested_bucket_cache[nested_cache_key] = extracted; + } + return extracted; } return e; } } + + // if we can cache its assumed we didn't load this into the cache so we should not return a miss + return DataBucketsRepository::NewEntity(); // Not found in cache } // Fetch the value from the database @@ -315,23 +370,42 @@ DataBucketsRepository::DataBuckets DataBucket::GetData(const DataBucketKey &k_, } // Add the value to the cache if it doesn't exist + // If cacheable and not found in cache, short-circuit and assume it doesn't exist if (can_cache) { - bool has_cache = false; + bool found_in_cache = false; for (const auto &e : g_data_bucket_cache) { - if (e.id == bucket.id) { - has_cache = true; + if (CheckBucketMatch(e, k)) { + found_in_cache = true; break; } } - if (!has_cache) { - g_data_bucket_cache.emplace_back(bucket); + if (!found_in_cache) { + LogDataBuckets("Cache miss for key [{}] - skipping DB due to CanCache", k.key); + return DataBucketsRepository::NewEntity(); } } // Handle nested key extraction if (is_nested_key && !k_.key.empty()) { - return ExtractNestedValue(bucket, k_.key); + if (CanCache(k_)) { + std::string nested_cache_key = MakeNestedCacheKey(k_, k.key); + + auto it = g_nested_bucket_cache.find(nested_cache_key); + if (it != g_nested_bucket_cache.end()) { + LogDataBucketsDetail("Nested cache hit for key [{}]", nested_cache_key); + return it->second; + } + + auto extracted = ExtractNestedValue(bucket, k_.key); + if (extracted.id > 0) { + g_nested_bucket_cache[nested_cache_key] = extracted; + } + return extracted; + } else { + // Not cacheable, just extract and return + return ExtractNestedValue(bucket, k_.key); + } } return bucket; diff --git a/common/database.cpp b/common/database.cpp index c79ae0117..099b796ad 100644 --- a/common/database.cpp +++ b/common/database.cpp @@ -708,6 +708,20 @@ const std::string Database::GetNPCNameByID(uint32 npc_id) return e.id ? e.name : std::string(); } +template +inline auto CleanMobName(InputIterator first, InputIterator last, OutputIterator result) +{ + for (; first != last; ++first) { + if (*first == '_') { + *result = ' '; + } + else if (isalpha(*first) || *first == '`') { + *result = *first; + } + } + return result; +} + const std::string Database::GetCleanNPCNameByID(uint32 npc_id) { const auto& e = NpcTypesRepository::FindOne(*this, npc_id); diff --git a/common/database/database_dump_service.cpp b/common/database/database_dump_service.cpp index acf0f4de0..6cbea2d48 100644 --- a/common/database/database_dump_service.cpp +++ b/common/database/database_dump_service.cpp @@ -204,7 +204,7 @@ void DatabaseDumpService::DatabaseDump() } if (IsDumpOutputToConsole()) { - LogSys.SilenceConsoleLogging(); + EQEmuLogSys::Instance()->SilenceConsoleLogging(); } LogInfo("MySQL installed [{}]", GetMySQLVersion()); @@ -324,7 +324,7 @@ void DatabaseDumpService::DatabaseDump() } if (!IsDumpOutputToConsole()) { - LogSys.LoadLogSettingsDefaults(); + EQEmuLogSys::Instance()->LoadLogSettingsDefaults(); } if (!pipe_file.empty()) { diff --git a/common/database/database_update.cpp b/common/database/database_update.cpp index c82e2e727..d296aa92b 100644 --- a/common/database/database_update.cpp +++ b/common/database/database_update.cpp @@ -154,7 +154,7 @@ bool DatabaseUpdate::UpdateManifest( std::vector missing_migrations = {}; if (version_low != version_high) { - LogSys.DisableMySQLErrorLogs(); + EQEmuLogSys::Instance()->DisableMySQLErrorLogs(); bool force_interactive = false; for (int version = version_low + 1; version <= version_high; ++version) { for (auto &e: entries) { @@ -184,7 +184,7 @@ bool DatabaseUpdate::UpdateManifest( } } } - LogSys.EnableMySQLErrorLogs(); + EQEmuLogSys::Instance()->EnableMySQLErrorLogs(); LogInfo("{}", Strings::Repeat("-", BREAK_LENGTH)); if (!missing_migrations.empty() && m_skip_backup) { diff --git a/common/database/database_update.h b/common/database/database_update.h index 03d55d5ea..a445422bc 100644 --- a/common/database/database_update.h +++ b/common/database/database_update.h @@ -33,6 +33,13 @@ public: DatabaseUpdate *SetContentDatabase(Database *db); DatabaseUpdate *SetSkipBackup(bool skip); bool HasPendingUpdates(); + + static DatabaseUpdate* Instance() + { + static DatabaseUpdate instance; + return &instance; + } + private: bool m_skip_backup = false; Database *m_database; diff --git a/common/database/database_update_manifest.cpp b/common/database/database_update_manifest.cpp index 1b2f7bc61..5a3a8f683 100644 --- a/common/database/database_update_manifest.cpp +++ b/common/database/database_update_manifest.cpp @@ -7109,6 +7109,18 @@ ALTER TABLE `npc_types` ALTER TABLE `character_data` CHANGE COLUMN `firstlogon` `ingame` tinyint(1) UNSIGNED NOT NULL DEFAULT 0 AFTER `xtargets`, ADD COLUMN `first_login` int(11) UNSIGNED NOT NULL DEFAULT 0 AFTER `xtargets`; +)", + .content_schema_update = false + }, + ManifestEntry{ + .version = 9324, + .description = "2025_06_11_player_event_logs_table.sql", + .check = "SHOW CREATE TABLE `player_event_logs`", + .condition = "missing", + .match = "COMPRESS", + .sql = R"( +ALTER TABLE player_event_logs ROW_FORMAT=COMPRESSED; +CREATE INDEX idx_event_type_char_id ON player_event_logs (event_type_id, character_id); )", .content_schema_update = false }, diff --git a/common/dbcore.cpp b/common/dbcore.cpp index a6117cfd2..ff0afac3a 100644 --- a/common/dbcore.cpp +++ b/common/dbcore.cpp @@ -160,7 +160,7 @@ MySQLRequestResult DBcore::QueryDatabase(const char *query, uint32 querylen, boo (uint32) mysql_insert_id(mysql) ); - if (LogSys.log_settings[Logs::MySQLQuery].is_category_enabled == 1) { + if (EQEmuLogSys::Instance()->log_settings[Logs::MySQLQuery].is_category_enabled == 1) { if ((strncasecmp(query, "select", 6) == 0)) { LogMySQLQuery( "{0} -- ({1} row{2} returned) ({3}s)", diff --git a/common/discord/discord.h b/common/discord/discord.h index 5cc59202a..8b8a19290 100644 --- a/common/discord/discord.h +++ b/common/discord/discord.h @@ -4,7 +4,6 @@ #include #include "../types.h" -#include "../http/httplib.h" #include "../repositories/player_event_logs_repository.h" #include "../events/player_events.h" diff --git a/common/discord/discord_manager.cpp b/common/discord/discord_manager.cpp index a425d4c34..dd84d863f 100644 --- a/common/discord/discord_manager.cpp +++ b/common/discord/discord_manager.cpp @@ -26,7 +26,7 @@ void DiscordManager::ProcessMessageQueue() continue; } - auto webhook = LogSys.GetDiscordWebhooks()[q.first]; + auto webhook = EQEmuLogSys::Instance()->GetDiscordWebhooks()[q.first]; std::string message; for (auto &m: q.second) { diff --git a/common/discord/discord_manager.h b/common/discord/discord_manager.h index f577d994f..d02180859 100644 --- a/common/discord/discord_manager.h +++ b/common/discord/discord_manager.h @@ -13,6 +13,12 @@ public: void QueueWebhookMessage(uint32 webhook_id, const std::string& message); void ProcessMessageQueue(); void QueuePlayerEventMessage(const PlayerEvent::PlayerEventContainer& e); + + static DiscordManager* Instance() + { + static DiscordManager instance; + return &instance; + } private: std::mutex webhook_queue_lock{}; std::map> webhook_message_queue{}; diff --git a/common/eq_stream.cpp b/common/eq_stream.cpp index 0182c53f4..d17ed54c0 100644 --- a/common/eq_stream.cpp +++ b/common/eq_stream.cpp @@ -545,13 +545,13 @@ void EQStream::SendPacket(uint16 opcode, EQApplicationPacket *p) uint32 chunksize, used; uint32 length; - if (LogSys.log_settings[Logs::Server_Client_Packet].is_category_enabled == 1){ + if (EQEmuLogSys::Instance()->log_settings[Logs::Server_Client_Packet].is_category_enabled == 1){ if (p->GetOpcode() != OP_SpecialMesg){ Log(Logs::General, Logs::Server_Client_Packet, "[%s - 0x%04x] [Size: %u]", OpcodeManager::EmuToName(p->GetOpcode()), p->GetOpcode(), p->Size()); } } - if (LogSys.log_settings[Logs::Server_Client_Packet_With_Dump].is_category_enabled == 1){ + if (EQEmuLogSys::Instance()->log_settings[Logs::Server_Client_Packet_With_Dump].is_category_enabled == 1){ if (p->GetOpcode() != OP_SpecialMesg){ Log(Logs::General, Logs::Server_Client_Packet_With_Dump, "[%s - 0x%04x] [Size: %u] %s", OpcodeManager::EmuToName(p->GetOpcode()), p->GetOpcode(), p->Size(), DumpPacketToString(p).c_str()); } diff --git a/common/eqemu_config.cpp b/common/eqemu_config.cpp index 453234604..e2f35106c 100644 --- a/common/eqemu_config.cpp +++ b/common/eqemu_config.cpp @@ -436,11 +436,11 @@ void EQEmuConfig::CheckUcsConfigConversion() LogInfo("Migrating old [eqemu_config] UCS configuration to new configuration"); std::string config_file_path = std::filesystem::path{ - path.GetServerPath() + "/eqemu_config.json" + PathManager::Instance()->GetServerPath() + "/eqemu_config.json" }.string(); std::string config_file_bak_path = std::filesystem::path{ - path.GetServerPath() + "/eqemu_config.ucs-migrate-json.bak" + PathManager::Instance()->GetServerPath() + "/eqemu_config.ucs-migrate-json.bak" }.string(); // copy eqemu_config.json to eqemu_config.json.bak diff --git a/common/eqemu_config.h b/common/eqemu_config.h index 6ba637ea8..57a0543c8 100644 --- a/common/eqemu_config.h +++ b/common/eqemu_config.h @@ -191,7 +191,7 @@ class EQEmuConfig std::string file = fmt::format( "{}/{}", - (file_path.empty() ? path.GetServerPath() : file_path), + (file_path.empty() ? PathManager::Instance()->GetServerPath() : file_path), EQEmuConfig::ConfigFile ); diff --git a/common/eqemu_logsys.cpp b/common/eqemu_logsys.cpp index bb28d0aec..0d735b407 100644 --- a/common/eqemu_logsys.cpp +++ b/common/eqemu_logsys.cpp @@ -537,9 +537,9 @@ void EQEmuLogSys::StartFileLogs(const std::string &log_name) { EQEmuLogSys::CloseFileLogs(); - if (!File::Exists(path.GetLogPath())) { - LogInfo("Logs directory not found, creating [{}]", path.GetLogPath()); - File::Makedir(path.GetLogPath()); + if (!File::Exists(PathManager::Instance()->GetLogPath())) { + LogInfo("Logs directory not found, creating [{}]", PathManager::Instance()->GetLogPath()); + File::Makedir(PathManager::Instance()->GetLogPath()); } /** @@ -656,7 +656,7 @@ EQEmuLogSys *EQEmuLogSys::LoadLogDatabaseSettings(bool silent_load) // If we go through this whole loop and nothing is set to any debug level, there // is no point to create a file or keep anything open if (log_settings[c.log_category_id].log_to_file > 0) { - LogSys.m_file_logs_enabled = true; + m_file_logs_enabled = true; } db_categories.emplace_back(c.log_category_id); diff --git a/common/eqemu_logsys.h b/common/eqemu_logsys.h index 39c9ab948..0757b3e98 100644 --- a/common/eqemu_logsys.h +++ b/common/eqemu_logsys.h @@ -266,8 +266,6 @@ namespace Logs { }; } -#include "eqemu_logsys_log_aliases.h" - class Database; constexpr uint16 MAX_DISCORD_WEBHOOK_ID = 300; @@ -285,6 +283,12 @@ public: EQEmuLogSys *LoadLogSettingsDefaults(); EQEmuLogSys *LoadLogDatabaseSettings(bool silent_load = false); + static EQEmuLogSys *Instance() + { + static EQEmuLogSys instance; + return &instance; + } + /** * @param directory_name */ @@ -350,7 +354,7 @@ public: /** * Internally used memory reference for all log settings per category * These are loaded via DB and have defaults loaded in LoadLogSettingsDefaults - * Database loaded via LogSys.SetDatabase(&database)->LoadLogDatabaseSettings(); + * Database loaded via EQEmuLogSys::Instance()->SetDatabase(&database)->LoadLogDatabaseSettings(); */ LogSettings log_settings[Logs::LogCategory::MaxCategoryID]{}; @@ -434,7 +438,7 @@ private: void InjectTablesIfNotExist(); }; -extern EQEmuLogSys LogSys; +#include "eqemu_logsys_log_aliases.h" /** template @@ -456,7 +460,7 @@ void OutF( #define OutF(ls, debug_level, log_category, file, func, line, formatStr, ...) \ do { \ - ls.Out(debug_level, log_category, file, func, line, fmt::format(formatStr, ##__VA_ARGS__).c_str()); \ + ls->Out(debug_level, log_category, file, func, line, fmt::format(formatStr, ##__VA_ARGS__).c_str()); \ } while(0) #endif diff --git a/common/eqemu_logsys_log_aliases.h b/common/eqemu_logsys_log_aliases.h index 55fa7fa20..a2c88a03f 100644 --- a/common/eqemu_logsys_log_aliases.h +++ b/common/eqemu_logsys_log_aliases.h @@ -21,917 +21,919 @@ #ifndef EQEMU_EQEMU_LOGSYS_LOG_ALIASES_H #define EQEMU_EQEMU_LOGSYS_LOG_ALIASES_H +inline auto logsys = EQEmuLogSys::Instance(); + #define LogAA(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::General, Logs::AA))\ - OutF(LogSys, Logs::General, Logs::AA, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::General, Logs::AA))\ + OutF(logsys, Logs::General, Logs::AA, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogAADetail(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::Detail, Logs::AA))\ - OutF(LogSys, Logs::Detail, Logs::AA, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::Detail, Logs::AA))\ + OutF(logsys, Logs::Detail, Logs::AA, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogAI(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::General, Logs::AI))\ - OutF(LogSys, Logs::General, Logs::AI, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::General, Logs::AI))\ + OutF(logsys, Logs::General, Logs::AI, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogAIDetail(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::Detail, Logs::AI))\ - OutF(LogSys, Logs::Detail, Logs::AI, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::Detail, Logs::AI))\ + OutF(logsys, Logs::Detail, Logs::AI, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogAggro(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::General, Logs::Aggro))\ - OutF(LogSys, Logs::General, Logs::Aggro, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::General, Logs::Aggro))\ + OutF(logsys, Logs::General, Logs::Aggro, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogAggroDetail(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::Detail, Logs::Aggro))\ - OutF(LogSys, Logs::Detail, Logs::Aggro, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::Detail, Logs::Aggro))\ + OutF(logsys, Logs::Detail, Logs::Aggro, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogAttack(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::General, Logs::Attack))\ - OutF(LogSys, Logs::General, Logs::Attack, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::General, Logs::Attack))\ + OutF(logsys, Logs::General, Logs::Attack, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogAttackDetail(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::Detail, Logs::Attack))\ - OutF(LogSys, Logs::Detail, Logs::Attack, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::Detail, Logs::Attack))\ + OutF(logsys, Logs::Detail, Logs::Attack, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogPacketClientServer(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::General, Logs::PacketClientServer))\ - OutF(LogSys, Logs::General, Logs::PacketClientServer, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::General, Logs::PacketClientServer))\ + OutF(logsys, Logs::General, Logs::PacketClientServer, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogPacketClientServerDetail(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::Detail, Logs::PacketClientServer))\ - OutF(LogSys, Logs::Detail, Logs::PacketClientServer, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::Detail, Logs::PacketClientServer))\ + OutF(logsys, Logs::Detail, Logs::PacketClientServer, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogCombat(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::General, Logs::Combat))\ - OutF(LogSys, Logs::General, Logs::Combat, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::General, Logs::Combat))\ + OutF(logsys, Logs::General, Logs::Combat, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogCombatDetail(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::Detail, Logs::Combat))\ - OutF(LogSys, Logs::Detail, Logs::Combat, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::Detail, Logs::Combat))\ + OutF(logsys, Logs::Detail, Logs::Combat, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogCommands(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::General, Logs::Commands))\ - OutF(LogSys, Logs::General, Logs::Commands, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::General, Logs::Commands))\ + OutF(logsys, Logs::General, Logs::Commands, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogCommandsDetail(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::Detail, Logs::Commands))\ - OutF(LogSys, Logs::Detail, Logs::Commands, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::Detail, Logs::Commands))\ + OutF(logsys, Logs::Detail, Logs::Commands, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogCrash(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::General, Logs::Crash))\ - OutF(LogSys, Logs::General, Logs::Crash, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::General, Logs::Crash))\ + OutF(logsys, Logs::General, Logs::Crash, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogCrashDetail(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::Detail, Logs::Crash))\ - OutF(LogSys, Logs::Detail, Logs::Crash, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::Detail, Logs::Crash))\ + OutF(logsys, Logs::Detail, Logs::Crash, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogDebug(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::General, Logs::Debug))\ - OutF(LogSys, Logs::General, Logs::Debug, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::General, Logs::Debug))\ + OutF(logsys, Logs::General, Logs::Debug, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogDebugDetail(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::Detail, Logs::Debug))\ - OutF(LogSys, Logs::Detail, Logs::Debug, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::Detail, Logs::Debug))\ + OutF(logsys, Logs::Detail, Logs::Debug, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogDoors(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::General, Logs::Doors))\ - OutF(LogSys, Logs::General, Logs::Doors, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::General, Logs::Doors))\ + OutF(logsys, Logs::General, Logs::Doors, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogDoorsDetail(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::Detail, Logs::Doors))\ - OutF(LogSys, Logs::Detail, Logs::Doors, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::Detail, Logs::Doors))\ + OutF(logsys, Logs::Detail, Logs::Doors, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogError(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::General, Logs::Error))\ - OutF(LogSys, Logs::General, Logs::Error, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::General, Logs::Error))\ + OutF(logsys, Logs::General, Logs::Error, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogErrorDetail(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::Detail, Logs::Error))\ - OutF(LogSys, Logs::Detail, Logs::Error, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::Detail, Logs::Error))\ + OutF(logsys, Logs::Detail, Logs::Error, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogEvolveItem(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::General, Logs::EvolveItem))\ - OutF(LogSys, Logs::General, Logs::EvolveItem, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::General, Logs::EvolveItem))\ + OutF(logsys, Logs::General, Logs::EvolveItem, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogEvolveItemDetail(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::Detail, Logs::EvolveItem))\ - OutF(LogSys, Logs::Detail, Logs::EvolveItem, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::Detail, Logs::EvolveItem))\ + OutF(logsys, Logs::Detail, Logs::EvolveItem, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogGuilds(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::General, Logs::Guilds))\ - OutF(LogSys, Logs::General, Logs::Guilds, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::General, Logs::Guilds))\ + OutF(logsys, Logs::General, Logs::Guilds, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogGuildsDetail(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::Detail, Logs::Guilds))\ - OutF(LogSys, Logs::Detail, Logs::Guilds, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::Detail, Logs::Guilds))\ + OutF(logsys, Logs::Detail, Logs::Guilds, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogInventory(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::General, Logs::Inventory))\ - OutF(LogSys, Logs::General, Logs::Inventory, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::General, Logs::Inventory))\ + OutF(logsys, Logs::General, Logs::Inventory, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogInventoryDetail(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::Detail, Logs::Inventory))\ - OutF(LogSys, Logs::Detail, Logs::Inventory, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::Detail, Logs::Inventory))\ + OutF(logsys, Logs::Detail, Logs::Inventory, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogLauncher(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::General, Logs::Launcher))\ - OutF(LogSys, Logs::General, Logs::Launcher, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::General, Logs::Launcher))\ + OutF(logsys, Logs::General, Logs::Launcher, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogLauncherDetail(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::Detail, Logs::Launcher))\ - OutF(LogSys, Logs::Detail, Logs::Launcher, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::Detail, Logs::Launcher))\ + OutF(logsys, Logs::Detail, Logs::Launcher, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogNetcode(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::General, Logs::Netcode))\ - OutF(LogSys, Logs::General, Logs::Netcode, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::General, Logs::Netcode))\ + OutF(logsys, Logs::General, Logs::Netcode, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogNetcodeDetail(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::Detail, Logs::Netcode))\ - OutF(LogSys, Logs::Detail, Logs::Netcode, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::Detail, Logs::Netcode))\ + OutF(logsys, Logs::Detail, Logs::Netcode, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogNormal(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::General, Logs::Normal))\ - OutF(LogSys, Logs::General, Logs::Normal, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::General, Logs::Normal))\ + OutF(logsys, Logs::General, Logs::Normal, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogNormalDetail(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::Detail, Logs::Normal))\ - OutF(LogSys, Logs::Detail, Logs::Normal, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::Detail, Logs::Normal))\ + OutF(logsys, Logs::Detail, Logs::Normal, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogObject(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::General, Logs::Object))\ - OutF(LogSys, Logs::General, Logs::Object, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::General, Logs::Object))\ + OutF(logsys, Logs::General, Logs::Object, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogObjectDetail(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::Detail, Logs::Object))\ - OutF(LogSys, Logs::Detail, Logs::Object, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::Detail, Logs::Object))\ + OutF(logsys, Logs::Detail, Logs::Object, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogPathing(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::General, Logs::Pathing))\ - OutF(LogSys, Logs::General, Logs::Pathing, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::General, Logs::Pathing))\ + OutF(logsys, Logs::General, Logs::Pathing, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogPathingDetail(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::Detail, Logs::Pathing))\ - OutF(LogSys, Logs::Detail, Logs::Pathing, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::Detail, Logs::Pathing))\ + OutF(logsys, Logs::Detail, Logs::Pathing, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogQuests(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::General, Logs::Quests))\ - OutF(LogSys, Logs::General, Logs::Quests, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::General, Logs::Quests))\ + OutF(logsys, Logs::General, Logs::Quests, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogQuestsDetail(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::Detail, Logs::Quests))\ - OutF(LogSys, Logs::Detail, Logs::Quests, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::Detail, Logs::Quests))\ + OutF(logsys, Logs::Detail, Logs::Quests, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogRules(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::General, Logs::Rules))\ - OutF(LogSys, Logs::General, Logs::Rules, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::General, Logs::Rules))\ + OutF(logsys, Logs::General, Logs::Rules, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogRulesDetail(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::Detail, Logs::Rules))\ - OutF(LogSys, Logs::Detail, Logs::Rules, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::Detail, Logs::Rules))\ + OutF(logsys, Logs::Detail, Logs::Rules, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogSkills(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::General, Logs::Skills))\ - OutF(LogSys, Logs::General, Logs::Skills, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::General, Logs::Skills))\ + OutF(logsys, Logs::General, Logs::Skills, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogSkillsDetail(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::Detail, Logs::Skills))\ - OutF(LogSys, Logs::Detail, Logs::Skills, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::Detail, Logs::Skills))\ + OutF(logsys, Logs::Detail, Logs::Skills, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogSpawns(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::General, Logs::Spawns))\ - OutF(LogSys, Logs::General, Logs::Spawns, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::General, Logs::Spawns))\ + OutF(logsys, Logs::General, Logs::Spawns, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogSpawnsDetail(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::Detail, Logs::Spawns))\ - OutF(LogSys, Logs::Detail, Logs::Spawns, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::Detail, Logs::Spawns))\ + OutF(logsys, Logs::Detail, Logs::Spawns, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogSpells(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::General, Logs::Spells))\ - OutF(LogSys, Logs::General, Logs::Spells, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::General, Logs::Spells))\ + OutF(logsys, Logs::General, Logs::Spells, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogSpellsDetail(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::Detail, Logs::Spells))\ - OutF(LogSys, Logs::Detail, Logs::Spells, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::Detail, Logs::Spells))\ + OutF(logsys, Logs::Detail, Logs::Spells, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogTasks(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::General, Logs::Tasks))\ - OutF(LogSys, Logs::General, Logs::Tasks, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::General, Logs::Tasks))\ + OutF(logsys, Logs::General, Logs::Tasks, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogTasksDetail(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::Detail, Logs::Tasks))\ - OutF(LogSys, Logs::Detail, Logs::Tasks, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::Detail, Logs::Tasks))\ + OutF(logsys, Logs::Detail, Logs::Tasks, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogTradeskills(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::General, Logs::Tradeskills))\ - OutF(LogSys, Logs::General, Logs::Tradeskills, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::General, Logs::Tradeskills))\ + OutF(logsys, Logs::General, Logs::Tradeskills, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogTradeskillsDetail(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::Detail, Logs::Tradeskills))\ - OutF(LogSys, Logs::Detail, Logs::Tradeskills, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::Detail, Logs::Tradeskills))\ + OutF(logsys, Logs::Detail, Logs::Tradeskills, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogTrading(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::General, Logs::Trading))\ - OutF(LogSys, Logs::General, Logs::Trading, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::General, Logs::Trading))\ + OutF(logsys, Logs::General, Logs::Trading, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogTradingDetail(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::Detail, Logs::Trading))\ - OutF(LogSys, Logs::Detail, Logs::Trading, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::Detail, Logs::Trading))\ + OutF(logsys, Logs::Detail, Logs::Trading, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogTribute(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::General, Logs::Tribute))\ - OutF(LogSys, Logs::General, Logs::Tribute, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::General, Logs::Tribute))\ + OutF(logsys, Logs::General, Logs::Tribute, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogTributeDetail(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::Detail, Logs::Tribute))\ - OutF(LogSys, Logs::Detail, Logs::Tribute, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::Detail, Logs::Tribute))\ + OutF(logsys, Logs::Detail, Logs::Tribute, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogMySQLError(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::General, Logs::MySQLError))\ - OutF(LogSys, Logs::General, Logs::MySQLError, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::General, Logs::MySQLError))\ + OutF(logsys, Logs::General, Logs::MySQLError, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogMySQLErrorDetail(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::Detail, Logs::MySQLError))\ - OutF(LogSys, Logs::Detail, Logs::MySQLError, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::Detail, Logs::MySQLError))\ + OutF(logsys, Logs::Detail, Logs::MySQLError, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogMySQLQuery(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::General, Logs::MySQLQuery))\ - OutF(LogSys, Logs::General, Logs::MySQLQuery, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::General, Logs::MySQLQuery))\ + OutF(logsys, Logs::General, Logs::MySQLQuery, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogMySQLQueryDetail(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::Detail, Logs::MySQLQuery))\ - OutF(LogSys, Logs::Detail, Logs::MySQLQuery, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::Detail, Logs::MySQLQuery))\ + OutF(logsys, Logs::Detail, Logs::MySQLQuery, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogMercenaries(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::General, Logs::Mercenaries))\ - OutF(LogSys, Logs::General, Logs::Mercenaries, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::General, Logs::Mercenaries))\ + OutF(logsys, Logs::General, Logs::Mercenaries, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogMercenariesDetail(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::Detail, Logs::Mercenaries))\ - OutF(LogSys, Logs::Detail, Logs::Mercenaries, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::Detail, Logs::Mercenaries))\ + OutF(logsys, Logs::Detail, Logs::Mercenaries, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogQuestDebug(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::General, Logs::QuestDebug))\ - OutF(LogSys, Logs::General, Logs::QuestDebug, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::General, Logs::QuestDebug))\ + OutF(logsys, Logs::General, Logs::QuestDebug, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogQuestDebugDetail(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::Detail, Logs::QuestDebug))\ - OutF(LogSys, Logs::Detail, Logs::QuestDebug, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::Detail, Logs::QuestDebug))\ + OutF(logsys, Logs::Detail, Logs::QuestDebug, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogPacketServerClient(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::General, Logs::PacketServerClient))\ - OutF(LogSys, Logs::General, Logs::PacketServerClient, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::General, Logs::PacketServerClient))\ + OutF(logsys, Logs::General, Logs::PacketServerClient, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogPacketServerClientDetail(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::Detail, Logs::PacketServerClient))\ - OutF(LogSys, Logs::Detail, Logs::PacketServerClient, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::Detail, Logs::PacketServerClient))\ + OutF(logsys, Logs::Detail, Logs::PacketServerClient, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogLoginserver(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::General, Logs::Loginserver))\ - OutF(LogSys, Logs::General, Logs::Loginserver, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::General, Logs::Loginserver))\ + OutF(logsys, Logs::General, Logs::Loginserver, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogLoginserverDetail(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::Detail, Logs::Loginserver))\ - OutF(LogSys, Logs::Detail, Logs::Loginserver, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::Detail, Logs::Loginserver))\ + OutF(logsys, Logs::Detail, Logs::Loginserver, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogClientLogin(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::General, Logs::ClientLogin))\ - OutF(LogSys, Logs::General, Logs::ClientLogin, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::General, Logs::ClientLogin))\ + OutF(logsys, Logs::General, Logs::ClientLogin, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogClientLoginDetail(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::Detail, Logs::ClientLogin))\ - OutF(LogSys, Logs::Detail, Logs::ClientLogin, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::Detail, Logs::ClientLogin))\ + OutF(logsys, Logs::Detail, Logs::ClientLogin, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogHPUpdate(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::General, Logs::HPUpdate))\ - OutF(LogSys, Logs::General, Logs::HPUpdate, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::General, Logs::HPUpdate))\ + OutF(logsys, Logs::General, Logs::HPUpdate, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogHPUpdateDetail(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::Detail, Logs::HPUpdate))\ - OutF(LogSys, Logs::Detail, Logs::HPUpdate, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::Detail, Logs::HPUpdate))\ + OutF(logsys, Logs::Detail, Logs::HPUpdate, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogFixZ(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::General, Logs::FixZ))\ - OutF(LogSys, Logs::General, Logs::FixZ, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::General, Logs::FixZ))\ + OutF(logsys, Logs::General, Logs::FixZ, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogFixZDetail(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::Detail, Logs::FixZ))\ - OutF(LogSys, Logs::Detail, Logs::FixZ, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::Detail, Logs::FixZ))\ + OutF(logsys, Logs::Detail, Logs::FixZ, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogFood(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::General, Logs::Food))\ - OutF(LogSys, Logs::General, Logs::Food, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::General, Logs::Food))\ + OutF(logsys, Logs::General, Logs::Food, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogFoodDetail(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::Detail, Logs::Food))\ - OutF(LogSys, Logs::Detail, Logs::Food, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::Detail, Logs::Food))\ + OutF(logsys, Logs::Detail, Logs::Food, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogTraps(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::General, Logs::Traps))\ - OutF(LogSys, Logs::General, Logs::Traps, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::General, Logs::Traps))\ + OutF(logsys, Logs::General, Logs::Traps, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogTrapsDetail(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::Detail, Logs::Traps))\ - OutF(LogSys, Logs::Detail, Logs::Traps, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::Detail, Logs::Traps))\ + OutF(logsys, Logs::Detail, Logs::Traps, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogNPCRoamBox(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::General, Logs::NPCRoamBox))\ - OutF(LogSys, Logs::General, Logs::NPCRoamBox, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::General, Logs::NPCRoamBox))\ + OutF(logsys, Logs::General, Logs::NPCRoamBox, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogNPCRoamBoxDetail(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::Detail, Logs::NPCRoamBox))\ - OutF(LogSys, Logs::Detail, Logs::NPCRoamBox, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::Detail, Logs::NPCRoamBox))\ + OutF(logsys, Logs::Detail, Logs::NPCRoamBox, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogNPCScaling(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::General, Logs::NPCScaling))\ - OutF(LogSys, Logs::General, Logs::NPCScaling, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::General, Logs::NPCScaling))\ + OutF(logsys, Logs::General, Logs::NPCScaling, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogNPCScalingDetail(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::Detail, Logs::NPCScaling))\ - OutF(LogSys, Logs::Detail, Logs::NPCScaling, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::Detail, Logs::NPCScaling))\ + OutF(logsys, Logs::Detail, Logs::NPCScaling, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogMobAppearance(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::General, Logs::MobAppearance))\ - OutF(LogSys, Logs::General, Logs::MobAppearance, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::General, Logs::MobAppearance))\ + OutF(logsys, Logs::General, Logs::MobAppearance, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogMobAppearanceDetail(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::Detail, Logs::MobAppearance))\ - OutF(LogSys, Logs::Detail, Logs::MobAppearance, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::Detail, Logs::MobAppearance))\ + OutF(logsys, Logs::Detail, Logs::MobAppearance, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogInfo(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::General, Logs::Info))\ - OutF(LogSys, Logs::General, Logs::Info, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::General, Logs::Info))\ + OutF(logsys, Logs::General, Logs::Info, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogInfoDetail(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::Detail, Logs::Info))\ - OutF(LogSys, Logs::Detail, Logs::Info, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::Detail, Logs::Info))\ + OutF(logsys, Logs::Detail, Logs::Info, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogWarning(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::General, Logs::Warning))\ - OutF(LogSys, Logs::General, Logs::Warning, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::General, Logs::Warning))\ + OutF(logsys, Logs::General, Logs::Warning, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogWarningDetail(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::Detail, Logs::Warning))\ - OutF(LogSys, Logs::Detail, Logs::Warning, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::Detail, Logs::Warning))\ + OutF(logsys, Logs::Detail, Logs::Warning, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogCritical(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::General, Logs::Critical))\ - OutF(LogSys, Logs::General, Logs::Critical, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::General, Logs::Critical))\ + OutF(logsys, Logs::General, Logs::Critical, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogCriticalDetail(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::Detail, Logs::Critical))\ - OutF(LogSys, Logs::Detail, Logs::Critical, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::Detail, Logs::Critical))\ + OutF(logsys, Logs::Detail, Logs::Critical, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogEmergency(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::General, Logs::Emergency))\ - OutF(LogSys, Logs::General, Logs::Emergency, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::General, Logs::Emergency))\ + OutF(logsys, Logs::General, Logs::Emergency, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogEmergencyDetail(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::Detail, Logs::Emergency))\ - OutF(LogSys, Logs::Detail, Logs::Emergency, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::Detail, Logs::Emergency))\ + OutF(logsys, Logs::Detail, Logs::Emergency, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogAlert(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::General, Logs::Alert))\ - OutF(LogSys, Logs::General, Logs::Alert, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::General, Logs::Alert))\ + OutF(logsys, Logs::General, Logs::Alert, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogAlertDetail(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::Detail, Logs::Alert))\ - OutF(LogSys, Logs::Detail, Logs::Alert, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::Detail, Logs::Alert))\ + OutF(logsys, Logs::Detail, Logs::Alert, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogNotice(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::General, Logs::Notice))\ - OutF(LogSys, Logs::General, Logs::Notice, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::General, Logs::Notice))\ + OutF(logsys, Logs::General, Logs::Notice, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogNoticeDetail(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::Detail, Logs::Notice))\ - OutF(LogSys, Logs::Detail, Logs::Notice, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::Detail, Logs::Notice))\ + OutF(logsys, Logs::Detail, Logs::Notice, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogAIScanClose(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::General, Logs::AIScanClose))\ - OutF(LogSys, Logs::General, Logs::AIScanClose, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::General, Logs::AIScanClose))\ + OutF(logsys, Logs::General, Logs::AIScanClose, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogAIScanCloseDetail(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::Detail, Logs::AIScanClose))\ - OutF(LogSys, Logs::Detail, Logs::AIScanClose, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::Detail, Logs::AIScanClose))\ + OutF(logsys, Logs::Detail, Logs::AIScanClose, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogAIYellForHelp(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::General, Logs::AIYellForHelp))\ - OutF(LogSys, Logs::General, Logs::AIYellForHelp, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::General, Logs::AIYellForHelp))\ + OutF(logsys, Logs::General, Logs::AIYellForHelp, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogAIYellForHelpDetail(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::Detail, Logs::AIYellForHelp))\ - OutF(LogSys, Logs::Detail, Logs::AIYellForHelp, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::Detail, Logs::AIYellForHelp))\ + OutF(logsys, Logs::Detail, Logs::AIYellForHelp, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogAICastBeneficialClose(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::General, Logs::AICastBeneficialClose))\ - OutF(LogSys, Logs::General, Logs::AICastBeneficialClose, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::General, Logs::AICastBeneficialClose))\ + OutF(logsys, Logs::General, Logs::AICastBeneficialClose, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogAICastBeneficialCloseDetail(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::Detail, Logs::AICastBeneficialClose))\ - OutF(LogSys, Logs::Detail, Logs::AICastBeneficialClose, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::Detail, Logs::AICastBeneficialClose))\ + OutF(logsys, Logs::Detail, Logs::AICastBeneficialClose, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogAoeCast(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::General, Logs::AoeCast))\ - OutF(LogSys, Logs::General, Logs::AoeCast, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::General, Logs::AoeCast))\ + OutF(logsys, Logs::General, Logs::AoeCast, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogAoeCastDetail(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::Detail, Logs::AoeCast))\ - OutF(LogSys, Logs::Detail, Logs::AoeCast, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::Detail, Logs::AoeCast))\ + OutF(logsys, Logs::Detail, Logs::AoeCast, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogEntityManagement(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::General, Logs::EntityManagement))\ - OutF(LogSys, Logs::General, Logs::EntityManagement, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::General, Logs::EntityManagement))\ + OutF(logsys, Logs::General, Logs::EntityManagement, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogEntityManagementDetail(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::Detail, Logs::EntityManagement))\ - OutF(LogSys, Logs::Detail, Logs::EntityManagement, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::Detail, Logs::EntityManagement))\ + OutF(logsys, Logs::Detail, Logs::EntityManagement, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogFlee(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::General, Logs::Flee))\ - OutF(LogSys, Logs::General, Logs::Flee, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::General, Logs::Flee))\ + OutF(logsys, Logs::General, Logs::Flee, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogFleeDetail(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::Detail, Logs::Flee))\ - OutF(LogSys, Logs::Detail, Logs::Flee, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::Detail, Logs::Flee))\ + OutF(logsys, Logs::Detail, Logs::Flee, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogAura(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::General, Logs::Aura))\ - OutF(LogSys, Logs::General, Logs::Aura, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::General, Logs::Aura))\ + OutF(logsys, Logs::General, Logs::Aura, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogAuraDetail(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::Detail, Logs::Aura))\ - OutF(LogSys, Logs::Detail, Logs::Aura, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::Detail, Logs::Aura))\ + OutF(logsys, Logs::Detail, Logs::Aura, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogHotReload(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::General, Logs::HotReload))\ - OutF(LogSys, Logs::General, Logs::HotReload, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::General, Logs::HotReload))\ + OutF(logsys, Logs::General, Logs::HotReload, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogHotReloadDetail(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::Detail, Logs::HotReload))\ - OutF(LogSys, Logs::Detail, Logs::HotReload, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::Detail, Logs::HotReload))\ + OutF(logsys, Logs::Detail, Logs::HotReload, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogMerchants(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::General, Logs::Merchants))\ - OutF(LogSys, Logs::General, Logs::Merchants, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::General, Logs::Merchants))\ + OutF(logsys, Logs::General, Logs::Merchants, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogMerchantsDetail(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::Detail, Logs::Merchants))\ - OutF(LogSys, Logs::Detail, Logs::Merchants, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::Detail, Logs::Merchants))\ + OutF(logsys, Logs::Detail, Logs::Merchants, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogZonePoints(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::General, Logs::ZonePoints))\ - OutF(LogSys, Logs::General, Logs::ZonePoints, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::General, Logs::ZonePoints))\ + OutF(logsys, Logs::General, Logs::ZonePoints, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogZonePointsDetail(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::Detail, Logs::ZonePoints))\ - OutF(LogSys, Logs::Detail, Logs::ZonePoints, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::Detail, Logs::ZonePoints))\ + OutF(logsys, Logs::Detail, Logs::ZonePoints, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogLoot(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::General, Logs::Loot))\ - OutF(LogSys, Logs::General, Logs::Loot, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::General, Logs::Loot))\ + OutF(logsys, Logs::General, Logs::Loot, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogLootDetail(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::Detail, Logs::Loot))\ - OutF(LogSys, Logs::Detail, Logs::Loot, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::Detail, Logs::Loot))\ + OutF(logsys, Logs::Detail, Logs::Loot, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogExpeditions(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::General, Logs::Expeditions))\ - OutF(LogSys, Logs::General, Logs::Expeditions, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::General, Logs::Expeditions))\ + OutF(logsys, Logs::General, Logs::Expeditions, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogExpeditionsDetail(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::Detail, Logs::Expeditions))\ - OutF(LogSys, Logs::Detail, Logs::Expeditions, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::Detail, Logs::Expeditions))\ + OutF(logsys, Logs::Detail, Logs::Expeditions, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogDynamicZones(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::General, Logs::DynamicZones))\ - OutF(LogSys, Logs::General, Logs::DynamicZones, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::General, Logs::DynamicZones))\ + OutF(logsys, Logs::General, Logs::DynamicZones, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogDynamicZonesDetail(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::Detail, Logs::DynamicZones))\ - OutF(LogSys, Logs::Detail, Logs::DynamicZones, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::Detail, Logs::DynamicZones))\ + OutF(logsys, Logs::Detail, Logs::DynamicZones, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogScheduler(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::General, Logs::Scheduler))\ - OutF(LogSys, Logs::General, Logs::Scheduler, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::General, Logs::Scheduler))\ + OutF(logsys, Logs::General, Logs::Scheduler, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogSchedulerDetail(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::Detail, Logs::Scheduler))\ - OutF(LogSys, Logs::Detail, Logs::Scheduler, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::Detail, Logs::Scheduler))\ + OutF(logsys, Logs::Detail, Logs::Scheduler, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogCheat(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::General, Logs::Cheat))\ - OutF(LogSys, Logs::General, Logs::Cheat, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::General, Logs::Cheat))\ + OutF(logsys, Logs::General, Logs::Cheat, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogCheatDetail(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::Detail, Logs::Cheat))\ - OutF(LogSys, Logs::Detail, Logs::Cheat, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::Detail, Logs::Cheat))\ + OutF(logsys, Logs::Detail, Logs::Cheat, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogClientList(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::General, Logs::ClientList))\ - OutF(LogSys, Logs::General, Logs::ClientList, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::General, Logs::ClientList))\ + OutF(logsys, Logs::General, Logs::ClientList, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogClientListDetail(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::Detail, Logs::ClientList))\ - OutF(LogSys, Logs::Detail, Logs::ClientList, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::Detail, Logs::ClientList))\ + OutF(logsys, Logs::Detail, Logs::ClientList, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogDiaWind(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::General, Logs::DiaWind))\ - OutF(LogSys, Logs::General, Logs::DiaWind, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::General, Logs::DiaWind))\ + OutF(logsys, Logs::General, Logs::DiaWind, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogDiaWindDetail(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::Detail, Logs::DiaWind))\ - OutF(LogSys, Logs::Detail, Logs::DiaWind, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::Detail, Logs::DiaWind))\ + OutF(logsys, Logs::Detail, Logs::DiaWind, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogHTTP(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::General, Logs::HTTP))\ - OutF(LogSys, Logs::General, Logs::HTTP, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::General, Logs::HTTP))\ + OutF(logsys, Logs::General, Logs::HTTP, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogHTTPDetail(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::Detail, Logs::HTTP))\ - OutF(LogSys, Logs::Detail, Logs::HTTP, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::Detail, Logs::HTTP))\ + OutF(logsys, Logs::Detail, Logs::HTTP, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogSaylink(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::General, Logs::Saylink))\ - OutF(LogSys, Logs::General, Logs::Saylink, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::General, Logs::Saylink))\ + OutF(logsys, Logs::General, Logs::Saylink, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogSaylinkDetail(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::Detail, Logs::Saylink))\ - OutF(LogSys, Logs::Detail, Logs::Saylink, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::Detail, Logs::Saylink))\ + OutF(logsys, Logs::Detail, Logs::Saylink, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogChecksumVerification(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::General, Logs::ChecksumVerification))\ - OutF(LogSys, Logs::General, Logs::ChecksumVerification, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::General, Logs::ChecksumVerification))\ + OutF(logsys, Logs::General, Logs::ChecksumVerification, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogChecksumVerificationDetail(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::Detail, Logs::ChecksumVerification))\ - OutF(LogSys, Logs::Detail, Logs::ChecksumVerification, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::Detail, Logs::ChecksumVerification))\ + OutF(logsys, Logs::Detail, Logs::ChecksumVerification, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogCombatRecord(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::General, Logs::CombatRecord))\ - OutF(LogSys, Logs::General, Logs::CombatRecord, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::General, Logs::CombatRecord))\ + OutF(logsys, Logs::General, Logs::CombatRecord, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogCombatRecordDetail(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::Detail, Logs::CombatRecord))\ - OutF(LogSys, Logs::Detail, Logs::CombatRecord, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::Detail, Logs::CombatRecord))\ + OutF(logsys, Logs::Detail, Logs::CombatRecord, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogHate(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::General, Logs::Hate))\ - OutF(LogSys, Logs::General, Logs::Hate, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::General, Logs::Hate))\ + OutF(logsys, Logs::General, Logs::Hate, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogHateDetail(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::Detail, Logs::Hate))\ - OutF(LogSys, Logs::Detail, Logs::Hate, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::Detail, Logs::Hate))\ + OutF(logsys, Logs::Detail, Logs::Hate, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogDiscord(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::General, Logs::Discord))\ - OutF(LogSys, Logs::General, Logs::Discord, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::General, Logs::Discord))\ + OutF(logsys, Logs::General, Logs::Discord, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogDiscordDetail(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::Detail, Logs::Discord))\ - OutF(LogSys, Logs::Detail, Logs::Discord, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::Detail, Logs::Discord))\ + OutF(logsys, Logs::Detail, Logs::Discord, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogFaction(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::General, Logs::Faction))\ - OutF(LogSys, Logs::General, Logs::Faction, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::General, Logs::Faction))\ + OutF(logsys, Logs::General, Logs::Faction, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogFactionDetail(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::Detail, Logs::Faction))\ - OutF(LogSys, Logs::Detail, Logs::Faction, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::Detail, Logs::Faction))\ + OutF(logsys, Logs::Detail, Logs::Faction, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogPacketServerToServer(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::General, Logs::PacketServerToServer))\ - OutF(LogSys, Logs::General, Logs::PacketServerToServer, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::General, Logs::PacketServerToServer))\ + OutF(logsys, Logs::General, Logs::PacketServerToServer, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogPacketServerToServerDetail(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::Detail, Logs::PacketServerToServer))\ - OutF(LogSys, Logs::Detail, Logs::PacketServerToServer, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::Detail, Logs::PacketServerToServer))\ + OutF(logsys, Logs::Detail, Logs::PacketServerToServer, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) // manually created #define LogBugs(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::General, Logs::Bugs))\ - OutF(LogSys, Logs::General, Logs::Bugs, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::General, Logs::Bugs))\ + OutF(logsys, Logs::General, Logs::Bugs, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogBugsDetail(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::Detail, Logs::Bugs))\ - OutF(LogSys, Logs::Detail, Logs::Bugs, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::Detail, Logs::Bugs))\ + OutF(logsys, Logs::Detail, Logs::Bugs, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogQuestErrors(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::General, Logs::QuestErrors))\ - OutF(LogSys, Logs::General, Logs::QuestErrors, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::General, Logs::QuestErrors))\ + OutF(logsys, Logs::General, Logs::QuestErrors, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogQuestErrorsDetail(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::Detail, Logs::QuestErrors))\ - OutF(LogSys, Logs::Detail, Logs::QuestErrors, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::Detail, Logs::QuestErrors))\ + OutF(logsys, Logs::Detail, Logs::QuestErrors, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogPlayerEvents(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::General, Logs::PlayerEvents))\ - OutF(LogSys, Logs::General, Logs::PlayerEvents, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::General, Logs::PlayerEvents))\ + OutF(logsys, Logs::General, Logs::PlayerEvents, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogPlayerEventsDetail(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::Detail, Logs::PlayerEvents))\ - OutF(LogSys, Logs::Detail, Logs::PlayerEvents, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::Detail, Logs::PlayerEvents))\ + OutF(logsys, Logs::Detail, Logs::PlayerEvents, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogDataBuckets(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::General, Logs::DataBuckets))\ - OutF(LogSys, Logs::General, Logs::DataBuckets, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::General, Logs::DataBuckets))\ + OutF(logsys, Logs::General, Logs::DataBuckets, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogDataBucketsDetail(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::Detail, Logs::DataBuckets))\ - OutF(LogSys, Logs::Detail, Logs::DataBuckets, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::Detail, Logs::DataBuckets))\ + OutF(logsys, Logs::Detail, Logs::DataBuckets, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogZoning(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::General, Logs::Zoning))\ - OutF(LogSys, Logs::General, Logs::Zoning, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::General, Logs::Zoning))\ + OutF(logsys, Logs::General, Logs::Zoning, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogZoningDetail(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::Detail, Logs::Zoning))\ - OutF(LogSys, Logs::Detail, Logs::Zoning, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::Detail, Logs::Zoning))\ + OutF(logsys, Logs::Detail, Logs::Zoning, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogEqTime(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::General, Logs::EqTime))\ - OutF(LogSys, Logs::General, Logs::EqTime, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::General, Logs::EqTime))\ + OutF(logsys, Logs::General, Logs::EqTime, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogEqTimeDetail(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::Detail, Logs::EqTime))\ - OutF(LogSys, Logs::Detail, Logs::EqTime, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::Detail, Logs::EqTime))\ + OutF(logsys, Logs::Detail, Logs::EqTime, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogCorpses(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::General, Logs::Corpses))\ - OutF(LogSys, Logs::General, Logs::Corpses, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::General, Logs::Corpses))\ + OutF(logsys, Logs::General, Logs::Corpses, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogCorpsesDetail(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::Detail, Logs::Corpses))\ - OutF(LogSys, Logs::Detail, Logs::Corpses, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::Detail, Logs::Corpses))\ + OutF(logsys, Logs::Detail, Logs::Corpses, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogXTargets(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::General, Logs::XTargets))\ - OutF(LogSys, Logs::General, Logs::XTargets, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::General, Logs::XTargets))\ + OutF(logsys, Logs::General, Logs::XTargets, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogXTargetsDetail(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::Detail, Logs::XTargets))\ - OutF(LogSys, Logs::Detail, Logs::XTargets, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::Detail, Logs::XTargets))\ + OutF(logsys, Logs::Detail, Logs::XTargets, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogPositionUpdate(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::General, Logs::PositionUpdate))\ - OutF(LogSys, Logs::General, Logs::PositionUpdate, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::General, Logs::PositionUpdate))\ + OutF(logsys, Logs::General, Logs::PositionUpdate, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogPositionUpdateDetail(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::Detail, Logs::PositionUpdate))\ - OutF(LogSys, Logs::Detail, Logs::PositionUpdate, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__); \ + if (logsys->IsLogEnabled(Logs::Detail, Logs::PositionUpdate))\ + OutF(logsys, Logs::Detail, Logs::PositionUpdate, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__); \ } while (0) #define LogKSM(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::General, Logs::KSM))\ - OutF(LogSys, Logs::General, Logs::KSM, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::General, Logs::KSM))\ + OutF(logsys, Logs::General, Logs::KSM, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogKSMDetail(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::Detail, Logs::KSM))\ - OutF(LogSys, Logs::Detail, Logs::KSM, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::Detail, Logs::KSM))\ + OutF(logsys, Logs::Detail, Logs::KSM, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogBotSettings(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::General, Logs::BotSettings))\ - OutF(LogSys, Logs::General, Logs::BotSettings, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::General, Logs::BotSettings))\ + OutF(logsys, Logs::General, Logs::BotSettings, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogBotSettingsDetail(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::Detail, Logs::BotSettings))\ - OutF(LogSys, Logs::Detail, Logs::BotSettings, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::Detail, Logs::BotSettings))\ + OutF(logsys, Logs::Detail, Logs::BotSettings, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogBotSpellChecks(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::General, Logs::BotSpellChecks))\ - OutF(LogSys, Logs::General, Logs::BotSpellChecks, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::General, Logs::BotSpellChecks))\ + OutF(logsys, Logs::General, Logs::BotSpellChecks, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogBotSpellChecksDetail(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::Detail, Logs::BotSpellChecks))\ - OutF(LogSys, Logs::Detail, Logs::BotSpellChecks, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::Detail, Logs::BotSpellChecks))\ + OutF(logsys, Logs::Detail, Logs::BotSpellChecks, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogBotSpellTypeChecks(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::General, Logs::BotSpellTypeChecks))\ - OutF(LogSys, Logs::General, Logs::BotSpellTypeChecks, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::General, Logs::BotSpellTypeChecks))\ + OutF(logsys, Logs::General, Logs::BotSpellTypeChecks, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogBotSpellTypeChecksDetail(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::Detail, Logs::BotSpellTypeChecks))\ - OutF(LogSys, Logs::Detail, Logs::BotSpellTypeChecks, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::Detail, Logs::BotSpellTypeChecks))\ + OutF(logsys, Logs::Detail, Logs::BotSpellTypeChecks, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogNpcHandin(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::General, Logs::NpcHandin))\ - OutF(LogSys, Logs::General, Logs::NpcHandin, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::General, Logs::NpcHandin))\ + OutF(logsys, Logs::General, Logs::NpcHandin, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogNpcHandinDetail(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::Detail, Logs::NpcHandin))\ - OutF(LogSys, Logs::Detail, Logs::NpcHandin, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::Detail, Logs::NpcHandin))\ + OutF(logsys, Logs::Detail, Logs::NpcHandin, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogZoneState(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::General, Logs::ZoneState))\ - OutF(LogSys, Logs::General, Logs::ZoneState, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::General, Logs::ZoneState))\ + OutF(logsys, Logs::General, Logs::ZoneState, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogZoneStateDetail(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::Detail, Logs::ZoneState))\ - OutF(LogSys, Logs::Detail, Logs::ZoneState, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::Detail, Logs::ZoneState))\ + OutF(logsys, Logs::Detail, Logs::ZoneState, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogNetClient(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::General, Logs::NetClient))\ - OutF(LogSys, Logs::General, Logs::NetClient, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::General, Logs::NetClient))\ + OutF(logsys, Logs::General, Logs::NetClient, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogNetClientDetail(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::Detail, Logs::NetClient))\ - OutF(LogSys, Logs::Detail, Logs::NetClient, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::Detail, Logs::NetClient))\ + OutF(logsys, Logs::Detail, Logs::NetClient, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogNetTCP(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::General, Logs::NetTCP))\ - OutF(LogSys, Logs::General, Logs::NetTCP, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::General, Logs::NetTCP))\ + OutF(logsys, Logs::General, Logs::NetTCP, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogNetTCPDetail(message, ...) do {\ - if (LogSys.IsLogEnabled(Logs::Detail, Logs::NetTCP))\ - OutF(LogSys, Logs::Detail, Logs::NetTCP, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(Logs::Detail, Logs::NetTCP))\ + OutF(logsys, Logs::Detail, Logs::NetTCP, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define Log(debug_level, log_category, message, ...) do {\ - if (LogSys.IsLogEnabled(debug_level, log_category))\ - LogSys.Out(debug_level, log_category, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(debug_level, log_category))\ + logsys->Out(debug_level, log_category, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) #define LogF(debug_level, log_category, message, ...) do {\ - if (LogSys.IsLogEnabled(debug_level, log_category))\ - OutF(LogSys, debug_level, log_category, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ + if (logsys->IsLogEnabled(debug_level, log_category))\ + OutF(logsys, debug_level, log_category, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) diff --git a/common/events/player_event_discord_formatter.cpp b/common/events/player_event_discord_formatter.cpp index e3e4e5c27..5b068f507 100644 --- a/common/events/player_event_discord_formatter.cpp +++ b/common/events/player_event_discord_formatter.cpp @@ -716,7 +716,7 @@ std::string PlayerEventDiscordFormatter::FormatNPCHandinEvent( ); for (int i = 0; i < h.augment_ids.size(); i++) { - if (!Strings::EqualFold(h.augment_names[i], "None")) { + if (!h.augment_names[i].empty()) { const uint8 slot_id = (i + 1); handin_items_info += fmt::format( "Augment {}: {} ({})\n", @@ -741,7 +741,7 @@ std::string PlayerEventDiscordFormatter::FormatNPCHandinEvent( ); for (int i = 0; i < r.augment_ids.size(); i++) { - if (!Strings::EqualFold(r.augment_names[i], "None")) { + if (!r.augment_names[i].empty()) { const uint8 slot_id = (i + 1); return_items_info += fmt::format( "Augment {}: {} ({})\n", diff --git a/common/events/player_event_logs.cpp b/common/events/player_event_logs.cpp index 41be9f7d1..daa8cd17c 100644 --- a/common/events/player_event_logs.cpp +++ b/common/events/player_event_logs.cpp @@ -195,10 +195,12 @@ void PlayerEventLogs::ProcessBatchQueue() }; // Helper to assign ETL table ID - auto AssignEtlId = [&]( - PlayerEventLogsRepository::PlayerEventLogs &r, - PlayerEvent::EventType type - ) { + + auto AssignEtlId = [&]( + PlayerEventLogsRepository::PlayerEventLogs& r, + PlayerEvent::EventType type + ) + { if (m_etl_settings.contains(type)) { r.etl_table_id = m_etl_settings.at(type).next_id++; } @@ -406,7 +408,6 @@ void PlayerEventLogs::ProcessBatchQueue() auto it = event_processors.find(static_cast(r.event_type_id)); if (it != event_processors.end()) { it->second(r); // Call the appropriate lambda - r.event_data = "{}"; // Clear event data } else { LogPlayerEventsDetail("Non-Implemented ETL routing [{}]", r.event_type_id); @@ -508,7 +509,7 @@ bool PlayerEventLogs::IsEventDiscordEnabled(int32_t event_type_id) } // ensure there is a matching webhook to begin with - if (!LogSys.GetDiscordWebhooks()[m_settings[event_type_id].discord_webhook_id].webhook_url.empty()) { + if (!EQEmuLogSys::Instance()->GetDiscordWebhooks()[m_settings[event_type_id].discord_webhook_id].webhook_url.empty()) { return true; } @@ -528,13 +529,27 @@ std::string PlayerEventLogs::GetDiscordWebhookUrlFromEventType(int32_t event_typ } // ensure there is a matching webhook to begin with - if (!LogSys.GetDiscordWebhooks()[m_settings[event_type_id].discord_webhook_id].webhook_url.empty()) { - return LogSys.GetDiscordWebhooks()[m_settings[event_type_id].discord_webhook_id].webhook_url; + if (!EQEmuLogSys::Instance()->GetDiscordWebhooks()[m_settings[event_type_id].discord_webhook_id].webhook_url.empty()) { + return EQEmuLogSys::Instance()->GetDiscordWebhooks()[m_settings[event_type_id].discord_webhook_id].webhook_url; } return ""; } +void PlayerEventLogs::LoadPlayerEventSettingsFromQS( + const std::vector &settings +) +{ + for (const auto &e : settings) { + if (e.id >= PlayerEvent::MAX || e.id < 0) { + continue; + } + m_settings[e.id] = e; + } + + LogInfo("Applied [{}] player event log settings from QS", settings.size()); +} + // GM_COMMAND | [x] Implemented Formatter // ZONING | [x] Implemented Formatter // AA_GAIN | [x] Implemented Formatter diff --git a/common/events/player_event_logs.h b/common/events/player_event_logs.h index 8a9ccb202..cbc455666 100644 --- a/common/events/player_event_logs.h +++ b/common/events/player_event_logs.h @@ -73,9 +73,11 @@ public: return BuildPlayerEventPacket(c); } - [[nodiscard]] const PlayerEventLogSettingsRepository::PlayerEventLogSettings *GetSettings() const; - bool IsEventDiscordEnabled(int32_t event_type_id); - std::string GetDiscordWebhookUrlFromEventType(int32_t event_type_id); + [[nodiscard]] const PlayerEventLogSettingsRepository::PlayerEventLogSettings * GetSettings() const; + bool IsEventDiscordEnabled(int32_t event_type_id); + std::string GetDiscordWebhookUrlFromEventType(int32_t event_type_id); + + void LoadPlayerEventSettingsFromQS(const std::vector& settings); static std::string GetDiscordPayloadFromEvent(const PlayerEvent::PlayerEventContainer &e); diff --git a/common/events/player_events.h b/common/events/player_events.h index 78b9fc10d..b2a485621 100644 --- a/common/events/player_events.h +++ b/common/events/player_events.h @@ -7,8 +7,16 @@ #include "../rulesys.h" #include "../repositories/player_event_logs_repository.h" -namespace PlayerEvent { +#define CEREAL_NVP_IF_NONZERO(ar, name) \ +if ((name) != 0) ar(cereal::make_nvp(#name, name)) +#define CEREAL_NVP_IF_NOT_EMPTY(ar, name) \ +if (!(name).empty()) ar(cereal::make_nvp(#name, name)) + +#define CEREAL_NVP_IF_TRUE(ar, name) \ +if ((name)) ar(cereal::make_nvp(#name, name)) + +namespace PlayerEvent { enum EventType { GM_COMMAND = 1, ZONING, @@ -26,10 +34,10 @@ namespace PlayerEvent { LOOT_ITEM, MERCHANT_PURCHASE, MERCHANT_SELL, - GROUP_JOIN, // unimplemented + GROUP_JOIN, // unimplemented GROUP_LEAVE, // unimplemented - RAID_JOIN, // unimplemented - RAID_LEAVE, // unimplemented + RAID_JOIN, // unimplemented + RAID_LEAVE, // unimplemented GROUNDSPAWN_PICKUP, NPC_HANDIN, SKILL_UP, @@ -45,12 +53,12 @@ namespace PlayerEvent { COMBINE_SUCCESS, DROPPED_ITEM, SPLIT_MONEY, - DZ_JOIN, // unimplemented + DZ_JOIN, // unimplemented DZ_LEAVE, // unimplemented TRADER_PURCHASE, TRADER_SELL, BANDOLIER_CREATE, // unimplemented - BANDOLIER_SWAP, // unimplemented + BANDOLIER_SWAP, // unimplemented DISCOVER_ITEM, POSSIBLE_HACK, KILLED_NPC, @@ -76,7 +84,7 @@ namespace PlayerEvent { // If event is unimplemented just tag (Unimplemented) in the name // Events don't get saved to the database if unimplemented or deprecated // Events tagged as deprecated will get automatically removed - static const char *EventName[EventType::MAX] = { + static const char* EventName[EventType::MAX] = { "None", "GM Command", "Zoning", @@ -156,8 +164,8 @@ namespace PlayerEvent { float heading; // cereal - template - void serialize(Archive &ar) + template + void serialize(Archive& ar) { ar( CEREAL_NVP(account_id), @@ -185,8 +193,8 @@ namespace PlayerEvent { PlayerEventLogsRepository::PlayerEventLogs player_event_log; // cereal - template - void serialize(Archive &ar) + template + void serialize(Archive& ar) { ar( CEREAL_NVP(player_event), @@ -200,8 +208,8 @@ namespace PlayerEvent { std::string noop; // noop, gets discard upstream // cereal - template - void serialize(Archive &ar) + template + void serialize(Archive& ar) { ar( CEREAL_NVP(noop) @@ -224,8 +232,38 @@ namespace PlayerEvent { bool attuned; // cereal - template - void serialize(Archive &ar) + template + void serialize(Archive& ar) + { + if constexpr (Archive::is_saving::value) { + save(ar); + } + else { + load(ar); + } + } + + template + void save(Archive& ar) const + { + ar( + CEREAL_NVP(item_id), + CEREAL_NVP(item_name), + CEREAL_NVP(to_slot), + CEREAL_NVP(charges) + ); + + CEREAL_NVP_IF_NONZERO(ar, augment_1_id); + CEREAL_NVP_IF_NONZERO(ar, augment_2_id); + CEREAL_NVP_IF_NONZERO(ar, augment_3_id); + CEREAL_NVP_IF_NONZERO(ar, augment_4_id); + CEREAL_NVP_IF_NONZERO(ar, augment_5_id); + CEREAL_NVP_IF_NONZERO(ar, augment_6_id); + CEREAL_NVP_IF_TRUE(ar, attuned); + } + + template + void load(Archive& ar) { ar( CEREAL_NVP(item_id), @@ -284,8 +322,37 @@ namespace PlayerEvent { // cereal - template - void serialize(Archive &ar) + template + void save(Archive& ar) const + { + ar( + CEREAL_NVP(slot), + CEREAL_NVP(item_id) + ); + + CEREAL_NVP_IF_NONZERO(ar, augment_1_id); + CEREAL_NVP_IF_NOT_EMPTY(ar, augment_1_name); + CEREAL_NVP_IF_NONZERO(ar, augment_2_id); + CEREAL_NVP_IF_NOT_EMPTY(ar, augment_2_name); + CEREAL_NVP_IF_NONZERO(ar, augment_3_id); + CEREAL_NVP_IF_NOT_EMPTY(ar, augment_3_name); + CEREAL_NVP_IF_NONZERO(ar, augment_4_id); + CEREAL_NVP_IF_NOT_EMPTY(ar, augment_4_name); + CEREAL_NVP_IF_NONZERO(ar, augment_5_id); + CEREAL_NVP_IF_NOT_EMPTY(ar, augment_5_name); + CEREAL_NVP_IF_NONZERO(ar, augment_6_id); + CEREAL_NVP_IF_NOT_EMPTY(ar, augment_6_name); + + ar( + CEREAL_NVP(item_name), + CEREAL_NVP(charges) + ); + + CEREAL_NVP_IF_TRUE(ar, in_bag); + } + + template + void load(Archive& ar) { ar( CEREAL_NVP(slot), @@ -295,7 +362,7 @@ namespace PlayerEvent { CEREAL_NVP(augment_2_id), CEREAL_NVP(augment_2_name), CEREAL_NVP(augment_3_id), - CEREAL_NVP(augment_1_name), + CEREAL_NVP(augment_3_name), CEREAL_NVP(augment_4_id), CEREAL_NVP(augment_4_name), CEREAL_NVP(augment_5_id), @@ -319,8 +386,8 @@ namespace PlayerEvent { int32 copper; // cereal - template - void serialize(Archive &ar) + template + void serialize(Archive& ar) { ar( CEREAL_NVP(platinum), @@ -342,8 +409,8 @@ namespace PlayerEvent { std::vector character_2_give_items; // cereal - template - void serialize(Archive &ar) + template + void serialize(Archive& ar) { ar( CEREAL_NVP(character_1_id), @@ -363,8 +430,8 @@ namespace PlayerEvent { std::string target; // cereal - template - void serialize(Archive &ar) + template + void serialize(Archive& ar) { ar( CEREAL_NVP(message), @@ -386,8 +453,8 @@ namespace PlayerEvent { int32 to_instance_version; // cereal - template - void serialize(Archive &ar) + template + void serialize(Archive& ar) { ar( CEREAL_NVP(from_zone_long_name), @@ -408,8 +475,8 @@ namespace PlayerEvent { uint32 aa_gained; // cereal - template - void serialize(Archive &ar) + template + void serialize(Archive& ar) { ar(CEREAL_NVP(aa_gained)); } @@ -422,8 +489,8 @@ namespace PlayerEvent { int32 aa_next_id; // cereal - template - void serialize(Archive &ar) + template + void serialize(Archive& ar) { ar( CEREAL_NVP(aa_id), @@ -444,9 +511,34 @@ namespace PlayerEvent { uint32 augment_6_id; std::string item_name; - // cereal - template - void serialize(Archive &ar) + template + void serialize(Archive& ar) + { + if constexpr (Archive::is_saving::value) { + save(ar); + } + else { + load(ar); + } + } + + template + void save(Archive& ar) const + { + ar(CEREAL_NVP(item_id)); + + CEREAL_NVP_IF_NONZERO(ar, augment_1_id); + CEREAL_NVP_IF_NONZERO(ar, augment_2_id); + CEREAL_NVP_IF_NONZERO(ar, augment_3_id); + CEREAL_NVP_IF_NONZERO(ar, augment_4_id); + CEREAL_NVP_IF_NONZERO(ar, augment_5_id); + CEREAL_NVP_IF_NONZERO(ar, augment_6_id); + + ar(CEREAL_NVP(item_name)); + } + + template + void load(Archive& ar) { ar( CEREAL_NVP(item_id), @@ -471,9 +563,34 @@ namespace PlayerEvent { uint32 augment_6_id; std::string item_name; - // cereal - template - void serialize(Archive &ar) + template + void serialize(Archive& ar) + { + if constexpr (Archive::is_saving::value) { + save(ar); + } + else { + load(ar); + } + } + + template + void save(Archive& ar) const + { + ar(CEREAL_NVP(item_id)); + + CEREAL_NVP_IF_NONZERO(ar, augment_1_id); + CEREAL_NVP_IF_NONZERO(ar, augment_2_id); + CEREAL_NVP_IF_NONZERO(ar, augment_3_id); + CEREAL_NVP_IF_NONZERO(ar, augment_4_id); + CEREAL_NVP_IF_NONZERO(ar, augment_5_id); + CEREAL_NVP_IF_NONZERO(ar, augment_6_id); + + ar(CEREAL_NVP(item_name)); + } + + template + void load(Archive& ar) { ar( CEREAL_NVP(item_id), @@ -501,9 +618,41 @@ namespace PlayerEvent { bool attuned; std::string reason; - // cereal - template - void serialize(Archive &ar) + template + void serialize(Archive& ar) + { + if constexpr (Archive::is_saving::value) { + save(ar); + } + else { + load(ar); + } + } + + template + void save(Archive& ar) const + { + ar( + CEREAL_NVP(item_id), + CEREAL_NVP(item_name), + CEREAL_NVP(charges) + ); + + CEREAL_NVP_IF_NONZERO(ar, augment_1_id); + CEREAL_NVP_IF_NONZERO(ar, augment_2_id); + CEREAL_NVP_IF_NONZERO(ar, augment_3_id); + CEREAL_NVP_IF_NONZERO(ar, augment_4_id); + CEREAL_NVP_IF_NONZERO(ar, augment_5_id); + CEREAL_NVP_IF_NONZERO(ar, augment_6_id); + + ar( + CEREAL_NVP(attuned), + CEREAL_NVP(reason) + ); + } + + template + void load(Archive& ar) { ar( CEREAL_NVP(item_id), @@ -521,14 +670,15 @@ namespace PlayerEvent { } }; + struct LevelGainedEvent { uint32 from_level; uint8 to_level; int levels_gained; // cereal - template - void serialize(Archive &ar) + template + void serialize(Archive& ar) { ar( CEREAL_NVP(from_level), @@ -544,8 +694,8 @@ namespace PlayerEvent { int levels_lost; // cereal - template - void serialize(Archive &ar) + template + void serialize(Archive& ar) { ar( CEREAL_NVP(from_level), @@ -569,8 +719,41 @@ namespace PlayerEvent { std::string corpse_name; // cereal - template - void serialize(Archive &ar) + template + void serialize(Archive& ar) + { + if constexpr (Archive::is_saving::value) { + save(ar); + } + else { + load(ar); + } + } + + template + void save(Archive& ar) const + { + ar( + CEREAL_NVP(item_id), + CEREAL_NVP(item_name), + CEREAL_NVP(charges) + ); + + CEREAL_NVP_IF_NONZERO(ar, augment_1_id); + CEREAL_NVP_IF_NONZERO(ar, augment_2_id); + CEREAL_NVP_IF_NONZERO(ar, augment_3_id); + CEREAL_NVP_IF_NONZERO(ar, augment_4_id); + CEREAL_NVP_IF_NONZERO(ar, augment_5_id); + CEREAL_NVP_IF_NONZERO(ar, augment_6_id); + + ar( + CEREAL_NVP(npc_id), + CEREAL_NVP(corpse_name) + ); + } + + template + void load(Archive& ar) { ar( CEREAL_NVP(item_id), @@ -601,8 +784,8 @@ namespace PlayerEvent { uint64 player_currency_balance; // cereal - template - void serialize(Archive &ar) + template + void serialize(Archive& ar) { ar( CEREAL_NVP(npc_id), @@ -632,8 +815,8 @@ namespace PlayerEvent { uint64 player_currency_balance; // cereal - template - void serialize(Archive &ar) + template + void serialize(Archive& ar) { ar( CEREAL_NVP(npc_id), @@ -657,8 +840,8 @@ namespace PlayerEvent { std::string against_who; // cereal - template - void serialize(Archive &ar) + template + void serialize(Archive& ar) { ar( CEREAL_NVP(skill_id), @@ -676,8 +859,8 @@ namespace PlayerEvent { std::string task_name; // cereal - template - void serialize(Archive &ar) + template + void serialize(Archive& ar) { ar( CEREAL_NVP(npc_id), @@ -695,8 +878,8 @@ namespace PlayerEvent { uint32 done_count; // cereal - template - void serialize(Archive &ar) + template + void serialize(Archive& ar) { ar( CEREAL_NVP(task_id), @@ -714,8 +897,8 @@ namespace PlayerEvent { uint32 done_count; // cereal - template - void serialize(Archive &ar) + template + void serialize(Archive& ar) { ar( CEREAL_NVP(task_id), @@ -731,8 +914,8 @@ namespace PlayerEvent { std::string item_name; // cereal - template - void serialize(Archive &ar) + template + void serialize(Archive& ar) { ar( CEREAL_NVP(item_id), @@ -746,8 +929,8 @@ namespace PlayerEvent { std::string target; // cereal - template - void serialize(Archive &ar) + template + void serialize(Archive& ar) { ar( CEREAL_NVP(message), @@ -762,8 +945,8 @@ namespace PlayerEvent { uint32 spell_id; // cereal - template - void serialize(Archive &ar) + template + void serialize(Archive& ar) { ar( CEREAL_NVP(resurrecter_name), @@ -780,8 +963,8 @@ namespace PlayerEvent { uint32 tradeskill_id; // cereal - template - void serialize(Archive &ar) + template + void serialize(Archive& ar) { ar( CEREAL_NVP(recipe_id), @@ -805,8 +988,38 @@ namespace PlayerEvent { uint32 charges; // cereal - template - void serialize(Archive &ar) + template + void serialize(Archive& ar) + { + if constexpr (Archive::is_saving::value) { + save(ar); + } + else { + load(ar); + } + } + + template + void save(Archive& ar) const + { + ar(CEREAL_NVP(item_id)); + + CEREAL_NVP_IF_NONZERO(ar, augment_1_id); + CEREAL_NVP_IF_NONZERO(ar, augment_2_id); + CEREAL_NVP_IF_NONZERO(ar, augment_3_id); + CEREAL_NVP_IF_NONZERO(ar, augment_4_id); + CEREAL_NVP_IF_NONZERO(ar, augment_5_id); + CEREAL_NVP_IF_NONZERO(ar, augment_6_id); + + ar( + CEREAL_NVP(item_name), + CEREAL_NVP(slot_id), + CEREAL_NVP(charges) + ); + } + + template + void load(Archive& ar) { ar( CEREAL_NVP(item_id), @@ -833,8 +1046,8 @@ namespace PlayerEvent { std::string skill_name; // cereal - template - void serialize(Archive &ar) + template + void serialize(Archive& ar) { ar( CEREAL_NVP(killer_id), @@ -856,8 +1069,8 @@ namespace PlayerEvent { uint64 player_money_balance; // cereal - template - void serialize(Archive &ar) + template + void serialize(Archive& ar) { ar( CEREAL_NVP(copper), @@ -886,10 +1099,44 @@ namespace PlayerEvent { uint64 total_cost; uint64 player_money_balance; - // cereal - template - void serialize(Archive &ar) + template + void serialize(Archive& ar) + { + if constexpr (Archive::is_saving::value) { + save(ar); + } + else { + load(ar); + } + } + + template + void save(Archive& ar) const + { + ar(CEREAL_NVP(item_id)); + + CEREAL_NVP_IF_NONZERO(ar, augment_1_id); + CEREAL_NVP_IF_NONZERO(ar, augment_2_id); + CEREAL_NVP_IF_NONZERO(ar, augment_3_id); + CEREAL_NVP_IF_NONZERO(ar, augment_4_id); + CEREAL_NVP_IF_NONZERO(ar, augment_5_id); + CEREAL_NVP_IF_NONZERO(ar, augment_6_id); + + ar( + CEREAL_NVP(item_name), + CEREAL_NVP(trader_id), + CEREAL_NVP(trader_name), + CEREAL_NVP(price), + CEREAL_NVP(quantity), + CEREAL_NVP(charges), + CEREAL_NVP(total_cost), + CEREAL_NVP(player_money_balance) + ); + } + + template + void load(Archive& ar) { ar( CEREAL_NVP(item_id), @@ -928,10 +1175,43 @@ namespace PlayerEvent { uint64 total_cost; uint64 player_money_balance; + template + void serialize(Archive& ar) + { + if constexpr (Archive::is_saving::value) { + save(ar); + } + else { + load(ar); + } + } - // cereal - template - void serialize(Archive &ar) + template + void save(Archive& ar) const + { + ar(CEREAL_NVP(item_id)); + + CEREAL_NVP_IF_NONZERO(ar, augment_1_id); + CEREAL_NVP_IF_NONZERO(ar, augment_2_id); + CEREAL_NVP_IF_NONZERO(ar, augment_3_id); + CEREAL_NVP_IF_NONZERO(ar, augment_4_id); + CEREAL_NVP_IF_NONZERO(ar, augment_5_id); + CEREAL_NVP_IF_NONZERO(ar, augment_6_id); + + ar( + CEREAL_NVP(item_name), + CEREAL_NVP(buyer_id), + CEREAL_NVP(buyer_name), + CEREAL_NVP(price), + CEREAL_NVP(quantity), + CEREAL_NVP(charges), + CEREAL_NVP(total_cost), + CEREAL_NVP(player_money_balance) + ); + } + + template + void load(Archive& ar) { ar( CEREAL_NVP(item_id), @@ -958,8 +1238,8 @@ namespace PlayerEvent { std::string item_name; // cereal - template - void serialize(Archive &ar) + template + void serialize(Archive& ar) { ar( CEREAL_NVP(item_id), @@ -978,8 +1258,8 @@ namespace PlayerEvent { bool attuned; // cereal - template - void serialize(Archive &ar) + template + void serialize(Archive& ar) { ar( CEREAL_NVP(item_id), @@ -1000,8 +1280,8 @@ namespace PlayerEvent { uint32 platinum; // cereal - template - void serialize(Archive &ar) + template + void serialize(Archive& ar) { ar( CEREAL_NVP(copper), @@ -1022,8 +1302,8 @@ namespace PlayerEvent { bool is_quest_handin; // cereal - template - void serialize(Archive &ar) + template + void serialize(Archive& ar) { ar( CEREAL_NVP(npc_id), @@ -1041,8 +1321,8 @@ namespace PlayerEvent { std::string message; // cereal - template - void serialize(Archive &ar) + template + void serialize(Archive& ar) { ar( CEREAL_NVP(message) @@ -1058,8 +1338,8 @@ namespace PlayerEvent { uint64 total_heal_per_second_taken; // cereal - template - void serialize(Archive &ar) + template + void serialize(Archive& ar) { ar( CEREAL_NVP(npc_id), @@ -1083,9 +1363,36 @@ namespace PlayerEvent { bool attuned; uint32 guild_favor; - // cereal - template - void serialize(Archive &ar) + template + void serialize(Archive& ar) + { + if constexpr (Archive::is_saving::value) { + save(ar); + } + else { + load(ar); + } + } + + template + void save(Archive& ar) const + { + ar(CEREAL_NVP(item_id)); + + CEREAL_NVP_IF_NONZERO(ar, augment_1_id); + CEREAL_NVP_IF_NONZERO(ar, augment_2_id); + CEREAL_NVP_IF_NONZERO(ar, augment_3_id); + CEREAL_NVP_IF_NONZERO(ar, augment_4_id); + CEREAL_NVP_IF_NONZERO(ar, augment_5_id); + CEREAL_NVP_IF_NONZERO(ar, augment_6_id); + CEREAL_NVP_IF_NONZERO(ar, charges); + CEREAL_NVP_IF_TRUE(ar, attuned); + + ar(CEREAL_NVP(guild_favor)); + } + + template + void load(Archive& ar) { ar( CEREAL_NVP(item_id), @@ -1095,6 +1402,8 @@ namespace PlayerEvent { CEREAL_NVP(augment_4_id), CEREAL_NVP(augment_5_id), CEREAL_NVP(augment_6_id), + CEREAL_NVP(charges), + CEREAL_NVP(attuned), CEREAL_NVP(guild_favor) ); } @@ -1105,8 +1414,8 @@ namespace PlayerEvent { uint32 guild_favor; // cereal - template - void serialize(Archive &ar) + template + void serialize(Archive& ar) { ar( CEREAL_NVP(plat), @@ -1127,9 +1436,38 @@ namespace PlayerEvent { std::string from_player_name; uint32 sent_date; - // cereal - template - void serialize(Archive &ar) + template + void serialize(Archive& ar) + { + if constexpr (Archive::is_saving::value) { + save(ar); + } + else { + load(ar); + } + } + + template + void save(Archive& ar) const + { + ar(CEREAL_NVP(item_id)); + + CEREAL_NVP_IF_NONZERO(ar, augment_1_id); + CEREAL_NVP_IF_NONZERO(ar, augment_2_id); + CEREAL_NVP_IF_NONZERO(ar, augment_3_id); + CEREAL_NVP_IF_NONZERO(ar, augment_4_id); + CEREAL_NVP_IF_NONZERO(ar, augment_5_id); + CEREAL_NVP_IF_NONZERO(ar, augment_6_id); + + ar( + CEREAL_NVP(quantity), + CEREAL_NVP(from_player_name), + CEREAL_NVP(sent_date) + ); + } + + template + void load(Archive& ar) { ar( CEREAL_NVP(item_id), @@ -1160,9 +1498,40 @@ namespace PlayerEvent { std::string to_player_name; uint32 sent_date; - // cereal - template - void serialize(Archive &ar) + template + void serialize(Archive& ar) + { + if constexpr (Archive::is_saving::value) { + save(ar); + } + else { + load(ar); + } + } + + template + void save(Archive& ar) const + { + ar(CEREAL_NVP(item_id)); + + CEREAL_NVP_IF_NONZERO(ar, augment_1_id); + CEREAL_NVP_IF_NONZERO(ar, augment_2_id); + CEREAL_NVP_IF_NONZERO(ar, augment_3_id); + CEREAL_NVP_IF_NONZERO(ar, augment_4_id); + CEREAL_NVP_IF_NONZERO(ar, augment_5_id); + CEREAL_NVP_IF_NONZERO(ar, augment_6_id); + CEREAL_NVP_IF_NONZERO(ar, charges); + + ar( + CEREAL_NVP(quantity), + CEREAL_NVP(from_player_name), + CEREAL_NVP(to_player_name), + CEREAL_NVP(sent_date) + ); + } + + template + void load(Archive& ar) { ar( CEREAL_NVP(item_id), @@ -1195,9 +1564,40 @@ namespace PlayerEvent { std::string from_name; std::string note; - // cereal - template - void serialize(Archive &ar) + template + void serialize(Archive& ar) + { + if constexpr (Archive::is_saving::value) { + save(ar); + } + else { + load(ar); + } + } + + template + void save(Archive& ar) const + { + ar(CEREAL_NVP(item_id)); + + CEREAL_NVP_IF_NONZERO(ar, augment_1_id); + CEREAL_NVP_IF_NONZERO(ar, augment_2_id); + CEREAL_NVP_IF_NONZERO(ar, augment_3_id); + CEREAL_NVP_IF_NONZERO(ar, augment_4_id); + CEREAL_NVP_IF_NONZERO(ar, augment_5_id); + CEREAL_NVP_IF_NONZERO(ar, augment_6_id); + + ar( + CEREAL_NVP(quantity), + CEREAL_NVP(char_id), + CEREAL_NVP(from_name), + CEREAL_NVP(note), + CEREAL_NVP(sent_date) + ); + } + + template + void load(Archive& ar) { ar( CEREAL_NVP(item_id), @@ -1226,8 +1626,8 @@ namespace PlayerEvent { std::string seller_name; uint64 total_cost; // cereal - template - void serialize(Archive &ar) + template + void serialize(Archive& ar) { ar( CEREAL_NVP(status), @@ -1251,8 +1651,8 @@ namespace PlayerEvent { double progression; // cereal - template - void serialize(Archive &ar) + template + void serialize(Archive& ar) { ar( CEREAL_NVP(status), @@ -1273,8 +1673,8 @@ namespace PlayerEvent { uint32 type; std::string message; - template - void serialize(Archive &ar) + template + void serialize(Archive& ar) { ar( CEREAL_NVP(to), @@ -1300,9 +1700,41 @@ namespace PlayerEvent { uint32 quantity; uint32 permission; - // cereal - template - void serialize(Archive &ar) + template + void serialize(Archive& ar) + { + if constexpr (Archive::is_saving::value) { + save(ar); + } + else { + load(ar); + } + } + + template + void save(Archive& ar) const + { + ar( + CEREAL_NVP(char_id), + CEREAL_NVP(guild_id), + CEREAL_NVP(item_id) + ); + + CEREAL_NVP_IF_NONZERO(ar, aug_slot_one); + CEREAL_NVP_IF_NONZERO(ar, aug_slot_two); + CEREAL_NVP_IF_NONZERO(ar, aug_slot_three); + CEREAL_NVP_IF_NONZERO(ar, aug_slot_four); + CEREAL_NVP_IF_NONZERO(ar, aug_slot_five); + CEREAL_NVP_IF_NONZERO(ar, aug_slot_six); + + ar( + CEREAL_NVP(quantity), + CEREAL_NVP(permission) + ); + } + + template + void load(Archive& ar) { ar( CEREAL_NVP(char_id), @@ -1314,8 +1746,9 @@ namespace PlayerEvent { CEREAL_NVP(aug_slot_four), CEREAL_NVP(aug_slot_five), CEREAL_NVP(aug_slot_six), - CEREAL_NVP(quantity) - ); + CEREAL_NVP(quantity), + CEREAL_NVP(permission) + ); } }; } diff --git a/common/ipc_mutex.cpp b/common/ipc_mutex.cpp index e2c123f22..ebd13a693 100644 --- a/common/ipc_mutex.cpp +++ b/common/ipc_mutex.cpp @@ -55,7 +55,7 @@ namespace EQ { EQ_EXCEPT("IPC Mutex", "Could not create mutex."); } #else - std::string final_name = fmt::format("{}/{}.lock", path.GetSharedMemoryPath(), name); + std::string final_name = fmt::format("{}/{}.lock", PathManager::Instance()->GetSharedMemoryPath(), name); #ifdef __DARWIN #if __DARWIN_C_LEVEL < 200809L diff --git a/common/item_instance.cpp b/common/item_instance.cpp index c25ea09d2..b2d619b5a 100644 --- a/common/item_instance.cpp +++ b/common/item_instance.cpp @@ -1799,7 +1799,7 @@ std::vector EQ::ItemInstance::GetAugmentNames() const for (uint8 slot_id = invaug::SOCKET_BEGIN; slot_id <= invaug::SOCKET_END; slot_id++) { const auto augment = GetAugment(slot_id); - augment_names.push_back(augment ? augment->GetItem()->Name : "None"); + augment_names.push_back(augment ? augment->GetItem()->Name : ""); } return augment_names; diff --git a/common/net/daybreak_connection.cpp b/common/net/daybreak_connection.cpp index 322107103..9d40eadb8 100644 --- a/common/net/daybreak_connection.cpp +++ b/common/net/daybreak_connection.cpp @@ -1167,7 +1167,7 @@ void EQ::Net::DaybreakConnection::ProcessResend(int stream) } } - if (LogSys.IsLogEnabled(Logs::General, Logs::NetClient)) { + if (EQEmuLogSys::Instance()->IsLogEnabled(Logs::General, Logs::NetClient)) { size_t total_size = 0; for (auto &e: s->sent_packets) { total_size += e.second.packet.Length(); diff --git a/common/net/eqstream.cpp b/common/net/eqstream.cpp index 34ad10e41..0e3c671d7 100644 --- a/common/net/eqstream.cpp +++ b/common/net/eqstream.cpp @@ -71,7 +71,7 @@ void EQ::Net::EQStream::QueuePacket(const EQApplicationPacket *p, bool ack_req) OpcodeManager::EmuToName(p->GetOpcode()), (*m_opcode_manager)->EmuToEQ(p->GetOpcode()), p->Size(), - (LogSys.IsLogEnabled(Logs::Detail, Logs::PacketServerClient) ? DumpPacketToString(p) : "") + (EQEmuLogSys::Instance()->IsLogEnabled(Logs::Detail, Logs::PacketServerClient) ? DumpPacketToString(p) : "") ); if (m_opcode_manager && *m_opcode_manager) { diff --git a/common/net/servertalk_server_connection.cpp b/common/net/servertalk_server_connection.cpp index 02d4f9419..efc2d572e 100644 --- a/common/net/servertalk_server_connection.cpp +++ b/common/net/servertalk_server_connection.cpp @@ -319,7 +319,7 @@ void EQ::Net::ServertalkServerConnection::ProcessMessage(EQ::Net::Packet &p) size_t message_len = length; EQ::Net::StaticPacket packet(&data[0], message_len); - const auto is_detail_enabled = LogSys.IsLogEnabled(Logs::Detail, Logs::PacketServerToServer); + const auto is_detail_enabled = EQEmuLogSys::Instance()->IsLogEnabled(Logs::Detail, Logs::PacketServerToServer); if (opcode != ServerOP_KeepAlive || is_detail_enabled) { LogPacketServerToServer( "[{:#06x}] Size [{}] {}", diff --git a/common/patches/rof.cpp b/common/patches/rof.cpp index 0e23bb429..15b745b16 100644 --- a/common/patches/rof.cpp +++ b/common/patches/rof.cpp @@ -78,7 +78,7 @@ namespace RoF { //create our opcode manager if we havent already if (opcodes == nullptr) { - std::string opfile = fmt::format("{}/patch_{}.conf", path.GetPatchPath(), name); + std::string opfile = fmt::format("{}/patch_{}.conf", PathManager::Instance()->GetPatchPath(), name); //load up the opcode manager. //TODO: figure out how to support shared memory with multiple patches... @@ -117,7 +117,7 @@ namespace RoF //we need to go to every stream and replace it's manager. if (opcodes != nullptr) { - std::string opfile = fmt::format("{}/patch_{}.conf", path.GetPatchPath(), name); + std::string opfile = fmt::format("{}/patch_{}.conf", PathManager::Instance()->GetPatchPath(), name); if (!opcodes->ReloadOpcodes(opfile.c_str())) { LogNetcode("[OPCODES] Error reloading opcodes file [{}] for patch [{}]", opfile.c_str(), name); return; diff --git a/common/patches/rof2.cpp b/common/patches/rof2.cpp index 747d68204..0d4043d30 100644 --- a/common/patches/rof2.cpp +++ b/common/patches/rof2.cpp @@ -81,7 +81,7 @@ namespace RoF2 //create our opcode manager if we havent already if (opcodes == nullptr) { - std::string opfile = fmt::format("{}/patch_{}.conf", path.GetPatchPath(), name); + std::string opfile = fmt::format("{}/patch_{}.conf", PathManager::Instance()->GetPatchPath(), name); //load up the opcode manager. //TODO: figure out how to support shared memory with multiple patches... @@ -123,7 +123,7 @@ namespace RoF2 //we need to go to every stream and replace it's manager. if (opcodes != nullptr) { - std::string opfile = fmt::format("{}/patch_{}.conf", path.GetPatchPath(), name); + std::string opfile = fmt::format("{}/patch_{}.conf", PathManager::Instance()->GetPatchPath(), name); if (!opcodes->ReloadOpcodes(opfile.c_str())) { LogNetcode("[OPCODES] Error reloading opcodes file [{}] for patch [{}]", opfile.c_str(), name); return; diff --git a/common/patches/sod.cpp b/common/patches/sod.cpp index d8f174196..72a3a3c48 100644 --- a/common/patches/sod.cpp +++ b/common/patches/sod.cpp @@ -72,7 +72,7 @@ namespace SoD { //create our opcode manager if we havent already if (opcodes == nullptr) { - std::string opfile = fmt::format("{}/patch_{}.conf", path.GetPatchPath(), name); + std::string opfile = fmt::format("{}/patch_{}.conf", PathManager::Instance()->GetPatchPath(), name); //load up the opcode manager. //TODO: figure out how to support shared memory with multiple patches... opcodes = new RegularOpcodeManager(); @@ -113,7 +113,7 @@ namespace SoD //we need to go to every stream and replace it's manager. if (opcodes != nullptr) { - std::string opfile = fmt::format("{}/patch_{}.conf", path.GetPatchPath(), name); + std::string opfile = fmt::format("{}/patch_{}.conf", PathManager::Instance()->GetPatchPath(), name); if (!opcodes->ReloadOpcodes(opfile.c_str())) { LogNetcode("[OPCODES] Error reloading opcodes file [{}] for patch [{}]", opfile.c_str(), name); return; @@ -3966,12 +3966,12 @@ namespace SoD SoDSlot = serverSlot - 2; } - else if (serverSlot <= EQ::invbag::GENERAL_BAGS_8_END && serverSlot >= EQ::invbag::GENERAL_BAGS_BEGIN) { - SoDSlot = serverSlot + 11; + else if (serverSlot <= EQ::invbag::GENERAL_BAGS_END && serverSlot >= EQ::invbag::GENERAL_BAGS_BEGIN) { + SoDSlot = serverSlot - (EQ::invbag::GENERAL_BAGS_BEGIN - invbag::GENERAL_BAGS_BEGIN) - ((EQ::invbag::SLOT_COUNT - invbag::SLOT_COUNT) * ((serverSlot - EQ::invbag::GENERAL_BAGS_BEGIN) / EQ::invbag::SLOT_COUNT));; } else if (serverSlot <= EQ::invbag::CURSOR_BAG_END && serverSlot >= EQ::invbag::CURSOR_BAG_BEGIN) { - SoDSlot = serverSlot - 9; + SoDSlot = serverSlot - (EQ::invbag::CURSOR_BAG_BEGIN - invbag::CURSOR_BAG_BEGIN); } else if (serverSlot <= EQ::invslot::TRIBUTE_END && serverSlot >= EQ::invslot::TRIBUTE_BEGIN) { @@ -3991,7 +3991,7 @@ namespace SoD } else if (serverSlot <= EQ::invbag::BANK_BAGS_END && serverSlot >= EQ::invbag::BANK_BAGS_BEGIN) { - SoDSlot = serverSlot + 1; + SoDSlot = serverSlot - (EQ::invbag::BANK_BAGS_BEGIN - invbag::BANK_BAGS_BEGIN) - ((EQ::invbag::SLOT_COUNT - invbag::SLOT_COUNT) * ((serverSlot - EQ::invbag::BANK_BAGS_BEGIN) / EQ::invbag::SLOT_COUNT));; } else if (serverSlot <= EQ::invslot::SHARED_BANK_END && serverSlot >= EQ::invslot::SHARED_BANK_BEGIN) { @@ -3999,7 +3999,7 @@ namespace SoD } else if (serverSlot <= EQ::invbag::SHARED_BANK_BAGS_END && serverSlot >= EQ::invbag::SHARED_BANK_BAGS_BEGIN) { - SoDSlot = serverSlot + 1; + SoDSlot = serverSlot - (EQ::invbag::SHARED_BANK_BAGS_BEGIN - invbag::SHARED_BANK_BAGS_BEGIN) - ((EQ::invbag::SLOT_COUNT - invbag::SLOT_COUNT) * ((serverSlot - EQ::invbag::SHARED_BANK_BAGS_BEGIN) / EQ::invbag::SLOT_COUNT)); } else if (serverSlot <= EQ::invslot::TRADE_END && serverSlot >= EQ::invslot::TRADE_BEGIN) { @@ -4007,7 +4007,7 @@ namespace SoD } else if (serverSlot <= EQ::invbag::TRADE_BAGS_END && serverSlot >= EQ::invbag::TRADE_BAGS_BEGIN) { - SoDSlot = serverSlot; + SoDSlot = serverSlot - (EQ::invbag::TRADE_BAGS_BEGIN - invbag::TRADE_BAGS_BEGIN) - ((EQ::invbag::SLOT_COUNT - invbag::SLOT_COUNT) * ((serverSlot - EQ::invbag::TRADE_BAGS_BEGIN) / EQ::invbag::SLOT_COUNT)); } else if (serverSlot <= EQ::invslot::WORLD_END && serverSlot >= EQ::invslot::WORLD_BEGIN) { @@ -4049,11 +4049,11 @@ namespace SoD } else if (sod_slot <= invbag::GENERAL_BAGS_END && sod_slot >= invbag::GENERAL_BAGS_BEGIN) { - server_slot = sod_slot - 11; + server_slot = sod_slot + (EQ::invbag::GENERAL_BAGS_BEGIN - invbag::GENERAL_BAGS_BEGIN) + ((EQ::invbag::SLOT_COUNT - invbag::SLOT_COUNT) * ((sod_slot - invbag::GENERAL_BAGS_BEGIN) / invbag::SLOT_COUNT)); } else if (sod_slot <= invbag::CURSOR_BAG_END && sod_slot >= invbag::CURSOR_BAG_BEGIN) { - server_slot = sod_slot + 9; + server_slot = sod_slot + (EQ::invbag::CURSOR_BAG_BEGIN - invbag::CURSOR_BAG_BEGIN); } else if (sod_slot <= invslot::TRIBUTE_END && sod_slot >= invslot::TRIBUTE_BEGIN) { @@ -4073,7 +4073,7 @@ namespace SoD } else if (sod_slot <= invbag::BANK_BAGS_END && sod_slot >= invbag::BANK_BAGS_BEGIN) { - server_slot = sod_slot - 1; + server_slot = sod_slot + (EQ::invbag::BANK_BAGS_BEGIN - invbag::BANK_BAGS_BEGIN) + ((EQ::invbag::SLOT_COUNT - invbag::SLOT_COUNT) * ((sod_slot - invbag::BANK_BAGS_BEGIN) / invbag::SLOT_COUNT)); } else if (sod_slot <= invslot::SHARED_BANK_END && sod_slot >= invslot::SHARED_BANK_BEGIN) { @@ -4081,7 +4081,7 @@ namespace SoD } else if (sod_slot <= invbag::SHARED_BANK_BAGS_END && sod_slot >= invbag::SHARED_BANK_BAGS_BEGIN) { - server_slot = sod_slot - 1; + server_slot = sod_slot + (EQ::invbag::SHARED_BANK_BAGS_BEGIN - invbag::SHARED_BANK_BAGS_BEGIN) + ((EQ::invbag::SLOT_COUNT - invbag::SLOT_COUNT) * ((sod_slot - invbag::SHARED_BANK_BAGS_BEGIN) / invbag::SLOT_COUNT)); } else if (sod_slot <= invslot::TRADE_END && sod_slot >= invslot::TRADE_BEGIN) { @@ -4089,7 +4089,7 @@ namespace SoD } else if (sod_slot <= invbag::TRADE_BAGS_END && sod_slot >= invbag::TRADE_BAGS_BEGIN) { - server_slot = sod_slot; + server_slot = sod_slot + (EQ::invbag::TRADE_BAGS_BEGIN - invbag::TRADE_BAGS_BEGIN) + ((EQ::invbag::SLOT_COUNT - invbag::SLOT_COUNT) * ((sod_slot - invbag::TRADE_BAGS_BEGIN) / invbag::SLOT_COUNT)); } else if (sod_slot <= invslot::WORLD_END && sod_slot >= invslot::WORLD_BEGIN) { diff --git a/common/patches/sof.cpp b/common/patches/sof.cpp index be18a78c7..444b33b35 100644 --- a/common/patches/sof.cpp +++ b/common/patches/sof.cpp @@ -71,7 +71,7 @@ namespace SoF { //create our opcode manager if we havent already if (opcodes == nullptr) { - std::string opfile = fmt::format("{}/patch_{}.conf", path.GetPatchPath(), name); + std::string opfile = fmt::format("{}/patch_{}.conf", PathManager::Instance()->GetPatchPath(), name); //load up the opcode manager. //TODO: figure out how to support shared memory with multiple patches... opcodes = new RegularOpcodeManager(); @@ -110,7 +110,7 @@ namespace SoF //we need to go to every stream and replace it's manager. if (opcodes != nullptr) { - std::string opfile = fmt::format("{}/patch_{}.conf", path.GetPatchPath(), name); + std::string opfile = fmt::format("{}/patch_{}.conf", PathManager::Instance()->GetPatchPath(), name); if (!opcodes->ReloadOpcodes(opfile.c_str())) { LogNetcode("[OPCODES] Error reloading opcodes file [{}] for patch [{}]", opfile.c_str(), name); return; @@ -3355,12 +3355,12 @@ namespace SoF sof_slot = server_slot - 2; } - else if (server_slot <= EQ::invbag::GENERAL_BAGS_8_END && server_slot >= EQ::invbag::GENERAL_BAGS_BEGIN) { - sof_slot = server_slot + 11; + else if (server_slot <= EQ::invbag::GENERAL_BAGS_END && server_slot >= EQ::invbag::GENERAL_BAGS_BEGIN) { + sof_slot = server_slot - (EQ::invbag::GENERAL_BAGS_BEGIN - invbag::GENERAL_BAGS_BEGIN) - ((EQ::invbag::SLOT_COUNT - invbag::SLOT_COUNT) * ((server_slot - EQ::invbag::GENERAL_BAGS_BEGIN) / EQ::invbag::SLOT_COUNT));; } else if (server_slot <= EQ::invbag::CURSOR_BAG_END && server_slot >= EQ::invbag::CURSOR_BAG_BEGIN) { - sof_slot = server_slot - 9; + sof_slot = server_slot - (EQ::invbag::CURSOR_BAG_BEGIN - invbag::CURSOR_BAG_BEGIN); } else if (server_slot <= EQ::invslot::TRIBUTE_END && server_slot >= EQ::invslot::TRIBUTE_BEGIN) { @@ -3380,7 +3380,7 @@ namespace SoF } else if (server_slot <= EQ::invbag::BANK_BAGS_END && server_slot >= EQ::invbag::BANK_BAGS_BEGIN) { - sof_slot = server_slot + 1; + sof_slot = server_slot - (EQ::invbag::BANK_BAGS_BEGIN - invbag::BANK_BAGS_BEGIN) - ((EQ::invbag::SLOT_COUNT - invbag::SLOT_COUNT) * ((server_slot - EQ::invbag::BANK_BAGS_BEGIN) / EQ::invbag::SLOT_COUNT)); } else if (server_slot <= EQ::invslot::SHARED_BANK_END && server_slot >= EQ::invslot::SHARED_BANK_BEGIN) { @@ -3388,7 +3388,7 @@ namespace SoF } else if (server_slot <= EQ::invbag::SHARED_BANK_BAGS_END && server_slot >= EQ::invbag::SHARED_BANK_BAGS_BEGIN) { - sof_slot = server_slot + 1; + sof_slot = server_slot - (EQ::invbag::SHARED_BANK_BAGS_BEGIN - invbag::SHARED_BANK_BAGS_BEGIN) - ((EQ::invbag::SLOT_COUNT - invbag::SLOT_COUNT) * ((server_slot - EQ::invbag::SHARED_BANK_BAGS_BEGIN) / EQ::invbag::SLOT_COUNT)); } else if (server_slot <= EQ::invslot::TRADE_END && server_slot >= EQ::invslot::TRADE_BEGIN) { @@ -3396,7 +3396,7 @@ namespace SoF } else if (server_slot <= EQ::invbag::TRADE_BAGS_END && server_slot >= EQ::invbag::TRADE_BAGS_BEGIN) { - sof_slot = server_slot; + sof_slot = server_slot - (EQ::invbag::TRADE_BAGS_BEGIN - invbag::TRADE_BAGS_BEGIN) - ((EQ::invbag::SLOT_COUNT - invbag::SLOT_COUNT) * ((server_slot - EQ::invbag::TRADE_BAGS_BEGIN) / EQ::invbag::SLOT_COUNT)); } else if (server_slot <= EQ::invslot::WORLD_END && server_slot >= EQ::invslot::WORLD_BEGIN) { @@ -3442,11 +3442,11 @@ namespace SoF } else if (sof_slot <= invbag::GENERAL_BAGS_END && sof_slot >= invbag::GENERAL_BAGS_BEGIN) { - server_slot = sof_slot - 11; + server_slot = sof_slot + (EQ::invbag::GENERAL_BAGS_BEGIN - invbag::GENERAL_BAGS_BEGIN) + ((EQ::invbag::SLOT_COUNT - invbag::SLOT_COUNT) * ((sof_slot - invbag::GENERAL_BAGS_BEGIN) / invbag::SLOT_COUNT));; } else if (sof_slot <= invbag::CURSOR_BAG_END && sof_slot >= invbag::CURSOR_BAG_BEGIN) { - server_slot = sof_slot + 9; + server_slot = sof_slot + (EQ::invbag::CURSOR_BAG_BEGIN - invbag::CURSOR_BAG_BEGIN); } else if (sof_slot <= invslot::TRIBUTE_END && sof_slot >= invslot::TRIBUTE_BEGIN) { @@ -3466,7 +3466,7 @@ namespace SoF } else if (sof_slot <= invbag::BANK_BAGS_END && sof_slot >= invbag::BANK_BAGS_BEGIN) { - server_slot = sof_slot - 1; + server_slot = sof_slot + (EQ::invbag::BANK_BAGS_BEGIN - invbag::BANK_BAGS_BEGIN) + ((EQ::invbag::SLOT_COUNT - invbag::SLOT_COUNT) * ((sof_slot - invbag::BANK_BAGS_BEGIN) / invbag::SLOT_COUNT));; } else if (sof_slot <= invslot::SHARED_BANK_END && sof_slot >= invslot::SHARED_BANK_BEGIN) { @@ -3474,7 +3474,7 @@ namespace SoF } else if (sof_slot <= invbag::SHARED_BANK_BAGS_END && sof_slot >= invbag::SHARED_BANK_BAGS_BEGIN) { - server_slot = sof_slot - 1; + server_slot = sof_slot + (EQ::invbag::SHARED_BANK_BAGS_BEGIN - invbag::SHARED_BANK_BAGS_BEGIN) + ((EQ::invbag::SLOT_COUNT - invbag::SLOT_COUNT) * ((sof_slot - invbag::SHARED_BANK_BAGS_BEGIN) / invbag::SLOT_COUNT));; } else if (sof_slot <= invslot::TRADE_END && sof_slot >= invslot::TRADE_BEGIN) { @@ -3482,7 +3482,7 @@ namespace SoF } else if (sof_slot <= invbag::TRADE_BAGS_END && sof_slot >= invbag::TRADE_BAGS_BEGIN) { - server_slot = sof_slot; + server_slot = sof_slot + (EQ::invbag::TRADE_BAGS_BEGIN - invbag::TRADE_BAGS_BEGIN) + ((EQ::invbag::SLOT_COUNT - invbag::SLOT_COUNT) * ((sof_slot - invbag::TRADE_BAGS_BEGIN) / invbag::SLOT_COUNT));; } else if (sof_slot <= invslot::WORLD_END && sof_slot >= invslot::WORLD_BEGIN) { diff --git a/common/patches/titanium.cpp b/common/patches/titanium.cpp index e9cec60a6..19d93addb 100644 --- a/common/patches/titanium.cpp +++ b/common/patches/titanium.cpp @@ -73,7 +73,7 @@ namespace Titanium auto Config = EQEmuConfig::get(); //create our opcode manager if we havent already if (opcodes == nullptr) { - std::string opfile = fmt::format("{}/patch_{}.conf", path.GetPatchPath(), name); + std::string opfile = fmt::format("{}/patch_{}.conf", PathManager::Instance()->GetPatchPath(), name); //load up the opcode manager. //TODO: figure out how to support shared memory with multiple patches... opcodes = new RegularOpcodeManager(); @@ -114,7 +114,7 @@ namespace Titanium //we need to go to every stream and replace it's manager. if (opcodes != nullptr) { - std::string opfile = fmt::format("{}/patch_{}.conf", path.GetPatchPath(), name); + std::string opfile = fmt::format("{}/patch_{}.conf", PathManager::Instance()->GetPatchPath(), name); if (!opcodes->ReloadOpcodes(opfile.c_str())) { LogNetcode("[OPCODES] Error reloading opcodes file [{}] for patch [{}]", opfile.c_str(), name); return; @@ -3596,12 +3596,12 @@ namespace Titanium else if (server_slot == (EQ::invslot::POSSESSIONS_COUNT + EQ::invslot::slotAmmo)) { titanium_slot = server_slot - 4; } - else if (server_slot <= EQ::invbag::GENERAL_BAGS_8_END && + else if (server_slot <= EQ::invbag::GENERAL_BAGS_END && server_slot >= EQ::invbag::GENERAL_BAGS_BEGIN) { - titanium_slot = server_slot; + titanium_slot = server_slot - (EQ::invbag::GENERAL_BAGS_BEGIN - invbag::GENERAL_BAGS_BEGIN) - ((EQ::invbag::SLOT_COUNT - invbag::SLOT_COUNT) * ((server_slot - EQ::invbag::GENERAL_BAGS_BEGIN) / EQ::invbag::SLOT_COUNT)); } else if (server_slot <= EQ::invbag::CURSOR_BAG_END && server_slot >= EQ::invbag::CURSOR_BAG_BEGIN) { - titanium_slot = server_slot - 20; + titanium_slot = server_slot - (EQ::invbag::CURSOR_BAG_BEGIN - invbag::CURSOR_BAG_BEGIN); } else if (server_slot <= EQ::invslot::TRIBUTE_END && server_slot >= EQ::invslot::TRIBUTE_BEGIN) { titanium_slot = server_slot; @@ -3616,21 +3616,21 @@ namespace Titanium else if (server_slot <= EQ::invslot::BANK_END && server_slot >= EQ::invslot::BANK_BEGIN) { titanium_slot = server_slot; } - else if (server_slot <= EQ::invbag::BANK_BAGS_16_END && server_slot >= EQ::invbag::BANK_BAGS_BEGIN) { - titanium_slot = server_slot; + else if (server_slot <= EQ::invbag::BANK_BAGS_END && server_slot >= EQ::invbag::BANK_BAGS_BEGIN) { + titanium_slot = server_slot - (EQ::invbag::BANK_BAGS_BEGIN - invbag::BANK_BAGS_BEGIN) - ((EQ::invbag::SLOT_COUNT - invbag::SLOT_COUNT) * ((server_slot - EQ::invbag::BANK_BAGS_BEGIN) / EQ::invbag::SLOT_COUNT)); } else if (server_slot <= EQ::invslot::SHARED_BANK_END && server_slot >= EQ::invslot::SHARED_BANK_BEGIN) { titanium_slot = server_slot; } else if (server_slot <= EQ::invbag::SHARED_BANK_BAGS_END && server_slot >= EQ::invbag::SHARED_BANK_BAGS_BEGIN) { - titanium_slot = server_slot; + titanium_slot = server_slot - (EQ::invbag::SHARED_BANK_BAGS_BEGIN - invbag::SHARED_BANK_BAGS_BEGIN) - ((EQ::invbag::SLOT_COUNT - invbag::SLOT_COUNT) * ((server_slot - EQ::invbag::SHARED_BANK_BAGS_BEGIN) / EQ::invbag::SLOT_COUNT)); } else if (server_slot <= EQ::invslot::TRADE_END && server_slot >= EQ::invslot::TRADE_BEGIN) { titanium_slot = server_slot; } else if (server_slot <= EQ::invbag::TRADE_BAGS_END && server_slot >= EQ::invbag::TRADE_BAGS_BEGIN) { - titanium_slot = server_slot; + titanium_slot = server_slot - (EQ::invbag::TRADE_BAGS_BEGIN - invbag::TRADE_BAGS_BEGIN) - ((EQ::invbag::SLOT_COUNT - invbag::SLOT_COUNT) * ((server_slot - EQ::invbag::TRADE_BAGS_BEGIN) / EQ::invbag::SLOT_COUNT)); } else if (server_slot <= EQ::invslot::WORLD_END && server_slot >= EQ::invslot::WORLD_BEGIN) { titanium_slot = server_slot; @@ -3687,10 +3687,10 @@ namespace Titanium server_slot = titanium_slot + 4; } else if (titanium_slot <= invbag::GENERAL_BAGS_END && titanium_slot >= invbag::GENERAL_BAGS_BEGIN) { - server_slot = titanium_slot; + server_slot = titanium_slot + (EQ::invbag::GENERAL_BAGS_BEGIN - invbag::GENERAL_BAGS_BEGIN) + ((EQ::invbag::SLOT_COUNT - invbag::SLOT_COUNT) * ((titanium_slot - invbag::GENERAL_BAGS_BEGIN) / invbag::SLOT_COUNT)); } else if (titanium_slot <= invbag::CURSOR_BAG_END && titanium_slot >= invbag::CURSOR_BAG_BEGIN) { - server_slot = titanium_slot + 20; + server_slot = titanium_slot + (EQ::invbag::CURSOR_BAG_BEGIN - invbag::CURSOR_BAG_BEGIN); } else if (titanium_slot <= invslot::TRIBUTE_END && titanium_slot >= invslot::TRIBUTE_BEGIN) { server_slot = titanium_slot; @@ -3705,19 +3705,19 @@ namespace Titanium server_slot = titanium_slot; } else if (titanium_slot <= invbag::BANK_BAGS_END && titanium_slot >= invbag::BANK_BAGS_BEGIN) { - server_slot = titanium_slot; + server_slot = titanium_slot + (EQ::invbag::BANK_BAGS_BEGIN - invbag::BANK_BAGS_BEGIN) + ((EQ::invbag::SLOT_COUNT - invbag::SLOT_COUNT) * ((titanium_slot - invbag::BANK_BAGS_BEGIN) / invbag::SLOT_COUNT)); } else if (titanium_slot <= invslot::SHARED_BANK_END && titanium_slot >= invslot::SHARED_BANK_BEGIN) { server_slot = titanium_slot; } else if (titanium_slot <= invbag::SHARED_BANK_BAGS_END && titanium_slot >= invbag::SHARED_BANK_BAGS_BEGIN) { - server_slot = titanium_slot; + server_slot = titanium_slot + (EQ::invbag::SHARED_BANK_BAGS_BEGIN - invbag::SHARED_BANK_BAGS_BEGIN) + ((EQ::invbag::SLOT_COUNT - invbag::SLOT_COUNT) * ((titanium_slot - invbag::SHARED_BANK_BAGS_BEGIN) / invbag::SLOT_COUNT)); } else if (titanium_slot <= invslot::TRADE_END && titanium_slot >= invslot::TRADE_BEGIN) { server_slot = titanium_slot; } else if (titanium_slot <= invbag::TRADE_BAGS_END && titanium_slot >= invbag::TRADE_BAGS_BEGIN) { - server_slot = titanium_slot; + server_slot = titanium_slot + (EQ::invbag::TRADE_BAGS_BEGIN - invbag::TRADE_BAGS_BEGIN) + ((EQ::invbag::SLOT_COUNT - invbag::SLOT_COUNT) * ((titanium_slot - invbag::TRADE_BAGS_BEGIN) / invbag::SLOT_COUNT)); } else if (titanium_slot <= invslot::WORLD_END && titanium_slot >= invslot::WORLD_BEGIN) { server_slot = titanium_slot; diff --git a/common/patches/uf.cpp b/common/patches/uf.cpp index 35452727b..6433621f5 100644 --- a/common/patches/uf.cpp +++ b/common/patches/uf.cpp @@ -76,7 +76,7 @@ namespace UF { //create our opcode manager if we havent already if (opcodes == nullptr) { - std::string opfile = fmt::format("{}/patch_{}.conf", path.GetPatchPath(), name); + std::string opfile = fmt::format("{}/patch_{}.conf", PathManager::Instance()->GetPatchPath(), name); //load up the opcode manager. //TODO: figure out how to support shared memory with multiple patches... opcodes = new RegularOpcodeManager(); @@ -117,7 +117,7 @@ namespace UF //we need to go to every stream and replace it's manager. if (opcodes != nullptr) { - std::string opfile = fmt::format("{}/patch_{}.conf", path.GetPatchPath(), name); + std::string opfile = fmt::format("{}/patch_{}.conf", PathManager::Instance()->GetPatchPath(), name); if (!opcodes->ReloadOpcodes(opfile.c_str())) { LogNetcode("[OPCODES] Error reloading opcodes file [{}] for patch [{}]", opfile.c_str(), name); return; diff --git a/common/path_manager.cpp b/common/path_manager.cpp index ed57f2f4a..c63835854 100644 --- a/common/path_manager.cpp +++ b/common/path_manager.cpp @@ -8,7 +8,7 @@ namespace fs = std::filesystem; -void PathManager::LoadPaths() +void PathManager::Init() { m_server_path = File::FindEqemuConfigPath(); diff --git a/common/path_manager.h b/common/path_manager.h index 55cc1489c..67919511e 100644 --- a/common/path_manager.h +++ b/common/path_manager.h @@ -7,7 +7,13 @@ class PathManager { public: - void LoadPaths(); + void Init(); + + static PathManager *Instance() + { + static PathManager instance; + return &instance; + } [[nodiscard]] const std::string &GetLogPath() const; [[nodiscard]] const std::string &GetLuaModsPath() const; @@ -38,6 +44,4 @@ private: std::string m_shared_memory_path; }; -extern PathManager path; - #endif //EQEMU_PATH_MANAGER_H diff --git a/common/pch/app-pch.h b/common/pch/app-pch.h new file mode 100644 index 000000000..aa2244f13 --- /dev/null +++ b/common/pch/app-pch.h @@ -0,0 +1,9 @@ +#pragma once + +#include "../types.h" +#include "../database.h" +#include "../strings.h" +#include "../eqemu_logsys.h" +#include "../eqemu_logsys_log_aliases.h" +#include "../features.h" +#include "../global_define.h" diff --git a/common/pch/pch.h b/common/pch/std-pch.h similarity index 100% rename from common/pch/pch.h rename to common/pch/std-pch.h diff --git a/common/process/process.cpp b/common/process/process.cpp index badb0fe11..56bbeff2b 100644 --- a/common/process/process.cpp +++ b/common/process/process.cpp @@ -1,6 +1,7 @@ #include #include #include "process.h" +#include std::string Process::execute(const std::string &cmd) { diff --git a/common/random.h b/common/random.h index 6d351121f..73b14369e 100644 --- a/common/random.h +++ b/common/random.h @@ -116,6 +116,12 @@ namespace EQ { Reseed(); } + static Random* Instance() + { + static Random instance; + return &instance; + } + private: #ifndef BIASED_INT_DIST typedef std::uniform_int_distribution::param_type int_param_t; diff --git a/common/repositories/base/base_player_event_log_settings_repository.h b/common/repositories/base/base_player_event_log_settings_repository.h index 4a2457576..94a53b981 100644 --- a/common/repositories/base/base_player_event_log_settings_repository.h +++ b/common/repositories/base/base_player_event_log_settings_repository.h @@ -15,7 +15,7 @@ #include "../../database.h" #include "../../strings.h" #include - +#include class BasePlayerEventLogSettingsRepository { public: struct PlayerEventLogSettings { @@ -25,6 +25,20 @@ public: int32_t retention_days; int32_t discord_webhook_id; uint8_t etl_enabled; + + // cereal + template + void serialize(Archive &ar) + { + ar( + CEREAL_NVP(id), + CEREAL_NVP(event_name), + CEREAL_NVP(event_enabled), + CEREAL_NVP(retention_days), + CEREAL_NVP(discord_webhook_id), + CEREAL_NVP(etl_enabled) + ); + } }; static std::string PrimaryKey() diff --git a/common/repositories/character_data_repository.h b/common/repositories/character_data_repository.h index 74f884cf3..d95ac2fda 100644 --- a/common/repositories/character_data_repository.h +++ b/common/repositories/character_data_repository.h @@ -167,6 +167,30 @@ public: return zone_player_counts; } + + static std::vector GetCharacterIDsByAccountID( + Database& db, + uint32_t account_id + ) + { + std::vector character_ids; + + auto query = fmt::format( + "SELECT id FROM character_data WHERE account_id = {} AND deleted_at IS NULL", + account_id + ); + + auto results = db.QueryDatabase(query); + if (results.Success()) { + for (auto row : results) { + if (row[0]) { + character_ids.push_back(static_cast(std::stoul(row[0]))); + } + } + } + + return character_ids; + } }; #endif //EQEMU_CHARACTER_DATA_REPOSITORY_H diff --git a/common/repositories/rule_values_repository.h b/common/repositories/rule_values_repository.h index 072175d5f..d7eb1530e 100644 --- a/common/repositories/rule_values_repository.h +++ b/common/repositories/rule_values_repository.h @@ -43,6 +43,47 @@ public: * method and encapsulate filters there */ + template + static std::vector join_tuple( + const std::string &glue, + const std::pair &encapsulation, + const std::vector> &src + ) + { + if (src.empty()) { + return {}; + } + + std::vector output; + + for (const std::tuple &src_iter: src) { + + output.emplace_back( + + fmt::format( + "{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}", + encapsulation.first, + std::get<0>(src_iter), + encapsulation.second, + glue, + encapsulation.first, + std::get<1>(src_iter), + encapsulation.second, + glue, + encapsulation.first, + std::get<2>(src_iter), + encapsulation.second, + glue, + encapsulation.first, + std::get<3>(src_iter), + encapsulation.second + ) + ); + } + + return output; + } + // Custom extended repository methods here static std::vector GetRuleNames(Database &db, int rule_set_id) { @@ -87,12 +128,28 @@ public: return v; } + template + static std::string + ImplodePair(const std::string &glue, const std::pair &encapsulation, const std::vector &src) + { + if (src.empty()) { + return {}; + } + std::ostringstream oss; + for (const T &src_iter: src) { + oss << encapsulation.first << src_iter << encapsulation.second << glue; + } + std::string output(oss.str()); + output.resize(output.size() - glue.size()); + return output; + } + static bool DeleteOrphanedRules(Database& db, std::vector& v) { const auto query = fmt::format( "DELETE FROM {} WHERE rule_name IN ({})", TableName(), - Strings::ImplodePair(",", std::pair('\'', '\''), v) + ImplodePair(",", std::pair('\'', '\''), v) ); return db.QueryDatabase(query).Success(); @@ -103,7 +160,7 @@ public: const auto query = fmt::format( "REPLACE INTO {} (`ruleset_id`, `rule_name`, `rule_value`, `notes`) VALUES {}", TableName(), - Strings::ImplodePair( + ImplodePair( ",", std::pair('(', ')'), join_tuple(",", std::pair('\'', '\''), v) diff --git a/common/servertalk.h b/common/servertalk.h index 3680ac76d..9985c875c 100644 --- a/common/servertalk.h +++ b/common/servertalk.h @@ -273,8 +273,9 @@ #define ServerOP_WWTaskUpdate 0x4758 // player events -#define ServerOP_QSSendQuery 0x5000 +#define ServerOP_QSSendQuery 0x5000 #define ServerOP_PlayerEvent 0x5100 +#define ServerOP_SendPlayerEventSettings 0x5101 enum { CZUpdateType_Character, @@ -1778,6 +1779,7 @@ struct BazaarPurchaseMessaging_Struct { uint32 id; }; + #pragma pack() #endif diff --git a/common/shareddb.cpp b/common/shareddb.cpp index 1187d80bb..d143dfbfd 100644 --- a/common/shareddb.cpp +++ b/common/shareddb.cpp @@ -974,7 +974,7 @@ bool SharedDatabase::LoadItems(const std::string &prefix) { const auto Config = EQEmuConfig::get(); EQ::IPCMutex mutex("items"); mutex.Lock(); - std::string file_name = fmt::format("{}/{}{}", path.GetSharedMemoryPath(), prefix, std::string("items")); + std::string file_name = fmt::format("{}/{}{}", PathManager::Instance()->GetSharedMemoryPath(), prefix, std::string("items")); items_mmf = std::make_unique(file_name); items_hash = std::make_unique>(static_cast(items_mmf->Get()), items_mmf->Size()); mutex.Unlock(); @@ -1544,12 +1544,60 @@ bool SharedDatabase::GetCommandSettings(std::map +inline std::vector join_pair( + const std::string &glue, + const std::pair &encapsulation, + const std::vector> &src +) +{ + if (src.empty()) { + return {}; + } + + std::vector output; + + for (const std::pair &src_iter: src) { + output.emplace_back( + + fmt::format( + "{}{}{}{}{}{}{}", + encapsulation.first, + src_iter.first, + encapsulation.second, + glue, + encapsulation.first, + src_iter.second, + encapsulation.second + ) + ); + } + + return output; +} + +template +inline std::string +ImplodePair(const std::string &glue, const std::pair &encapsulation, const std::vector &src) +{ + if (src.empty()) { + return {}; + } + std::ostringstream oss; + for (const T &src_iter: src) { + oss << encapsulation.first << src_iter << encapsulation.second << glue; + } + std::string output(oss.str()); + output.resize(output.size() - glue.size()); + return output; +} + bool SharedDatabase::UpdateInjectedCommandSettings(const std::vector> &injected) { if (injected.size()) { const std::string query = fmt::format( "REPLACE INTO `command_settings`(`command`, `access`) VALUES {}", - Strings::ImplodePair( + ImplodePair( ",", std::pair('(', ')'), join_pair(",", std::pair('\'', '\''), injected) @@ -1576,7 +1624,7 @@ bool SharedDatabase::UpdateOrphanedCommandSettings(const std::vector('\'', '\''), orphaned) + ImplodePair(",", std::pair('\'', '\''), orphaned) ); auto results = QueryDatabase(query); @@ -1586,7 +1634,7 @@ bool SharedDatabase::UpdateOrphanedCommandSettings(const std::vector('\'', '\''), orphaned) + ImplodePair(",", std::pair('\'', '\''), orphaned) ); auto results_two = QueryDatabase(query); @@ -1665,7 +1713,7 @@ bool SharedDatabase::LoadSpells(const std::string &prefix, int32 *records, const EQ::IPCMutex mutex("spells"); mutex.Lock(); - std::string file_name = fmt::format("{}/{}{}", path.GetSharedMemoryPath(), prefix, std::string("spells")); + std::string file_name = fmt::format("{}/{}{}", PathManager::Instance()->GetSharedMemoryPath(), prefix, std::string("spells")); spells_mmf = std::make_unique(file_name); LogInfo("Loading [{}]", file_name); *records = *static_cast(spells_mmf->Get()); diff --git a/common/skill_caps.h b/common/skill_caps.h index 9630ed7d7..6566a1104 100644 --- a/common/skill_caps.h +++ b/common/skill_caps.h @@ -16,12 +16,16 @@ public: static int32_t GetSkillCapMaxLevel(uint8 class_id, EQ::skills::SkillType skill_id); SkillCaps *SetContentDatabase(Database *db); + + static SkillCaps* Instance() + { + static SkillCaps instance; + return &instance; + } private: Database *m_content_database{}; std::map m_skill_caps = {}; }; -extern SkillCaps skill_caps; - #endif //CODE_SKILL_CAPS_H diff --git a/common/strings.cpp b/common/strings.cpp index 58261388f..52990aa85 100644 --- a/common/strings.cpp +++ b/common/strings.cpp @@ -34,6 +34,7 @@ */ #include "strings.h" +#include #include #include #include @@ -41,6 +42,7 @@ #include #include #include +#include #include #include @@ -49,6 +51,12 @@ #include "strings_legacy.cpp" // legacy c functions #include "strings_misc.cpp" // anything non "Strings" scoped +#ifdef _WINDOWS +#include +#include +#include +#endif + std::string Strings::Random(size_t length) { static auto &chrs = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; @@ -701,6 +709,18 @@ std::string &Strings::Trim(std::string &str, const std::string &chars) return LTrim(RTrim(str, chars), chars); } +const std::string NUM_TO_ENGLISH_X[] = { + "", "One ", "Two ", "Three ", "Four ", + "Five ", "Six ", "Seven ", "Eight ", "Nine ", "Ten ", "Eleven ", + "Twelve ", "Thirteen ", "Fourteen ", "Fifteen ", + "Sixteen ", "Seventeen ", "Eighteen ", "Nineteen " +}; + +const std::string NUM_TO_ENGLISH_Y[] = { + "", "", "Twenty ", "Thirty ", "Forty ", + "Fifty ", "Sixty ", "Seventy ", "Eighty ", "Ninety " +}; + // Function to convert single digit or two digit number into words std::string Strings::ConvertToDigit(int n, const std::string& suffix) { diff --git a/common/strings.h b/common/strings.h index 5338949b5..8ae8fee25 100644 --- a/common/strings.h +++ b/common/strings.h @@ -36,53 +36,19 @@ #define _STRINGUTIL_H_ #include -#include -#include +#include #include +#include #include #include -#include #include -#include -#include - -#ifndef _WIN32 -// this doesn't appear to affect linux-based systems..need feedback for _WIN64 - -#endif - -#ifdef _WINDOWS +#ifdef _WIN32 #include -#include -#include #endif #include "types.h" -namespace detail { - // template magic to check if std::from_chars floating point functions exist - template - struct has_from_chars_float : std::false_type { }; - - // basically it "uses" this template if they do exist because reasons - template - struct has_from_chars_float < T, - std::void_t(), std::declval(), - std::declval()))>> : std::true_type { }; -}; // namespace detail - -namespace EQ { -// lame -- older GCC's didn't define this, clang's libc++ however does, even though they lack FP support -#if defined(__GNUC__) && (__GNUC__ < 11) && !defined(__clang__) - enum class chars_format { - scientific = 1, fixed = 2, hex = 4, general = fixed | scientific - }; -#else - using chars_format = std::chars_format; -#endif -}; // namespace EQ - class Strings { public: static bool Contains(std::vector container, const std::string& element); @@ -133,61 +99,6 @@ public: static bool BeginsWith(const std::string& subject, const std::string& search); static bool EndsWith(const std::string& subject, const std::string& search); static std::string ZoneTime(const uint8 hours, const uint8 minutes); - - template - static std::string - ImplodePair(const std::string &glue, const std::pair &encapsulation, const std::vector &src) - { - if (src.empty()) { - return {}; - } - std::ostringstream oss; - for (const T &src_iter: src) { - oss << encapsulation.first << src_iter << encapsulation.second << glue; - } - std::string output(oss.str()); - output.resize(output.size() - glue.size()); - return output; - } - - // basic string_view overloads that just use std stuff since they work! - template - std::enable_if_t && detail::has_from_chars_float::value, std::from_chars_result> - static from_chars(std::string_view str, T& value, EQ::chars_format fmt = EQ::chars_format::general) - { - return std::from_chars(str.data(), str.data() + str.size(), value, fmt); - } - - template - std::enable_if_t, std::from_chars_result> - static from_chars(std::string_view str, T& value, int base = 10) - { - return std::from_chars(str.data(), str.data() + str.size(), value, base); - } - - // fallback versions of floating point in case they're not implemented - // TODO: add error handling ... - // This does have to allocate since from_chars doesn't need a null terminated string and neither does string_view - template - std::enable_if_t && !detail::has_from_chars_float::value && std::is_same_v, std::from_chars_result> - static from_chars(std::string_view str, T& value, EQ::chars_format fmt = EQ::chars_format::general) - { - std::from_chars_result res{}; - std::string tmp_str(str.data(), str.size()); - value = strtof(tmp_str.data(), nullptr); - return res; - } - - template - std::enable_if_t && !detail::has_from_chars_float::value && std::is_same_v, std::from_chars_result> - static from_chars(std::string_view str, T& value, EQ::chars_format fmt = EQ::chars_format::general) - { - std::from_chars_result res{}; - std::string tmp_str(str.data(), str.size()); - value = strtod(tmp_str.data(), nullptr); - return res; - } - static std::string Slugify(const std::string &input, const std::string &separator = "-"); static bool IsValidJson(const std::string& json); }; @@ -199,93 +110,6 @@ const std::string vStringFormat(const char *format, va_list args); // Used for grid nodes, as NPC names remove numerals. // But general purpose -const std::string NUM_TO_ENGLISH_X[] = { - "", "One ", "Two ", "Three ", "Four ", - "Five ", "Six ", "Seven ", "Eight ", "Nine ", "Ten ", "Eleven ", - "Twelve ", "Thirteen ", "Fourteen ", "Fifteen ", - "Sixteen ", "Seventeen ", "Eighteen ", "Nineteen " -}; - -const std::string NUM_TO_ENGLISH_Y[] = { - "", "", "Twenty ", "Thirty ", "Forty ", - "Fifty ", "Sixty ", "Seventy ", "Eighty ", "Ninety " -}; - -// _WIN32 builds require that #include be included in whatever code file the invocation is made from (no header files) -template -std::vector join_pair( - const std::string &glue, - const std::pair &encapsulation, - const std::vector> &src -) -{ - if (src.empty()) { - return {}; - } - - std::vector output; - - for (const std::pair &src_iter: src) { - output.emplace_back( - - fmt::format( - "{}{}{}{}{}{}{}", - encapsulation.first, - src_iter.first, - encapsulation.second, - glue, - encapsulation.first, - src_iter.second, - encapsulation.second - ) - ); - } - - return output; -} - -// _WIN32 builds require that #include be included in whatever code file the invocation is made from (no header files) -template -std::vector join_tuple( - const std::string &glue, - const std::pair &encapsulation, - const std::vector> &src -) -{ - if (src.empty()) { - return {}; - } - - std::vector output; - - for (const std::tuple &src_iter: src) { - - output.emplace_back( - - fmt::format( - "{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}", - encapsulation.first, - std::get<0>(src_iter), - encapsulation.second, - glue, - encapsulation.first, - std::get<1>(src_iter), - encapsulation.second, - glue, - encapsulation.first, - std::get<2>(src_iter), - encapsulation.second, - glue, - encapsulation.first, - std::get<3>(src_iter), - encapsulation.second - ) - ); - } - - return output; -} - // misc functions std::string SanitizeWorldServerName(std::string server_long_name); std::vector GetBadWords(); @@ -310,18 +134,4 @@ std::string FormatName(const std::string &char_name); bool IsAllowedWorldServerCharacterList(char c); void SanitizeWorldServerName(char *name); -template -auto CleanMobName(InputIterator first, InputIterator last, OutputIterator result) -{ - for (; first != last; ++first) { - if (*first == '_') { - *result = ' '; - } - else if (isalpha(*first) || *first == '`') { - *result = *first; - } - } - return result; -} - #endif diff --git a/common/version.h b/common/version.h index 5a2c1bdff..9e0614f12 100644 --- a/common/version.h +++ b/common/version.h @@ -42,7 +42,7 @@ * Manifest: https://github.com/EQEmu/Server/blob/master/utils/sql/db_update_manifest.txt */ -#define CURRENT_BINARY_DATABASE_VERSION 9323 +#define CURRENT_BINARY_DATABASE_VERSION 9324 #define CURRENT_BINARY_BOTS_DATABASE_VERSION 9054 #define CUSTOM_BINARY_DATABASE_VERSION 0 diff --git a/common/zone_store.h b/common/zone_store.h index d8ee7233d..4a6940f4d 100644 --- a/common/zone_store.h +++ b/common/zone_store.h @@ -104,36 +104,39 @@ public: uint8 GetZoneIdleWhenEmpty(uint32 zone_id, int version = 0); uint32 GetZoneSecondsBeforeIdle(uint32 zone_id, int version = 0); + static ZoneStore* Instance() + { + static ZoneStore instance; + return &instance; + } private: std::vector m_zones; }; -extern ZoneStore zone_store; - /** * Global helpers */ -inline uint32 ZoneID(const char *in_zone_name) { return zone_store.GetZoneID(in_zone_name); } -inline uint32 ZoneID(const std::string& zone_name) { return zone_store.GetZoneID(zone_name); } +inline uint32 ZoneID(const char *in_zone_name) { return ZoneStore::Instance()->GetZoneID(in_zone_name); } +inline uint32 ZoneID(const std::string& zone_name) { return ZoneStore::Instance()->GetZoneID(zone_name); } inline const char *ZoneName(uint32 zone_id, bool error_unknown = false) { - return zone_store.GetZoneName( + return ZoneStore::Instance()->GetZoneName( zone_id, error_unknown ); } inline const char *ZoneLongName(uint32 zone_id, bool error_unknown = false) { - return zone_store.GetZoneLongName( + return ZoneStore::Instance()->GetZoneLongName( zone_id, error_unknown ); } -inline ZoneRepository::Zone *GetZone(uint32 zone_id, int version = 0) { return zone_store.GetZone(zone_id, version); }; -inline ZoneRepository::Zone *GetZone(const char *in_zone_name) { return zone_store.GetZone(in_zone_name); }; +inline ZoneRepository::Zone *GetZone(uint32 zone_id, int version = 0) { return ZoneStore::Instance()->GetZone(zone_id, version); }; +inline ZoneRepository::Zone *GetZone(const char *in_zone_name) { return ZoneStore::Instance()->GetZone(in_zone_name); }; inline ZoneRepository::Zone *GetZone(const char *in_zone_name, int version = 0) { - return zone_store.GetZone( + return ZoneStore::Instance()->GetZone( ZoneID( in_zone_name ), version @@ -141,7 +144,7 @@ inline ZoneRepository::Zone *GetZone(const char *in_zone_name, int version = 0) }; inline ZoneRepository::Zone *GetZoneVersionWithFallback(uint32 zone_id, int version = 0) { - return zone_store.GetZoneWithFallback( + return ZoneStore::Instance()->GetZoneWithFallback( zone_id, version ); diff --git a/eqlaunch/eqlaunch.cpp b/eqlaunch/eqlaunch.cpp index ea41b1803..edc50aea7 100644 --- a/eqlaunch/eqlaunch.cpp +++ b/eqlaunch/eqlaunch.cpp @@ -33,19 +33,16 @@ #include #include -EQEmuLogSys LogSys; -PathManager path; - bool RunLoops = false; void CatchSignal(int sig_num); int main(int argc, char *argv[]) { RegisterExecutablePlatform(ExePlatformLaunch); - LogSys.LoadLogSettingsDefaults(); + EQEmuLogSys::Instance()->LoadLogSettingsDefaults(); set_exception_handler(); - path.LoadPaths(); + PathManager::Instance()->Init(); std::string launcher_name; if(argc == 2) { @@ -169,7 +166,7 @@ int main(int argc, char *argv[]) { delete zone->second; } - LogSys.CloseFileLogs(); + EQEmuLogSys::Instance()->CloseFileLogs(); return 0; } diff --git a/loginserver/client.cpp b/loginserver/client.cpp index 41cbec896..754c83ab5 100644 --- a/loginserver/client.cpp +++ b/loginserver/client.cpp @@ -25,7 +25,7 @@ bool Client::Process() OpcodeManager::EmuToName(app->GetOpcode()), o->EmuToEQ(app->GetOpcode()) == 0 ? app->GetProtocolOpcode() : o->EmuToEQ(app->GetOpcode()), app->Size(), - (LogSys.IsLogEnabled(Logs::Detail, Logs::PacketClientServer) ? DumpPacketToString(app) : "") + (EQEmuLogSys::Instance()->IsLogEnabled(Logs::Detail, Logs::PacketClientServer) ? DumpPacketToString(app) : "") ); if (m_client_status == cs_failed_to_login) { diff --git a/loginserver/client_manager.cpp b/loginserver/client_manager.cpp index 8f283c973..5767f538b 100644 --- a/loginserver/client_manager.cpp +++ b/loginserver/client_manager.cpp @@ -94,7 +94,7 @@ ClientManager::ClientManager() std::string opcodes_path = fmt::format( "{}/{}", - path.GetOpcodePath(), + PathManager::Instance()->GetOpcodePath(), "login_opcodes.conf" ); @@ -131,7 +131,7 @@ ClientManager::ClientManager() opcodes_path = fmt::format( "{}/{}", - path.GetOpcodePath(), + PathManager::Instance()->GetOpcodePath(), "login_opcodes_sod.conf" ); @@ -169,7 +169,7 @@ ClientManager::ClientManager() opcodes_path = fmt::format( "{}/{}", - path.GetOpcodePath(), + PathManager::Instance()->GetOpcodePath(), "login_opcodes_larion.conf" ); diff --git a/loginserver/main.cpp b/loginserver/main.cpp index c541930ff..338c9e2c8 100644 --- a/loginserver/main.cpp +++ b/loginserver/main.cpp @@ -22,12 +22,9 @@ #include LoginServer server; -EQEmuLogSys LogSys; bool run_server = true; -PathManager path; Database database; PlayerEventLogs player_event_logs; -ZoneStore zone_store; void CatchSignal(int sig_num) { @@ -52,7 +49,7 @@ void LoadDatabaseConnection() void LoadServerConfig() { server.config = EQ::JsonConfigFile::Load( - fmt::format("{}/login.json", path.GetServerPath()) + fmt::format("{}/login.json", PathManager::Instance()->GetServerPath()) ); LogInfo("Config System Init"); @@ -159,21 +156,21 @@ int main(int argc, char **argv) LogInfo("Logging System Init"); if (argc == 1) { - LogSys.LoadLogSettingsDefaults(); + EQEmuLogSys::Instance()->LoadLogSettingsDefaults(); } - path.LoadPaths(); + PathManager::Instance()->Init(); // command handler if (argc > 1) { - LogSys.SilenceConsoleLogging(); + EQEmuLogSys::Instance()->SilenceConsoleLogging(); LoadServerConfig(); LoadDatabaseConnection(); - LogSys.LoadLogSettingsDefaults(); - LogSys.log_settings[Logs::Debug].log_to_console = static_cast(Logs::General); - LogSys.log_settings[Logs::Debug].is_category_enabled = 1; + EQEmuLogSys::Instance()->LoadLogSettingsDefaults(); + EQEmuLogSys::Instance()->log_settings[Logs::Debug].log_to_console = static_cast(Logs::General); + EQEmuLogSys::Instance()->log_settings[Logs::Debug].is_category_enabled = 1; LoginserverCommandHandler::CommandHandler(argc, argv); } @@ -182,7 +179,7 @@ int main(int argc, char **argv) LoadDatabaseConnection(); if (argc == 1) { - LogSys.SetDatabase(&database) + EQEmuLogSys::Instance()->SetDatabase(&database) ->SetLogPath("logs") ->LoadLogDatabaseSettings() ->StartFileLogs(); diff --git a/queryserv/lfguild.h b/queryserv/lfguild.h index c9c59ded3..1c0cb1cdd 100644 --- a/queryserv/lfguild.h +++ b/queryserv/lfguild.h @@ -44,6 +44,12 @@ public: bool LoadDatabase(); void HandlePacket(ServerPacket *pack); void ExpireEntries(); + + static LFGuildManager* Instance() + { + static LFGuildManager instance; + return &instance; + } private: void SendPlayerMatches(uint32 FromZoneID, uint32 FromInstanceID, char *From, uint32 FromLevel, uint32 ToLevel, uint32 MinAA, uint32 TimeZone, uint32 Classes); void SendGuildMatches(uint32 FromZoneID, uint32 FromInstanceID, char *From, uint32 Level, uint32 AAPoints, uint32 TimeZone, uint32 Class); diff --git a/queryserv/queryserv.cpp b/queryserv/queryserv.cpp index 74c6244a8..9533c21bb 100644 --- a/queryserv/queryserv.cpp +++ b/queryserv/queryserv.cpp @@ -20,23 +20,17 @@ #include "../common/net/console_server.h" #include "../queryserv/zonelist.h" #include "../queryserv/zoneserver.h" -#include "../common/discord/discord_manager.h" volatile bool RunLoops = true; QSDatabase qs_database; Database database; -LFGuildManager lfguildmanager; std::string WorldShortName; const queryservconfig *Config; WorldServer *worldserver = 0; -EQEmuLogSys LogSys; -PathManager path; -ZoneStore zone_store; PlayerEventLogs player_event_logs; ZSList zs_list; uint32 numzones = 0; -DiscordManager discord_manager; void CatchSignal(int sig_num) { @@ -46,11 +40,11 @@ void CatchSignal(int sig_num) int main() { RegisterExecutablePlatform(ExePlatformQueryServ); - LogSys.LoadLogSettingsDefaults(); + EQEmuLogSys::Instance()->LoadLogSettingsDefaults(); set_exception_handler(); Timer LFGuildExpireTimer(60000); - path.LoadPaths(); + PathManager::Instance()->Init(); LogInfo("Starting EQEmu QueryServ"); if (!queryservconfig::LoadConfig()) { @@ -85,8 +79,8 @@ int main() return 1; } - LogSys.SetDatabase(&database) - ->SetLogPath(path.GetLogPath()) + EQEmuLogSys::Instance()->SetDatabase(&database) + ->SetLogPath(PathManager::Instance()->GetLogPath()) ->LoadLogDatabaseSettings() ->StartFileLogs(); @@ -159,7 +153,7 @@ int main() worldserver->Connect(); /* Load Looking For Guild Manager */ - lfguildmanager.LoadDatabase(); + LFGuildManager::Instance()->LoadDatabase(); Timer player_event_process_timer(1000); player_event_logs.SetDatabase(&qs_database)->Init(); @@ -173,7 +167,7 @@ int main() } if (LFGuildExpireTimer.Check()) { - lfguildmanager.ExpireEntries(); + LFGuildManager::Instance()->ExpireEntries(); } if (player_event_process_timer.Check()) { @@ -187,7 +181,7 @@ int main() EQ::EventLoop::Get().Run(); safe_delete(worldserver); - LogSys.CloseFileLogs(); + EQEmuLogSys::Instance()->CloseFileLogs(); } void UpdateWindowTitle(char *iNewTitle) diff --git a/queryserv/worldserver.cpp b/queryserv/worldserver.cpp index 948ab931e..955169871 100644 --- a/queryserv/worldserver.cpp +++ b/queryserv/worldserver.cpp @@ -21,10 +21,12 @@ #include #include +#include "zonelist.h" + extern WorldServer worldserver; extern const queryservconfig *Config; extern QSDatabase qs_database; -extern LFGuildManager lfguildmanager; +extern ZSList zs_list; WorldServer::WorldServer() { @@ -76,8 +78,9 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) case ServerOP_ServerReloadRequest: { auto o = (ServerReload::Request*) p.Data(); if (o->type == ServerReload::Type::Logs) { - LogSys.LoadLogDatabaseSettings(); + EQEmuLogSys::Instance()->LoadLogDatabaseSettings(); player_event_logs.ReloadSettings(); + zs_list.SendPlayerEventLogSettings(); } break; @@ -112,7 +115,7 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) pack.pBuffer = (uchar *) p.Data(); pack.opcode = opcode; pack.size = (uint32) p.Length(); - lfguildmanager.HandlePacket(&pack); + LFGuildManager::Instance()->HandlePacket(&pack); pack.pBuffer = nullptr; break; } diff --git a/queryserv/zonelist.cpp b/queryserv/zonelist.cpp index d06cfefe8..16ad65371 100644 --- a/queryserv/zonelist.cpp +++ b/queryserv/zonelist.cpp @@ -5,6 +5,8 @@ void ZSList::Add(ZoneServer* zoneserver) { zone_server_list.emplace_back(std::unique_ptr(zoneserver)); zoneserver->SetIsZoneConnected(true); + + zoneserver->SendPlayerEventLogSettings(); } void ZSList::Remove(const std::string &uuid) @@ -18,3 +20,10 @@ void ZSList::Remove(const std::string &uuid) iter++; } } + +void ZSList::SendPlayerEventLogSettings() +{ + for (auto &zs : zone_server_list) { + zs->SendPlayerEventLogSettings(); + } +} diff --git a/queryserv/zonelist.h b/queryserv/zonelist.h index c63d1c211..3fc41676d 100644 --- a/queryserv/zonelist.h +++ b/queryserv/zonelist.h @@ -12,9 +12,10 @@ class ZoneServer; class ZSList { public: - std::list> &GetZsList() { return zone_server_list; } - void Add(ZoneServer *zoneserver); - void Remove(const std::string &uuid); + std::list>& GetZsList() { return zone_server_list; } + void Add(ZoneServer* zoneserver); + void Remove(const std::string& uuid); + void SendPlayerEventLogSettings(); private: std::list> zone_server_list; diff --git a/queryserv/zoneserver.cpp b/queryserv/zoneserver.cpp index 2c3fd92d4..dfa71f66b 100644 --- a/queryserv/zoneserver.cpp +++ b/queryserv/zoneserver.cpp @@ -5,8 +5,6 @@ #include "../common/events/player_event_logs.h" #include "../common/discord/discord_manager.h" -extern DiscordManager discord_manager; - ZoneServer::ZoneServer( std::shared_ptr in_connection, EQ::Net::ConsoleServer *in_console @@ -37,7 +35,7 @@ void ZoneServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) player_event_logs.AddToQueue(n.player_event_log); - discord_manager.QueuePlayerEventMessage(n); + DiscordManager::Instance()->QueuePlayerEventMessage(n); break; } default: { @@ -46,3 +44,27 @@ void ZoneServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) } } } + +void ZoneServer::SendPlayerEventLogSettings() +{ + EQ::Net::DynamicPacket dyn_pack; + std::vector settings( + player_event_logs.GetSettings(), + player_event_logs.GetSettings() + PlayerEvent::EventType::MAX + ); + + dyn_pack.PutSerialize(0, settings); + + auto packet_size = sizeof(ServerSendPlayerEvent_Struct) + dyn_pack.Length(); + + auto pack = std::make_unique( + ServerOP_SendPlayerEventSettings, + static_cast(packet_size) + ); + + auto* buf = reinterpret_cast(pack->pBuffer); + buf->cereal_size = static_cast(dyn_pack.Length()); + memcpy(buf->cereal_data, dyn_pack.Data(), dyn_pack.Length()); + + SendPacket(pack.release()); +} diff --git a/queryserv/zoneserver.h b/queryserv/zoneserver.h index db36bd4ff..f4a4b08e6 100644 --- a/queryserv/zoneserver.h +++ b/queryserv/zoneserver.h @@ -16,11 +16,12 @@ class ZoneServer : public WorldTCPConnection { public: ZoneServer(std::shared_ptr in_connection, EQ::Net::ConsoleServer *in_console); ~ZoneServer(); - void SendPacket(ServerPacket *pack) { m_connection->SendPacket(pack); } - void SetIsZoneConnected(bool in) { m_is_zone_connected = in; } - bool GetIsZoneConnected() { return m_is_zone_connected; } - void HandleMessage(uint16 opcode, const EQ::Net::Packet &p); + void SendPacket(ServerPacket *pack) { m_connection->SendPacket(pack); } + void SetIsZoneConnected(bool in) { m_is_zone_connected = in; } + bool GetIsZoneConnected() { return m_is_zone_connected; } + void HandleMessage(uint16 opcode, const EQ::Net::Packet &p); std::string GetUUID() const { return m_connection->GetUUID(); } + void SendPlayerEventLogSettings(); private: std::shared_ptr m_connection{}; diff --git a/shared_memory/main.cpp b/shared_memory/main.cpp index f395867ce..a9a043f58 100644 --- a/shared_memory/main.cpp +++ b/shared_memory/main.cpp @@ -35,10 +35,7 @@ #include "../common/events/player_event_logs.h" #include "../common/evolving_items.h" -EQEmuLogSys LogSys; WorldContentService content_service; -ZoneStore zone_store; -PathManager path; PlayerEventLogs player_event_logs; EvolvingItemsManager evolving_items_manager; @@ -81,10 +78,10 @@ inline bool MakeDirectory(const std::string &directory_name) int main(int argc, char **argv) { RegisterExecutablePlatform(ExePlatformSharedMemory); - LogSys.LoadLogSettingsDefaults(); + EQEmuLogSys::Instance()->LoadLogSettingsDefaults(); set_exception_handler(); - path.LoadPaths(); + PathManager::Instance()->Init(); LogInfo("Shared Memory Loader Program"); if (!EQEmuConfig::LoadConfig()) { @@ -126,8 +123,8 @@ int main(int argc, char **argv) content_db.SetMySQL(database); } - LogSys.SetDatabase(&database) - ->SetLogPath(path.GetLogPath()) + EQEmuLogSys::Instance()->SetDatabase(&database) + ->SetLogPath(PathManager::Instance()->GetLogPath()) ->LoadLogDatabaseSettings() ->StartFileLogs(); @@ -244,6 +241,6 @@ int main(int argc, char **argv) } } - LogSys.CloseFileLogs(); + EQEmuLogSys::Instance()->CloseFileLogs(); return 0; } diff --git a/tests/main.cpp b/tests/main.cpp index 50ddf890b..9c9af40c9 100644 --- a/tests/main.cpp +++ b/tests/main.cpp @@ -34,14 +34,12 @@ #include "task_state_test.h" const EQEmuConfig *Config; -EQEmuLogSys LogSys; -PathManager path; int main() { RegisterExecutablePlatform(ExePlatformClientImport); - LogSys.LoadLogSettingsDefaults(); - path.LoadPaths(); + EQEmuLogSys::Instance()->LoadLogSettingsDefaults(); + PathManager::Instance()->Init(); auto ConfigLoadResult = EQEmuConfig::LoadConfig(); Config = EQEmuConfig::get(); diff --git a/tests/string_util_test.h b/tests/string_util_test.h index af88a5a03..37bd539f7 100644 --- a/tests/string_util_test.h +++ b/tests/string_util_test.h @@ -30,7 +30,6 @@ public: TEST_ADD(StringUtilTest::EscapeStringTest); TEST_ADD(StringUtilTest::SearchDeliminatedStringTest); TEST_ADD(StringUtilTest::SplitStringTest); - TEST_ADD(StringUtilTest::FromCharsTest); TEST_ADD(StringUtilTest::TestIsFloat); TEST_ADD(StringUtilTest::TestIsNumber); } @@ -108,21 +107,6 @@ public: TEST_ASSERT(v[2] == "789"); } - void FromCharsTest() { - char int_chars[] = "123"; - int int_value = 0; - - char float_chars[] = "3.14"; - float float_value = 0.0f; - - Strings::from_chars(int_chars, int_value); - TEST_ASSERT(int_value == 123); - - Strings::from_chars(float_chars, float_value); - TEST_ASSERT(float_value == 3.14f); - - } - void TestIsFloat() { TEST_ASSERT_EQUALS(Strings::IsFloat("0.23424523"), true); TEST_ASSERT_EQUALS(Strings::IsFloat("12312312313.23424523"), true); diff --git a/ucs/clientlist.cpp b/ucs/clientlist.cpp index cbb6e0910..251fd8f05 100644 --- a/ucs/clientlist.cpp +++ b/ucs/clientlist.cpp @@ -482,7 +482,7 @@ Clientlist::Clientlist(int ChatPort) { const ucsconfig *Config = ucsconfig::get(); - std::string opcodes_file = fmt::format("{}/{}", path.GetServerPath(), Config->MailOpCodesFile); + std::string opcodes_file = fmt::format("{}/{}", PathManager::Instance()->GetServerPath(), Config->MailOpCodesFile); LogInfo("Loading [{}]", opcodes_file); if (!ChatOpMgr->LoadOpcodes(opcodes_file.c_str())) @@ -651,7 +651,7 @@ void Clientlist::Process() OpcodeManager::EmuToName(app->GetOpcode()), o->EmuToEQ(app->GetOpcode()) == 0 ? app->GetProtocolOpcode() : o->EmuToEQ(app->GetOpcode()), app->Size(), - (LogSys.IsLogEnabled(Logs::Detail, Logs::PacketClientServer) ? DumpPacketToString(app) : "") + (EQEmuLogSys::Instance()->IsLogEnabled(Logs::Detail, Logs::PacketClientServer) ? DumpPacketToString(app) : "") ); switch (opcode) { diff --git a/ucs/ucs.cpp b/ucs/ucs.cpp index c89c3f4fd..de1557495 100644 --- a/ucs/ucs.cpp +++ b/ucs/ucs.cpp @@ -44,12 +44,8 @@ ChatChannelList *ChannelList; Clientlist *g_Clientlist; -EQEmuLogSys LogSys; UCSDatabase database; WorldServer *worldserver = nullptr; -DiscordManager discord_manager; -PathManager path; -ZoneStore zone_store; PlayerEventLogs player_event_logs; const ucsconfig *Config; @@ -75,7 +71,7 @@ void Shutdown() { LogInfo("Shutting down..."); ChannelList->RemoveAllChannels(); g_Clientlist->CloseAllConnections(); - LogSys.CloseFileLogs(); + EQEmuLogSys::Instance()->CloseFileLogs(); } int caught_loop = 0; @@ -90,24 +86,24 @@ void CatchSignal(int sig_num) { LogInfo("In a signal handler loop and process is incapable of exiting properly, forcefully cleaning up"); ChannelList->RemoveAllChannels(); g_Clientlist->CloseAllConnections(); - LogSys.CloseFileLogs(); + EQEmuLogSys::Instance()->CloseFileLogs(); std::exit(0); } } void PlayerEventQueueListener() { while (caught_loop == 0) { - discord_manager.ProcessMessageQueue(); + DiscordManager::Instance()->ProcessMessageQueue(); Sleep(100); } } int main() { RegisterExecutablePlatform(ExePlatformUCS); - LogSys.LoadLogSettingsDefaults(); + EQEmuLogSys::Instance()->LoadLogSettingsDefaults(); set_exception_handler(); - path.LoadPaths(); + PathManager::Instance()->Init(); // Check every minute for unused channels we can delete // @@ -139,8 +135,9 @@ int main() { return 1; } - LogSys.SetDatabase(&database) - ->SetLogPath(path.GetLogPath()) + EQEmuLogSys::Instance() + ->SetDatabase(&database) + ->SetLogPath(PathManager::Instance()->GetLogPath()) ->LoadLogDatabaseSettings() ->StartFileLogs(); diff --git a/ucs/worldserver.cpp b/ucs/worldserver.cpp index 253f61fc3..969eed824 100644 --- a/ucs/worldserver.cpp +++ b/ucs/worldserver.cpp @@ -42,7 +42,6 @@ extern WorldServer worldserver; extern Clientlist *g_Clientlist; extern const ucsconfig *Config; extern UCSDatabase database; -extern DiscordManager discord_manager; void ProcessMailTo(Client *c, const std::string& from, const std::string& subject, const std::string& message); @@ -79,7 +78,7 @@ void WorldServer::ProcessMessage(uint16 opcode, EQ::Net::Packet &p) case ServerOP_ServerReloadRequest: { auto o = (ServerReload::Request*) pack->pBuffer; if (o->type == ServerReload::Type::Logs) { - LogSys.LoadLogDatabaseSettings(); + EQEmuLogSys::Instance()->LoadLogDatabaseSettings(); player_event_logs.ReloadSettings(); } @@ -92,14 +91,14 @@ void WorldServer::ProcessMessage(uint16 opcode, EQ::Net::Packet &p) cereal::BinaryInputArchive archive(ss); archive(n); - discord_manager.QueuePlayerEventMessage(n); + DiscordManager::Instance()->QueuePlayerEventMessage(n); break; } case ServerOP_DiscordWebhookMessage: { auto *q = (DiscordWebhookMessage_Struct *) p.Data(); - discord_manager.QueueWebhookMessage( + DiscordManager::Instance()->QueueWebhookMessage( q->webhook_id, q->message ); diff --git a/utils/scripts/build/should-release/go.mod b/utils/scripts/build/should-release/go.mod index b74fc2889..eaa798134 100644 --- a/utils/scripts/build/should-release/go.mod +++ b/utils/scripts/build/should-release/go.mod @@ -1,6 +1,8 @@ module should-release -go 1.18 +go 1.23.0 + +toolchain go1.23.5 require ( github.com/google/go-github/v41 v41.0.0 diff --git a/utils/scripts/generators/log-alias-generator.pl b/utils/scripts/generators/log-alias-generator.pl index be79fa32e..391b4d4a2 100755 --- a/utils/scripts/generators/log-alias-generator.pl +++ b/utils/scripts/generators/log-alias-generator.pl @@ -35,12 +35,12 @@ if (scalar(@enum) > 0) { foreach my $cat (@cats) { print "#define Log" . $cat . "(message, ...) do {\\ - if (LogSys.IsLogEnabled(Logs::General, Logs::" . $cat . "))\\ + if (EQEmuLogSys::Instance()->IsLogEnabled(Logs::General, Logs::" . $cat . "))\\ OutF(LogSys, Logs::General, Logs::" . $cat . ", __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\\ } while (0) #define Log" . $cat . "Detail(message, ...) do {\\ - if (LogSys.IsLogEnabled(Logs::Detail, Logs::" . $cat . "))\\ + if (EQEmuLogSys::Instance()->IsLogEnabled(Logs::Detail, Logs::" . $cat . "))\\ OutF(LogSys, Logs::Detail, Logs::" . $cat . ", __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\\ } while (0) diff --git a/utils/scripts/generators/repository-generator.pl b/utils/scripts/generators/repository-generator.pl index 6cb6a137c..3def50506 100644 --- a/utils/scripts/generators/repository-generator.pl +++ b/utils/scripts/generators/repository-generator.pl @@ -114,7 +114,8 @@ if ($requested_table_to_generate ne "all") { my @cereal_enabled_tables = ( "data_buckets", - "player_event_logs" + "player_event_logs", + "player_event_log_settings" ); my $generated_base_repository_files = ""; diff --git a/world/CMakeLists.txt b/world/CMakeLists.txt index 0eed74b9b..1963c83ae 100644 --- a/world/CMakeLists.txt +++ b/world/CMakeLists.txt @@ -77,7 +77,7 @@ ADD_EXECUTABLE(world ${world_sources} ${world_headers}) INSTALL(TARGETS world RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin) IF (WIN32 AND EQEMU_BUILD_PCH) - TARGET_PRECOMPILE_HEADERS(world PRIVATE ../common/pch/pch.h) + TARGET_PRECOMPILE_HEADERS(world PRIVATE ../common/pch/std-pch.h) ENDIF () ADD_DEFINITIONS(-DWORLD) diff --git a/world/adventure.cpp b/world/adventure.cpp index ae923b3be..3abd5aa61 100644 --- a/world/adventure.cpp +++ b/world/adventure.cpp @@ -18,7 +18,6 @@ extern ZSList zoneserver_list; extern ClientList client_list; extern AdventureManager adventure_manager; -extern EQ::Random emu_random; Adventure::Adventure(AdventureTemplate *t) { @@ -368,8 +367,8 @@ void Adventure::MoveCorpsesToGraveyard() glm::vec4 position; - float x = GetTemplate()->graveyard_x + emu_random.Real(-GetTemplate()->graveyard_radius, GetTemplate()->graveyard_radius); - float y = GetTemplate()->graveyard_y + emu_random.Real(-GetTemplate()->graveyard_radius, GetTemplate()->graveyard_radius); + float x = GetTemplate()->graveyard_x + EQ::Random::Instance()->Real(-GetTemplate()->graveyard_radius, GetTemplate()->graveyard_radius); + float y = GetTemplate()->graveyard_y + EQ::Random::Instance()->Real(-GetTemplate()->graveyard_radius, GetTemplate()->graveyard_radius); float z = GetTemplate()->graveyard_z; position.x = x; diff --git a/world/adventure_manager.cpp b/world/adventure_manager.cpp index 3d8442e53..34198c159 100644 --- a/world/adventure_manager.cpp +++ b/world/adventure_manager.cpp @@ -16,7 +16,6 @@ extern ZSList zoneserver_list; extern ClientList client_list; -extern EQ::Random emu_random; AdventureManager::AdventureManager() { @@ -68,7 +67,7 @@ void AdventureManager::Process() void AdventureManager::CalculateAdventureRequestReply(const char *data) { ServerAdventureRequest_Struct *sar = (ServerAdventureRequest_Struct*)data; - ClientListEntry *leader = client_list.FindCharacter(sar->leader); + ClientListEntry *leader = ClientList::Instance()->FindCharacter(sar->leader); if(!leader) { return; @@ -185,7 +184,7 @@ void AdventureManager::CalculateAdventureRequestReply(const char *data) for(int i = 0; i < sar->member_count; ++i) { - ClientListEntry *current = client_list.FindCharacter((data + sizeof(ServerAdventureRequest_Struct) + (64 * i))); + ClientListEntry *current = ClientList::Instance()->FindCharacter((data + sizeof(ServerAdventureRequest_Struct) + (64 * i))); if(current) { int lvl = current->level(); @@ -324,7 +323,7 @@ void AdventureManager::CalculateAdventureRequestReply(const char *data) if(eligible_adventures.size() > 0) { ea_iter = eligible_adventures.begin(); - int c_index = emu_random.Int(0, (eligible_adventures.size()-1)); + int c_index = EQ::Random::Instance()->Int(0, (eligible_adventures.size()-1)); for(int i = 0; i < c_index; ++i) { ++ea_iter; @@ -357,7 +356,7 @@ void AdventureManager::CalculateAdventureRequestReply(const char *data) void AdventureManager::TryAdventureCreate(const char *data) { ServerAdventureRequestCreate_Struct *src = (ServerAdventureRequestCreate_Struct*)data; - ClientListEntry *leader = client_list.FindCharacter(src->leader); + ClientListEntry *leader = ClientList::Instance()->FindCharacter(src->leader); if(!leader) { return; @@ -404,7 +403,7 @@ void AdventureManager::TryAdventureCreate(const char *data) for(int i = 0; i < src->member_count; ++i) { - ClientListEntry *player = client_list.FindCharacter((data + sizeof(ServerAdventureRequestCreate_Struct) + (64 * i))); + ClientListEntry *player = ClientList::Instance()->FindCharacter((data + sizeof(ServerAdventureRequestCreate_Struct) + (64 * i))); if(player) { int f_count = 0; @@ -458,7 +457,7 @@ void AdventureManager::GetAdventureData(Adventure *adv) void AdventureManager::GetAdventureData(const char *name) { - ClientListEntry *player = client_list.FindCharacter(name); + ClientListEntry *player = ClientList::Instance()->FindCharacter(name); if(player) { int f_count = 0; @@ -764,7 +763,7 @@ void AdventureManager::PlayerClickedDoor(const char *player, int zone_id, int do { if((*iter)->PlayerExists(player)) { - ClientListEntry *pc = client_list.FindCharacter(player); + ClientListEntry *pc = ClientList::Instance()->FindCharacter(player); if(pc) { auto pack = @@ -792,7 +791,7 @@ void AdventureManager::PlayerClickedDoor(const char *player, int zone_id, int do ++iter; } - ClientListEntry *pc = client_list.FindCharacter(player); + ClientListEntry *pc = ClientList::Instance()->FindCharacter(player); if(pc) { auto pack = new ServerPacket(ServerOP_AdventureClickDoorError, 64); @@ -804,7 +803,7 @@ void AdventureManager::PlayerClickedDoor(const char *player, int zone_id, int do void AdventureManager::LeaveAdventure(const char *name) { - ClientListEntry *pc = client_list.FindCharacter(name); + ClientListEntry *pc = ClientList::Instance()->FindCharacter(name); if(pc) { Adventure *current = GetActiveAdventure(name); @@ -867,7 +866,7 @@ void AdventureManager::IncrementCount(uint16 instance_id) while(siter != slist.end()) { - ClientListEntry *pc = client_list.FindCharacter((*siter).c_str()); + ClientListEntry *pc = ClientList::Instance()->FindCharacter((*siter).c_str()); if(pc) { memset(ac->player, 0, 64); @@ -1262,7 +1261,7 @@ void AdventureManager::DoLeaderboardRequest(const char* player, uint8 type) void AdventureManager::DoLeaderboardRequestWins(const char* player) { - ClientListEntry *pc = client_list.FindCharacter(player); + ClientListEntry *pc = ClientList::Instance()->FindCharacter(player); if(pc) { auto pack = new ServerPacket(ServerOP_AdventureLeaderboard, 64 + sizeof(AdventureLeaderboard_Struct)); @@ -1328,7 +1327,7 @@ void AdventureManager::DoLeaderboardRequestWins(const char* player) void AdventureManager::DoLeaderboardRequestPercentage(const char* player) { - ClientListEntry *pc = client_list.FindCharacter(player); + ClientListEntry *pc = ClientList::Instance()->FindCharacter(player); if(pc) { auto pack = new ServerPacket(ServerOP_AdventureLeaderboard, 64 + sizeof(AdventureLeaderboard_Struct)); @@ -1394,7 +1393,7 @@ void AdventureManager::DoLeaderboardRequestPercentage(const char* player) void AdventureManager::DoLeaderboardRequestWinsGuk(const char* player) { - ClientListEntry *pc = client_list.FindCharacter(player); + ClientListEntry *pc = ClientList::Instance()->FindCharacter(player); if(pc) { auto pack = new ServerPacket(ServerOP_AdventureLeaderboard, 64 + sizeof(AdventureLeaderboard_Struct)); @@ -1460,7 +1459,7 @@ void AdventureManager::DoLeaderboardRequestWinsGuk(const char* player) void AdventureManager::DoLeaderboardRequestPercentageGuk(const char* player) { - ClientListEntry *pc = client_list.FindCharacter(player); + ClientListEntry *pc = ClientList::Instance()->FindCharacter(player); if(pc) { auto pack = new ServerPacket(ServerOP_AdventureLeaderboard, 64 + sizeof(AdventureLeaderboard_Struct)); @@ -1526,7 +1525,7 @@ void AdventureManager::DoLeaderboardRequestPercentageGuk(const char* player) void AdventureManager::DoLeaderboardRequestWinsMir(const char* player) { - ClientListEntry *pc = client_list.FindCharacter(player); + ClientListEntry *pc = ClientList::Instance()->FindCharacter(player); if(pc) { auto pack = new ServerPacket(ServerOP_AdventureLeaderboard, 64 + sizeof(AdventureLeaderboard_Struct)); @@ -1592,7 +1591,7 @@ void AdventureManager::DoLeaderboardRequestWinsMir(const char* player) void AdventureManager::DoLeaderboardRequestPercentageMir(const char* player) { - ClientListEntry *pc = client_list.FindCharacter(player); + ClientListEntry *pc = ClientList::Instance()->FindCharacter(player); if(pc) { auto pack = new ServerPacket(ServerOP_AdventureLeaderboard, 64 + sizeof(AdventureLeaderboard_Struct)); @@ -1658,7 +1657,7 @@ void AdventureManager::DoLeaderboardRequestPercentageMir(const char* player) void AdventureManager::DoLeaderboardRequestWinsMmc(const char* player) { - ClientListEntry *pc = client_list.FindCharacter(player); + ClientListEntry *pc = ClientList::Instance()->FindCharacter(player); if(pc) { auto pack = new ServerPacket(ServerOP_AdventureLeaderboard, 64 + sizeof(AdventureLeaderboard_Struct)); @@ -1724,7 +1723,7 @@ void AdventureManager::DoLeaderboardRequestWinsMmc(const char* player) void AdventureManager::DoLeaderboardRequestPercentageMmc(const char* player) { - ClientListEntry *pc = client_list.FindCharacter(player); + ClientListEntry *pc = ClientList::Instance()->FindCharacter(player); if(pc) { auto pack = new ServerPacket(ServerOP_AdventureLeaderboard, 64 + sizeof(AdventureLeaderboard_Struct)); @@ -1790,7 +1789,7 @@ void AdventureManager::DoLeaderboardRequestPercentageMmc(const char* player) void AdventureManager::DoLeaderboardRequestWinsRuj(const char* player) { - ClientListEntry *pc = client_list.FindCharacter(player); + ClientListEntry *pc = ClientList::Instance()->FindCharacter(player); if(pc) { auto pack = new ServerPacket(ServerOP_AdventureLeaderboard, 64 + sizeof(AdventureLeaderboard_Struct)); diff --git a/world/client.cpp b/world/client.cpp index 243d9f203..07ca03431 100644 --- a/world/client.cpp +++ b/world/client.cpp @@ -36,6 +36,7 @@ #include "../common/shareddb.h" #include "../common/opcodemgr.h" #include "../common/data_verification.h" +#include "../common/data_bucket.h" #include "client.h" #include "worlddb.h" @@ -89,9 +90,7 @@ std::vector character_create_allocations; std::vector character_create_race_class_combos; extern ZSList zoneserver_list; -extern LoginServerList loginserverlist; extern ClientList client_list; -extern EQ::Random emu_random; extern uint32 numclients; extern volatile bool RunLoops; extern volatile bool UCSServerAvailable_; @@ -135,6 +134,8 @@ Client::Client(EQStreamInterface* ieqs) } Client::~Client() { + ClearDataBucketsCache(); + if (RunLoops && cle && zone_id == 0) cle->SetOnline(CLE_Status::Offline); @@ -477,6 +478,8 @@ bool Client::HandleSendLoginInfoPacket(const EQApplicationPacket *app) LogClientLogin("Checking authentication id [{}]", id); if ((cle = client_list.CheckAuth(id, password))) { + LoadDataBucketsCache(); + LogClientLogin("Checking authentication id [{}] passed", id); if (!is_player_zoning) { // Track who is in and who is out of the game @@ -514,7 +517,7 @@ bool Client::HandleSendLoginInfoPacket(const EQApplicationPacket *app) ServerLSPlayerJoinWorld_Struct* join =(ServerLSPlayerJoinWorld_Struct*)pack->pBuffer; strcpy(join->key,GetLSKey()); join->lsaccount_id = GetLSID(); - loginserverlist.SendPacket(pack); + LoginServerList::Instance()->SendPacket(pack); safe_delete(pack); } @@ -984,7 +987,7 @@ bool Client::HandleEnterWorldPacket(const EQApplicationPacket *app) { safe_delete(outapp); // set mailkey - used for duration of character session - int mail_key = emu_random.Int(1, INT_MAX); + int mail_key = EQ::Random::Instance()->Int(1, INT_MAX); database.SetMailKey(charid, GetIP(), mail_key); if (UCSServerAvailable_) { @@ -1097,7 +1100,7 @@ bool Client::HandlePacket(const EQApplicationPacket *app) { OpcodeManager::EmuToName(app->GetOpcode()), o->EmuToEQ(app->GetOpcode()) == 0 ? app->GetProtocolOpcode() : o->EmuToEQ(app->GetOpcode()), app->Size(), - (LogSys.IsLogEnabled(Logs::Detail, Logs::PacketClientServer) ? DumpPacketToString(app) : "") + (EQEmuLogSys::Instance()->IsLogEnabled(Logs::Detail, Logs::PacketClientServer) ? DumpPacketToString(app) : "") ); if (!eqs->CheckState(ESTABLISHED)) { @@ -1246,7 +1249,7 @@ bool Client::Process() { ServerLSPlayerLeftWorld_Struct* logout =(ServerLSPlayerLeftWorld_Struct*)pack->pBuffer; strcpy(logout->key,GetLSKey()); logout->lsaccount_id = GetLSID(); - loginserverlist.SendPacket(pack); + LoginServerList::Instance()->SendPacket(pack); safe_delete(pack); } LogInfo("Client disconnected (not active in process)"); @@ -2171,7 +2174,7 @@ void Client::SetClassStartingSkills(PlayerProfile_Struct *pp) i == EQ::skills::SkillAlcoholTolerance || i == EQ::skills::SkillBindWound) continue; - pp->skills[i] = skill_caps.GetSkillCap(pp->class_, (EQ::skills::SkillType)i, 1).cap; + pp->skills[i] = SkillCaps::Instance()->GetSkillCap(pp->class_, (EQ::skills::SkillType)i, 1).cap; } } @@ -2369,7 +2372,7 @@ bool Client::StoreCharacter( return false; } - const std::string& zone_name = zone_store.GetZoneName(p_player_profile_struct->zone_id, true); + const std::string& zone_name = ZoneStore::Instance()->GetZoneName(p_player_profile_struct->zone_id, true); if (Strings::EqualFold(zone_name, "UNKNOWN")) { p_player_profile_struct->zone_id = Zones::QEYNOS; } @@ -2518,3 +2521,19 @@ void Client::SendUnsupportedClientPacket(const std::string& message) QueuePacket(&packet); } + +void Client::LoadDataBucketsCache() +{ + DataBucket::BulkLoadEntitiesToCache(DataBucketLoadType::Account, {GetAccountID()}); + const auto ids = CharacterDataRepository::GetCharacterIDsByAccountID(database, GetAccountID()); + DataBucket::BulkLoadEntitiesToCache(DataBucketLoadType::Client, ids); +} + +void Client::ClearDataBucketsCache() +{ + DataBucket::DeleteFromCache(GetAccountID(), DataBucketLoadType::Account); + auto ids = CharacterDataRepository::GetCharacterIDsByAccountID(database, GetAccountID()); + for (const auto& id : ids) { + DataBucket::DeleteFromCache(id, DataBucketLoadType::Client); + } +} diff --git a/world/client.h b/world/client.h index e88f8a94e..5890cfcf0 100644 --- a/world/client.h +++ b/world/client.h @@ -121,6 +121,9 @@ private: bool CanTradeFVNoDropItem(); void RecordPossibleHack(const std::string& message); void SendUnsupportedClientPacket(const std::string& message); + + void LoadDataBucketsCache(); + void ClearDataBucketsCache(); }; bool CheckCharCreateInfoSoF(CharCreate_Struct *cc); diff --git a/world/cliententry.cpp b/world/cliententry.cpp index cd043b157..ff30a2ec0 100644 --- a/world/cliententry.cpp +++ b/world/cliententry.cpp @@ -9,10 +9,8 @@ #include "world_config.h" extern uint32 numplayers; -extern LoginServerList loginserverlist; extern ClientList client_list; extern volatile bool RunLoops; -extern SharedTaskManager shared_task_manager; ClientListEntry::ClientListEntry( uint32 id, @@ -94,7 +92,7 @@ ClientListEntry::~ClientListEntry() { if (RunLoops) { Camp(); // updates zoneserver's numplayers - client_list.RemoveCLEReferances(this); + ClientList::Instance()->RemoveCLEReferances(this); } for (auto &elem: m_tell_queue) { safe_delete_array(elem); @@ -146,7 +144,7 @@ void ClientListEntry::LSUpdate(ZoneServer *iZS) zone->count = iZS->NumPlayers(); zone->zone = iZS->GetZoneID(); zone->zone_wid = iZS->GetID(); - loginserverlist.SendPacket(pack); + LoginServerList::Instance()->SendPacket(pack); safe_delete(pack); } } @@ -162,7 +160,7 @@ void ClientListEntry::LSZoneChange(ZoneToZone_Struct *ztz) zonechange->lsaccount_id = LSID(); zonechange->from = ztz->current_zone_id; zonechange->to = ztz->requested_zone_id; - loginserverlist.SendPacket(pack); + LoginServerList::Instance()->SendPacket(pack); safe_delete(pack); } } @@ -224,7 +222,7 @@ void ClientListEntry::LeavingZone(ZoneServer *iZS, CLE_Status iOnline) } SetOnline(iOnline); - shared_task_manager.RemoveActiveInvitationByCharacterID(CharID()); + SharedTaskManager::Instance()->RemoveActiveInvitationByCharacterID(CharID()); if (m_zone_server) { m_zone_server->RemovePlayer(); diff --git a/world/clientlist.h b/world/clientlist.h index fbf8c290c..64501f265 100644 --- a/world/clientlist.h +++ b/world/clientlist.h @@ -85,6 +85,12 @@ public: return {m_gm_zone_server_ids.begin(), m_gm_zone_server_ids.end()}; } + static ClientList* Instance() + { + static ClientList instance; + return &instance; + } + private: void OnTick(EQ::Timer *t); inline uint32 GetNextCLEID() { return NextCLEID++; } diff --git a/world/console.cpp b/world/console.cpp index 2fcc878bf..9cc95134d 100644 --- a/world/console.cpp +++ b/world/console.cpp @@ -35,7 +35,6 @@ extern ClientList client_list; extern ZSList zoneserver_list; -extern LoginServerList loginserverlist; /** * @param username @@ -534,8 +533,8 @@ void ConsoleLock( ) { WorldConfig::LockWorld(); - if (loginserverlist.Connected()) { - loginserverlist.SendStatus(); + if (LoginServerList::Instance()->Connected()) { + LoginServerList::Instance()->SendStatus(); connection->SendLine("World locked."); } else { @@ -555,8 +554,8 @@ void ConsoleUnlock( ) { WorldConfig::UnlockWorld(); - if (loginserverlist.Connected()) { - loginserverlist.SendStatus(); + if (LoginServerList::Instance()->Connected()) { + LoginServerList::Instance()->SendStatus(); connection->SendLine("World unlocked."); } else { @@ -1219,7 +1218,7 @@ void ConsoleCrossZoneMove( const auto& zone_short_name = !Strings::IsNumber(args[2]) ? args[2] : ""; const uint16 instance_id = Strings::IsNumber(args[2]) ? static_cast(Strings::ToUnsignedInt(args[2])) : 0; - const auto& z = !zone_short_name.empty() ? zone_store.GetZone(zone_short_name) : nullptr; + const auto& z = !zone_short_name.empty() ? ZoneStore::Instance()->GetZone(zone_short_name) : nullptr; if (z && !z->id) { connection->SendLine(fmt::format("No zone with the short name '{}' exists.", zone_short_name)); @@ -1289,7 +1288,7 @@ void ConsoleWorldWideMove( const auto& zone_short_name = !Strings::IsNumber(args[2]) ? args[2] : ""; const uint16 instance_id = Strings::IsNumber(args[2]) ? static_cast(Strings::ToUnsignedInt(args[2])) : 0; - const auto& z = !zone_short_name.empty() ? zone_store.GetZone(zone_short_name) : nullptr; + const auto& z = !zone_short_name.empty() ? ZoneStore::Instance()->GetZone(zone_short_name) : nullptr; if (z && !z->id) { connection->SendLine(fmt::format("No zone with the short name '{}' exists.", zone_short_name)); @@ -1330,6 +1329,42 @@ void ConsoleWorldWideMove( ); } +void ConsoleWWMarquee( + EQ::Net::ConsoleServerConnection* connection, + const std::string& command, + const std::vector& args +) +{ + if (args.size() < 2) { + connection->SendLine("Usage: wwmarquee "); + return; + } + + const uint32 type = Strings::IsNumber(args[0]) ? Strings::ToUnsignedInt(args[0]) : 0; + std::string message = Strings::Join(std::vector(args.begin() + 1, args.end()), " "); + if (message.empty()) { + connection->SendLine("Message cannot be empty."); + return; + } + + auto pack = new ServerPacket(ServerOP_WWMarquee, sizeof(WWMarquee_Struct)); + auto* wwm = (WWMarquee_Struct*)pack->pBuffer; + + wwm->type = type; + wwm->priority = 510; + wwm->fade_in = 0; + wwm->fade_out = 0; + wwm->duration = 5000; + wwm->min_status = AccountStatus::Player; + wwm->max_status = AccountStatus::Player; + + strn0cpy(wwm->message, message.c_str(), sizeof(wwm->message)); + + zoneserver_list.SendPacket(pack); + safe_delete(pack); + + connection->SendLine(fmt::format("Sent world marquee type {}: {}", type, message)); +} /** * @param console @@ -1367,6 +1402,12 @@ void RegisterConsoleFunctions(std::unique_ptr& console) console->RegisterCall("whoami", 50, "whoami", std::bind(ConsoleWhoami, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); console->RegisterCall("worldshutdown", 200, "worldshutdown", std::bind(ConsoleWorldShutdown, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); console->RegisterCall("wwcast", 50, "wwcast [spell_id] [min_status] [max_status] - min_status and max_status are optional", std::bind(ConsoleWorldWideCastSpell, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); + console->RegisterCall( + "wwmarquee", + 50, + "wwmarquee ", + std::bind(ConsoleWWMarquee, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3) + ); console->RegisterCall("wwmove", 50, "wwmove [instance_id|zone_short_name] [min_status] [max_status] - min_status and max_status are optional, instance_id and zone_short_name are interchangeable", std::bind(ConsoleWorldWideMove, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); console->RegisterCall("zonebootup", 150, "zonebootup [zone_server_id] [zone_short_name]", std::bind(ConsoleZoneBootup, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); console->RegisterCall("zonelock", 150, "zonelock [list|lock|unlock] [zone_short_name]", std::bind(ConsoleZoneLock, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); diff --git a/world/dynamic_zone.cpp b/world/dynamic_zone.cpp index ba53b58d0..97a7b6df8 100644 --- a/world/dynamic_zone.cpp +++ b/world/dynamic_zone.cpp @@ -41,7 +41,7 @@ void DynamicZone::ChooseNewLeader() auto it = std::find_if(m_members.begin(), m_members.end(), [&](const DynamicZoneMember& member) { if (member.id != GetLeaderID() && member.IsOnline()) { - auto member_cle = client_list.FindCLEByCharacterID(member.id); + auto member_cle = ClientList::Instance()->FindCLEByCharacterID(member.id); return (member_cle && member_cle->GetOnline() == CLE_Status::InZone); } return false; @@ -230,8 +230,8 @@ void DynamicZone::CacheMemberStatuses() // called when a new dz is cached to fill member statuses std::string zone_name; std::vector all_clients; - all_clients.reserve(client_list.GetClientCount()); - client_list.GetClients(zone_name.c_str(), all_clients); + all_clients.reserve(ClientList::Instance()->GetClientCount()); + ClientList::Instance()->GetClients(zone_name.c_str(), all_clients); for (const auto& member : m_members) { diff --git a/world/dynamic_zone_manager.cpp b/world/dynamic_zone_manager.cpp index 18263f996..c7845b02a 100644 --- a/world/dynamic_zone_manager.cpp +++ b/world/dynamic_zone_manager.cpp @@ -210,7 +210,7 @@ void DynamicZoneManager::HandleZoneMessage(ServerPacket* pack) { auto buf = reinterpret_cast(pack->pBuffer); - ClientListEntry* cle = client_list.FindCharacter(buf->target_name); + ClientListEntry* cle = ClientList::Instance()->FindCharacter(buf->target_name); if (cle && cle->Server()) { // continue in the add target's zone @@ -220,7 +220,7 @@ void DynamicZoneManager::HandleZoneMessage(ServerPacket* pack) else { // add target not online, return to inviter - ClientListEntry* inviter_cle = client_list.FindCharacter(buf->requester_name); + ClientListEntry* inviter_cle = ClientList::Instance()->FindCharacter(buf->requester_name); if (inviter_cle && inviter_cle->Server()) { inviter_cle->Server()->SendPacket(pack); @@ -231,7 +231,7 @@ void DynamicZoneManager::HandleZoneMessage(ServerPacket* pack) case ServerOP_DzSaveInvite: { auto buf = reinterpret_cast(pack->pBuffer); - if (ClientListEntry* cle = client_list.FindCharacter(buf->target_name)) + if (ClientListEntry* cle = ClientList::Instance()->FindCharacter(buf->target_name)) { // store packet on cle and re-send it when client requests it buf->is_char_online = true; @@ -243,7 +243,7 @@ void DynamicZoneManager::HandleZoneMessage(ServerPacket* pack) case ServerOP_DzRequestInvite: { auto buf = reinterpret_cast(pack->pBuffer); - if (ClientListEntry* cle = client_list.FindCLEByCharacterID(buf->char_id)) + if (ClientListEntry* cle = ClientList::Instance()->FindCLEByCharacterID(buf->char_id)) { auto invite_pack = cle->GetPendingDzInvite(); if (invite_pack && cle->Server()) @@ -259,7 +259,7 @@ void DynamicZoneManager::HandleZoneMessage(ServerPacket* pack) // notify requester (old leader) and new leader of the result ZoneServer* new_leader_zs = nullptr; - ClientListEntry* leader_cle = client_list.FindCharacter(buf->new_leader_name); + ClientListEntry* leader_cle = ClientList::Instance()->FindCharacter(buf->new_leader_name); if (leader_cle && leader_cle->Server()) { auto dz = DynamicZone::FindDynamicZoneByID(buf->dz_id); @@ -274,7 +274,7 @@ void DynamicZoneManager::HandleZoneMessage(ServerPacket* pack) } // if old and new leader are in the same zone only send one message - ClientListEntry* requester_cle = client_list.FindCLEByCharacterID(buf->requester_id); + ClientListEntry* requester_cle = ClientList::Instance()->FindCLEByCharacterID(buf->requester_id); if (requester_cle && requester_cle->Server() && requester_cle->Server() != new_leader_zs) { requester_cle->Server()->SendPacket(pack); @@ -441,7 +441,7 @@ void DynamicZoneManager::HandleZoneMessage(ServerPacket* pack) case ServerOP_DzCharacterLockout: { auto buf = reinterpret_cast(pack->pBuffer); - auto cle = client_list.FindCLEByCharacterID(buf->char_id); + auto cle = ClientList::Instance()->FindCLEByCharacterID(buf->char_id); if (cle && cle->Server()) { cle->Server()->SendPacket(pack); diff --git a/world/eqemu_api_world_data_service.cpp b/world/eqemu_api_world_data_service.cpp index ee25f4463..e3a75d052 100644 --- a/world/eqemu_api_world_data_service.cpp +++ b/world/eqemu_api_world_data_service.cpp @@ -124,7 +124,7 @@ void callGetClientList(Json::Value &response, const std::vector &ar } } - client_list.GetClientList(response, full_list); + ClientList::Instance()->GetClientList(response, full_list); } void getReloadTypes(Json::Value &response) @@ -141,7 +141,7 @@ void getReloadTypes(Json::Value &response) void getServerCounts(Json::Value &response, const std::vector &args) { response["zone_count"] = zoneserver_list.GetServerListCount(); - response["client_count"] = client_list.GetClientCount(); + response["client_count"] = ClientList::Instance()->GetClientCount(); } void EQEmuApiWorldDataService::reload(Json::Value &r, const std::vector &args) @@ -258,7 +258,7 @@ void EQEmuApiWorldDataService::callGetGuildDetails(Json::Value &response, const row["tribute"]["time_remaining"] = guild->tribute.time_remaining; row["tribute"]["enabled"] = guild->tribute.enabled; - client_list.GetGuildClientList(response, guild_id); + ClientList::Instance()->GetGuildClientList(response, guild_id); response.append(row); } diff --git a/world/eqw.cpp b/world/eqw.cpp index 1a7e6c147..ba316b680 100644 --- a/world/eqw.cpp +++ b/world/eqw.cpp @@ -48,7 +48,6 @@ extern ZSList zoneserver_list; extern ClientList client_list; extern uint32 numzones; -extern LoginServerList loginserverlist; extern LauncherList launcher_list; extern volatile bool RunLoops; @@ -86,15 +85,15 @@ const std::string &EQW::GetOutput() const { void EQW::LockWorld() { WorldConfig::LockWorld(); - if (loginserverlist.Connected()) { - loginserverlist.SendStatus(); + if (LoginServerList::Instance()->Connected()) { + LoginServerList::Instance()->SendStatus(); } } void EQW::UnlockWorld() { WorldConfig::UnlockWorld(); - if (loginserverlist.Connected()) { - loginserverlist.SendStatus(); + if (LoginServerList::Instance()->Connected()) { + LoginServerList::Instance()->SendStatus(); } } @@ -104,7 +103,7 @@ Const_char *EQW::GetConfig(Const_char *var_name) { } bool EQW::LSConnected() { - return(loginserverlist.Connected()); + return(LoginServerList::Instance()->Connected()); } int EQW::CountZones() { diff --git a/world/login_server.cpp b/world/login_server.cpp index 1c8d498d1..f758dbb7a 100644 --- a/world/login_server.cpp +++ b/world/login_server.cpp @@ -108,7 +108,7 @@ void LoginServer::ProcessUsertoWorldReqLeg(uint16_t opcode, EQ::Net::Packet &p) } if (RuleB(World, EnforceCharacterLimitAtLogin)) { - if (client_list.IsAccountInGame(utwr->lsaccountid)) { + if (ClientList::Instance()->IsAccountInGame(utwr->lsaccountid)) { LogDebug("User already online account_id [{0}]", utwr->lsaccountid); utwrs->response = UserToWorldStatusAlreadyOnline; SendPacket(&outpack); @@ -189,7 +189,7 @@ void LoginServer::ProcessUsertoWorldReq(uint16_t opcode, EQ::Net::Packet &p) } if (RuleB(World, EnforceCharacterLimitAtLogin)) { - if (client_list.IsAccountInGame(utwr->lsaccountid)) { + if (ClientList::Instance()->IsAccountInGame(utwr->lsaccountid)) { LogDebug("User already online account_id [{0}]", utwr->lsaccountid); utwrs->response = UserToWorldStatusAlreadyOnline; SendPacket(&outpack); @@ -221,7 +221,7 @@ void LoginServer::ProcessLSClientAuthLegacy(uint16_t opcode, EQ::Net::Packet &p) r.is_client_from_local_network ); - client_list.CLEAdd( + ClientList::Instance()->CLEAdd( r.loginserver_account_id, "eqemu", r.loginserver_account_name, @@ -256,7 +256,7 @@ void LoginServer::ProcessLSClientAuth(uint16_t opcode, EQ::Net::Packet &p) r.is_client_from_local_network ); - client_list.CLEAdd( + ClientList::Instance()->CLEAdd( r.loginserver_account_id, r.loginserver_name, r.account_name, diff --git a/world/login_server_list.cpp b/world/login_server_list.cpp index 30285c72a..8f4cd0eee 100644 --- a/world/login_server_list.cpp +++ b/world/login_server_list.cpp @@ -37,7 +37,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #include "world_config.h" extern ZSList zoneserver_list; -extern LoginServerList loginserverlist; extern ClientList client_list; extern uint32 numzones; extern uint32 numplayers; diff --git a/world/login_server_list.h b/world/login_server_list.h index d9a270e55..54de20bef 100644 --- a/world/login_server_list.h +++ b/world/login_server_list.h @@ -21,6 +21,13 @@ public: bool SendAccountUpdate(ServerPacket *pack); bool Connected(); size_t GetServerCount() const { return m_list.size(); } + + static LoginServerList* Instance() + { + static LoginServerList instance; + return &instance; + } + protected: std::list> m_list; }; diff --git a/world/main.cpp b/world/main.cpp index c1ec78a46..666a01a45 100644 --- a/world/main.cpp +++ b/world/main.cpp @@ -91,26 +91,24 @@ #include "../common/repositories/character_parcels_repository.h" #include "../common/ip_util.h" -SkillCaps skill_caps; -ZoneStore zone_store; ClientList client_list; GroupLFPList LFPGroupList; ZSList zoneserver_list; +<<<<<<< kinglykrab/ucsconnection-global-to-singleton LoginServerList loginserverlist; +======= +UCSConnection UCSLink; +>>>>>>> master QueryServConnection QSLink; LauncherList launcher_list; AdventureManager adventure_manager; WorldEventScheduler event_scheduler; -SharedTaskManager shared_task_manager; -EQ::Random emu_random; volatile bool RunLoops = true; uint32 numclients = 0; uint32 numzones = 0; const WorldConfig *Config; -EQEmuLogSys LogSys; WorldContentService content_service; WebInterfaceList web_interface; -PathManager path; PlayerEventLogs player_event_logs; EvolvingItemsManager evolving_items_manager; @@ -134,14 +132,14 @@ inline void UpdateWindowTitle(std::string new_title) int main(int argc, char **argv) { RegisterExecutablePlatform(ExePlatformWorld); - LogSys.LoadLogSettingsDefaults(); + EQEmuLogSys::Instance()->LoadLogSettingsDefaults(); set_exception_handler(); if (WorldBoot::HandleCommandInput(argc, argv)) { return 0; } - path.LoadPaths(); + PathManager::Instance()->Init(); if (!WorldBoot::LoadServerConfig()) { return 0; @@ -206,7 +204,7 @@ int main(int argc, char **argv) ->SetExpansionContext() ->ReloadContentFlags(); - skill_caps.SetContentDatabase(&content_db)->LoadSkillCaps(); + SkillCaps::Instance()->SetContentDatabase(&content_db)->LoadSkillCaps(); std::unique_ptr server_connection; server_connection = std::make_unique(); @@ -475,7 +473,7 @@ int main(int argc, char **argv) launcher_list.Process(); LFPGroupList.Process(); adventure_manager.Process(); - shared_task_manager.Process(); + SharedTaskManager::Instance()->Process(); dynamic_zone_manager.Process(); if (!RuleB(Logging, PlayerEventsQSProcess)) { @@ -508,7 +506,7 @@ int main(int argc, char **argv) zoneserver_list.KillAll(); LogInfo("Zone (TCP) listener stopped"); LogInfo("Signaling HTTP service to stop"); - LogSys.CloseFileLogs(); + EQEmuLogSys::Instance()->CloseFileLogs(); WorldBoot::Shutdown(); diff --git a/world/shared_task_manager.cpp b/world/shared_task_manager.cpp index 61a280f55..ecdd520f2 100644 --- a/world/shared_task_manager.cpp +++ b/world/shared_task_manager.cpp @@ -199,7 +199,7 @@ void SharedTaskManager::RemoveMember(SharedTask* s, const SharedTaskMember& memb SendSharedTaskMemberRemovedToAllMembers(s, member.character_name); - client_list.SendCharacterMessageID(member.character_id, Chat::Yellow, + ClientList::Instance()->SendCharacterMessageID(member.character_id, Chat::Yellow, TaskStr::PLAYER_REMOVED, {member.character_name, s->GetTaskData().title}); if (member.is_leader) { @@ -229,10 +229,10 @@ void SharedTaskManager::RemoveEveryoneFromSharedTask(SharedTask *t, uint32 reque SendRemovePlayerFromSharedTaskPacket(m.character_id, t->GetTaskData().id, true); - client_list.SendCharacterMessageID(m.character_id, Chat::Yellow, TaskStr::YOU_REMOVED, {t->GetTaskData().title}); + ClientList::Instance()->SendCharacterMessageID(m.character_id, Chat::Yellow, TaskStr::YOU_REMOVED, {t->GetTaskData().title}); } - client_list.SendCharacterMessageID(requested_character_id, Chat::Red, TaskStr::PLAYER_REMOVED, {"Everyone", t->GetTaskData().title}); + ClientList::Instance()->SendCharacterMessageID(requested_character_id, Chat::Red, TaskStr::PLAYER_REMOVED, {"Everyone", t->GetTaskData().title}); RemoveAllMembersFromDynamicZones(t); @@ -252,7 +252,7 @@ void SharedTaskManager::Terminate(SharedTask& s, bool send_fail, bool erase) SendSharedTaskFailed(member.character_id, s.GetTaskData().id); } SendRemovePlayerFromSharedTaskPacket(member.character_id, s.GetTaskData().id, true); - client_list.SendCharacterMessageID(member.character_id, Chat::Yellow, TaskStr::HAS_ENDED, {s.GetTaskData().title}); + ClientList::Instance()->SendCharacterMessageID(member.character_id, Chat::Yellow, TaskStr::HAS_ENDED, {s.GetTaskData().title}); } RemoveAllMembersFromDynamicZones(&s); @@ -581,7 +581,7 @@ void SharedTaskManager::SharedTaskActivityUpdate( d->ignore_quest_update = ignore_quest_update; // get requested character zone server - ClientListEntry *c = client_list.FindCLEByCharacterID(m.character_id); + ClientListEntry *c = ClientList::Instance()->FindCLEByCharacterID(m.character_id); if (c && c->Server()) { c->Server()->SendPacket(p.get()); } @@ -683,7 +683,7 @@ void SharedTaskManager::SendAcceptNewSharedTaskPacket( d->accept_time = accept_time; // get requested character zone server - ClientListEntry *cle = client_list.FindCLEByCharacterID(character_id); + ClientListEntry *cle = ClientList::Instance()->FindCLEByCharacterID(character_id); if (cle && cle->Server()) { cle->Server()->SendPacket(p.get()); } @@ -704,7 +704,7 @@ void SharedTaskManager::SendRemovePlayerFromSharedTaskPacket( d->remove_from_db = remove_from_db; // get requested character zone server - ClientListEntry *cle = client_list.FindCLEByCharacterID(character_id); + ClientListEntry *cle = ClientList::Instance()->FindCLEByCharacterID(character_id); if (cle && cle->Server()) { cle->Server()->SendPacket(p.get()); } @@ -717,7 +717,7 @@ void SharedTaskManager::SendSharedTaskFailed(uint32_t character_id, uint32_t tas buf->character_id = character_id; buf->task_id = task_id; - ClientListEntry* cle = client_list.FindCLEByCharacterID(character_id); + ClientListEntry* cle = ClientList::Instance()->FindCLEByCharacterID(character_id); if (cle && cle->Server()) { cle->Server()->SendPacket(&pack); @@ -746,7 +746,7 @@ void SharedTaskManager::SendSharedTaskMemberList(uint32 character_id, const EQ:: memcpy(d->cereal_serialized_members, serialized_members.Data(), serialized_members.Length()); // send memberlist - ClientListEntry *cle = client_list.FindCLEByCharacterID(character_id); + ClientListEntry *cle = ClientList::Instance()->FindCLEByCharacterID(character_id); if (cle && cle->Server()) { cle->Server()->SendPacket(p.get()); } @@ -768,7 +768,7 @@ void SharedTaskManager::SendSharedTaskMemberChange( d->removed = removed; strn0cpy(d->player_name, player_name.c_str(), sizeof(d->player_name)); - ClientListEntry *cle = client_list.FindCLEByCharacterID(character_id); + ClientListEntry *cle = ClientList::Instance()->FindCLEByCharacterID(character_id); if (cle && cle->Server()) { cle->Server()->SendPacket(p.get()); } @@ -990,7 +990,7 @@ void SharedTaskManager::SendSharedTaskInvitePacket(SharedTask *s, int64 invited_ strn0cpy(d->task_name, s->GetTaskData().title.c_str(), sizeof(d->task_name)); // get requested character zone server - ClientListEntry *cle = client_list.FindCLEByCharacterID(invited_character_id); + ClientListEntry *cle = ClientList::Instance()->FindCLEByCharacterID(invited_character_id); if (cle && cle->Server()) { SendLeaderMessageID(s, Chat::Yellow, TaskStr::SEND_INVITE_TO, {cle->name()}); cle->Server()->SendPacket(p.get()); @@ -1213,7 +1213,7 @@ void SharedTaskManager::SendLeaderMessage(SharedTask *shared_task, int chat_type for (const auto &member : shared_task->GetMembers()) { if (member.is_leader) { - client_list.SendCharacterMessage(member.character_id, chat_type, message); + ClientList::Instance()->SendCharacterMessage(member.character_id, chat_type, message); break; } } @@ -1230,7 +1230,7 @@ void SharedTaskManager::SendLeaderMessageID( for (const auto &member : shared_task->GetMembers()) { if (member.is_leader) { - client_list.SendCharacterMessageID(member.character_id, chat_type, eqstr_id, args); + ClientList::Instance()->SendCharacterMessageID(member.character_id, chat_type, eqstr_id, args); break; } } @@ -1243,7 +1243,7 @@ void SharedTaskManager::SendMembersMessage(SharedTask *shared_task, int chat_typ } for (const auto &member : shared_task->GetMembers()) { - client_list.SendCharacterMessage(member.character_id, chat_type, message); + ClientList::Instance()->SendCharacterMessage(member.character_id, chat_type, message); } } diff --git a/world/shared_task_manager.h b/world/shared_task_manager.h index 3f41ef7be..197a8bce2 100644 --- a/world/shared_task_manager.h +++ b/world/shared_task_manager.h @@ -102,6 +102,12 @@ public: void SetSharedTasks(const std::vector &shared_tasks); SharedTaskManager * PurgeExpiredSharedTasks(); + + static SharedTaskManager* Instance() + { + static SharedTaskManager instance; + return &instance; + } protected: // reference to database Database *m_database; diff --git a/world/shared_task_world_messaging.cpp b/world/shared_task_world_messaging.cpp index 0256263ce..c848af89d 100644 --- a/world/shared_task_world_messaging.cpp +++ b/world/shared_task_world_messaging.cpp @@ -16,7 +16,6 @@ extern ClientList client_list; extern ZSList zoneserver_list; -extern SharedTaskManager shared_task_manager; void SharedTaskWorldMessaging::HandleZoneMessage(ServerPacket *pack) { @@ -30,7 +29,7 @@ void SharedTaskWorldMessaging::HandleZoneMessage(ServerPacket *pack) r->requested_npc_entity_id ); - shared_task_manager.AttemptSharedTaskCreation( + SharedTaskManager::Instance()->AttemptSharedTaskCreation( r->requested_task_id, r->requested_character_id, r->requested_npc_entity_id @@ -47,11 +46,11 @@ void SharedTaskWorldMessaging::HandleZoneMessage(ServerPacket *pack) r->remove_from_db ); - auto s = shared_task_manager.FindSharedTaskByTaskIdAndCharacterId(r->task_id, r->requested_character_id); + auto s = SharedTaskManager::Instance()->FindSharedTaskByTaskIdAndCharacterId(r->task_id, r->requested_character_id); if (s) { auto member = s->FindMemberFromCharacterID(r->requested_character_id); if (member.character_id != 0) { - shared_task_manager.RemoveMember(s, member, r->remove_from_db); + SharedTaskManager::Instance()->RemoveMember(s, member, r->remove_from_db); } } break; @@ -64,14 +63,14 @@ void SharedTaskWorldMessaging::HandleZoneMessage(ServerPacket *pack) r->task_id ); - auto t = shared_task_manager.FindSharedTaskByTaskIdAndCharacterId(r->task_id, r->source_character_id); + auto t = SharedTaskManager::Instance()->FindSharedTaskByTaskIdAndCharacterId(r->task_id, r->source_character_id); if (t) { auto leader = t->GetLeader(); if (leader.character_id != r->source_character_id) { - client_list.SendCharacterMessageID(r->source_character_id, Chat::Red, TaskStr::NOT_LEADER, {leader.character_name}); + ClientList::Instance()->SendCharacterMessageID(r->source_character_id, Chat::Red, TaskStr::NOT_LEADER, {leader.character_name}); } else { - shared_task_manager.RemoveEveryoneFromSharedTask(t, r->source_character_id); + SharedTaskManager::Instance()->RemoveEveryoneFromSharedTask(t, r->source_character_id); } } @@ -89,7 +88,7 @@ void SharedTaskWorldMessaging::HandleZoneMessage(ServerPacket *pack) (r->ignore_quest_update ? "true" : "false") ); - shared_task_manager.SharedTaskActivityUpdate( + SharedTaskManager::Instance()->SharedTaskActivityUpdate( r->source_character_id, r->task_id, r->activity_id, @@ -108,7 +107,7 @@ void SharedTaskWorldMessaging::HandleZoneMessage(ServerPacket *pack) r->task_id ); - auto t = shared_task_manager.FindSharedTaskByTaskIdAndCharacterId(r->task_id, r->source_character_id); + auto t = SharedTaskManager::Instance()->FindSharedTaskByTaskIdAndCharacterId(r->task_id, r->source_character_id); if (t) { LogTasksDetail( "[ServerOP_SharedTaskRequestMemberlist] Found shared task character [{}] shared_task_id [{}]", @@ -116,7 +115,7 @@ void SharedTaskWorldMessaging::HandleZoneMessage(ServerPacket *pack) t->GetDbSharedTask().id ); - shared_task_manager.SendSharedTaskMemberList( + SharedTaskManager::Instance()->SendSharedTaskMemberList( r->source_character_id, t->GetMembers() ); @@ -134,7 +133,7 @@ void SharedTaskWorldMessaging::HandleZoneMessage(ServerPacket *pack) r->player_name ); - auto t = shared_task_manager.FindSharedTaskByTaskIdAndCharacterId(r->task_id, r->source_character_id); + auto t = SharedTaskManager::Instance()->FindSharedTaskByTaskIdAndCharacterId(r->task_id, r->source_character_id); if (t) { LogTasksDetail( "[ServerOP_SharedTaskRemovePlayer] Found shared task character [{}] shared_task_id [{}]", @@ -144,7 +143,7 @@ void SharedTaskWorldMessaging::HandleZoneMessage(ServerPacket *pack) auto leader = t->GetLeader(); if (leader.character_id != r->source_character_id) { - client_list.SendCharacterMessageID(r->source_character_id, Chat::Red, TaskStr::NOT_LEADER, {leader.character_name}); + ClientList::Instance()->SendCharacterMessageID(r->source_character_id, Chat::Red, TaskStr::NOT_LEADER, {leader.character_name}); } else { LogTasksDetail( @@ -155,11 +154,11 @@ void SharedTaskWorldMessaging::HandleZoneMessage(ServerPacket *pack) auto member = t->FindMemberFromCharacterName(r->player_name); if (member.character_id == 0) { - shared_task_manager.SendLeaderMessageID(t, Chat::Red, TaskStr::IS_NOT_MEMBER, {r->player_name}); + SharedTaskManager::Instance()->SendLeaderMessageID(t, Chat::Red, TaskStr::IS_NOT_MEMBER, {r->player_name}); } else { - shared_task_manager.RemoveMember(t, member, true); - shared_task_manager.SendLeaderMessageID(t, Chat::Yellow, TaskStr::PLAYER_REMOVED, {member.character_name, t->GetTaskData().title}); + SharedTaskManager::Instance()->RemoveMember(t, member, true); + SharedTaskManager::Instance()->SendLeaderMessageID(t, Chat::Yellow, TaskStr::PLAYER_REMOVED, {member.character_name, t->GetTaskData().title}); } } } @@ -176,7 +175,7 @@ void SharedTaskWorldMessaging::HandleZoneMessage(ServerPacket *pack) r->player_name ); - auto t = shared_task_manager.FindSharedTaskByTaskIdAndCharacterId(r->task_id, r->source_character_id); + auto t = SharedTaskManager::Instance()->FindSharedTaskByTaskIdAndCharacterId(r->task_id, r->source_character_id); if (t) { LogTasksDetail( "[ServerOP_SharedTaskMakeLeader] Found shared task character [{}] shared_task_id [{}]", @@ -186,10 +185,10 @@ void SharedTaskWorldMessaging::HandleZoneMessage(ServerPacket *pack) auto leader = t->GetLeader(); if (leader.character_id != r->source_character_id) { - client_list.SendCharacterMessageID(r->source_character_id, Chat::Red, TaskStr::NOT_LEADER, {leader.character_name}); + ClientList::Instance()->SendCharacterMessageID(r->source_character_id, Chat::Red, TaskStr::NOT_LEADER, {leader.character_name}); } else if (strcasecmp(leader.character_name.c_str(), r->player_name) == 0) { - client_list.SendCharacterMessageID(r->source_character_id, Chat::Red, TaskStr::YOU_ALREADY_LEADER); + ClientList::Instance()->SendCharacterMessageID(r->source_character_id, Chat::Red, TaskStr::YOU_ALREADY_LEADER); } else { LogTasksDetail( @@ -199,7 +198,7 @@ void SharedTaskWorldMessaging::HandleZoneMessage(ServerPacket *pack) ); std::string character_name = r->player_name; - shared_task_manager.MakeLeaderByPlayerName(t, character_name); + SharedTaskManager::Instance()->MakeLeaderByPlayerName(t, character_name); } } @@ -215,7 +214,7 @@ void SharedTaskWorldMessaging::HandleZoneMessage(ServerPacket *pack) r->player_name ); - auto t = shared_task_manager.FindSharedTaskByTaskIdAndCharacterId(r->task_id, r->source_character_id); + auto t = SharedTaskManager::Instance()->FindSharedTaskByTaskIdAndCharacterId(r->task_id, r->source_character_id); if (t) { LogTasksDetail( "[ServerOP_SharedTaskAddPlayer] Found shared task character [{}] shared_task_id [{}]", @@ -226,7 +225,7 @@ void SharedTaskWorldMessaging::HandleZoneMessage(ServerPacket *pack) auto leader = t->GetLeader(); if (leader.character_id != r->source_character_id) { // taskadd is client sided with System color in newer clients, server side might still be red - client_list.SendCharacterMessageID(r->source_character_id, Chat::Red, TaskStr::NOT_LEADER, {leader.character_name}); + ClientList::Instance()->SendCharacterMessageID(r->source_character_id, Chat::Red, TaskStr::NOT_LEADER, {leader.character_name}); } else { LogTasksDetail( @@ -236,7 +235,7 @@ void SharedTaskWorldMessaging::HandleZoneMessage(ServerPacket *pack) ); std::string character_name = r->player_name; - shared_task_manager.InvitePlayerByPlayerName(t, character_name); + SharedTaskManager::Instance()->InvitePlayerByPlayerName(t, character_name); } } @@ -252,21 +251,21 @@ void SharedTaskWorldMessaging::HandleZoneMessage(ServerPacket *pack) r->accepted ); - auto t = shared_task_manager.FindSharedTaskById(r->shared_task_id); - if (t && shared_task_manager.IsInvitationActive(r->shared_task_id, r->source_character_id)) { + auto t = SharedTaskManager::Instance()->FindSharedTaskById(r->shared_task_id); + if (t && SharedTaskManager::Instance()->IsInvitationActive(r->shared_task_id, r->source_character_id)) { LogTasksDetail( "[ServerOP_SharedTaskInviteAcceptedPlayer] Found shared task character [{}] shared_task_id [{}]", r->source_character_id, t->GetDbSharedTask().id ); - shared_task_manager.RemoveActiveInvitation(r->shared_task_id, r->source_character_id); + SharedTaskManager::Instance()->RemoveActiveInvitation(r->shared_task_id, r->source_character_id); if (r->accepted) { - shared_task_manager.AddPlayerByCharacterIdAndName(t, r->source_character_id, r->player_name); + SharedTaskManager::Instance()->AddPlayerByCharacterIdAndName(t, r->source_character_id, r->player_name); } else { - shared_task_manager.SendLeaderMessageID(t, Chat::Red, TaskStr::PLAYER_DECLINED_OFFER, {r->player_name}); + SharedTaskManager::Instance()->SendLeaderMessageID(t, Chat::Red, TaskStr::PLAYER_DECLINED_OFFER, {r->player_name}); } } break; @@ -280,19 +279,19 @@ void SharedTaskWorldMessaging::HandleZoneMessage(ServerPacket *pack) buf->task_id ); - auto t = shared_task_manager.FindSharedTaskByTaskIdAndCharacterId(buf->task_id, buf->source_character_id); + auto t = SharedTaskManager::Instance()->FindSharedTaskByTaskIdAndCharacterId(buf->task_id, buf->source_character_id); if (t) { DynamicZone dz; dz.Unserialize({ buf->cereal_data, buf->cereal_size }); - shared_task_manager.CreateDynamicZone(t, dz); + SharedTaskManager::Instance()->CreateDynamicZone(t, dz); } break; } case ServerOP_SharedTaskPurgeAllCommand: { LogTasksDetail("[ServerOP_SharedTaskPurgeAllCommand] Received request to purge all shared tasks"); - shared_task_manager.PurgeAllSharedTasks(); + SharedTaskManager::Instance()->PurgeAllSharedTasks(); auto p = std::make_unique( ServerOP_SharedTaskPurgeAllCommand, 0 @@ -311,7 +310,7 @@ void SharedTaskWorldMessaging::HandleZoneMessage(ServerPacket *pack) buf->task_id ); - auto s = shared_task_manager.FindSharedTaskByTaskIdAndCharacterId(buf->task_id, buf->source_character_id); + auto s = SharedTaskManager::Instance()->FindSharedTaskByTaskIdAndCharacterId(buf->task_id, buf->source_character_id); if (s) { std::vector player_names; @@ -319,40 +318,40 @@ void SharedTaskWorldMessaging::HandleZoneMessage(ServerPacket *pack) player_names.emplace_back(member.character_name); if (member.is_leader) { - client_list.SendCharacterMessageID(buf->source_character_id, Chat::Yellow, TaskStr::LEADER_PRINT, {member.character_name}); + ClientList::Instance()->SendCharacterMessageID(buf->source_character_id, Chat::Yellow, TaskStr::LEADER_PRINT, {member.character_name}); } } std::string player_list = fmt::format("{}", Strings::Join(player_names, ", ")); - client_list.SendCharacterMessageID(buf->source_character_id, Chat::Yellow, TaskStr::MEMBERS_PRINT, {player_list}); + ClientList::Instance()->SendCharacterMessageID(buf->source_character_id, Chat::Yellow, TaskStr::MEMBERS_PRINT, {player_list}); } break; } case ServerOP_SharedTaskLock: { auto buf = reinterpret_cast(pack->pBuffer); - auto shared_task = shared_task_manager.FindSharedTaskByTaskIdAndCharacterId(buf->task_id, buf->source_character_id); + auto shared_task = SharedTaskManager::Instance()->FindSharedTaskByTaskIdAndCharacterId(buf->task_id, buf->source_character_id); if (shared_task) { - shared_task_manager.LockTask(shared_task, buf->lock); + SharedTaskManager::Instance()->LockTask(shared_task, buf->lock); } break; } case ServerOP_SharedTaskEndByDz: { auto buf = reinterpret_cast(pack->pBuffer); - auto shared_task = shared_task_manager.FindSharedTaskByDzId(buf->dz_id); + auto shared_task = SharedTaskManager::Instance()->FindSharedTaskByDzId(buf->dz_id); if (shared_task) { - shared_task_manager.Terminate(*shared_task, buf->send_fail, true); + SharedTaskManager::Instance()->Terminate(*shared_task, buf->send_fail, true); } break; } case ServerOP_SharedTaskEnd: { auto buf = reinterpret_cast(pack->pBuffer); - auto shared_task = shared_task_manager.FindSharedTaskByTaskIdAndCharacterId(buf->task_id, buf->character_id); + auto shared_task = SharedTaskManager::Instance()->FindSharedTaskByTaskIdAndCharacterId(buf->task_id, buf->character_id); if (shared_task) { - shared_task_manager.Terminate(*shared_task, buf->send_fail, true); + SharedTaskManager::Instance()->Terminate(*shared_task, buf->send_fail, true); } break; } diff --git a/world/web_interface_eqw.cpp b/world/web_interface_eqw.cpp index ad0cf6953..832f8e8c6 100644 --- a/world/web_interface_eqw.cpp +++ b/world/web_interface_eqw.cpp @@ -6,7 +6,6 @@ #include "zonelist.h" #include "launcher_list.h" -extern LoginServerList loginserverlist; extern ClientList client_list; extern ZSList zoneserver_list; extern LauncherList launcher_list; @@ -33,8 +32,8 @@ void EQW__IsLocked(WebInterface *i, const std::string& method, const std::string void EQW__Lock(WebInterface *i, const std::string& method, const std::string& id, const Json::Value& params) { WorldConfig::LockWorld(); - if (loginserverlist.Connected()) { - loginserverlist.SendStatus(); + if (LoginServerList::Instance()->Connected()) { + LoginServerList::Instance()->SendStatus(); } Json::Value ret; @@ -44,8 +43,8 @@ void EQW__Lock(WebInterface *i, const std::string& method, const std::string& id void EQW__Unlock(WebInterface *i, const std::string& method, const std::string& id, const Json::Value& params) { WorldConfig::UnlockWorld(); - if (loginserverlist.Connected()) { - loginserverlist.SendStatus(); + if (LoginServerList::Instance()->Connected()) { + LoginServerList::Instance()->SendStatus(); } Json::Value ret; @@ -69,7 +68,7 @@ void EQW__GetLauncherCount(WebInterface *i, const std::string& method, const std } void EQW__GetLoginServerCount(WebInterface *i, const std::string& method, const std::string& id, const Json::Value& params) { - Json::Value ret = loginserverlist.GetServerCount(); + Json::Value ret = LoginServerList::Instance()->GetServerCount(); i->SendResponse(id, ret); } diff --git a/world/world_boot.cpp b/world/world_boot.cpp index 64b49bd59..6ec44e2c0 100644 --- a/world/world_boot.cpp +++ b/world/world_boot.cpp @@ -57,7 +57,7 @@ void WorldBoot::GMSayHookCallBackProcessWorld(uint16 log_category, const char *f 0, 0, AccountStatus::QuestTroupe, - LogSys.GetGMSayColorFromCategory(log_category), + EQEmuLogSys::Instance()->GetGMSayColorFromCategory(log_category), fmt::format( " {}{}", (iter == 0 ? " ---" : ""), @@ -73,7 +73,7 @@ void WorldBoot::GMSayHookCallBackProcessWorld(uint16 log_category, const char *f 0, 0, AccountStatus::QuestTroupe, - LogSys.GetGMSayColorFromCategory(log_category), + EQEmuLogSys::Instance()->GetGMSayColorFromCategory(log_category), "%s", fmt::format("[{}] [{}] {}", Logs::LogCategoryName[log_category], func, message).c_str() ); @@ -83,12 +83,12 @@ bool WorldBoot::HandleCommandInput(int argc, char **argv) { // command handler if (argc > 1) { - LogSys.SilenceConsoleLogging(); - path.LoadPaths(); + EQEmuLogSys::Instance()->SilenceConsoleLogging(); + PathManager::Instance()->Init(); WorldConfig::LoadConfig(); LoadDatabaseConnections(); RuleManager::Instance()->LoadRules(&database, "default", false); - LogSys.EnableConsoleLogging(); + EQEmuLogSys::Instance()->EnableConsoleLogging(); WorldserverCLI::CommandHandler(argc, argv); } @@ -183,15 +183,13 @@ int get_file_size(const std::string &filename) // path to file return size; } -extern LoginServerList loginserverlist; - void WorldBoot::RegisterLoginservers() { const auto c = EQEmuConfig::get(); if (c->LoginCount == 0) { if (c->LoginHost.length()) { - loginserverlist.Add( + LoginServerList::Instance()->Add( c->LoginHost.c_str(), c->LoginPort, c->LoginAccount.c_str(), @@ -207,7 +205,7 @@ void WorldBoot::RegisterLoginservers() iterator.Reset(); while (iterator.MoreElements()) { if (iterator.GetData()->LoginHost.length()) { - loginserverlist.Add( + LoginServerList::Instance()->Add( iterator.GetData()->LoginHost.c_str(), iterator.GetData()->LoginPort, iterator.GetData()->LoginAccount.c_str(), @@ -226,18 +224,17 @@ void WorldBoot::RegisterLoginservers() } } -extern SharedTaskManager shared_task_manager; extern AdventureManager adventure_manager; extern WorldEventScheduler event_scheduler; bool WorldBoot::DatabaseLoadRoutines(int argc, char **argv) { // logging system init - auto logging = LogSys.SetDatabase(&database) - ->SetLogPath(path.GetLogPath()) + auto logging = EQEmuLogSys::Instance()->SetDatabase(&database) + ->SetLogPath(PathManager::Instance()->GetLogPath()) ->LoadLogDatabaseSettings(); - LogSys.SetDiscordHandler(&WorldBoot::DiscordWebhookMessageHandler); + EQEmuLogSys::Instance()->SetDiscordHandler(&WorldBoot::DiscordWebhookMessageHandler); const auto c = EQEmuConfig::get(); if (c->auto_database_updates) { @@ -279,9 +276,9 @@ bool WorldBoot::DatabaseLoadRoutines(int argc, char **argv) LogInfo("Loading zones"); - zone_store.LoadZones(content_db); + ZoneStore::Instance()->LoadZones(content_db); - if (zone_store.GetZones().empty()) { + if (ZoneStore::Instance()->GetZones().empty()) { LogError("Failed to load zones data, check your schema for possible errors"); return 1; } @@ -402,13 +399,13 @@ bool WorldBoot::DatabaseLoadRoutines(int argc, char **argv) ->ReloadContentFlags(); LogInfo("Initializing [SharedTaskManager]"); - shared_task_manager.SetDatabase(&database) + SharedTaskManager::Instance()->SetDatabase(&database) ->SetContentDatabase(&content_db) ->LoadTaskData() ->LoadSharedTaskState(); LogInfo("Purging expired shared tasks"); - shared_task_manager.PurgeExpiredSharedTasks(); + SharedTaskManager::Instance()->PurgeExpiredSharedTasks(); LogInfo("Cleaning up instance corpses"); database.CleanupInstanceCorpses(); diff --git a/world/zonelist.cpp b/world/zonelist.cpp index 28d1c7f9a..265747fbc 100644 --- a/world/zonelist.cpp +++ b/world/zonelist.cpp @@ -37,14 +37,14 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #include "dynamic_zone_manager.h" #include "ucs.h" #include "clientlist.h" +#include "queryserv.h" #include "../common/repositories/trader_repository.h" #include "../common/repositories/buyer_repository.h" extern uint32 numzones; -extern EQ::Random emu_random; extern WebInterfaceList web_interface; -extern SharedTaskManager shared_task_manager; extern ClientList client_list; +extern QueryServConnection QSLink; volatile bool UCSServerAvailable_ = false; void CatchSignal(int sig_num); @@ -694,7 +694,7 @@ void ZSList::RebootZone(const char* ip1, uint16 port, const char* ip2, uint32 sk safe_delete_array(tmp); return; } - uint32 z = emu_random.Int(0, y - 1); + uint32 z = EQ::Random::Instance()->Int(0, y - 1); auto pack = new ServerPacket(ServerOP_ZoneReboot, sizeof(ServerZoneReboot_Struct)); ServerZoneReboot_Struct* s = (ServerZoneReboot_Struct*)pack->pBuffer; @@ -912,7 +912,7 @@ bool ZSList::SendPacketToBootedZones(ServerPacket* pack) bool ZSList::SendPacketToZonesWithGuild(uint32 guild_id, ServerPacket* pack) { - auto servers = client_list.GetGuildZoneServers(guild_id); + auto servers = ClientList::Instance()->GetGuildZoneServers(guild_id); for (auto const& z : zone_server_list) { for (auto const& server_id : servers) { if (z->GetID() == server_id && z->GetZoneID() > 0) { @@ -926,7 +926,7 @@ bool ZSList::SendPacketToZonesWithGuild(uint32 guild_id, ServerPacket* pack) bool ZSList::SendPacketToZonesWithGMs(ServerPacket* pack) { - auto servers = client_list.GetZoneServersWithGMs(); + auto servers = ClientList::Instance()->GetZoneServersWithGMs(); for (auto const &z: zone_server_list) { for (auto const &server_id: servers) { if (z->GetID() == server_id && z->GetZoneID() > 0) { @@ -978,15 +978,16 @@ void ZSList::SendServerReload(ServerReload::Type type, uchar *packet) } else if (type == ServerReload::Type::Rules) { RuleManager::Instance()->LoadRules(&database, RuleManager::Instance()->GetActiveRuleset(), true); } else if (type == ServerReload::Type::SkillCaps) { - skill_caps.ReloadSkillCaps(); + SkillCaps::Instance()->ReloadSkillCaps(); } else if (type == ServerReload::Type::ContentFlags) { content_service.SetExpansionContext()->ReloadContentFlags(); } else if (type == ServerReload::Type::Logs) { - LogSys.LoadLogDatabaseSettings(); + EQEmuLogSys::Instance()->LoadLogDatabaseSettings(); player_event_logs.ReloadSettings(); UCSConnection::Instance()->SendPacket(&pack); + QSLink.SendPacket(&pack); } else if (type == ServerReload::Type::Tasks) { - shared_task_manager.LoadTaskData(); + SharedTaskManager::Instance()->LoadTaskData(); } else if (type == ServerReload::Type::DzTemplates) { dynamic_zone_manager.LoadTemplates(); } diff --git a/world/zoneserver.cpp b/world/zoneserver.cpp index e2fbb41ff..83a6bfdd0 100644 --- a/world/zoneserver.cpp +++ b/world/zoneserver.cpp @@ -55,12 +55,10 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA extern ClientList client_list; extern GroupLFPList LFPGroupList; extern ZSList zoneserver_list; -extern LoginServerList loginserverlist; extern volatile bool RunLoops; extern volatile bool UCSServerAvailable_; extern AdventureManager adventure_manager; extern QueryServConnection QSLink; -extern SharedTaskManager shared_task_manager; void CatchSignal(int sig_num); @@ -163,7 +161,7 @@ void ZoneServer::LSBootUpdate(uint32 zone_id, uint32 instanceid, bool startup) { bootup->zone = zone_id; bootup->zone_wid = GetID(); bootup->instance = instanceid; - loginserverlist.SendPacket(pack); + LoginServerList::Instance()->SendPacket(pack); safe_delete(pack); } } @@ -178,7 +176,7 @@ void ZoneServer::LSSleepUpdate(uint32 zone_id) { auto sleep = (ServerLSZoneSleep_Struct*) pack->pBuffer; sleep->zone = zone_id; sleep->zone_wid = GetID(); - loginserverlist.SendPacket(pack); + LoginServerList::Instance()->SendPacket(pack); safe_delete(pack); } } @@ -1075,8 +1073,8 @@ void ZoneServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) { WorldConfig::UnlockWorld(); } - if (loginserverlist.Connected()) { - loginserverlist.SendStatus(); + if (LoginServerList::Instance()->Connected()) { + LoginServerList::Instance()->SendStatus(); SendEmoteMessage( l->character_name, 0, @@ -1338,7 +1336,7 @@ void ZoneServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) { } case ServerOP_LSAccountUpdate: { LogNetcode("Received ServerOP_LSAccountUpdate packet from zone"); - loginserverlist.SendAccountUpdate(pack); + LoginServerList::Instance()->SendAccountUpdate(pack); break; } case ServerOP_DiscordWebhookMessage: diff --git a/zone/CMakeLists.txt b/zone/CMakeLists.txt index 56dcf29fe..07ac97cdc 100644 --- a/zone/CMakeLists.txt +++ b/zone/CMakeLists.txt @@ -12,7 +12,6 @@ SET(zone_sources bonuses.cpp bot.cpp bot_raid.cpp - bot_command.cpp bot_database.cpp botspellsai.cpp cheat_manager.cpp @@ -23,7 +22,6 @@ SET(zone_sources client_packet.cpp client_process.cpp combat_record.cpp - command.cpp corpse.cpp ../common/data_bucket.cpp doors.cpp @@ -48,36 +46,6 @@ SET(zone_sources horse.cpp inventory.cpp loot.cpp - lua_bot.cpp - lua_bit.cpp - lua_buff.cpp - lua_corpse.cpp - lua_client.cpp - lua_database.cpp - lua_door.cpp - lua_encounter.cpp - lua_entity.cpp - lua_entity_list.cpp - lua_expedition.cpp - lua_general.cpp - lua_group.cpp - lua_hate_list.cpp - lua_inventory.cpp - lua_item.cpp - lua_iteminst.cpp - lua_merc.cpp - lua_mob.cpp - lua_mod.cpp - lua_npc.cpp - lua_object.cpp - lua_packet.cpp - lua_parser.cpp - lua_parser_events.cpp - lua_raid.cpp - lua_spawn.cpp - lua_spell.cpp - lua_stat_bonuses.cpp - lua_zone.cpp embperl.cpp entity.cpp exp.cpp @@ -108,30 +76,6 @@ SET(zone_sources pathfinder_nav_mesh.cpp pathfinder_null.cpp pathing.cpp - perl_bot.cpp - perl_buff.cpp - perl_client.cpp - perl_database.cpp - perl_doors.cpp - perl_entity.cpp - perl_expedition.cpp - perl_groups.cpp - perl_hateentry.cpp - perl_inventory.cpp - perl_merc.cpp - perl_mob.cpp - perl_npc.cpp - perl_object.cpp - perl_perlpacket.cpp - perl_player_corpse.cpp - perl_questitem.cpp - perl_questitem_data.cpp - perl_raids.cpp - perl_spawn.cpp - perl_spell.cpp - perl_stat_bonuses.cpp - perl_zone.cpp - perlpacket.cpp petitions.cpp pets.cpp position.cpp @@ -296,18 +240,268 @@ SET(zone_headers zone_save_state.h zone_cli.cpp) +# lua unity build +set(lua_sources + lua_bot.cpp + lua_bit.cpp + lua_buff.cpp + lua_corpse.cpp + lua_client.cpp + lua_database.cpp + lua_door.cpp + lua_encounter.cpp + lua_entity.cpp + lua_entity_list.cpp + lua_expedition.cpp + lua_general.cpp + lua_group.cpp + lua_hate_list.cpp + lua_inventory.cpp + lua_item.cpp + lua_iteminst.cpp + lua_merc.cpp + lua_mob.cpp + lua_mod.cpp + lua_npc.cpp + lua_object.cpp + lua_packet.cpp + lua_parser.cpp + lua_parser_events.cpp + lua_raid.cpp + lua_spawn.cpp + lua_spell.cpp + lua_stat_bonuses.cpp + lua_zone.cpp +) + +add_library(lua_zone STATIC ${lua_sources}) +set_target_properties(lua_zone PROPERTIES UNITY_BUILD ON UNITY_BUILD_BATCH_SIZE 8) + +# perl unity build +set(perl_sources + perl_bot.cpp + perl_buff.cpp + perl_client.cpp + perl_database.cpp + perl_doors.cpp + perl_entity.cpp + perl_expedition.cpp + perl_groups.cpp + perl_hateentry.cpp + perl_inventory.cpp + perl_merc.cpp + perl_mob.cpp + perl_npc.cpp + perl_object.cpp + perl_perlpacket.cpp + perl_player_corpse.cpp + perl_questitem.cpp + perl_questitem_data.cpp + perl_raids.cpp + perl_spawn.cpp + perl_spell.cpp + perl_stat_bonuses.cpp + perl_zone.cpp + perlpacket.cpp +) + +add_library(perl_zone STATIC ${perl_sources}) +set_target_properties(perl_zone PROPERTIES UNITY_BUILD ON UNITY_BUILD_BATCH_SIZE 8) + +# gm commands +set(gm_command_sources + command.cpp + bot_command.cpp + gm_commands/acceptrules.cpp + gm_commands/advnpcspawn.cpp + gm_commands/aggrozone.cpp + gm_commands/ai.cpp + gm_commands/appearance.cpp + gm_commands/appearanceeffects.cpp + gm_commands/attack.cpp + gm_commands/augmentitem.cpp + gm_commands/ban.cpp + gm_commands/bugs.cpp + gm_commands/camerashake.cpp + gm_commands/castspell.cpp + gm_commands/chat.cpp + gm_commands/clearxtargets.cpp + gm_commands/copycharacter.cpp + gm_commands/corpse.cpp + gm_commands/corpsefix.cpp + gm_commands/countitem.cpp + gm_commands/damage.cpp + gm_commands/databuckets.cpp + gm_commands/dbspawn2.cpp + gm_commands/delacct.cpp + gm_commands/delpetition.cpp + gm_commands/depop.cpp + gm_commands/depopzone.cpp + gm_commands/devtools.cpp + gm_commands/disablerecipe.cpp + gm_commands/disarmtrap.cpp + gm_commands/doanim.cpp + gm_commands/door.cpp + gm_commands/door_manipulation.cpp + gm_commands/dye.cpp + gm_commands/dz.cpp + gm_commands/dzkickplayers.cpp + gm_commands/editmassrespawn.cpp + gm_commands/emote.cpp + gm_commands/emptyinventory.cpp + gm_commands/enablerecipe.cpp + gm_commands/entityvariable.cpp + gm_commands/exptoggle.cpp + gm_commands/faction.cpp + gm_commands/evolving_items.cpp + gm_commands/feature.cpp + gm_commands/find.cpp + gm_commands/fish.cpp + gm_commands/fixmob.cpp + gm_commands/flagedit.cpp + gm_commands/fleeinfo.cpp + gm_commands/forage.cpp + gm_commands/gearup.cpp + gm_commands/giveitem.cpp + gm_commands/givemoney.cpp + gm_commands/gmzone.cpp + gm_commands/goto.cpp + gm_commands/grantaa.cpp + gm_commands/grid.cpp + gm_commands/guild.cpp + gm_commands/hp.cpp + gm_commands/illusion_block.cpp + gm_commands/instance.cpp + gm_commands/interrogateinv.cpp + gm_commands/interrupt.cpp + gm_commands/invsnapshot.cpp + gm_commands/ipban.cpp + gm_commands/kick.cpp + gm_commands/kill.cpp + gm_commands/killallnpcs.cpp + gm_commands/list.cpp + gm_commands/lootsim.cpp + gm_commands/loc.cpp + gm_commands/logs.cpp + gm_commands/makepet.cpp + gm_commands/memspell.cpp + gm_commands/merchantshop.cpp + gm_commands/modifynpcstat.cpp + gm_commands/movechar.cpp + gm_commands/movement.cpp + gm_commands/myskills.cpp + gm_commands/mysql.cpp + gm_commands/mystats.cpp + gm_commands/npccast.cpp + gm_commands/npcedit.cpp + gm_commands/npceditmass.cpp + gm_commands/npcemote.cpp + gm_commands/npcloot.cpp + gm_commands/npcsay.cpp + gm_commands/npcshout.cpp + gm_commands/npcspawn.cpp + gm_commands/npctypespawn.cpp + gm_commands/nudge.cpp + gm_commands/nukebuffs.cpp + gm_commands/nukeitem.cpp + gm_commands/object.cpp + gm_commands/object_manipulation.cpp + gm_commands/parcels.cpp + gm_commands/path.cpp + gm_commands/peqzone.cpp + gm_commands/petitems.cpp + gm_commands/petname.cpp + gm_commands/picklock.cpp + gm_commands/profanity.cpp + gm_commands/push.cpp + gm_commands/raidloot.cpp + gm_commands/randomfeatures.cpp + gm_commands/refreshgroup.cpp + gm_commands/reload.cpp + gm_commands/removeitem.cpp + gm_commands/repop.cpp + gm_commands/resetaa.cpp + gm_commands/resetaa_timer.cpp + gm_commands/resetdisc_timer.cpp + gm_commands/revoke.cpp + gm_commands/roambox.cpp + gm_commands/rules.cpp + gm_commands/save.cpp + gm_commands/scale.cpp + gm_commands/scribespell.cpp + gm_commands/scribespells.cpp + gm_commands/sendzonespawns.cpp + gm_commands/sensetrap.cpp + gm_commands/serverrules.cpp + gm_commands/set.cpp + gm_commands/show.cpp + gm_commands/shutdown.cpp + gm_commands/spawn.cpp + gm_commands/spawneditmass.cpp + gm_commands/spawnfix.cpp + gm_commands/faction_association.cpp + gm_commands/stun.cpp + gm_commands/summon.cpp + gm_commands/summonburiedplayercorpse.cpp + gm_commands/summonitem.cpp + gm_commands/suspend.cpp + gm_commands/suspendmulti.cpp + gm_commands/takeplatinum.cpp + gm_commands/task.cpp + gm_commands/traindisc.cpp + gm_commands/tune.cpp + gm_commands/undye.cpp + gm_commands/unmemspell.cpp + gm_commands/unmemspells.cpp + gm_commands/unscribespell.cpp + gm_commands/unscribespells.cpp + gm_commands/untraindisc.cpp + gm_commands/untraindiscs.cpp + gm_commands/wc.cpp + gm_commands/worldshutdown.cpp + gm_commands/worldwide.cpp + gm_commands/wp.cpp + gm_commands/wpadd.cpp + gm_commands/zone.cpp + gm_commands/zonebootup.cpp + gm_commands/zoneshutdown.cpp + gm_commands/zonevariable.cpp + gm_commands/zone_instance.cpp + gm_commands/zone_shard.cpp + gm_commands/zsave.cpp +) + +add_library(gm_commands_zone STATIC ${gm_command_sources}) +set_target_properties(gm_commands_zone PROPERTIES UNITY_BUILD ON UNITY_BUILD_BATCH_SIZE 32) + +# zone combine sources and headers ADD_EXECUTABLE(zone ${zone_sources} ${zone_headers}) +# binary output directory INSTALL(TARGETS zone RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin) -IF (WIN32 AND EQEMU_BUILD_PCH) - TARGET_PRECOMPILE_HEADERS(zone PRIVATE ../common/pch/pch.h) - TARGET_PRECOMPILE_HEADERS(zone PRIVATE ../common/types.h ../common/eqemu_logsys.h ../common/eqemu_logsys_log_aliases.h ../common/features.h ../common/global_define.h) - TARGET_PRECOMPILE_HEADERS(zone PRIVATE mob.h npc.h corpse.h doors.h bot.h entity.h client.h zone.h) +# precompiled headers +IF (EQEMU_BUILD_PCH) + TARGET_PRECOMPILE_HEADERS(zone PRIVATE ../common/pch/app-pch.h) + TARGET_PRECOMPILE_HEADERS(zone PRIVATE ./pch/pch.h) ENDIF() ADD_DEFINITIONS(-DZONE) -TARGET_LINK_LIBRARIES(zone ${ZONE_LIBS}) +# link lua_zone unity build against luabind +target_link_libraries(lua_zone PRIVATE luabind) +if (EQEMU_BUILD_STATIC AND LUA_LIBRARY) + target_link_libraries(zone PRIVATE ${LUA_LIBRARY}) +endif() + +# perl unity build links against perl_zone +target_link_libraries(perl_zone PRIVATE perlbind) +if (EQEMU_BUILD_STATIC AND PERL_LIBRARY) + target_link_libraries(zone PRIVATE ${PERL_LIBRARY}) +endif() + +# link zone against common libraries +target_link_libraries(zone PRIVATE ${ZONE_LIBS} lua_zone perl_zone gm_commands_zone) SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin) + diff --git a/zone/api_service.cpp b/zone/api_service.cpp index a0d02b1c9..6f1c16d9d 100644 --- a/zone/api_service.cpp +++ b/zone/api_service.cpp @@ -835,9 +835,9 @@ Json::Value ApiGetLogsysCategories(EQ::Net::WebsocketServerConnection *connectio row["log_category_id"] = i; row["log_category_description"] = Logs::LogCategoryName[i]; - row["log_to_console"] = LogSys.log_settings[i].log_to_console; - row["log_to_file"] = LogSys.log_settings[i].log_to_file; - row["log_to_gmsay"] = LogSys.log_settings[i].log_to_gmsay; + row["log_to_console"] = EQEmuLogSys::Instance()->log_settings[i].log_to_console; + row["log_to_file"] = EQEmuLogSys::Instance()->log_settings[i].log_to_file; + row["log_to_gmsay"] = EQEmuLogSys::Instance()->log_settings[i].log_to_gmsay; response.append(row); } @@ -866,15 +866,15 @@ Json::Value ApiSetLoggingLevel(EQ::Net::WebsocketServerConnection *connection, J if (logging_category < Logs::LogCategory::MaxCategoryID && logging_category > Logs::LogCategory::None ) { - LogSys.log_settings[logging_category].log_to_console = logging_level; + EQEmuLogSys::Instance()->log_settings[logging_category].log_to_console = logging_level; response["status"] = "Category log level updated"; } if (logging_level > 0) { - LogSys.log_settings[logging_category].is_category_enabled = 1; + EQEmuLogSys::Instance()->log_settings[logging_category].is_category_enabled = 1; } else { - LogSys.log_settings[logging_category].is_category_enabled = 0; + EQEmuLogSys::Instance()->log_settings[logging_category].is_category_enabled = 0; } return response; @@ -882,7 +882,7 @@ Json::Value ApiSetLoggingLevel(EQ::Net::WebsocketServerConnection *connection, J void RegisterApiLogEvent(std::unique_ptr &server) { - LogSys.SetConsoleHandler( + EQEmuLogSys::Instance()->SetConsoleHandler( [&](uint16 log_category, const std::string &msg) { Json::Value data; data["log_category"] = log_category; diff --git a/zone/attack.cpp b/zone/attack.cpp index 10cec2877..e46177352 100644 --- a/zone/attack.cpp +++ b/zone/attack.cpp @@ -2683,7 +2683,7 @@ bool NPC::Death(Mob* killer_mob, int64 damage, uint16 spell, EQ::skills::SkillTy give_exp_client->GetCleanName(), GetNPCTypeID() ); - task_manager->HandleUpdateTasksOnKill(give_exp_client, this); + TaskManager::Instance()->HandleUpdateTasksOnKill(give_exp_client, this); } if (killer_raid) { diff --git a/zone/bot.cpp b/zone/bot.cpp index 47d153705..36fd4e753 100644 --- a/zone/bot.cpp +++ b/zone/bot.cpp @@ -1242,7 +1242,7 @@ uint16 Bot::GetPrimarySkillValue() { } uint16 Bot::MaxSkill(EQ::skills::SkillType skillid, uint16 class_, uint16 level) const { - return skill_caps.GetSkillCap(class_, skillid, level).cap; + return SkillCaps::Instance()->GetSkillCap(class_, skillid, level).cap; } uint32 Bot::GetTotalATK() { @@ -3575,7 +3575,7 @@ void Bot::Depop() { RemoveAllAuras(); Mob* bot_pet = GetPet(); - + if (bot_pet) { if (bot_pet->Charmed()) { bot_pet->BuffFadeByEffect(SE_Charm); @@ -7342,7 +7342,7 @@ void Bot::CalcBotStats(bool showtext) { SetLevel(GetBotOwner()->GetLevel()); for (int sindex = 0; sindex <= EQ::skills::HIGHEST_SKILL; ++sindex) { - skills[sindex] = skill_caps.GetSkillCap(GetClass(), (EQ::skills::SkillType)sindex, GetLevel()).cap; + skills[sindex] = SkillCaps::Instance()->GetSkillCap(GetClass(), (EQ::skills::SkillType)sindex, GetLevel()).cap; } taunt_timer.Start(1000); @@ -11274,7 +11274,7 @@ void Bot::SetSpellTypePriority(uint16 spell_type, uint8 priority_type, uint16 pr std::list Bot::GetSpellTypesPrioritized(uint8 priority_type) { std::list cast_order; - + for (uint16 i = BotSpellTypes::START; i <= BotSpellTypes::END; i++) { BotSpellTypeOrder typeSettings = { .spellType = i, @@ -13463,4 +13463,4 @@ bool Bot::HasControllablePet(uint8 ranks_required) { return GetClass() != Class::Enchanter || GetPet()->GetPetType() != petAnimation || GetAA(aaAnimationEmpathy) >= ranks_required; -} \ No newline at end of file +} diff --git a/zone/bot_command.cpp b/zone/bot_command.cpp index 854054bfa..a697fc6bb 100644 --- a/zone/bot_command.cpp +++ b/zone/bot_command.cpp @@ -63,7 +63,6 @@ extern QueryServ* QServ; extern WorldServer worldserver; -extern TaskManager *task_manager; int bot_command_count; @@ -165,7 +164,7 @@ int bot_command_init(void) bot_command_add("inventoryremove", "Removes an item from a bot's inventory", AccountStatus::Player, bot_command_inventory_remove) || bot_command_add("inventorywindow", "Displays all items in a bot's inventory in a pop-up window", AccountStatus::Player, bot_command_inventory_window) || bot_command_add("itemuse", "Elicits a report from spawned bots that can use the item on your cursor (option 'empty' yields only empty slots)", AccountStatus::Player, bot_command_item_use) || - bot_command_add("maxmeleerange", "Toggles whether your bot is at max melee range or not. This will disable all special abilities, including taunt.", AccountStatus::Player, bot_command_max_melee_range) || + bot_command_add("maxmeleerange", "Toggles whether your bot is at max melee range or not. This will disable all special abilities, including taunt.", AccountStatus::Player, bot_command_max_melee_range) || bot_command_add("owneroption", "Sets options available to bot owners", AccountStatus::Player, bot_command_owner_option) || bot_command_add("pet", "Lists the available bot pet [subcommands]", AccountStatus::Player, bot_command_pet) || bot_command_add("petgetlost", "Orders a bot to remove its summoned pet", AccountStatus::Player, bot_command_pet_get_lost) || @@ -189,11 +188,11 @@ int bot_command_init(void) bot_command_add("spellmaxhppct", "Controls at what HP percent a bot will stop casting different spell types", AccountStatus::Player, bot_command_spell_max_hp_pct) || bot_command_add("spellmaxmanapct", "Controls at what mana percent a bot will stop casting different spell types", AccountStatus::Player, bot_command_spell_max_mana_pct) || bot_command_add("spellmaxthresholds", "Controls the minimum target HP threshold for a spell to be cast for a specific type", AccountStatus::Player, bot_command_spell_max_thresholds) || - bot_command_add("spellminhppct", "Controls at what HP percent a bot will start casting different spell types", AccountStatus::Player, bot_command_spell_min_hp_pct) || + bot_command_add("spellminhppct", "Controls at what HP percent a bot will start casting different spell types", AccountStatus::Player, bot_command_spell_min_hp_pct) || bot_command_add("spellminmanapct", "Controls at what mana percent a bot will start casting different spell types", AccountStatus::Player, bot_command_spell_min_mana_pct) || - bot_command_add("spellminthresholds", "Controls the maximum target HP threshold for a spell to be cast for a specific type", AccountStatus::Player, bot_command_spell_min_thresholds) || + bot_command_add("spellminthresholds", "Controls the maximum target HP threshold for a spell to be cast for a specific type", AccountStatus::Player, bot_command_spell_min_thresholds) || bot_command_add("spellresistlimits", "Controls the resist limits for bots to cast spells on their target", AccountStatus::Player, bot_command_spell_resist_limits) || - bot_command_add("spellpursuepriority", "Controls the order of casts by spell type when pursuing in combat", AccountStatus::Player, bot_command_spell_pursue_priority) || + bot_command_add("spellpursuepriority", "Controls the order of casts by spell type when pursuing in combat", AccountStatus::Player, bot_command_spell_pursue_priority) || bot_command_add("spelltargetcount", "Sets the required target amount for group/AE spells by spell type", AccountStatus::Player, bot_command_spell_target_count) || bot_command_add("spellinfo", "Opens a dialogue window with spell info", AccountStatus::Player, bot_spell_info_dialogue_window) || bot_command_add("spells", "Lists all Spells learned by the Bot.", AccountStatus::Player, bot_command_spell_list) || diff --git a/zone/bot_database.cpp b/zone/bot_database.cpp index 4c78284e6..10d681913 100644 --- a/zone/bot_database.cpp +++ b/zone/bot_database.cpp @@ -74,13 +74,61 @@ bool BotDatabase::LoadBotCommandSettings(std::map +inline std::vector join_pair( + const std::string &glue, + const std::pair &encapsulation, + const std::vector> &src +) +{ + if (src.empty()) { + return {}; + } + + std::vector output; + + for (const std::pair &src_iter: src) { + output.emplace_back( + + fmt::format( + "{}{}{}{}{}{}{}", + encapsulation.first, + src_iter.first, + encapsulation.second, + glue, + encapsulation.first, + src_iter.second, + encapsulation.second + ) + ); + } + + return output; +} + +template +inline std::string +ImplodePair(const std::string &glue, const std::pair &encapsulation, const std::vector &src) +{ + if (src.empty()) { + return {}; + } + std::ostringstream oss; + for (const T &src_iter: src) { + oss << encapsulation.first << src_iter << encapsulation.second << glue; + } + std::string output(oss.str()); + output.resize(output.size() - glue.size()); + return output; +} + bool BotDatabase::UpdateInjectedBotCommandSettings(const std::vector> &injected) { if (injected.size()) { query = fmt::format( "REPLACE INTO `bot_command_settings`(`bot_command`, `access`) VALUES {}", - Strings::ImplodePair( + ImplodePair( ",", std::pair('(', ')'), join_pair(",", std::pair('\'', '\''), injected) @@ -107,7 +155,7 @@ bool BotDatabase::UpdateOrphanedBotCommandSettings(const std::vector('\'', '\''), orphaned) + ImplodePair(",", std::pair('\'', '\''), orphaned) ); if (!database.QueryDatabase(query).Success()) { @@ -248,7 +296,7 @@ bool BotDatabase::LoadBotsList(const uint32 owner_id, std::listGetCleanName(), Stance::GetName(Stance::Passive), Stance::Passive); return true; @@ -2278,7 +2326,7 @@ bool BotDatabase::SaveBotSettings(Mob* m) if (!m->IsOfClientBot()) { return false; } - + uint32 bot_id = (m->IsBot() ? m->CastToBot()->GetBotID() : 0); uint32 character_id = (m->IsClient() ? m->CastToClient()->CharacterID() : 0); uint8 stance_id = (m->IsBot() ? m->CastToBot()->GetBotStance() : 0); @@ -2289,10 +2337,10 @@ bool BotDatabase::SaveBotSettings(Mob* m) } std::string query = ""; - + if (m->IsClient()) { query = fmt::format("`character_id` = {} AND `stance` = {}", character_id, stance_id); - } + } else { query = fmt::format("`bot_id` = {} AND `stance` = {}", bot_id, stance_id); } diff --git a/zone/cli/benchmark_databuckets.cpp b/zone/cli/benchmark_databuckets.cpp index 383465713..af0dcb84a 100644 --- a/zone/cli/benchmark_databuckets.cpp +++ b/zone/cli/benchmark_databuckets.cpp @@ -195,6 +195,25 @@ void RunBenchmarkCycle(uint64_t target_rows) std::cout << "✅ Completed " << Strings::Commify(OPERATIONS_PER_TEST) << " cached reads in " << read_cached_time.count() << " seconds. (DataBucket::GetData)\n"; + // 🔍 **Measure Client-Scoped Cache Miss Performance (Skips DB via CanCache)** + auto read_client_cache_miss_start = std::chrono::high_resolution_clock::now(); + for (size_t i = 0; i < OPERATIONS_PER_TEST; ++i) { + // generate key that doesn't exist + std::string key = "nonexistent_key_" + std::to_string(i); + + DataBucketKey k{ + .key = key, + .character_id = 999999999, // use scoped value + }; + + DataBucket::GetData(k); + } + auto read_client_cache_miss_end = std::chrono::high_resolution_clock::now(); + std::chrono::duration read_client_cache_miss_time = read_client_cache_miss_end - read_client_cache_miss_start; + std::cout << "✅ Completed " << Strings::Commify(OPERATIONS_PER_TEST) + << " scoped cache-miss reads (no DB) in " + << read_client_cache_miss_time.count() << " seconds. (Client Scoped, Cache Miss, No DB)\n"; + // 🔍 **Measure Non-Cached Read Performance (Direct Query)** auto read_uncached_start = std::chrono::high_resolution_clock::now(); for (size_t i = 0; i < OPERATIONS_PER_TEST; ++i) { @@ -259,7 +278,7 @@ void ZoneCLI::BenchmarkDatabuckets(int argc, char **argv, argh::parser &cmd, std } if (std::getenv("DEBUG")) { - LogSys.SetDatabase(&database)->LoadLogDatabaseSettings(); + EQEmuLogSys::Instance()->SetDatabase(&database)->LoadLogDatabaseSettings(); } auto start_time = std::chrono::high_resolution_clock::now(); diff --git a/zone/cli/tests/_test_util.cpp b/zone/cli/tests/_test_util.cpp index eba6aa01e..0bd118166 100644 --- a/zone/cli/tests/_test_util.cpp +++ b/zone/cli/tests/_test_util.cpp @@ -41,11 +41,11 @@ inline void RunTest(const std::string &test_name, int expected, int actual) extern Zone *zone; inline void SetupZone(std::string zone_short_name, uint32 instance_id = 0) { - LogSys.SilenceConsoleLogging(); + EQEmuLogSys::Instance()->SilenceConsoleLogging(); - LogSys.log_settings[Logs::ZoneState].log_to_console = std::getenv("DEBUG") ? 3 : 0; - LogSys.log_settings[Logs::Info].log_to_console = std::getenv("DEBUG") ? 3 : 0; - LogSys.log_settings[Logs::Spawns].log_to_console = std::getenv("DEBUG") ? 3 : 0; + EQEmuLogSys::Instance()->log_settings[Logs::ZoneState].log_to_console = std::getenv("DEBUG") ? 3 : 0; + EQEmuLogSys::Instance()->log_settings[Logs::Info].log_to_console = std::getenv("DEBUG") ? 3 : 0; + EQEmuLogSys::Instance()->log_settings[Logs::Spawns].log_to_console = std::getenv("DEBUG") ? 3 : 0; // boot shell zone for testing Zone::Bootup(ZoneID(zone_short_name), 0, false); @@ -53,5 +53,5 @@ inline void SetupZone(std::string zone_short_name, uint32 instance_id = 0) { entity_list.Process(); entity_list.MobProcess(); - LogSys.EnableConsoleLogging(); + EQEmuLogSys::Instance()->EnableConsoleLogging(); } diff --git a/zone/cli/tests/databuckets.cpp b/zone/cli/tests/databuckets.cpp index 0c61cb393..c51b99c6a 100644 --- a/zone/cli/tests/databuckets.cpp +++ b/zone/cli/tests/databuckets.cpp @@ -5,18 +5,18 @@ #include "../../client.h" #include "../../common/net/eqstream.h" -extern Zone *zone; +extern Zone* zone; -void ZoneCLI::TestDataBuckets(int argc, char **argv, argh::parser &cmd, std::string &description) +void ZoneCLI::TestDataBuckets(int argc, char** argv, argh::parser& cmd, std::string& description) { if (cmd[{"-h", "--help"}]) { return; } uint32 break_length = 50; - int failed_count = 0; + int failed_count = 0; - LogSys.SilenceConsoleLogging(); + EQEmuLogSys::Instance()->SilenceConsoleLogging(); // boot shell zone for testing Zone::Bootup(ZoneID("qrg"), 0, false); @@ -25,14 +25,36 @@ void ZoneCLI::TestDataBuckets(int argc, char **argv, argh::parser &cmd, std::str entity_list.Process(); entity_list.MobProcess(); - LogSys.EnableConsoleLogging(); + EQEmuLogSys::Instance()->EnableConsoleLogging(); + + Client* client = new Client(); + client->SetCharacterId(1); // Set a dummy character ID for testing + + EQEmuLogSys::Instance()->log_settings[Logs::MySQLQuery].is_category_enabled = std::getenv("DEBUG") ? 1 : 0; + EQEmuLogSys::Instance()->log_settings[Logs::MySQLQuery].log_to_console = std::getenv("DEBUG") ? 3 : 0; + + // 🧹 Delete all test keys before running tests + std::vector test_keys_to_clear = { + "basic_key", "expiring_key", "cache_key", "json_key", "non_existent_key", "simple_key", + "nested", "nested.test1", "nested.test2", "nested.test1.a", "nested.test2.a", + "exp_test", "cache_test", "full_json", "full_json.key2", "complex", "complex.nested.obj1", + "complex.nested.obj2", "plain_string", "json_array", "nested_partial", + "nested_override", "empty_json", "json_string", "deep_nested", + "nested_expire", "scoped_miss_test", "scoped_nested_miss.key", + "cache_miss_overwrite", "missed_nested_set", "account_client_test", "ac_nested.test", + "scoped_db_only_key" + }; + + DataBucketsRepository::DeleteWhere( + database, + fmt::format("`key` IN ('{}')", Strings::Join(test_keys_to_clear, "','")) + ); + DataBucket::ClearCache(); std::cout << "===========================================\n"; std::cout << "⚙\uFE0F> Running DataBuckets Tests...\n"; std::cout << "===========================================\n\n"; - Client *client = new Client(); - // Basic Key-Value Set/Get client->DeleteBucket("basic_key"); client->SetBucket("basic_key", "simple_value"); @@ -101,7 +123,7 @@ void ZoneCLI::TestDataBuckets(int argc, char **argv, argh::parser &cmd, std::str client->DeleteBucket("nested"); client->SetBucket("nested.test1.a", "value1"); client->SetBucket("nested.test2.a", "value2"); - client->SetBucket("nested.test2", "new_value"); // Should be **rejected** + client->SetBucket("nested.test2", "new_value"); // Should be **rejected** value = client->GetBucket("nested"); RunTest("Prevent Overwriting Objects", R"({"test1":{"a":"value1"},"test2":{"a":"value2"}})", value); @@ -160,9 +182,10 @@ void ZoneCLI::TestDataBuckets(int argc, char **argv, argh::parser &cmd, std::str client->DeleteBucket("complex"); client->SetBucket("complex.nested.obj1", "data1"); client->SetBucket("complex.nested.obj2", "data2"); - client->DeleteBucket("does_not_exist"); // Should do nothing + client->DeleteBucket("does_not_exist"); // Should do nothing value = client->GetBucket("complex"); - RunTest("Deleting Non-Existent Key Doesn't Break Existing Data", R"({"nested":{"obj1":"data1","obj2":"data2"}})", value); + RunTest("Deleting Non-Existent Key Doesn't Break Existing Data", R"({"nested":{"obj1":"data1","obj2":"data2"}})", + value); // Get nested key value one level up ** client->DeleteBucket("complex"); @@ -190,12 +213,12 @@ void ZoneCLI::TestDataBuckets(int argc, char **argv, argh::parser &cmd, std::str value = client->GetBucket("json_array"); RunTest("Store and Retrieve JSON Array", R"(["item1", "item2"])", value); -// // Prevent Overwriting Array with Object** -// client->DeleteBucket("json_array"); -// client->SetBucket("json_array", R"(["item1", "item2"])"); -// client->SetBucket("json_array.item", "new_value"); // Should be rejected -// value = client->GetBucket("json_array"); -// RunTest("Prevent Overwriting Array with Object", R"(["item1", "item2"])", value); + // // Prevent Overwriting Array with Object** + // client->DeleteBucket("json_array"); + // client->SetBucket("json_array", R"(["item1", "item2"])"); + // client->SetBucket("json_array.item", "new_value"); // Should be rejected + // value = client->GetBucket("json_array"); + // RunTest("Prevent Overwriting Array with Object", R"(["item1", "item2"])", value); // Retrieve Non-Existent Nested Key** client->DeleteBucket("nested_partial"); @@ -235,11 +258,93 @@ void ZoneCLI::TestDataBuckets(int argc, char **argv, argh::parser &cmd, std::str RunTest("Setting a nested key with an expiration protection test", R"({"test":{"test":"shouldnt_expire"}})", value); // Delete Deep Nested Key Keeps Parent** -// client->DeleteBucket("deep_nested"); -// client->SetBucket("deep_nested.level1.level2.level3", R"({"key": "value"})"); -// client->DeleteBucket("deep_nested.level1.level2.level3.key"); -// value = client->GetBucket("deep_nested.level1.level2.level3"); -// RunTest("Delete Deep Nested Key Keeps Parent", "{}", value); + // client->DeleteBucket("deep_nested"); + // client->SetBucket("deep_nested.level1.level2.level3", R"({"key": "value"})"); + // client->DeleteBucket("deep_nested.level1.level2.level3.key"); + // value = client->GetBucket("deep_nested.level1.level2.level3"); + // RunTest("Delete Deep Nested Key Keeps Parent", "{}", value); + + // ================================ + // 🧪 Scoped Cache-Miss Behavior Tests + // ================================ + + // Ensure a scoped key (character ID) that doesn't exist is not fetched from DB if not in cache + client->DeleteBucket("scoped_miss_test"); // Ensure not in DB + DataBucket::ClearCache(); // Clear all caches + std::string scoped_miss_value = client->GetBucket("scoped_miss_test"); + RunTest("Scoped Missing Key Returns Empty (Skips DB)", "", scoped_miss_value); + + // Ensure nested scoped key that isn't in cache returns empty immediately + client->DeleteBucket("scoped_nested_miss.key"); + DataBucket::ClearCache(); // Clear cache again + std::string scoped_nested_miss = client->GetBucket("scoped_nested_miss.key"); + RunTest("Nested Scoped Key Miss Returns Empty (Skips DB)", "", scoped_nested_miss); + + // Write to a key that was previously missed (0-id cached miss) + client->DeleteBucket("cache_miss_overwrite"); + DataBucket::ClearCache(); // Ensure clean slate + std::string missed_value = client->GetBucket("cache_miss_overwrite"); + RunTest("Initial Cache Miss Returns Empty", "", missed_value); + client->SetBucket("cache_miss_overwrite", "new_value"); + std::string new_val = client->GetBucket("cache_miss_overwrite"); + RunTest("Overwrite After Cache Miss Works", "new_value", new_val); + + // Write a nested key that previously missed + client->DeleteBucket("missed_nested_set.test"); + DataBucket::ClearCache(); + std::string initial = client->GetBucket("missed_nested_set.test"); + RunTest("Missed Nested Key Returns Empty", "", initial); + client->SetBucket("missed_nested_set.test", "set_value"); + std::string after_write = client->GetBucket("missed_nested_set.test"); + RunTest("Nested Set After Miss Works", "set_value", after_write); + + // ================================ + // 🧪 Scoped Cache Preload Tests (Account + Client) + // ================================ + + // Clear everything for a clean test + // Insert directly into the DB without touching cache + const std::string scoped_key = "scoped_db_only_key"; + client->DeleteBucket(scoped_key); + DataBucket::ClearCache(); + + // ✅ Scoped insert + DataBucketsRepository::InsertOne( + database, { + .key_ = scoped_key, + .value = "cached_value", + .character_id = client->CharacterID() + } + ); + + // Cold cache test — should return "" + std::string cold_value = client->GetBucket(scoped_key); + RunTest("Cold Cache Scoped Key Returns Empty (Due to Skip DB)", "", cold_value); + + // ✅ Reload cache + client->LoadDataBucketsCache(); + + // Cache should now return the value + std::string hot_value = client->GetBucket(scoped_key); + RunTest("Post-BulkLoad Scoped Key Returns Value", "cached_value", hot_value); + + // Also test nested key after preload + client->DeleteBucket("ac_nested.test"); + client->SetBucket("ac_nested.test", "nested_val"); + + // Clear cache, then preload + DataBucket::ClearCache(); + client->LoadDataBucketsCache(); + + std::string nested_value = client->GetBucket("ac_nested.test"); + RunTest("Post-BulkLoad Nested Scoped Key Returns Value", "nested_val", nested_value); + + // Remove and check that cache misses properly again + client->DeleteBucket("ac_nested.test"); + DataBucket::ClearCache(); + std::string post_delete_check = client->GetBucket("ac_nested.test"); + RunTest("Post-Delete Nested Scoped Key Returns Empty", "", post_delete_check); + std::cout << "\n===========================================\n"; std::cout << "✅ All DataBucket Tests Completed!\n"; diff --git a/zone/cli/tests/npc_handins.cpp b/zone/cli/tests/npc_handins.cpp index eceaa1d37..c9eed484d 100644 --- a/zone/cli/tests/npc_handins.cpp +++ b/zone/cli/tests/npc_handins.cpp @@ -68,7 +68,7 @@ void ZoneCLI::TestNpcHandins(int argc, char **argv, argh::parser &cmd, std::stri return; } - LogSys.SilenceConsoleLogging(); + EQEmuLogSys::Instance()->SilenceConsoleLogging(); Zone::Bootup(ZoneID("qrg"), 0, false); zone->StopShutdownTimer(); @@ -426,10 +426,10 @@ void ZoneCLI::TestNpcHandins(int argc, char **argv, argh::parser &cmd, std::stri std::map required; std::vector items; - LogSys.EnableConsoleLogging(); + EQEmuLogSys::Instance()->EnableConsoleLogging(); // turn this on to see debugging output - LogSys.log_settings[Logs::NpcHandin].log_to_console = std::getenv("DEBUG") ? 3 : 0; + EQEmuLogSys::Instance()->log_settings[Logs::NpcHandin].log_to_console = std::getenv("DEBUG") ? 3 : 0; for (auto &test: test_cases) { hand_ins.clear(); @@ -524,7 +524,7 @@ void ZoneCLI::TestNpcHandins(int argc, char **argv, argh::parser &cmd, std::stri npc->ResetHandin(); - if (LogSys.log_settings[Logs::NpcHandin].log_to_console > 0) { + if (EQEmuLogSys::Instance()->log_settings[Logs::NpcHandin].log_to_console > 0) { std::cout << std::endl; } } diff --git a/zone/cli/tests/npc_handins_multiquest.cpp b/zone/cli/tests/npc_handins_multiquest.cpp index 43f141591..1c560cdc9 100644 --- a/zone/cli/tests/npc_handins_multiquest.cpp +++ b/zone/cli/tests/npc_handins_multiquest.cpp @@ -1,4 +1,3 @@ -#include "../../common/http/httplib.h" #include "../../common/eqemu_logsys.h" #include "../../common/platform.h" #include "../../zone.h" @@ -16,7 +15,7 @@ void ZoneCLI::TestNpcHandinsMultiQuest(int argc, char **argv, argh::parser &cmd, uint32 break_length = 50; int failed_count = 0; - LogSys.SilenceConsoleLogging(); + EQEmuLogSys::Instance()->SilenceConsoleLogging(); Zone::Bootup(ZoneID("qrg"), 0, false); zone->StopShutdownTimer(); @@ -94,10 +93,10 @@ void ZoneCLI::TestNpcHandinsMultiQuest(int argc, char **argv, argh::parser &cmd, std::map required; std::vector items; - LogSys.EnableConsoleLogging(); + EQEmuLogSys::Instance()->EnableConsoleLogging(); // turn this on to see debugging output - LogSys.log_settings[Logs::NpcHandin].log_to_console = std::getenv("DEBUG") ? 3 : 0; + EQEmuLogSys::Instance()->log_settings[Logs::NpcHandin].log_to_console = std::getenv("DEBUG") ? 3 : 0; for (auto &test: test_cases) { required.clear(); @@ -163,7 +162,7 @@ void ZoneCLI::TestNpcHandinsMultiQuest(int argc, char **argv, argh::parser &cmd, npc->ResetHandin(); - if (LogSys.log_settings[Logs::NpcHandin].log_to_console > 0) { + if (EQEmuLogSys::Instance()->log_settings[Logs::NpcHandin].log_to_console > 0) { std::cout << std::endl; } } diff --git a/zone/client.cpp b/zone/client.cpp index 4b18ab6b8..5e3f78aae 100644 --- a/zone/client.cpp +++ b/zone/client.cpp @@ -68,6 +68,7 @@ extern volatile bool RunLoops; #include "../common/repositories/character_disciplines_repository.h" #include "../common/repositories/character_data_repository.h" #include "../common/repositories/character_pet_name_repository.h" +#include "../common/repositories/completed_tasks_repository.h" #include "../common/repositories/discovered_items_repository.h" #include "../common/repositories/inventory_repository.h" #include "../common/repositories/keyring_repository.h" @@ -85,7 +86,6 @@ extern Zone* zone; extern volatile bool is_zone_loaded; extern WorldServer worldserver; extern uint32 numclients; -extern PetitionList petition_list; void UpdateWindowTitle(char* iNewTitle); @@ -2232,7 +2232,7 @@ void Client::UpdateAdmin(bool from_database) { if (m_pp.gm) { LogInfo("[{}] - [{}] is a GM", __FUNCTION__ , GetName()); - petition_list.UpdateGMQueue(); + PetitionList::Instance()->UpdateGMQueue(); } UpdateWho(); @@ -3196,7 +3196,7 @@ bool Client::CanHaveSkill(EQ::skills::SkillType skill_id) const skill_id = EQ::skills::Skill2HPiercing; } - return skill_caps.GetSkillCap(GetClass(), skill_id, RuleI(Character, MaxLevel)).cap > 0; + return SkillCaps::Instance()->GetSkillCap(GetClass(), skill_id, RuleI(Character, MaxLevel)).cap > 0; } uint16 Client::MaxSkill(EQ::skills::SkillType skill_id, uint8 class_id, uint8 level) const @@ -3209,7 +3209,7 @@ uint16 Client::MaxSkill(EQ::skills::SkillType skill_id, uint8 class_id, uint8 le skill_id = EQ::skills::Skill2HPiercing; } - return skill_caps.GetSkillCap(class_id, skill_id, level).cap; + return SkillCaps::Instance()->GetSkillCap(class_id, skill_id, level).cap; } uint8 Client::GetSkillTrainLevel(EQ::skills::SkillType skill_id, uint8 class_id) @@ -3222,7 +3222,7 @@ uint8 Client::GetSkillTrainLevel(EQ::skills::SkillType skill_id, uint8 class_id) skill_id = EQ::skills::Skill2HPiercing; } - return skill_caps.GetSkillTrainLevel(class_id, skill_id, RuleI(Character, MaxLevel)); + return SkillCaps::Instance()->GetSkillTrainLevel(class_id, skill_id, RuleI(Character, MaxLevel)); } uint16 Client::GetMaxSkillAfterSpecializationRules(EQ::skills::SkillType skillid, uint16 maxSkill) @@ -12099,7 +12099,7 @@ void Client::MaxSkills() auto current_skill_value = ( EQ::skills::IsSpecializedSkill(s.first) ? MAX_SPECIALIZED_SKILL : - skill_caps.GetSkillCap(GetClass(), s.first, GetLevel()).cap + SkillCaps::Instance()->GetSkillCap(GetClass(), s.first, GetLevel()).cap ); if (GetSkill(s.first) < current_skill_value) { @@ -13253,3 +13253,17 @@ void Client::CheckItemDiscoverability(uint32 item_id) DiscoverItem(item_id); } + +bool Client::UncompleteTask(int task_id) +{ + CompletedTasksRepository::DeleteWhere( + database, + fmt::format( + "charid = {} AND taskid = {}", + CharacterID(), + task_id + ) + ); + + return task_state->UncompleteTask(task_id); +} diff --git a/zone/client.h b/zone/client.h index 9f96ba235..b75fb56f0 100644 --- a/zone/client.h +++ b/zone/client.h @@ -98,7 +98,6 @@ namespace EQ #define MAX_SPECIALIZED_SKILL 50 extern Zone* zone; -extern TaskManager *task_manager; class CLIENTPACKET { @@ -1359,7 +1358,7 @@ public: } inline bool SaveTaskState() { - return task_manager != nullptr && task_manager->SaveClientState(this, task_state); + return TaskManager::Instance()->SaveClientState(this, task_state); } inline bool IsTaskStateLoaded() { return task_state != nullptr; } inline bool IsTaskActive(int task_id) { return task_state != nullptr && task_state->IsTaskActive(task_id); } @@ -1433,14 +1432,14 @@ public: } inline void TaskSetSelector(Mob* mob, int task_set_id, bool ignore_cooldown) { - if (task_manager && task_state) { - task_manager->TaskSetSelector(this, mob, task_set_id, ignore_cooldown); + if (task_state) { + TaskManager::Instance()->TaskSetSelector(this, mob, task_set_id, ignore_cooldown); } } inline void TaskQuestSetSelector(Mob* mob, const std::vector& tasks, bool ignore_cooldown) { - if (task_manager && task_state) { - task_manager->TaskQuestSetSelector(this, mob, tasks, ignore_cooldown); + if (task_state) { + TaskManager::Instance()->TaskQuestSetSelector(this, mob, tasks, ignore_cooldown); } } inline void EnableTask(int task_count, int *task_list) @@ -1501,6 +1500,7 @@ public: { return task_state ? task_state->CompleteTask(this, task_id) : false; } + bool UncompleteTask(int task_id); inline void FailTask(int task_id) { if (task_state) { task_state->FailTask(this, task_id); }} inline int TaskTimeLeft(int task_id) { return (task_state ? task_state->TaskTimeLeft(task_id) : 0); } inline int EnabledTaskCount(int task_set_id) @@ -1959,6 +1959,9 @@ public: ExternalHandinMoneyReturned GetExternalHandinMoneyReturned() { return m_external_handin_money_returned; } std::vector GetExternalHandinItemsReturned() { return m_external_handin_items_returned; } + // used only for testing + inline void SetCharacterId(uint32_t id) { character_id = id; } + protected: friend class Mob; void CalcEdibleBonuses(StatBonuses* newbon); diff --git a/zone/client_evolving_items.cpp b/zone/client_evolving_items.cpp index e1259c77f..fef8fa085 100644 --- a/zone/client_evolving_items.cpp +++ b/zone/client_evolving_items.cpp @@ -337,24 +337,29 @@ bool Client::DoEvolveCheckProgression(EQ::ItemInstance &inst) !RuleB(EvolvingItems, DestroyAugmentsOnEvolve) && inst.IsAugmented() ) { - auto const augs = inst.GetAugmentIDs(); - std::vector parcels; - for (auto const &item_id: augs) { - if (!item_id) { - continue; - } + auto const augs = inst.GetAugmentIDs(); + std::vector parcels; + int32 next_slot = FindNextFreeParcelSlotUsingMemory(); + for (auto const &item_id: augs) { + if (!item_id) { + continue; + } - CharacterParcelsRepository::CharacterParcels p{}; - p.char_id = CharacterID(); - p.from_name = "Evolving Item Sub-System"; - p.note = fmt::format( - "System automatically removed from {} which recently evolved.", - inst.GetItem()->Name - ); - p.slot_id = FindNextFreeParcelSlotUsingMemory(); - p.sent_date = time(nullptr); - p.item_id = item_id; - p.quantity = 1; + if (next_slot == INVALID_INDEX) { + break; + } + + CharacterParcelsRepository::CharacterParcels p{}; + p.char_id = CharacterID(); + p.from_name = "Evolving Item Sub-System"; + p.note = fmt::format( + "System automatically removed from {} which recently evolved.", + inst.GetItem()->Name + ); + p.slot_id = next_slot; + p.sent_date = time(nullptr); + p.item_id = item_id; + p.quantity = 1; if (player_event_logs.IsEventEnabled(PlayerEvent::PARCEL_SEND)) { PlayerEvent::ParcelSend e{}; @@ -367,8 +372,10 @@ bool Client::DoEvolveCheckProgression(EQ::ItemInstance &inst) RecordPlayerEventLog(PlayerEvent::PARCEL_SEND, e); } - parcels.push_back(p); - } + parcels.push_back(p); + m_parcels.emplace(p.slot_id, p); + next_slot = FindNextFreeParcelSlotUsingMemory(); + } CharacterParcelsRepository::InsertMany(database, parcels); SendParcelStatus(); diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index 9ba3bbf8a..31b608552 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -79,7 +79,6 @@ extern QueryServ* QServ; extern Zone* zone; extern volatile bool is_zone_loaded; extern WorldServer worldserver; -extern PetitionList petition_list; extern EntityList entity_list; typedef void (Client::*ClientPacketProc)(const EQApplicationPacket *app); @@ -464,7 +463,7 @@ int Client::HandlePacket(const EQApplicationPacket *app) OpcodeManager::EmuToName(app->GetOpcode()), o->EmuToEQ(app->GetOpcode()) == 0 ? app->GetProtocolOpcode() : o->EmuToEQ(app->GetOpcode()), app->Size(), - (LogSys.IsLogEnabled(Logs::Detail, Logs::PacketClientServer) ? DumpPacketToString(app) : "") + (EQEmuLogSys::Instance()->IsLogEnabled(Logs::Detail, Logs::PacketClientServer) ? DumpPacketToString(app) : "") ); EmuOpcode opcode = app->GetOpcode(); @@ -5534,7 +5533,7 @@ void Client::Handle_OP_CrashDump(const EQApplicationPacket *app) void Client::Handle_OP_CreateObject(const EQApplicationPacket *app) { - if (LogSys.log_settings[Logs::Inventory].is_category_enabled) + if (EQEmuLogSys::Instance()->log_settings[Logs::Inventory].is_category_enabled) LogInventory("Handle_OP_CreateObject() [psize: [{}]] [{}]", app->size, DumpPacketToString(app).c_str()); DropItem(EQ::invslot::slotCursor); @@ -6963,7 +6962,7 @@ void Client::Handle_OP_GMSearchCorpse(const EQApplicationPacket *app) DialogueWindow::TableCell( fmt::format( "{} ({})", - zone_store.GetZoneLongName(e.zone_id, true), + ZoneStore::Instance()->GetZoneLongName(e.zone_id, true), e.zone_id ) ) + @@ -11058,7 +11057,7 @@ void Client::Handle_OP_PDeletePetition(const EQApplicationPacket *app) LogError("Wrong size: OP_PDeletePetition, size=[{}], expected [{}]", app->size, 2); return; } - if (petition_list.DeletePetitionByCharName((char*)app->pBuffer)) + if (PetitionList::Instance()->DeletePetitionByCharName((char*)app->pBuffer)) MessageString(Chat::White, PETITION_DELETED); else MessageString(Chat::White, PETITION_NO_DELETE); @@ -11736,7 +11735,7 @@ void Client::Handle_OP_Petition(const EQApplicationPacket *app) }*/ else { - if (petition_list.FindPetitionByAccountName(AccountName())) + if (PetitionList::Instance()->FindPetitionByAccountName(AccountName())) { Message(Chat::White, "You already have a petition in the queue, you must wait for it to be answered or use /deletepetition to delete it."); return; @@ -11752,10 +11751,10 @@ void Client::Handle_OP_Petition(const EQApplicationPacket *app) pet->SetPetitionText((char*)app->pBuffer); pet->SetZone(zone->GetZoneID()); pet->SetUrgency(0); - petition_list.AddPetition(pet); + PetitionList::Instance()->AddPetition(pet); database.InsertPetitionToDB(pet); - petition_list.UpdateGMQueue(); - petition_list.UpdateZoneListQueue(); + PetitionList::Instance()->UpdateGMQueue(); + PetitionList::Instance()->UpdateZoneListQueue(); worldserver.SendEmoteMessage( 0, 0, @@ -11786,16 +11785,16 @@ void Client::Handle_OP_PetitionCheckIn(const EQApplicationPacket *app) } Petition_Struct* inpet = (Petition_Struct*)app->pBuffer; - Petition* pet = petition_list.GetPetitionByID(inpet->petnumber); + Petition* pet = PetitionList::Instance()->GetPetitionByID(inpet->petnumber); //if (inpet->urgency != pet->GetUrgency()) pet->SetUrgency(inpet->urgency); pet->SetLastGM(GetName()); pet->SetGMText(inpet->gmtext); pet->SetCheckedOut(false); - petition_list.UpdatePetition(pet); - petition_list.UpdateGMQueue(); - petition_list.UpdateZoneListQueue(); + PetitionList::Instance()->UpdatePetition(pet); + PetitionList::Instance()->UpdateGMQueue(); + PetitionList::Instance()->UpdateZoneListQueue(); return; } @@ -11809,14 +11808,14 @@ void Client::Handle_OP_PetitionCheckout(const EQApplicationPacket *app) Message(Chat::Red, "Error: World server disconnected"); else { uint32 getpetnum = *((uint32*)app->pBuffer); - Petition* getpet = petition_list.GetPetitionByID(getpetnum); + Petition* getpet = PetitionList::Instance()->GetPetitionByID(getpetnum); if (getpet != 0) { getpet->AddCheckout(); getpet->SetCheckedOut(true); getpet->SendPetitionToPlayer(CastToClient()); - petition_list.UpdatePetition(getpet); - petition_list.UpdateGMQueue(); - petition_list.UpdateZoneListQueue(); + PetitionList::Instance()->UpdatePetition(getpet); + PetitionList::Instance()->UpdateGMQueue(); + PetitionList::Instance()->UpdateZoneListQueue(); } } return; @@ -11836,16 +11835,16 @@ void Client::Handle_OP_PetitionDelete(const EQApplicationPacket *app) pet->senttime = 0; strcpy(pet->accountid, ""); strcpy(pet->gmsenttoo, ""); - pet->quetotal = petition_list.GetTotalPetitions(); + pet->quetotal = PetitionList::Instance()->GetTotalPetitions(); strcpy(pet->charname, ""); FastQueuePacket(&outapp); - if (petition_list.DeletePetition(pet->petnumber) == -1) + if (PetitionList::Instance()->DeletePetition(pet->petnumber) == -1) std::cout << "Something is borked with: " << pet->petnumber << std::endl; - petition_list.ClearPetitions(); - petition_list.UpdateGMQueue(); - petition_list.ReadDatabase(); - petition_list.UpdateZoneListQueue(); + PetitionList::Instance()->ClearPetitions(); + PetitionList::Instance()->UpdateGMQueue(); + PetitionList::Instance()->ReadDatabase(); + PetitionList::Instance()->UpdateZoneListQueue(); return; } @@ -11880,12 +11879,12 @@ void Client::Handle_OP_PetitionUnCheckout(const EQApplicationPacket *app) Message(Chat::Red, "Error: World server disconnected"); else { uint32 getpetnum = *((uint32*)app->pBuffer); - Petition* getpet = petition_list.GetPetitionByID(getpetnum); + Petition* getpet = PetitionList::Instance()->GetPetitionByID(getpetnum); if (getpet != 0) { getpet->SetCheckedOut(false); - petition_list.UpdatePetition(getpet); - petition_list.UpdateGMQueue(); - petition_list.UpdateZoneListQueue(); + PetitionList::Instance()->UpdatePetition(getpet); + PetitionList::Instance()->UpdateGMQueue(); + PetitionList::Instance()->UpdateZoneListQueue(); } } return; diff --git a/zone/client_process.cpp b/zone/client_process.cpp index 04f724c98..31e914cc8 100644 --- a/zone/client_process.cpp +++ b/zone/client_process.cpp @@ -57,7 +57,6 @@ extern QueryServ* QServ; extern Zone* zone; extern volatile bool is_zone_loaded; extern WorldServer worldserver; -extern PetitionList petition_list; extern EntityList entity_list; bool Client::Process() { diff --git a/zone/command.cpp b/zone/command.cpp index 09721321e..ff3a9f0e7 100644 --- a/zone/command.cpp +++ b/zone/command.cpp @@ -34,7 +34,6 @@ extern QueryServ* QServ; extern WorldServer worldserver; -extern TaskManager *task_manager; extern FastMath g_Math; void CatchSignal(int sig_num); @@ -783,161 +782,3 @@ void command_bot(Client *c, const Seperator *sep) c->Message(Chat::Red, "Bots are disabled on this server."); } } - -#include "gm_commands/acceptrules.cpp" -#include "gm_commands/advnpcspawn.cpp" -#include "gm_commands/aggrozone.cpp" -#include "gm_commands/ai.cpp" -#include "gm_commands/appearance.cpp" -#include "gm_commands/appearanceeffects.cpp" -#include "gm_commands/attack.cpp" -#include "gm_commands/augmentitem.cpp" -#include "gm_commands/ban.cpp" -#include "gm_commands/bugs.cpp" -#include "gm_commands/camerashake.cpp" -#include "gm_commands/castspell.cpp" -#include "gm_commands/chat.cpp" -#include "gm_commands/clearxtargets.cpp" -#include "gm_commands/copycharacter.cpp" -#include "gm_commands/corpse.cpp" -#include "gm_commands/corpsefix.cpp" -#include "gm_commands/countitem.cpp" -#include "gm_commands/damage.cpp" -#include "gm_commands/databuckets.cpp" -#include "gm_commands/dbspawn2.cpp" -#include "gm_commands/delacct.cpp" -#include "gm_commands/delpetition.cpp" -#include "gm_commands/depop.cpp" -#include "gm_commands/depopzone.cpp" -#include "gm_commands/devtools.cpp" -#include "gm_commands/disablerecipe.cpp" -#include "gm_commands/disarmtrap.cpp" -#include "gm_commands/doanim.cpp" -#include "gm_commands/door.cpp" -#include "gm_commands/door_manipulation.cpp" -#include "gm_commands/dye.cpp" -#include "gm_commands/dz.cpp" -#include "gm_commands/dzkickplayers.cpp" -#include "gm_commands/editmassrespawn.cpp" -#include "gm_commands/emote.cpp" -#include "gm_commands/emptyinventory.cpp" -#include "gm_commands/enablerecipe.cpp" -#include "gm_commands/entityvariable.cpp" -#include "gm_commands/exptoggle.cpp" -#include "gm_commands/faction.cpp" -#include "gm_commands/evolving_items.cpp" -#include "gm_commands/feature.cpp" -#include "gm_commands/find.cpp" -#include "gm_commands/fish.cpp" -#include "gm_commands/fixmob.cpp" -#include "gm_commands/flagedit.cpp" -#include "gm_commands/fleeinfo.cpp" -#include "gm_commands/forage.cpp" -#include "gm_commands/gearup.cpp" -#include "gm_commands/giveitem.cpp" -#include "gm_commands/givemoney.cpp" -#include "gm_commands/gmzone.cpp" -#include "gm_commands/goto.cpp" -#include "gm_commands/grantaa.cpp" -#include "gm_commands/grid.cpp" -#include "gm_commands/guild.cpp" -#include "gm_commands/hp.cpp" -#include "gm_commands/illusion_block.cpp" -#include "gm_commands/instance.cpp" -#include "gm_commands/interrogateinv.cpp" -#include "gm_commands/interrupt.cpp" -#include "gm_commands/invsnapshot.cpp" -#include "gm_commands/ipban.cpp" -#include "gm_commands/kick.cpp" -#include "gm_commands/kill.cpp" -#include "gm_commands/killallnpcs.cpp" -#include "gm_commands/list.cpp" -#include "gm_commands/lootsim.cpp" -#include "gm_commands/loc.cpp" -#include "gm_commands/logs.cpp" -#include "gm_commands/makepet.cpp" -#include "gm_commands/memspell.cpp" -#include "gm_commands/merchantshop.cpp" -#include "gm_commands/modifynpcstat.cpp" -#include "gm_commands/movechar.cpp" -#include "gm_commands/movement.cpp" -#include "gm_commands/myskills.cpp" -#include "gm_commands/mysql.cpp" -#include "gm_commands/mystats.cpp" -#include "gm_commands/npccast.cpp" -#include "gm_commands/npcedit.cpp" -#include "gm_commands/npceditmass.cpp" -#include "gm_commands/npcemote.cpp" -#include "gm_commands/npcloot.cpp" -#include "gm_commands/npcsay.cpp" -#include "gm_commands/npcshout.cpp" -#include "gm_commands/npcspawn.cpp" -#include "gm_commands/npctypespawn.cpp" -#include "gm_commands/nudge.cpp" -#include "gm_commands/nukebuffs.cpp" -#include "gm_commands/nukeitem.cpp" -#include "gm_commands/object.cpp" -#include "gm_commands/object_manipulation.cpp" -#include "gm_commands/parcels.cpp" -#include "gm_commands/path.cpp" -#include "gm_commands/peqzone.cpp" -#include "gm_commands/petitems.cpp" -#include "gm_commands/petname.cpp" -#include "gm_commands/picklock.cpp" -#include "gm_commands/profanity.cpp" -#include "gm_commands/push.cpp" -#include "gm_commands/raidloot.cpp" -#include "gm_commands/randomfeatures.cpp" -#include "gm_commands/refreshgroup.cpp" -#include "gm_commands/reload.cpp" -#include "gm_commands/removeitem.cpp" -#include "gm_commands/repop.cpp" -#include "gm_commands/resetaa.cpp" -#include "gm_commands/resetaa_timer.cpp" -#include "gm_commands/resetdisc_timer.cpp" -#include "gm_commands/revoke.cpp" -#include "gm_commands/roambox.cpp" -#include "gm_commands/rules.cpp" -#include "gm_commands/save.cpp" -#include "gm_commands/scale.cpp" -#include "gm_commands/scribespell.cpp" -#include "gm_commands/scribespells.cpp" -#include "gm_commands/sendzonespawns.cpp" -#include "gm_commands/sensetrap.cpp" -#include "gm_commands/serverrules.cpp" -#include "gm_commands/set.cpp" -#include "gm_commands/show.cpp" -#include "gm_commands/shutdown.cpp" -#include "gm_commands/spawn.cpp" -#include "gm_commands/spawneditmass.cpp" -#include "gm_commands/spawnfix.cpp" -#include "gm_commands/faction_association.cpp" -#include "gm_commands/stun.cpp" -#include "gm_commands/summon.cpp" -#include "gm_commands/summonburiedplayercorpse.cpp" -#include "gm_commands/summonitem.cpp" -#include "gm_commands/suspend.cpp" -#include "gm_commands/suspendmulti.cpp" -#include "gm_commands/takeplatinum.cpp" -#include "gm_commands/task.cpp" -#include "gm_commands/traindisc.cpp" -#include "gm_commands/tune.cpp" -#include "gm_commands/undye.cpp" -#include "gm_commands/unmemspell.cpp" -#include "gm_commands/unmemspells.cpp" -#include "gm_commands/unscribespell.cpp" -#include "gm_commands/unscribespells.cpp" -#include "gm_commands/untraindisc.cpp" -#include "gm_commands/untraindiscs.cpp" -#include "gm_commands/wc.cpp" -#include "gm_commands/worldshutdown.cpp" -#include "gm_commands/worldwide.cpp" -#include "gm_commands/wp.cpp" -#include "gm_commands/wpadd.cpp" -#include "gm_commands/zone.cpp" -#include "gm_commands/zonebootup.cpp" -#include "gm_commands/zoneshutdown.cpp" -#include "gm_commands/zonevariable.cpp" -#include "gm_commands/zone_instance.cpp" -#include "gm_commands/zone_shard.cpp" -#include "gm_commands/zsave.cpp" diff --git a/zone/dialogue_window.cpp b/zone/dialogue_window.cpp index a02e90723..326d706d4 100644 --- a/zone/dialogue_window.cpp +++ b/zone/dialogue_window.cpp @@ -1,5 +1,3 @@ -#include - #include "dialogue_window.h" void DialogueWindow::Render(Client *c, std::string markdown) @@ -529,12 +527,19 @@ std::string DialogueWindow::CenterMessage(std::string message) return std::string(); } - auto cleaned_message = message; + std::string cleaned_message; + cleaned_message.reserve(message.size()); - std::regex tags("<[^>]*>"); - - if (std::regex_search(cleaned_message, tags)) { - std::regex_replace(cleaned_message, tags, cleaned_message); + // Strip HTML-like tags + bool in_tag = false; + for (char c : message) { + if (c == '<') { + in_tag = true; + } else if (c == '>' && in_tag) { + in_tag = false; + } else if (!in_tag) { + cleaned_message += c; + } } auto message_len = cleaned_message.length(); diff --git a/zone/embparser_api.cpp b/zone/embparser_api.cpp index 81ceff206..44acfb6e4 100644 --- a/zone/embparser_api.cpp +++ b/zone/embparser_api.cpp @@ -1271,6 +1271,16 @@ void Perl__failtask(int task_id) quest_manager.failtask(task_id); } +bool Perl__completetask(int task_id) +{ + return quest_manager.completetask(task_id); +} + +bool Perl__uncompletetask(int task_id) +{ + return quest_manager.uncompletetask(task_id); +} + int Perl__tasktimeleft(int task_id) { return quest_manager.tasktimeleft(task_id); @@ -5115,627 +5125,627 @@ void Perl__send_player_handin_event() float Perl__GetZoneSafeX(uint32 zone_id) { - return zone_store.GetZoneSafeCoordinates(zone_id).x; + return ZoneStore::Instance()->GetZoneSafeCoordinates(zone_id).x; } float Perl__GetZoneSafeX(uint32 zone_id, int version) { - return zone_store.GetZoneSafeCoordinates(zone_id, version).x; + return ZoneStore::Instance()->GetZoneSafeCoordinates(zone_id, version).x; } float Perl__GetZoneSafeY(uint32 zone_id) { - return zone_store.GetZoneSafeCoordinates(zone_id).y; + return ZoneStore::Instance()->GetZoneSafeCoordinates(zone_id).y; } float Perl__GetZoneSafeY(uint32 zone_id, int version) { - return zone_store.GetZoneSafeCoordinates(zone_id, version).y; + return ZoneStore::Instance()->GetZoneSafeCoordinates(zone_id, version).y; } float Perl__GetZoneSafeZ(uint32 zone_id) { - return zone_store.GetZoneSafeCoordinates(zone_id).z; + return ZoneStore::Instance()->GetZoneSafeCoordinates(zone_id).z; } float Perl__GetZoneSafeZ(uint32 zone_id, int version) { - return zone_store.GetZoneSafeCoordinates(zone_id, version).z; + return ZoneStore::Instance()->GetZoneSafeCoordinates(zone_id, version).z; } float Perl__GetZoneSafeHeading(uint32 zone_id) { - return zone_store.GetZoneSafeCoordinates(zone_id).w; + return ZoneStore::Instance()->GetZoneSafeCoordinates(zone_id).w; } float Perl__GetZoneSafeHeading(uint32 zone_id, int version) { - return zone_store.GetZoneSafeCoordinates(zone_id, version).w; + return ZoneStore::Instance()->GetZoneSafeCoordinates(zone_id, version).w; } float Perl__GetZoneGraveyardID(uint32 zone_id) { - return zone_store.GetZoneGraveyardID(zone_id); + return ZoneStore::Instance()->GetZoneGraveyardID(zone_id); } float Perl__GetZoneGraveyardID(uint32 zone_id, int version) { - return zone_store.GetZoneGraveyardID(zone_id, version); + return ZoneStore::Instance()->GetZoneGraveyardID(zone_id, version); } uint8 Perl__GetZoneMinimumLevel(uint32 zone_id) { - return zone_store.GetZoneMinimumLevel(zone_id); + return ZoneStore::Instance()->GetZoneMinimumLevel(zone_id); } uint8 Perl__GetZoneMinimumLevel(uint32 zone_id, int version) { - return zone_store.GetZoneMinimumLevel(zone_id, version); + return ZoneStore::Instance()->GetZoneMinimumLevel(zone_id, version); } uint8 Perl__GetZoneMaximumLevel(uint32 zone_id) { - return zone_store.GetZoneMaximumLevel(zone_id); + return ZoneStore::Instance()->GetZoneMaximumLevel(zone_id); } uint8 Perl__GetZoneMaximumLevel(uint32 zone_id, int version) { - return zone_store.GetZoneMaximumLevel(zone_id, version); + return ZoneStore::Instance()->GetZoneMaximumLevel(zone_id, version); } uint8 Perl__GetZoneMinimumStatus(uint32 zone_id) { - return zone_store.GetZoneMinimumStatus(zone_id); + return ZoneStore::Instance()->GetZoneMinimumStatus(zone_id); } uint8 Perl__GetZoneMinimumStatus(uint32 zone_id, int version) { - return zone_store.GetZoneMinimumStatus(zone_id, version); + return ZoneStore::Instance()->GetZoneMinimumStatus(zone_id, version); } int Perl__GetZoneTimeZone(uint32 zone_id) { - return zone_store.GetZoneTimeZone(zone_id); + return ZoneStore::Instance()->GetZoneTimeZone(zone_id); } int Perl__GetZoneTimeZone(uint32 zone_id, int version) { - return zone_store.GetZoneTimeZone(zone_id, version); + return ZoneStore::Instance()->GetZoneTimeZone(zone_id, version); } int Perl__GetZoneMaximumPlayers(uint32 zone_id) { - return zone_store.GetZoneMaximumPlayers(zone_id); + return ZoneStore::Instance()->GetZoneMaximumPlayers(zone_id); } int Perl__GetZoneMaximumPlayers(uint32 zone_id, int version) { - return zone_store.GetZoneMaximumPlayers(zone_id, version); + return ZoneStore::Instance()->GetZoneMaximumPlayers(zone_id, version); } uint32 Perl__GetZoneRuleSet(uint32 zone_id) { - return zone_store.GetZoneRuleSet(zone_id); + return ZoneStore::Instance()->GetZoneRuleSet(zone_id); } uint32 Perl__GetZoneRuleSet(uint32 zone_id, int version) { - return zone_store.GetZoneRuleSet(zone_id, version); + return ZoneStore::Instance()->GetZoneRuleSet(zone_id, version); } std::string Perl__GetZoneNote(uint32 zone_id) { - return zone_store.GetZoneNote(zone_id); + return ZoneStore::Instance()->GetZoneNote(zone_id); } std::string Perl__GetZoneNote(uint32 zone_id, int version) { - return zone_store.GetZoneNote(zone_id, version); + return ZoneStore::Instance()->GetZoneNote(zone_id, version); } float Perl__GetZoneUnderworld(uint32 zone_id) { - return zone_store.GetZoneUnderworld(zone_id); + return ZoneStore::Instance()->GetZoneUnderworld(zone_id); } float Perl__GetZoneUnderworld(uint32 zone_id, int version) { - return zone_store.GetZoneUnderworld(zone_id, version); + return ZoneStore::Instance()->GetZoneUnderworld(zone_id, version); } float Perl__GetZoneMinimumClip(uint32 zone_id) { - return zone_store.GetZoneMinimumClip(zone_id); + return ZoneStore::Instance()->GetZoneMinimumClip(zone_id); } float Perl__GetZoneMinimumClip(uint32 zone_id, int version) { - return zone_store.GetZoneMinimumClip(zone_id, version); + return ZoneStore::Instance()->GetZoneMinimumClip(zone_id, version); } float Perl__GetZoneMaximumClip(uint32 zone_id) { - return zone_store.GetZoneMaximumClip(zone_id); + return ZoneStore::Instance()->GetZoneMaximumClip(zone_id); } float Perl__GetZoneMaximumClip(uint32 zone_id, int version) { - return zone_store.GetZoneMaximumClip(zone_id, version); + return ZoneStore::Instance()->GetZoneMaximumClip(zone_id, version); } float Perl__GetZoneFogMinimumClip(uint32 zone_id) { - return zone_store.GetZoneFogMinimumClip(zone_id); + return ZoneStore::Instance()->GetZoneFogMinimumClip(zone_id); } float Perl__GetZoneFogMinimumClip(uint32 zone_id, uint8 slot) { - return zone_store.GetZoneFogMinimumClip(zone_id, slot); + return ZoneStore::Instance()->GetZoneFogMinimumClip(zone_id, slot); } float Perl__GetZoneFogMinimumClip(uint32 zone_id, uint8 slot, int version) { - return zone_store.GetZoneFogMinimumClip(zone_id, slot, version); + return ZoneStore::Instance()->GetZoneFogMinimumClip(zone_id, slot, version); } float Perl__GetZoneFogMaximumClip(uint32 zone_id) { - return zone_store.GetZoneFogMaximumClip(zone_id); + return ZoneStore::Instance()->GetZoneFogMaximumClip(zone_id); } float Perl__GetZoneFogMaximumClip(uint32 zone_id, uint8 slot) { - return zone_store.GetZoneFogMaximumClip(zone_id, slot); + return ZoneStore::Instance()->GetZoneFogMaximumClip(zone_id, slot); } float Perl__GetZoneFogMaximumClip(uint32 zone_id, uint8 slot, int version) { - return zone_store.GetZoneFogMaximumClip(zone_id, slot, version); + return ZoneStore::Instance()->GetZoneFogMaximumClip(zone_id, slot, version); } uint8 Perl__GetZoneFogRed(uint32 zone_id) { - return zone_store.GetZoneFogRed(zone_id); + return ZoneStore::Instance()->GetZoneFogRed(zone_id); } uint8 Perl__GetZoneFogRed(uint32 zone_id, uint8 slot) { - return zone_store.GetZoneFogRed(zone_id, slot); + return ZoneStore::Instance()->GetZoneFogRed(zone_id, slot); } uint8 Perl__GetZoneFogRed(uint32 zone_id, uint8 slot, int version) { - return zone_store.GetZoneFogRed(zone_id, slot, version); + return ZoneStore::Instance()->GetZoneFogRed(zone_id, slot, version); } uint8 Perl__GetZoneFogGreen(uint32 zone_id) { - return zone_store.GetZoneFogGreen(zone_id); + return ZoneStore::Instance()->GetZoneFogGreen(zone_id); } uint8 Perl__GetZoneFogGreen(uint32 zone_id, uint8 slot) { - return zone_store.GetZoneFogGreen(zone_id, slot); + return ZoneStore::Instance()->GetZoneFogGreen(zone_id, slot); } uint8 Perl__GetZoneFogGreen(uint32 zone_id, uint8 slot, int version) { - return zone_store.GetZoneFogGreen(zone_id, slot, version); + return ZoneStore::Instance()->GetZoneFogGreen(zone_id, slot, version); } uint8 Perl__GetZoneFogBlue(uint32 zone_id) { - return zone_store.GetZoneFogBlue(zone_id); + return ZoneStore::Instance()->GetZoneFogBlue(zone_id); } uint8 Perl__GetZoneFogBlue(uint32 zone_id, uint8 slot) { - return zone_store.GetZoneFogBlue(zone_id, slot); + return ZoneStore::Instance()->GetZoneFogBlue(zone_id, slot); } uint8 Perl__GetZoneFogBlue(uint32 zone_id, uint8 slot, int version) { - return zone_store.GetZoneFogBlue(zone_id, slot, version); + return ZoneStore::Instance()->GetZoneFogBlue(zone_id, slot, version); } uint8 Perl__GetZoneSky(uint32 zone_id) { - return zone_store.GetZoneSky(zone_id); + return ZoneStore::Instance()->GetZoneSky(zone_id); } uint8 Perl__GetZoneSky(uint32 zone_id, int version) { - return zone_store.GetZoneSky(zone_id, version); + return ZoneStore::Instance()->GetZoneSky(zone_id, version); } uint8 Perl__GetZoneZType(uint32 zone_id) { - return zone_store.GetZoneZType(zone_id); + return ZoneStore::Instance()->GetZoneZType(zone_id); } uint8 Perl__GetZoneZType(uint32 zone_id, int version) { - return zone_store.GetZoneZType(zone_id, version); + return ZoneStore::Instance()->GetZoneZType(zone_id, version); } float Perl__GetZoneExperienceMultiplier(uint32 zone_id) { - return zone_store.GetZoneExperienceMultiplier(zone_id); + return ZoneStore::Instance()->GetZoneExperienceMultiplier(zone_id); } float Perl__GetZoneExperienceMultiplier(uint32 zone_id, int version) { - return zone_store.GetZoneExperienceMultiplier(zone_id, version); + return ZoneStore::Instance()->GetZoneExperienceMultiplier(zone_id, version); } float Perl__GetZoneWalkSpeed(uint32 zone_id) { - return zone_store.GetZoneWalkSpeed(zone_id); + return ZoneStore::Instance()->GetZoneWalkSpeed(zone_id); } float Perl__GetZoneWalkSpeed(uint32 zone_id, int version) { - return zone_store.GetZoneWalkSpeed(zone_id, version); + return ZoneStore::Instance()->GetZoneWalkSpeed(zone_id, version); } uint8 Perl__GetZoneTimeType(uint32 zone_id) { - return zone_store.GetZoneTimeType(zone_id); + return ZoneStore::Instance()->GetZoneTimeType(zone_id); } uint8 Perl__GetZoneTimeType(uint32 zone_id, int version) { - return zone_store.GetZoneTimeType(zone_id, version); + return ZoneStore::Instance()->GetZoneTimeType(zone_id, version); } float Perl__GetZoneFogDensity(uint32 zone_id) { - return zone_store.GetZoneFogDensity(zone_id); + return ZoneStore::Instance()->GetZoneFogDensity(zone_id); } float Perl__GetZoneFogDensity(uint32 zone_id, int version) { - return zone_store.GetZoneFogDensity(zone_id, version); + return ZoneStore::Instance()->GetZoneFogDensity(zone_id, version); } std::string Perl__GetZoneFlagNeeded(uint32 zone_id) { - return zone_store.GetZoneFlagNeeded(zone_id); + return ZoneStore::Instance()->GetZoneFlagNeeded(zone_id); } std::string Perl__GetZoneFlagNeeded(uint32 zone_id, int version) { - return zone_store.GetZoneFlagNeeded(zone_id, version); + return ZoneStore::Instance()->GetZoneFlagNeeded(zone_id, version); } int8 Perl__GetZoneCanBind(uint32 zone_id) { - return zone_store.GetZoneCanBind(zone_id); + return ZoneStore::Instance()->GetZoneCanBind(zone_id); } int8 Perl__GetZoneCanBind(uint32 zone_id, int version) { - return zone_store.GetZoneCanBind(zone_id, version); + return ZoneStore::Instance()->GetZoneCanBind(zone_id, version); } int8 Perl__GetZoneCanCombat(uint32 zone_id) { - return zone_store.GetZoneCanCombat(zone_id); + return ZoneStore::Instance()->GetZoneCanCombat(zone_id); } int8 Perl__GetZoneCanCombat(uint32 zone_id, int version) { - return zone_store.GetZoneCanCombat(zone_id, version); + return ZoneStore::Instance()->GetZoneCanCombat(zone_id, version); } int8 Perl__GetZoneCanLevitate(uint32 zone_id) { - return zone_store.GetZoneCanLevitate(zone_id); + return ZoneStore::Instance()->GetZoneCanLevitate(zone_id); } int8 Perl__GetZoneCanLevitate(uint32 zone_id, int version) { - return zone_store.GetZoneCanLevitate(zone_id, version); + return ZoneStore::Instance()->GetZoneCanLevitate(zone_id, version); } int8 Perl__GetZoneCastOutdoor(uint32 zone_id) { - return zone_store.GetZoneCastOutdoor(zone_id); + return ZoneStore::Instance()->GetZoneCastOutdoor(zone_id); } int8 Perl__GetZoneCastOutdoor(uint32 zone_id, int version) { - return zone_store.GetZoneCastOutdoor(zone_id, version); + return ZoneStore::Instance()->GetZoneCastOutdoor(zone_id, version); } uint8 Perl__GetZoneHotzone(uint32 zone_id) { - return zone_store.GetZoneHotzone(zone_id); + return ZoneStore::Instance()->GetZoneHotzone(zone_id); } uint8 Perl__GetZoneHotzone(uint32 zone_id, int version) { - return zone_store.GetZoneHotzone(zone_id, version); + return ZoneStore::Instance()->GetZoneHotzone(zone_id, version); } uint8 Perl__GetZoneInstanceType(uint32 zone_id) { - return zone_store.GetZoneInstanceType(zone_id); + return ZoneStore::Instance()->GetZoneInstanceType(zone_id); } uint8 Perl__GetZoneInstanceType(uint32 zone_id, int version) { - return zone_store.GetZoneInstanceType(zone_id, version); + return ZoneStore::Instance()->GetZoneInstanceType(zone_id, version); } uint64 Perl__GetZoneShutdownDelay(uint32 zone_id) { - return zone_store.GetZoneShutdownDelay(zone_id); + return ZoneStore::Instance()->GetZoneShutdownDelay(zone_id); } uint64 Perl__GetZoneShutdownDelay(uint32 zone_id, int version) { - return zone_store.GetZoneShutdownDelay(zone_id, version); + return ZoneStore::Instance()->GetZoneShutdownDelay(zone_id, version); } int8 Perl__GetZonePEQZone(uint32 zone_id) { - return zone_store.GetZonePEQZone(zone_id); + return ZoneStore::Instance()->GetZonePEQZone(zone_id); } int8 Perl__GetZonePEQZone(uint32 zone_id, int version) { - return zone_store.GetZonePEQZone(zone_id, version); + return ZoneStore::Instance()->GetZonePEQZone(zone_id, version); } int8 Perl__GetZoneExpansion(uint32 zone_id) { - return zone_store.GetZoneExpansion(zone_id); + return ZoneStore::Instance()->GetZoneExpansion(zone_id); } int8 Perl__GetZoneExpansion(uint32 zone_id, int version) { - return zone_store.GetZoneExpansion(zone_id, version); + return ZoneStore::Instance()->GetZoneExpansion(zone_id, version); } int8 Perl__GetZoneBypassExpansionCheck(uint32 zone_id) { - return zone_store.GetZoneBypassExpansionCheck(zone_id); + return ZoneStore::Instance()->GetZoneBypassExpansionCheck(zone_id); } int8 Perl__GetZoneBypassExpansionCheck(uint32 zone_id, int version) { - return zone_store.GetZoneBypassExpansionCheck(zone_id, version); + return ZoneStore::Instance()->GetZoneBypassExpansionCheck(zone_id, version); } uint8 Perl__GetZoneSuspendBuffs(uint32 zone_id) { - return zone_store.GetZoneSuspendBuffs(zone_id); + return ZoneStore::Instance()->GetZoneSuspendBuffs(zone_id); } uint8 Perl__GetZoneSuspendBuffs(uint32 zone_id, int version) { - return zone_store.GetZoneSuspendBuffs(zone_id, version); + return ZoneStore::Instance()->GetZoneSuspendBuffs(zone_id, version); } int Perl__GetZoneRainChance(uint32 zone_id) { - return zone_store.GetZoneRainChance(zone_id); + return ZoneStore::Instance()->GetZoneRainChance(zone_id); } int Perl__GetZoneRainChance(uint32 zone_id, uint8 slot) { - return zone_store.GetZoneRainChance(zone_id, slot); + return ZoneStore::Instance()->GetZoneRainChance(zone_id, slot); } int Perl__GetZoneRainChance(uint32 zone_id, uint8 slot, int version) { - return zone_store.GetZoneRainChance(zone_id, slot, version); + return ZoneStore::Instance()->GetZoneRainChance(zone_id, slot, version); } int Perl__GetZoneRainDuration(uint32 zone_id) { - return zone_store.GetZoneRainDuration(zone_id); + return ZoneStore::Instance()->GetZoneRainDuration(zone_id); } int Perl__GetZoneRainDuration(uint32 zone_id, uint8 slot) { - return zone_store.GetZoneRainDuration(zone_id, slot); + return ZoneStore::Instance()->GetZoneRainDuration(zone_id, slot); } int Perl__GetZoneRainDuration(uint32 zone_id, uint8 slot, int version) { - return zone_store.GetZoneRainDuration(zone_id, slot, version); + return ZoneStore::Instance()->GetZoneRainDuration(zone_id, slot, version); } int Perl__GetZoneSnowChance(uint32 zone_id) { - return zone_store.GetZoneSnowChance(zone_id); + return ZoneStore::Instance()->GetZoneSnowChance(zone_id); } int Perl__GetZoneSnowChance(uint32 zone_id, uint8 slot) { - return zone_store.GetZoneSnowChance(zone_id, slot); + return ZoneStore::Instance()->GetZoneSnowChance(zone_id, slot); } int Perl__GetZoneSnowChance(uint32 zone_id, uint8 slot, int version) { - return zone_store.GetZoneSnowChance(zone_id, slot, version); + return ZoneStore::Instance()->GetZoneSnowChance(zone_id, slot, version); } int Perl__GetZoneSnowDuration(uint32 zone_id) { - return zone_store.GetZoneSnowDuration(zone_id); + return ZoneStore::Instance()->GetZoneSnowDuration(zone_id); } int Perl__GetZoneSnowDuration(uint32 zone_id, uint8 slot) { - return zone_store.GetZoneSnowDuration(zone_id, slot); + return ZoneStore::Instance()->GetZoneSnowDuration(zone_id, slot); } int Perl__GetZoneSnowDuration(uint32 zone_id, uint8 slot, int version) { - return zone_store.GetZoneSnowDuration(zone_id, slot, version); + return ZoneStore::Instance()->GetZoneSnowDuration(zone_id, slot, version); } float Perl__GetZoneGravity(uint32 zone_id) { - return zone_store.GetZoneGravity(zone_id); + return ZoneStore::Instance()->GetZoneGravity(zone_id); } float Perl__GetZoneGravity(uint32 zone_id, int version) { - return zone_store.GetZoneGravity(zone_id, version); + return ZoneStore::Instance()->GetZoneGravity(zone_id, version); } int Perl__GetZoneType(uint32 zone_id) { - return zone_store.GetZoneType(zone_id); + return ZoneStore::Instance()->GetZoneType(zone_id); } int Perl__GetZoneType(uint32 zone_id, int version) { - return zone_store.GetZoneType(zone_id, version); + return ZoneStore::Instance()->GetZoneType(zone_id, version); } int8 Perl__GetZoneSkyLock(uint32 zone_id) { - return zone_store.GetZoneSkyLock(zone_id); + return ZoneStore::Instance()->GetZoneSkyLock(zone_id); } int8 Perl__GetZoneSkyLock(uint32 zone_id, int version) { - return zone_store.GetZoneSkyLock(zone_id, version); + return ZoneStore::Instance()->GetZoneSkyLock(zone_id, version); } int Perl__GetZoneFastRegenHP(uint32 zone_id) { - return zone_store.GetZoneFastRegenHP(zone_id); + return ZoneStore::Instance()->GetZoneFastRegenHP(zone_id); } int Perl__GetZoneFastRegenHP(uint32 zone_id, int version) { - return zone_store.GetZoneFastRegenHP(zone_id, version); + return ZoneStore::Instance()->GetZoneFastRegenHP(zone_id, version); } int Perl__GetZoneFastRegenMana(uint32 zone_id) { - return zone_store.GetZoneFastRegenMana(zone_id); + return ZoneStore::Instance()->GetZoneFastRegenMana(zone_id); } int Perl__GetZoneFastRegenMana(uint32 zone_id, int version) { - return zone_store.GetZoneFastRegenMana(zone_id, version); + return ZoneStore::Instance()->GetZoneFastRegenMana(zone_id, version); } int Perl__GetZoneFastRegenEndurance(uint32 zone_id) { - return zone_store.GetZoneFastRegenEndurance(zone_id); + return ZoneStore::Instance()->GetZoneFastRegenEndurance(zone_id); } int Perl__GetZoneFastRegenEndurance(uint32 zone_id, int version) { - return zone_store.GetZoneFastRegenEndurance(zone_id, version); + return ZoneStore::Instance()->GetZoneFastRegenEndurance(zone_id, version); } int Perl__GetZoneNPCMaximumAggroDistance(uint32 zone_id) { - return zone_store.GetZoneNPCMaximumAggroDistance(zone_id); + return ZoneStore::Instance()->GetZoneNPCMaximumAggroDistance(zone_id); } int Perl__GetZoneNPCMaximumAggroDistance(uint32 zone_id, int version) { - return zone_store.GetZoneNPCMaximumAggroDistance(zone_id, version); + return ZoneStore::Instance()->GetZoneNPCMaximumAggroDistance(zone_id, version); } int8 Perl__GetZoneMinimumExpansion(uint32 zone_id) { - return zone_store.GetZoneMinimumExpansion(zone_id); + return ZoneStore::Instance()->GetZoneMinimumExpansion(zone_id); } int8 Perl__GetZoneMinimumExpansion(uint32 zone_id, int version) { - return zone_store.GetZoneMinimumExpansion(zone_id, version); + return ZoneStore::Instance()->GetZoneMinimumExpansion(zone_id, version); } int8 Perl__GetZoneMaximumExpansion(uint32 zone_id) { - return zone_store.GetZoneMaximumExpansion(zone_id); + return ZoneStore::Instance()->GetZoneMaximumExpansion(zone_id); } int8 Perl__GetZoneMaximumExpansion(uint32 zone_id, int version) { - return zone_store.GetZoneMaximumExpansion(zone_id, version); + return ZoneStore::Instance()->GetZoneMaximumExpansion(zone_id, version); } std::string Perl__GetZoneContentFlags(uint32 zone_id) { - return zone_store.GetZoneContentFlags(zone_id); + return ZoneStore::Instance()->GetZoneContentFlags(zone_id); } std::string Perl__GetZoneContentFlags(uint32 zone_id, int version) { - return zone_store.GetZoneContentFlags(zone_id, version); + return ZoneStore::Instance()->GetZoneContentFlags(zone_id, version); } std::string Perl__GetZoneContentFlagsDisabled(uint32 zone_id) { - return zone_store.GetZoneContentFlagsDisabled(zone_id); + return ZoneStore::Instance()->GetZoneContentFlagsDisabled(zone_id); } std::string Perl__GetZoneContentFlagsDisabled(uint32 zone_id, int version) { - return zone_store.GetZoneContentFlagsDisabled(zone_id, version); + return ZoneStore::Instance()->GetZoneContentFlagsDisabled(zone_id, version); } int Perl__GetZoneUnderworldTeleportIndex(uint32 zone_id) { - return zone_store.GetZoneUnderworldTeleportIndex(zone_id); + return ZoneStore::Instance()->GetZoneUnderworldTeleportIndex(zone_id); } int Perl__GetZoneUnderworldTeleportIndex(uint32 zone_id, int version) { - return zone_store.GetZoneUnderworldTeleportIndex(zone_id, version); + return ZoneStore::Instance()->GetZoneUnderworldTeleportIndex(zone_id, version); } int Perl__GetZoneLavaDamage(uint32 zone_id) { - return zone_store.GetZoneLavaDamage(zone_id); + return ZoneStore::Instance()->GetZoneLavaDamage(zone_id); } int Perl__GetZoneLavaDamage(uint32 zone_id, int version) { - return zone_store.GetZoneLavaDamage(zone_id, version); + return ZoneStore::Instance()->GetZoneLavaDamage(zone_id, version); } int Perl__GetZoneMinimumLavaDamage(uint32 zone_id) { - return zone_store.GetZoneMinimumLavaDamage(zone_id); + return ZoneStore::Instance()->GetZoneMinimumLavaDamage(zone_id); } int Perl__GetZoneMinimumLavaDamage(uint32 zone_id, int version) { - return zone_store.GetZoneMinimumLavaDamage(zone_id, version); + return ZoneStore::Instance()->GetZoneMinimumLavaDamage(zone_id, version); } uint8 Perl__GetZoneIdleWhenEmpty(uint32 zone_id) { - return zone_store.GetZoneIdleWhenEmpty(zone_id); + return ZoneStore::Instance()->GetZoneIdleWhenEmpty(zone_id); } uint8 Perl__GetZoneIdleWhenEmpty(uint32 zone_id, int version) { - return zone_store.GetZoneIdleWhenEmpty(zone_id, version); + return ZoneStore::Instance()->GetZoneIdleWhenEmpty(zone_id, version); } uint32 Perl__GetZoneSecondsBeforeIdle(uint32 zone_id) { - return zone_store.GetZoneSecondsBeforeIdle(zone_id); + return ZoneStore::Instance()->GetZoneSecondsBeforeIdle(zone_id); } uint32 Perl__GetZoneSecondsBeforeIdle(uint32 zone_id, int version) { - return zone_store.GetZoneSecondsBeforeIdle(zone_id, version); + return ZoneStore::Instance()->GetZoneSecondsBeforeIdle(zone_id, version); } void Perl__send_channel_message(uint8 channel_number, uint32 guild_id, uint8 language_id, uint8 language_skill, const char* message) @@ -5860,12 +5870,12 @@ bool Perl__SetAutoLoginCharacterNameByAccountID(uint32 account_id, std::string c uint32 Perl__GetZoneIDByLongName(std::string zone_long_name) { - return zone_store.GetZoneIDByLongName(zone_long_name); + return ZoneStore::Instance()->GetZoneIDByLongName(zone_long_name); } std::string Perl__GetZoneShortNameByLongName(std::string zone_long_name) { - return zone_store.GetZoneShortNameByLongName(zone_long_name); + return ZoneStore::Instance()->GetZoneShortNameByLongName(zone_long_name); } bool Perl__send_parcel(perl::reference table_ref) @@ -6628,6 +6638,8 @@ void perl_register_quest() package.add("faction", (void(*)(int, int, int))&Perl__faction); package.add("factionvalue", &Perl__FactionValue); package.add("failtask", &Perl__failtask); + package.add("completetask", &Perl__completetask); + package.add("uncompletetask", &Perl__uncompletetask); package.add("firsttaskinset", &Perl__firsttaskinset); package.add("follow", (void(*)(int))&Perl__follow); package.add("follow", (void(*)(int, int))&Perl__follow); diff --git a/zone/embperl.cpp b/zone/embperl.cpp index 799669ec3..b48c714e3 100644 --- a/zone/embperl.cpp +++ b/zone/embperl.cpp @@ -138,7 +138,7 @@ void Embperl::DoInit() LogQuests("Warning [{}]: [{}]", Config->PluginPlFile, e); } - for (auto & dir : path.GetPluginPaths()) { + for (auto & dir : PathManager::Instance()->GetPluginPaths()) { try { //should probably read the directory in c, instead, so that //I can echo filenames as I do it, but c'mon... I'm lazy and this 1 line reads in all the plugins diff --git a/zone/entity.cpp b/zone/entity.cpp index 3658c9045..b87895001 100644 --- a/zone/entity.cpp +++ b/zone/entity.cpp @@ -55,7 +55,6 @@ extern Zone *zone; extern volatile bool is_zone_loaded; extern WorldServer worldserver; extern uint32 numclients; -extern PetitionList petition_list; extern char errorname[32]; @@ -3447,7 +3446,7 @@ void EntityList::SendPetitionToAdmins(Petition *pet) strcpy(pcus->accountid, pet->GetAccountName()); strcpy(pcus->charname, pet->GetCharName()); } - pcus->quetotal = petition_list.GetTotalPetitions(); + pcus->quetotal = PetitionList::Instance()->GetTotalPetitions(); auto it = client_list.begin(); while (it != client_list.end()) { if (it->second->CastToClient()->Admin() >= AccountStatus::QuestTroupe) { @@ -3472,7 +3471,7 @@ void EntityList::ClearClientPetitionQueue() strcpy(pet->accountid, ""); strcpy(pet->gmsenttoo, ""); strcpy(pet->charname, ""); - pet->quetotal = petition_list.GetTotalPetitions(); + pet->quetotal = PetitionList::Instance()->GetTotalPetitions(); auto it = client_list.begin(); while (it != client_list.end()) { if (it->second->CastToClient()->Admin() >= AccountStatus::GMAdmin) { @@ -4175,10 +4174,6 @@ void EntityList::ProcessProximitySay(const char *message, Client *c, uint8 langu void EntityList::SaveAllClientsTaskState() { - if (!task_manager) { - return; - } - auto it = client_list.begin(); while (it != client_list.end()) { Client *client = it->second; @@ -4192,9 +4187,6 @@ void EntityList::SaveAllClientsTaskState() void EntityList::ReloadAllClientsTaskState(int task_id) { - if (!task_manager) - return; - auto it = client_list.begin(); while (it != client_list.end()) { Client *client = it->second; @@ -4205,7 +4197,7 @@ void EntityList::ReloadAllClientsTaskState(int task_id) Log(Logs::General, Logs::Tasks, "[CLIENTLOAD] Reloading Task State For Client %s", client->GetName()); client->RemoveClientTaskState(); client->LoadClientTaskState(); - task_manager->SendActiveTasksToClient(client); + TaskManager::Instance()->SendActiveTasksToClient(client); } } ++it; diff --git a/zone/gm_commands/databuckets.cpp b/zone/gm_commands/databuckets.cpp index 952a276dd..af78f528e 100755 --- a/zone/gm_commands/databuckets.cpp +++ b/zone/gm_commands/databuckets.cpp @@ -3,6 +3,15 @@ #include "../dialogue_window.h" #include "../../common/repositories/data_buckets_repository.h" +void SendDataBucketsSubCommands(Client *c) +{ + c->Message(Chat::White, "Usage: #databuckets delete [Key] [Character ID] [NPC ID] [Bot ID]"); + c->Message(Chat::White, "Usage: #databuckets edit [Key] [Character ID] [NPC ID] [Bot ID] [Value] [Expires]"); + c->Message(Chat::White, "Usage: #databuckets view [Partial Key] [Character ID] [NPC ID] [Bot ID]"); + c->Message(Chat::White, "Note: Character ID, NPC ID, and Bot ID are optional if not needed, if needed they are required for specificity"); + c->Message(Chat::White, "Note: Edit requires Character ID, NPC ID, Bot ID, and Value, Expires is optional and does not modify the existing expiration time if not provided"); +} + void command_databuckets(Client *c, const Seperator *sep) { const int arguments = sep->argnum; @@ -251,12 +260,3 @@ void command_databuckets(Client *c, const Seperator *sep) c->Message(Chat::White, response.c_str()); } } - -void SendDataBucketsSubCommands(Client *c) -{ - c->Message(Chat::White, "Usage: #databuckets delete [Key] [Character ID] [NPC ID] [Bot ID]"); - c->Message(Chat::White, "Usage: #databuckets edit [Key] [Character ID] [NPC ID] [Bot ID] [Value] [Expires]"); - c->Message(Chat::White, "Usage: #databuckets view [Partial Key] [Character ID] [NPC ID] [Bot ID]"); - c->Message(Chat::White, "Note: Character ID, NPC ID, and Bot ID are optional if not needed, if needed they are required for specificity"); - c->Message(Chat::White, "Note: Edit requires Character ID, NPC ID, Bot ID, and Value, Expires is optional and does not modify the existing expiration time if not provided"); -} diff --git a/zone/gm_commands/find/object_type.cpp b/zone/gm_commands/find/object_type.cpp index 39a94fd5e..1e7dc69aa 100644 --- a/zone/gm_commands/find/object_type.cpp +++ b/zone/gm_commands/find/object_type.cpp @@ -1,3 +1,4 @@ +#include "../../object.h" #include "../../client.h" void FindObjectType(Client *c, const Seperator *sep) diff --git a/zone/gm_commands/find/task.cpp b/zone/gm_commands/find/task.cpp index ed08ad534..c51f1892d 100644 --- a/zone/gm_commands/find/task.cpp +++ b/zone/gm_commands/find/task.cpp @@ -11,7 +11,7 @@ void FindTask(Client *c, const Seperator *sep) if (sep->IsNumber(2)) { const auto task_id = Strings::ToUnsignedInt(sep->arg[2]); - const auto& task_name = task_manager->GetTaskName(task_id); + const auto& task_name = TaskManager::Instance()->GetTaskName(task_id); if (task_name.empty()) { c->Message( @@ -41,7 +41,7 @@ void FindTask(Client *c, const Seperator *sep) auto found_count = 0; - for (const auto& t : task_manager->GetTaskData()) { + for (const auto& t : TaskManager::Instance()->GetTaskData()) { const auto& task_name = t.second.title; const auto& task_name_lower = Strings::ToLower(task_name); if (!Strings::Contains(task_name_lower, search_criteria)) { diff --git a/zone/gm_commands/guild.cpp b/zone/gm_commands/guild.cpp index 39a30c4ed..97d280e80 100755 --- a/zone/gm_commands/guild.cpp +++ b/zone/gm_commands/guild.cpp @@ -8,6 +8,22 @@ extern QueryServ *QServ; #include "../guild_mgr.h" #include "../doors.h" +void SendGuildSubCommands(Client* c) +{ + c->Message(Chat::White, "#guild create [Character ID|Character Name] [Guild Name]"); + c->Message(Chat::White, "#guild delete [Guild ID]"); + c->Message(Chat::White, "#guild details [Guild ID]"); + c->Message(Chat::White, "#guild help"); + c->Message(Chat::White, "#guild info [Guild ID]"); + c->Message(Chat::White, "#guild list"); + c->Message(Chat::White, "#guild rename [Guild ID] [New Name]"); + c->Message(Chat::White, "#guild search [Search Criteria]"); + c->Message(Chat::White, "#guild set [Character ID|Character Name] [Guild ID] (Guild ID 0 is Guildless)"); + c->Message(Chat::White, "#guild setleader [Guild ID] [Character ID|Character Name]"); + c->Message(Chat::White, "#guild setrank [Character ID|Character Name] [Rank]"); + c->Message(Chat::White, "#guild status [Character ID|Character Name]"); +} + void command_guild(Client* c, const Seperator* sep) { const auto arguments = sep->argnum; @@ -675,20 +691,4 @@ void command_guild(Client* c, const Seperator* sep) // } } } -} - -void SendGuildSubCommands(Client* c) -{ - c->Message(Chat::White, "#guild create [Character ID|Character Name] [Guild Name]"); - c->Message(Chat::White, "#guild delete [Guild ID]"); - c->Message(Chat::White, "#guild details [Guild ID]"); - c->Message(Chat::White, "#guild help"); - c->Message(Chat::White, "#guild info [Guild ID]"); - c->Message(Chat::White, "#guild list"); - c->Message(Chat::White, "#guild rename [Guild ID] [New Name]"); - c->Message(Chat::White, "#guild search [Search Criteria]"); - c->Message(Chat::White, "#guild set [Character ID|Character Name] [Guild ID] (Guild ID 0 is Guildless)"); - c->Message(Chat::White, "#guild setleader [Guild ID] [Character ID|Character Name]"); - c->Message(Chat::White, "#guild setrank [Character ID|Character Name] [Rank]"); - c->Message(Chat::White, "#guild status [Character ID|Character Name]"); -} +} \ No newline at end of file diff --git a/zone/gm_commands/illusion_block.cpp b/zone/gm_commands/illusion_block.cpp index f9c3e9514..8aa274b4a 100644 --- a/zone/gm_commands/illusion_block.cpp +++ b/zone/gm_commands/illusion_block.cpp @@ -1,3 +1,4 @@ +#include "../dialogue_window.h" #include "../client.h" void command_illusion_block(Client* c, const Seperator* sep) diff --git a/zone/gm_commands/list.cpp b/zone/gm_commands/list.cpp index 7e05a1d6a..d39b424ba 100755 --- a/zone/gm_commands/list.cpp +++ b/zone/gm_commands/list.cpp @@ -2,6 +2,7 @@ #include "../corpse.h" #include "../object.h" #include "../doors.h" +#include "../command.h" struct UniqueEntity { uint16 entity_id; diff --git a/zone/gm_commands/loc.cpp b/zone/gm_commands/loc.cpp index 4e4085add..b7b627fcb 100755 --- a/zone/gm_commands/loc.cpp +++ b/zone/gm_commands/loc.cpp @@ -1,4 +1,5 @@ #include "../client.h" +#include "../water_map.h" void command_loc(Client *c, const Seperator *sep) { diff --git a/zone/gm_commands/logs.cpp b/zone/gm_commands/logs.cpp index 031d04dd1..366a56c79 100755 --- a/zone/gm_commands/logs.cpp +++ b/zone/gm_commands/logs.cpp @@ -76,7 +76,7 @@ void command_logs(Client *c, const Seperator *sep) std::vector gmsay; for (int i = 0; i <= 2; i++) { - if (LogSys.log_settings[index].log_to_gmsay == i) { + if (EQEmuLogSys::Instance()->log_settings[index].log_to_gmsay == i) { gmsay.emplace_back(std::to_string(i)); continue; } @@ -90,7 +90,7 @@ void command_logs(Client *c, const Seperator *sep) std::vector file; for (int i = 0; i <= 2; i++) { - if (LogSys.log_settings[index].log_to_file == i) { + if (EQEmuLogSys::Instance()->log_settings[index].log_to_file == i) { file.emplace_back(std::to_string(i)); continue; } @@ -104,7 +104,7 @@ void command_logs(Client *c, const Seperator *sep) std::vector console; for (int i = 0; i <= 2; i++) { - if (LogSys.log_settings[index].log_to_console == i) { + if (EQEmuLogSys::Instance()->log_settings[index].log_to_console == i) { console.emplace_back(std::to_string(i)); continue; } @@ -118,7 +118,7 @@ void command_logs(Client *c, const Seperator *sep) std::vector discord; for (int i = 0; i <= 2; i++) { - if (LogSys.log_settings[index].log_to_discord == i) { + if (EQEmuLogSys::Instance()->log_settings[index].log_to_discord == i) { discord.emplace_back(std::to_string(i)); continue; } @@ -206,16 +206,16 @@ void command_logs(Client *c, const Seperator *sep) auto setting = Strings::ToUnsignedInt(sep->arg[4]); if (is_console) { - LogSys.log_settings[category_id].log_to_console = setting; + EQEmuLogSys::Instance()->log_settings[category_id].log_to_console = setting; } else if (is_file) { - LogSys.log_settings[category_id].log_to_file = setting; + EQEmuLogSys::Instance()->log_settings[category_id].log_to_file = setting; } else if (is_gmsay) { - LogSys.log_settings[category_id].log_to_gmsay = setting; + EQEmuLogSys::Instance()->log_settings[category_id].log_to_gmsay = setting; } else if (is_discord) { - LogSys.log_settings[category_id].log_to_discord = setting; + EQEmuLogSys::Instance()->log_settings[category_id].log_to_discord = setting; } if (logs_set) { @@ -231,7 +231,7 @@ void command_logs(Client *c, const Seperator *sep) ); } - LogSys.log_settings[category_id].is_category_enabled = setting ? 1 : 0; + EQEmuLogSys::Instance()->log_settings[category_id].is_category_enabled = setting ? 1 : 0; } } diff --git a/zone/gm_commands/lootsim.cpp b/zone/gm_commands/lootsim.cpp index b61957f1d..783206219 100755 --- a/zone/gm_commands/lootsim.cpp +++ b/zone/gm_commands/lootsim.cpp @@ -14,9 +14,9 @@ void command_lootsim(Client *c, const Seperator *sep) auto log_enabled = arguments > 3 ? Strings::ToUnsignedInt(sep->arg[4]) : false; // temporarily disable loot logging unless set explicitly - LogSys.log_settings[Logs::Loot].log_to_console = log_enabled ? LogSys.log_settings[Logs::Loot].log_to_console : 0; - LogSys.log_settings[Logs::Loot].log_to_file = log_enabled ? LogSys.log_settings[Logs::Loot].log_to_file : 0; - LogSys.log_settings[Logs::Loot].log_to_gmsay = log_enabled ? LogSys.log_settings[Logs::Loot].log_to_gmsay : 0; + EQEmuLogSys::Instance()->log_settings[Logs::Loot].log_to_console = log_enabled ? EQEmuLogSys::Instance()->log_settings[Logs::Loot].log_to_console : 0; + EQEmuLogSys::Instance()->log_settings[Logs::Loot].log_to_file = log_enabled ? EQEmuLogSys::Instance()->log_settings[Logs::Loot].log_to_file : 0; + EQEmuLogSys::Instance()->log_settings[Logs::Loot].log_to_gmsay = log_enabled ? EQEmuLogSys::Instance()->log_settings[Logs::Loot].log_to_gmsay : 0; auto npc_type = content_db.LoadNPCTypesData(npc_id); if (npc_type) { @@ -182,7 +182,7 @@ void command_lootsim(Client *c, const Seperator *sep) ); c->SendChatLineBreak(); - LogSys.LoadLogDatabaseSettings(); + EQEmuLogSys::Instance()->LoadLogDatabaseSettings(); } } else { diff --git a/zone/gm_commands/modifynpcstat.cpp b/zone/gm_commands/modifynpcstat.cpp index 463e625f1..124f8ceca 100755 --- a/zone/gm_commands/modifynpcstat.cpp +++ b/zone/gm_commands/modifynpcstat.cpp @@ -1,63 +1,5 @@ #include "../client.h" -void command_modifynpcstat(Client *c, const Seperator *sep) -{ - auto arguments = sep->argnum; - if (!arguments) { - c->Message(Chat::White, "Usage: #modifynpcstat [Stat] [Value]"); - ListModifyNPCStatMap(c); - return; - } - - if (!c->GetTarget() || !c->GetTarget()->IsNPC()) { - c->Message(Chat::White, "You must target an NPC to use this command."); - return; - } - - auto target = c->GetTarget()->CastToNPC(); - - const std::string& stat = sep->arg[1] ? sep->arg[1] : ""; - const std::string& value = sep->arg[2] ? sep->arg[2] : ""; - - if (stat.empty() || value.empty()) { - c->Message(Chat::White, "Usage: #modifynpcstat [Stat] [Value]"); - ListModifyNPCStatMap(c); - return; - } - - auto stat_description = GetModifyNPCStatDescription(stat); - if (!stat_description.length()) { - c->Message( - Chat::White, - fmt::format( - "Stat '{}' does not exist.", - stat - ).c_str() - ); - return; - } - - target->ModifyNPCStat(stat, value); - - c->Message( - Chat::White, - fmt::format( - "Stat Modified | Target: {}", - c->GetTargetDescription(target) - ).c_str() - ); - - c->Message( - Chat::White, - fmt::format( - "Stat Modified | Stat: {} ({}) Value: {}", - GetModifyNPCStatDescription(stat), - stat, - value - ).c_str() - ); -} - std::map GetModifyNPCStatMap() { std::map identifiers_map = { @@ -134,3 +76,61 @@ void ListModifyNPCStatMap(Client *c) ); } } + +void command_modifynpcstat(Client *c, const Seperator *sep) +{ + auto arguments = sep->argnum; + if (!arguments) { + c->Message(Chat::White, "Usage: #modifynpcstat [Stat] [Value]"); + ListModifyNPCStatMap(c); + return; + } + + if (!c->GetTarget() || !c->GetTarget()->IsNPC()) { + c->Message(Chat::White, "You must target an NPC to use this command."); + return; + } + + auto target = c->GetTarget()->CastToNPC(); + + const std::string& stat = sep->arg[1] ? sep->arg[1] : ""; + const std::string& value = sep->arg[2] ? sep->arg[2] : ""; + + if (stat.empty() || value.empty()) { + c->Message(Chat::White, "Usage: #modifynpcstat [Stat] [Value]"); + ListModifyNPCStatMap(c); + return; + } + + auto stat_description = GetModifyNPCStatDescription(stat); + if (!stat_description.length()) { + c->Message( + Chat::White, + fmt::format( + "Stat '{}' does not exist.", + stat + ).c_str() + ); + return; + } + + target->ModifyNPCStat(stat, value); + + c->Message( + Chat::White, + fmt::format( + "Stat Modified | Target: {}", + c->GetTargetDescription(target) + ).c_str() + ); + + c->Message( + Chat::White, + fmt::format( + "Stat Modified | Stat: {} ({}) Value: {}", + GetModifyNPCStatDescription(stat), + stat, + value + ).c_str() + ); +} diff --git a/zone/gm_commands/mystats.cpp b/zone/gm_commands/mystats.cpp index 69343b304..fc16929d4 100755 --- a/zone/gm_commands/mystats.cpp +++ b/zone/gm_commands/mystats.cpp @@ -1,3 +1,4 @@ +#include "../bot.h" #include "../client.h" void command_mystats(Client *c, const Seperator *sep) diff --git a/zone/gm_commands/npcedit.cpp b/zone/gm_commands/npcedit.cpp index 54315070e..4f372b1e0 100755 --- a/zone/gm_commands/npcedit.cpp +++ b/zone/gm_commands/npcedit.cpp @@ -3,6 +3,115 @@ #include "../raids.h" #include "../../common/repositories/npc_types_repository.h" +void SendNPCEditSubCommands(Client *c) +{ + c->Message(Chat::White, "Usage: #npcedit name [Name] - Sets an NPC's Name"); + c->Message(Chat::White, "Usage: #npcedit lastname [Last Name] - Sets an NPC's Last Name"); + c->Message(Chat::White, "Usage: #npcedit level [Level] - Sets an NPC's Level"); + c->Message(Chat::White, "Usage: #npcedit race [Race ID] - Sets an NPC's Race"); + c->Message(Chat::White, "Usage: #npcedit class [Class ID] - Sets an NPC's Class"); + c->Message(Chat::White, "Usage: #npcedit bodytype [Body Type ID] - Sets an NPC's Bodytype"); + c->Message(Chat::White, "Usage: #npcedit hp [HP] - Sets an NPC's HP"); + c->Message(Chat::White, "Usage: #npcedit mana [Mana] - Sets an NPC's Mana"); + c->Message(Chat::White, "Usage: #npcedit gender [Gender ID] - Sets an NPC's Gender"); + c->Message(Chat::White, "Usage: #npcedit texture [Texture] - Sets an NPC's Texture"); + c->Message(Chat::White, "Usage: #npcedit helmtexture [Helmet Texture] - Sets an NPC's Helmet Texture"); + c->Message(Chat::White, "Usage: #npcedit herosforgemodel [Model Number] - Sets an NPC's Hero's Forge Model"); + c->Message(Chat::White, "Usage: #npcedit size [Size] - Sets an NPC's Size"); + c->Message(Chat::White, "Usage: #npcedit hpregen [HP Regen] - Sets an NPC's HP Regen Rate Per Tick"); + c->Message(Chat::White, "Usage: #npcedit hp_regen_per_second [HP Regen] - Sets an NPC's HP Regen Rate Per Second"); + c->Message(Chat::White, "Usage: #npcedit manaregen [Mana Regen] - Sets an NPC's Mana Regen Rate Per Tick"); + c->Message(Chat::White, "Usage: #npcedit loottable [Loottable ID] - Sets an NPC's Loottable ID"); + c->Message(Chat::White, "Usage: #npcedit merchantid [Merchant ID] - Sets an NPC's Merchant ID"); + c->Message(Chat::White, "Usage: #npcedit alt_currency_id [Alternate Currency ID] - Sets an NPC's Alternate Currency ID"); + c->Message(Chat::White, "Usage: #npcedit spell [Spell List ID] - Sets an NPC's Spells List ID"); + c->Message(Chat::White, "Usage: #npcedit npc_spells_effects_id [Spell Effects ID] - Sets an NPC's Spell Effects ID"); + c->Message(Chat::White, "Usage: #npcedit faction [Faction ID] - Sets an NPC's Faction ID"); + c->Message(Chat::White, "Usage: #npcedit adventure_template_id [Template ID] - Sets an NPC's Adventure Template ID"); + c->Message(Chat::White, "Usage: #npcedit trap_template [Template ID] - Sets an NPC's Trap Template ID"); + c->Message(Chat::White, "Usage: #npcedit damage [Minimum] [Maximum] - Sets an NPC's Damage"); + c->Message(Chat::White, "Usage: #npcedit attackcount [Attack Count] - Sets an NPC's Attack Count"); + c->Message(Chat::White, "Usage: #npcedit special_attacks [Special Attacks] - Sets an NPC's Special Attacks"); + c->Message(Chat::White, "Usage: #npcedit special_abilities [Special Abilities] - Sets an NPC's Special Abilities"); + c->Message(Chat::White, "Usage: #npcedit aggroradius [Radius] - Sets an NPC's Aggro Radius"); + c->Message(Chat::White, "Usage: #npcedit assistradius [Radius] - Sets an NPC's Assist Radius"); + c->Message(Chat::White, "Usage: #npcedit featuresave - Saves an NPC's current facial features to the database"); + c->Message(Chat::White, "Usage: #npcedit armortint_id [Armor Tint ID] - Sets an NPC's Armor Tint ID"); + c->Message(Chat::White, "Usage: #npcedit color [Red] [Green] [Blue] - Sets an NPC's Red, Green, and Blue armor tint"); + c->Message(Chat::White, "Usage: #npcedit ammoidfile [ID File] - Sets an NPC's Ammo ID File"); + c->Message(Chat::White, "Usage: #npcedit weapon [Primary Model] [Secondary Model] - Sets an NPC's Primary and Secondary Weapon Model"); + c->Message(Chat::White, "Usage: #npcedit meleetype [Primary Type] [Secondary Type] - Sets an NPC's Melee Skill Types"); + c->Message(Chat::White, "Usage: #npcedit rangedtype [Type] - Sets an NPC's Ranged Skill Type"); + c->Message(Chat::White, "Usage: #npcedit runspeed [Run Speed] - Sets an NPC's Run Speed"); + c->Message(Chat::White, "Usage: #npcedit mr [Resistance] - Sets an NPC's Magic Resistance"); + c->Message(Chat::White, "Usage: #npcedit pr [Resistance] - Sets an NPC's Poison Resistance"); + c->Message(Chat::White, "Usage: #npcedit dr [Resistance] - Sets an NPC's Disease Resistance"); + c->Message(Chat::White, "Usage: #npcedit fr [Resistance] - Sets an NPC's Fire Resistance"); + c->Message(Chat::White, "Usage: #npcedit cr [Resistance] - Sets an NPC's Cold Resistance"); + c->Message(Chat::White, "Usage: #npcedit corrup [Resistance] - Sets an NPC's Corruption Resistance"); + c->Message(Chat::White, "Usage: #npcedit phr [Resistance] - Sets and NPC's Physical Resistance"); + c->Message(Chat::White, "Usage: #npcedit seeinvis [Flag] - Sets an NPC's See Invisible Flag [0 = Cannot See Invisible, 1 = Can See Invisible]"); + c->Message(Chat::White, "Usage: #npcedit seeinvisundead [Flag] - Sets an NPC's See Invisible vs. Undead Flag [0 = Cannot See Invisible vs. Undead, 1 = Can See Invisible vs. Undead]"); + c->Message(Chat::White, "Usage: #npcedit qglobal [Flag] - Sets an NPC's Quest Global Flag [0 = Quest Globals Off, 1 = Quest Globals On]"); + c->Message(Chat::White, "Usage: #npcedit ac [Armor Class] - Sets an NPC's Armor Class"); + c->Message(Chat::White, "Usage: #npcedit npcaggro [Flag] - Sets an NPC's NPC Aggro Flag [0 = Aggro NPCs Off, 1 = Aggro NPCs On]"); + c->Message(Chat::White, "Usage: #npcedit spawn_limit [Limit] - Sets an NPC's Spawn Limit Counter"); + c->Message(Chat::White, "Usage: #npcedit attackspeed [Attack Speed] - Sets an NPC's Attack Speed Modifier"); + c->Message(Chat::White, "Usage: #npcedit attackdelay [Attack Delay] - Sets an NPC's Attack Delay"); + c->Message(Chat::White, "Usage: #npcedit findable [Flag] - Sets an NPC's Findable Flag [0 = Not Findable, 1 = Findable]"); + c->Message(Chat::White, "Usage: #npcedit str [Strength] - Sets an NPC's Strength"); + c->Message(Chat::White, "Usage: #npcedit sta [Stamina] - Sets an NPC's Stamina"); + c->Message(Chat::White, "Usage: #npcedit agi [Agility] - Sets an NPC's Agility"); + c->Message(Chat::White, "Usage: #npcedit dex [Dexterity] - Sets an NPC's Dexterity"); + c->Message(Chat::White, "Usage: #npcedit int [Intelligence] - Sets an NPC's Intelligence"); + c->Message(Chat::White, "Usage: #npcedit wis [Wisdom] - Sets an NPC's Wisdom"); + c->Message(Chat::White, "Usage: #npcedit cha [Charisma] - Sets an NPC's Charisma"); + c->Message(Chat::White, "Usage: #npcedit seehide [Flag] - Sets an NPC's See Hide Flag [0 = Cannot See Hide, 1 = Can See Hide]"); + c->Message(Chat::White, "Usage: #npcedit seeimprovedhide [Flag] - Sets an NPC's See Improved Hide Flag [0 = Cannot See Improved Hide, 1 = Can See Improved Hide]"); + c->Message(Chat::White, "Usage: #npcedit trackable [Flag] - Sets an NPC's Trackable Flag [0 = Not Trackable, 1 = Trackable]"); + c->Message(Chat::White, "Usage: #npcedit atk [Attack] - Sets an NPC's Attack"); + c->Message(Chat::White, "Usage: #npcedit accuracy [Accuracy] - Sets an NPC's Accuracy"); + c->Message(Chat::White, "Usage: #npcedit avoidance [Avoidance] - Sets an NPC's Avoidance"); + c->Message(Chat::White, "Usage: #npcedit slow_mitigation [Slow Mitigation] - Sets an NPC's Slow Mitigation"); + c->Message(Chat::White, "Usage: #npcedit version [Version] - Sets an NPC's Version"); + c->Message(Chat::White, "Usage: #npcedit maxlevel [Max Level] - Sets an NPC's Maximum Level"); + c->Message(Chat::White, "Usage: #npcedit scalerate [Scale Rate] - Sets an NPC's Scaling Rate [50 = 50%, 100 = 100%, 200 = 200%]"); + c->Message(Chat::White, "Usage: #npcedit emoteid [Emote ID] - Sets an NPC's Emote ID"); + c->Message(Chat::White, "Usage: #npcedit spellscale [Scale Rate] - Sets an NPC's Spell Scaling Rate [50 = 50%, 100 = 100%, 200 = 200%]"); + c->Message(Chat::White, "Usage: #npcedit healscale [Scale Rate] - Sets an NPC's Heal Scaling Rate [50 = 50%, 100 = 100%, 200 = 200%]"); + c->Message(Chat::White, "Usage: #npcedit no_target [Flag] - Sets an NPC's No Target Hotkey Flag [0 = Not Targetable with Target Hotkey, 1 = Targetable with Target Hotkey]"); + c->Message(Chat::White, "Usage: #npcedit raidtarget [Flag] - Sets an NPC's Raid Target Flag [0 = Not a Raid Target, 1 = Raid Target]"); + c->Message(Chat::White, "Usage: #npcedit armtexture [Texture] - Sets an NPC's Arm Texture"); + c->Message(Chat::White, "Usage: #npcedit bracertexture [Texture] - Sets an NPC's Bracer Texture"); + c->Message(Chat::White, "Usage: #npcedit handtexture [Texture] - Sets an NPC's Hand Texture"); + c->Message(Chat::White, "Usage: #npcedit legtexture [Texture] - Sets an NPC's Leg Texture"); + c->Message(Chat::White, "Usage: #npcedit feettexture [Texture] - Sets an NPC's Feet Texture"); + c->Message(Chat::White, "Usage: #npcedit walkspeed [Walk Speed] - Sets an NPC's Walk Speed"); + c->Message(Chat::White, "Usage: #npcedit show_name [Flag] - Sets an NPC's Show Name Flag [0 = Hidden, 1 = Shown]"); + c->Message(Chat::White, "Usage: #npcedit untargetable [Flag] - Sets an NPC's Untargetable Flag [0 = Targetable, 1 = Untargetable]"); + c->Message(Chat::White, "Usage: #npcedit charm_ac [Armor Class] - Sets an NPC's Armor Class while Charmed"); + c->Message(Chat::White, "Usage: #npcedit charm_min_dmg [Damage] - Sets an NPC's Minimum Damage while Charmed"); + c->Message(Chat::White, "Usage: #npcedit charm_max_dmg [Damage] - Sets an NPC's Maximum Damage while Charmed"); + c->Message(Chat::White, "Usage: #npcedit charm_attack_delay [Attack Delay] - Sets an NPC's Attack Delay while Charmed"); + c->Message(Chat::White, "Usage: #npcedit charm_accuracy_rating [Accuracy] - Sets an NPC's Accuracy Rating while Charmed"); + c->Message(Chat::White, "Usage: #npcedit charm_avoidance_rating [Avoidance] - Sets an NPC's Avoidance Rating while Charmed"); + c->Message(Chat::White, "Usage: #npcedit charm_atk [Attack] - Sets an NPC's Attack while Charmed"); + c->Message(Chat::White, "Usage: #npcedit skip_global_loot [Flag] - Sets an NPC's Skip Global Loot Flag [0 = Don't Skip, 1 = Skip"); + c->Message(Chat::White, "Usage: #npcedit rarespawn [Flag] - Sets an NPC's Rare Spawn Flag [0 = Not a Rare Spawn, 1 = Rare Spawn]"); + c->Message(Chat::White, "Usage: #npcedit stuck_behavior [Stuck Behavior] - Sets an NPC's Stuck Behavior [0 = Run to Target, 1 = Warp to Target, 2 = Take No Action, 3 = Evade Combat]"); + c->Message(Chat::White, "Usage: #npcedit model [Race ID] - Sets an NPC's Race Model"); + c->Message(Chat::White, "Usage: #npcedit flymode [Fly Mode] - Sets an NPC's Fly Mode [0 = Ground, 1 = Flying, 2 = Levitating, 3 = Water, 4 = Floating, 5 = Levitating While Running]"); + c->Message(Chat::White, "Usage: #npcedit always_aggro [Flag] - Sets an NPC's Always Aggro Flag [0 = Does not Always Aggro, 1 = Always Aggro]"); + c->Message(Chat::White, "Usage: #npcedit exp_mod [Modifier] - Sets an NPC's Experience Modifier [50 = 50%, 100 = 100%, 200 = 200%]"); + c->Message(Chat::White, "Usage: #npcedit heroic_strikethrough [Heroic Strikethrough] - Sets an NPC's Heroic Strikethrough"); + c->Message(Chat::White, "Usage: #npcedit faction_amount [Faction Amount] - Sets an NPC's Faction Amount"); + c->Message(Chat::White, "Usage: #npcedit keeps_sold_items [Flag] - Sets an NPC's Keeps Sold Items Flag [0 = False, 1 = True]"); + c->Message(Chat::White, "Usage: #npcedit is_parcel_merchant [Flag] - Sets an NPC's Parcel Merchant Flag [0 = False, 1 = True]"); + c->Message(Chat::White, "Usage: #npcedit setanimation [Animation ID] - Sets an NPC's Animation on Spawn (Stored in spawn2 table)"); + c->Message(Chat::White, "Usage: #npcedit respawntime [Respawn Time] - Sets an NPC's Respawn Timer in Seconds (Stored in spawn2 table)"); + c->Message(Chat::White, "Usage: #npcedit set_grid [Grid ID] - Sets an NPC's Grid ID"); +} + void command_npcedit(Client *c, const Seperator *sep) { if (!c->GetTarget() || !c->GetTarget()->IsNPC()) { @@ -1727,113 +1836,4 @@ void command_npcedit(Client *c, const Seperator *sep) } c->Message(Chat::White, d.c_str()); -} - -void SendNPCEditSubCommands(Client *c) -{ - c->Message(Chat::White, "Usage: #npcedit name [Name] - Sets an NPC's Name"); - c->Message(Chat::White, "Usage: #npcedit lastname [Last Name] - Sets an NPC's Last Name"); - c->Message(Chat::White, "Usage: #npcedit level [Level] - Sets an NPC's Level"); - c->Message(Chat::White, "Usage: #npcedit race [Race ID] - Sets an NPC's Race"); - c->Message(Chat::White, "Usage: #npcedit class [Class ID] - Sets an NPC's Class"); - c->Message(Chat::White, "Usage: #npcedit bodytype [Body Type ID] - Sets an NPC's Bodytype"); - c->Message(Chat::White, "Usage: #npcedit hp [HP] - Sets an NPC's HP"); - c->Message(Chat::White, "Usage: #npcedit mana [Mana] - Sets an NPC's Mana"); - c->Message(Chat::White, "Usage: #npcedit gender [Gender ID] - Sets an NPC's Gender"); - c->Message(Chat::White, "Usage: #npcedit texture [Texture] - Sets an NPC's Texture"); - c->Message(Chat::White, "Usage: #npcedit helmtexture [Helmet Texture] - Sets an NPC's Helmet Texture"); - c->Message(Chat::White, "Usage: #npcedit herosforgemodel [Model Number] - Sets an NPC's Hero's Forge Model"); - c->Message(Chat::White, "Usage: #npcedit size [Size] - Sets an NPC's Size"); - c->Message(Chat::White, "Usage: #npcedit hpregen [HP Regen] - Sets an NPC's HP Regen Rate Per Tick"); - c->Message(Chat::White, "Usage: #npcedit hp_regen_per_second [HP Regen] - Sets an NPC's HP Regen Rate Per Second"); - c->Message(Chat::White, "Usage: #npcedit manaregen [Mana Regen] - Sets an NPC's Mana Regen Rate Per Tick"); - c->Message(Chat::White, "Usage: #npcedit loottable [Loottable ID] - Sets an NPC's Loottable ID"); - c->Message(Chat::White, "Usage: #npcedit merchantid [Merchant ID] - Sets an NPC's Merchant ID"); - c->Message(Chat::White, "Usage: #npcedit alt_currency_id [Alternate Currency ID] - Sets an NPC's Alternate Currency ID"); - c->Message(Chat::White, "Usage: #npcedit spell [Spell List ID] - Sets an NPC's Spells List ID"); - c->Message(Chat::White, "Usage: #npcedit npc_spells_effects_id [Spell Effects ID] - Sets an NPC's Spell Effects ID"); - c->Message(Chat::White, "Usage: #npcedit faction [Faction ID] - Sets an NPC's Faction ID"); - c->Message(Chat::White, "Usage: #npcedit adventure_template_id [Template ID] - Sets an NPC's Adventure Template ID"); - c->Message(Chat::White, "Usage: #npcedit trap_template [Template ID] - Sets an NPC's Trap Template ID"); - c->Message(Chat::White, "Usage: #npcedit damage [Minimum] [Maximum] - Sets an NPC's Damage"); - c->Message(Chat::White, "Usage: #npcedit attackcount [Attack Count] - Sets an NPC's Attack Count"); - c->Message(Chat::White, "Usage: #npcedit special_attacks [Special Attacks] - Sets an NPC's Special Attacks"); - c->Message(Chat::White, "Usage: #npcedit special_abilities [Special Abilities] - Sets an NPC's Special Abilities"); - c->Message(Chat::White, "Usage: #npcedit aggroradius [Radius] - Sets an NPC's Aggro Radius"); - c->Message(Chat::White, "Usage: #npcedit assistradius [Radius] - Sets an NPC's Assist Radius"); - c->Message(Chat::White, "Usage: #npcedit featuresave - Saves an NPC's current facial features to the database"); - c->Message(Chat::White, "Usage: #npcedit armortint_id [Armor Tint ID] - Sets an NPC's Armor Tint ID"); - c->Message(Chat::White, "Usage: #npcedit color [Red] [Green] [Blue] - Sets an NPC's Red, Green, and Blue armor tint"); - c->Message(Chat::White, "Usage: #npcedit ammoidfile [ID File] - Sets an NPC's Ammo ID File"); - c->Message(Chat::White, "Usage: #npcedit weapon [Primary Model] [Secondary Model] - Sets an NPC's Primary and Secondary Weapon Model"); - c->Message(Chat::White, "Usage: #npcedit meleetype [Primary Type] [Secondary Type] - Sets an NPC's Melee Skill Types"); - c->Message(Chat::White, "Usage: #npcedit rangedtype [Type] - Sets an NPC's Ranged Skill Type"); - c->Message(Chat::White, "Usage: #npcedit runspeed [Run Speed] - Sets an NPC's Run Speed"); - c->Message(Chat::White, "Usage: #npcedit mr [Resistance] - Sets an NPC's Magic Resistance"); - c->Message(Chat::White, "Usage: #npcedit pr [Resistance] - Sets an NPC's Poison Resistance"); - c->Message(Chat::White, "Usage: #npcedit dr [Resistance] - Sets an NPC's Disease Resistance"); - c->Message(Chat::White, "Usage: #npcedit fr [Resistance] - Sets an NPC's Fire Resistance"); - c->Message(Chat::White, "Usage: #npcedit cr [Resistance] - Sets an NPC's Cold Resistance"); - c->Message(Chat::White, "Usage: #npcedit corrup [Resistance] - Sets an NPC's Corruption Resistance"); - c->Message(Chat::White, "Usage: #npcedit phr [Resistance] - Sets and NPC's Physical Resistance"); - c->Message(Chat::White, "Usage: #npcedit seeinvis [Flag] - Sets an NPC's See Invisible Flag [0 = Cannot See Invisible, 1 = Can See Invisible]"); - c->Message(Chat::White, "Usage: #npcedit seeinvisundead [Flag] - Sets an NPC's See Invisible vs. Undead Flag [0 = Cannot See Invisible vs. Undead, 1 = Can See Invisible vs. Undead]"); - c->Message(Chat::White, "Usage: #npcedit qglobal [Flag] - Sets an NPC's Quest Global Flag [0 = Quest Globals Off, 1 = Quest Globals On]"); - c->Message(Chat::White, "Usage: #npcedit ac [Armor Class] - Sets an NPC's Armor Class"); - c->Message(Chat::White, "Usage: #npcedit npcaggro [Flag] - Sets an NPC's NPC Aggro Flag [0 = Aggro NPCs Off, 1 = Aggro NPCs On]"); - c->Message(Chat::White, "Usage: #npcedit spawn_limit [Limit] - Sets an NPC's Spawn Limit Counter"); - c->Message(Chat::White, "Usage: #npcedit attackspeed [Attack Speed] - Sets an NPC's Attack Speed Modifier"); - c->Message(Chat::White, "Usage: #npcedit attackdelay [Attack Delay] - Sets an NPC's Attack Delay"); - c->Message(Chat::White, "Usage: #npcedit findable [Flag] - Sets an NPC's Findable Flag [0 = Not Findable, 1 = Findable]"); - c->Message(Chat::White, "Usage: #npcedit str [Strength] - Sets an NPC's Strength"); - c->Message(Chat::White, "Usage: #npcedit sta [Stamina] - Sets an NPC's Stamina"); - c->Message(Chat::White, "Usage: #npcedit agi [Agility] - Sets an NPC's Agility"); - c->Message(Chat::White, "Usage: #npcedit dex [Dexterity] - Sets an NPC's Dexterity"); - c->Message(Chat::White, "Usage: #npcedit int [Intelligence] - Sets an NPC's Intelligence"); - c->Message(Chat::White, "Usage: #npcedit wis [Wisdom] - Sets an NPC's Wisdom"); - c->Message(Chat::White, "Usage: #npcedit cha [Charisma] - Sets an NPC's Charisma"); - c->Message(Chat::White, "Usage: #npcedit seehide [Flag] - Sets an NPC's See Hide Flag [0 = Cannot See Hide, 1 = Can See Hide]"); - c->Message(Chat::White, "Usage: #npcedit seeimprovedhide [Flag] - Sets an NPC's See Improved Hide Flag [0 = Cannot See Improved Hide, 1 = Can See Improved Hide]"); - c->Message(Chat::White, "Usage: #npcedit trackable [Flag] - Sets an NPC's Trackable Flag [0 = Not Trackable, 1 = Trackable]"); - c->Message(Chat::White, "Usage: #npcedit atk [Attack] - Sets an NPC's Attack"); - c->Message(Chat::White, "Usage: #npcedit accuracy [Accuracy] - Sets an NPC's Accuracy"); - c->Message(Chat::White, "Usage: #npcedit avoidance [Avoidance] - Sets an NPC's Avoidance"); - c->Message(Chat::White, "Usage: #npcedit slow_mitigation [Slow Mitigation] - Sets an NPC's Slow Mitigation"); - c->Message(Chat::White, "Usage: #npcedit version [Version] - Sets an NPC's Version"); - c->Message(Chat::White, "Usage: #npcedit maxlevel [Max Level] - Sets an NPC's Maximum Level"); - c->Message(Chat::White, "Usage: #npcedit scalerate [Scale Rate] - Sets an NPC's Scaling Rate [50 = 50%, 100 = 100%, 200 = 200%]"); - c->Message(Chat::White, "Usage: #npcedit emoteid [Emote ID] - Sets an NPC's Emote ID"); - c->Message(Chat::White, "Usage: #npcedit spellscale [Scale Rate] - Sets an NPC's Spell Scaling Rate [50 = 50%, 100 = 100%, 200 = 200%]"); - c->Message(Chat::White, "Usage: #npcedit healscale [Scale Rate] - Sets an NPC's Heal Scaling Rate [50 = 50%, 100 = 100%, 200 = 200%]"); - c->Message(Chat::White, "Usage: #npcedit no_target [Flag] - Sets an NPC's No Target Hotkey Flag [0 = Not Targetable with Target Hotkey, 1 = Targetable with Target Hotkey]"); - c->Message(Chat::White, "Usage: #npcedit raidtarget [Flag] - Sets an NPC's Raid Target Flag [0 = Not a Raid Target, 1 = Raid Target]"); - c->Message(Chat::White, "Usage: #npcedit armtexture [Texture] - Sets an NPC's Arm Texture"); - c->Message(Chat::White, "Usage: #npcedit bracertexture [Texture] - Sets an NPC's Bracer Texture"); - c->Message(Chat::White, "Usage: #npcedit handtexture [Texture] - Sets an NPC's Hand Texture"); - c->Message(Chat::White, "Usage: #npcedit legtexture [Texture] - Sets an NPC's Leg Texture"); - c->Message(Chat::White, "Usage: #npcedit feettexture [Texture] - Sets an NPC's Feet Texture"); - c->Message(Chat::White, "Usage: #npcedit walkspeed [Walk Speed] - Sets an NPC's Walk Speed"); - c->Message(Chat::White, "Usage: #npcedit show_name [Flag] - Sets an NPC's Show Name Flag [0 = Hidden, 1 = Shown]"); - c->Message(Chat::White, "Usage: #npcedit untargetable [Flag] - Sets an NPC's Untargetable Flag [0 = Targetable, 1 = Untargetable]"); - c->Message(Chat::White, "Usage: #npcedit charm_ac [Armor Class] - Sets an NPC's Armor Class while Charmed"); - c->Message(Chat::White, "Usage: #npcedit charm_min_dmg [Damage] - Sets an NPC's Minimum Damage while Charmed"); - c->Message(Chat::White, "Usage: #npcedit charm_max_dmg [Damage] - Sets an NPC's Maximum Damage while Charmed"); - c->Message(Chat::White, "Usage: #npcedit charm_attack_delay [Attack Delay] - Sets an NPC's Attack Delay while Charmed"); - c->Message(Chat::White, "Usage: #npcedit charm_accuracy_rating [Accuracy] - Sets an NPC's Accuracy Rating while Charmed"); - c->Message(Chat::White, "Usage: #npcedit charm_avoidance_rating [Avoidance] - Sets an NPC's Avoidance Rating while Charmed"); - c->Message(Chat::White, "Usage: #npcedit charm_atk [Attack] - Sets an NPC's Attack while Charmed"); - c->Message(Chat::White, "Usage: #npcedit skip_global_loot [Flag] - Sets an NPC's Skip Global Loot Flag [0 = Don't Skip, 1 = Skip"); - c->Message(Chat::White, "Usage: #npcedit rarespawn [Flag] - Sets an NPC's Rare Spawn Flag [0 = Not a Rare Spawn, 1 = Rare Spawn]"); - c->Message(Chat::White, "Usage: #npcedit stuck_behavior [Stuck Behavior] - Sets an NPC's Stuck Behavior [0 = Run to Target, 1 = Warp to Target, 2 = Take No Action, 3 = Evade Combat]"); - c->Message(Chat::White, "Usage: #npcedit model [Race ID] - Sets an NPC's Race Model"); - c->Message(Chat::White, "Usage: #npcedit flymode [Fly Mode] - Sets an NPC's Fly Mode [0 = Ground, 1 = Flying, 2 = Levitating, 3 = Water, 4 = Floating, 5 = Levitating While Running]"); - c->Message(Chat::White, "Usage: #npcedit always_aggro [Flag] - Sets an NPC's Always Aggro Flag [0 = Does not Always Aggro, 1 = Always Aggro]"); - c->Message(Chat::White, "Usage: #npcedit exp_mod [Modifier] - Sets an NPC's Experience Modifier [50 = 50%, 100 = 100%, 200 = 200%]"); - c->Message(Chat::White, "Usage: #npcedit heroic_strikethrough [Heroic Strikethrough] - Sets an NPC's Heroic Strikethrough"); - c->Message(Chat::White, "Usage: #npcedit faction_amount [Faction Amount] - Sets an NPC's Faction Amount"); - c->Message(Chat::White, "Usage: #npcedit keeps_sold_items [Flag] - Sets an NPC's Keeps Sold Items Flag [0 = False, 1 = True]"); - c->Message(Chat::White, "Usage: #npcedit is_parcel_merchant [Flag] - Sets an NPC's Parcel Merchant Flag [0 = False, 1 = True]"); - c->Message(Chat::White, "Usage: #npcedit setanimation [Animation ID] - Sets an NPC's Animation on Spawn (Stored in spawn2 table)"); - c->Message(Chat::White, "Usage: #npcedit respawntime [Respawn Time] - Sets an NPC's Respawn Timer in Seconds (Stored in spawn2 table)"); - c->Message(Chat::White, "Usage: #npcedit set_grid [Grid ID] - Sets an NPC's Grid ID"); -} +} \ No newline at end of file diff --git a/zone/gm_commands/parcels.cpp b/zone/gm_commands/parcels.cpp index 07cb8244c..141dfdd69 100644 --- a/zone/gm_commands/parcels.cpp +++ b/zone/gm_commands/parcels.cpp @@ -1,9 +1,23 @@ #include "../client.h" +#include "../queryserv.h" #include "../worldserver.h" -#include "../../common/events/player_events.h" +#include "../../common/events/player_event_logs.h" +#include "../string_ids.h" +extern QueryServ *QServ; extern WorldServer worldserver; +void SendParcelsSubCommands(Client *c) +{ + c->Message(Chat::White, "#parcels listdb [Character Name]"); + c->Message(Chat::White, "#parcels listmemory [Character Name] (Must be in the same zone)"); + c->Message( + Chat::White, + "#parcels add [Character Name] [item id] [quantity] [note]. To send money use item id of 99990. Quantity is valid for stackable items, charges on an item, or amount of copper." + ); + c->Message(Chat::White, "#parcels details [Character Name]"); +} + void command_parcels(Client *c, const Seperator *sep) { const auto arguments = sep->argnum; @@ -305,15 +319,4 @@ void command_parcels(Client *c, const Seperator *sep) c->SendParcelDeliveryToWorld(ps); } } -} - -void SendParcelsSubCommands(Client *c) -{ - c->Message(Chat::White, "#parcels listdb [Character Name]"); - c->Message(Chat::White, "#parcels listmemory [Character Name] (Must be in the same zone)"); - c->Message( - Chat::White, - "#parcels add [Character Name] [item id] [quantity] [note]. To send money use item id of 99990. Quantity is valid for stackable items, charges on an item, or amount of copper." - ); - c->Message(Chat::White, "#parcels details [Character Name]"); -} +} \ No newline at end of file diff --git a/zone/gm_commands/petitems.cpp b/zone/gm_commands/petitems.cpp index 5fded03cc..6dd6462e5 100644 --- a/zone/gm_commands/petitems.cpp +++ b/zone/gm_commands/petitems.cpp @@ -1,3 +1,4 @@ +#include "../bot.h" #include "../client.h" void command_petitems(Client *c, const Seperator *sep) diff --git a/zone/gm_commands/set/haste.cpp b/zone/gm_commands/set/haste.cpp index a7e9b118f..96647c970 100644 --- a/zone/gm_commands/set/haste.cpp +++ b/zone/gm_commands/set/haste.cpp @@ -1,3 +1,4 @@ +#include "../../bot.h" #include "../../client.h" void SetHaste(Client *c, const Seperator *sep) diff --git a/zone/gm_commands/set/zone.cpp b/zone/gm_commands/set/zone.cpp index e1bf852ea..0ff3c24cb 100755 --- a/zone/gm_commands/set/zone.cpp +++ b/zone/gm_commands/set/zone.cpp @@ -273,7 +273,7 @@ void SetZoneData(Client *c, const Seperator *sep) entity_list.QueueClients(c, outapp); safe_delete(outapp); - zone_store.LoadZones(content_db); + ZoneStore::Instance()->LoadZones(content_db); c->Message( Chat::White, diff --git a/zone/gm_commands/show/inventory.cpp b/zone/gm_commands/show/inventory.cpp index 2cffdc82f..2a3e2a377 100644 --- a/zone/gm_commands/show/inventory.cpp +++ b/zone/gm_commands/show/inventory.cpp @@ -1,6 +1,22 @@ #include "../../client.h" #include "../../object.h" +void SendShowInventorySubCommands(Client* c) { + c->Message(Chat::White, "Usage: #show inventory equip - Shows items in Equipment slots"); + c->Message(Chat::White, "Usage: #show inventory gen - Shows items in General slots"); + c->Message(Chat::White, "Usage: #show inventory cursor - Shows items in Cursor slots"); + c->Message(Chat::White, "Usage: #show inventory poss - Shows items in Equipment, General, and Cursor slots"); + c->Message(Chat::White, "Usage: #show inventory limbo - Shows items in Limbo slots"); + c->Message(Chat::White, "Usage: #show inventory curlim - Shows items in Cursor and Limbo slots"); + c->Message(Chat::White, "Usage: #show inventory trib - Shows items in Tribute slots"); + c->Message(Chat::White, "Usage: #show inventory bank - Shows items in Bank slots"); + c->Message(Chat::White, "Usage: #show inventory shbank - Shows items in Shared Bank slots"); + c->Message(Chat::White, "Usage: #show inventory allbank - Shows items in Bank and Shared Bank slots"); + c->Message(Chat::White, "Usage: #show inventory trade - Shows items in Trade slots"); + c->Message(Chat::White, "Usage: #show inventory world - Shows items in World slots"); + c->Message(Chat::White, "Usage: #show inventory all - Shows items in all slots"); +} + void ShowInventory(Client *c, const Seperator *sep) { const auto arguments = sep->argnum; @@ -432,20 +448,4 @@ void ShowInventory(Client *c, const Seperator *sep) if (!found_items) { c->Message(Chat::White, "No items found."); } -} - -void SendShowInventorySubCommands(Client* c) { - c->Message(Chat::White, "Usage: #show inventory equip - Shows items in Equipment slots"); - c->Message(Chat::White, "Usage: #show inventory gen - Shows items in General slots"); - c->Message(Chat::White, "Usage: #show inventory cursor - Shows items in Cursor slots"); - c->Message(Chat::White, "Usage: #show inventory poss - Shows items in Equipment, General, and Cursor slots"); - c->Message(Chat::White, "Usage: #show inventory limbo - Shows items in Limbo slots"); - c->Message(Chat::White, "Usage: #show inventory curlim - Shows items in Cursor and Limbo slots"); - c->Message(Chat::White, "Usage: #show inventory trib - Shows items in Tribute slots"); - c->Message(Chat::White, "Usage: #show inventory bank - Shows items in Bank slots"); - c->Message(Chat::White, "Usage: #show inventory shbank - Shows items in Shared Bank slots"); - c->Message(Chat::White, "Usage: #show inventory allbank - Shows items in Bank and Shared Bank slots"); - c->Message(Chat::White, "Usage: #show inventory trade - Shows items in Trade slots"); - c->Message(Chat::White, "Usage: #show inventory world - Shows items in World slots"); - c->Message(Chat::White, "Usage: #show inventory all - Shows items in all slots"); -} +} \ No newline at end of file diff --git a/zone/gm_commands/task.cpp b/zone/gm_commands/task.cpp index bd28c2518..407184f59 100755 --- a/zone/gm_commands/task.cpp +++ b/zone/gm_commands/task.cpp @@ -176,7 +176,7 @@ void command_task(Client *c, const Seperator *sep) Chat::White, fmt::format( "Assigned {} (ID {}) to {}.", - task_manager->GetTaskName(task_id), + TaskManager::Instance()->GetTaskName(task_id), task_id, c->GetTargetDescription(t) ).c_str() @@ -197,7 +197,7 @@ void command_task(Client *c, const Seperator *sep) Chat::White, fmt::format( "Successfully completed {} (ID {}) for {}.", - task_manager->GetTaskName(task_id), + TaskManager::Instance()->GetTaskName(task_id), task_id, c->GetTargetDescription(t) ).c_str() @@ -207,7 +207,7 @@ void command_task(Client *c, const Seperator *sep) Chat::White, fmt::format( "Failed to complete {} (ID {}) for {}.", - task_manager->GetTaskName(task_id), + TaskManager::Instance()->GetTaskName(task_id), task_id, c->GetTargetDescription(t) ).c_str() @@ -220,7 +220,7 @@ void command_task(Client *c, const Seperator *sep) "{} {} not have not {} (ID {}) assigned to them.", c->GetTargetDescription(t, TargetDescriptionType::UCYou), c == t ? "do" : "does", - task_manager->GetTaskName(task_id), + TaskManager::Instance()->GetTaskName(task_id), task_id ).c_str() ); @@ -256,7 +256,7 @@ void command_task(Client *c, const Seperator *sep) Chat::White, fmt::format( "Attempting to reload {} (ID {}).", - task_manager->GetTaskName(task_id), + TaskManager::Instance()->GetTaskName(task_id), task_id ).c_str() ); @@ -265,7 +265,7 @@ void command_task(Client *c, const Seperator *sep) Chat::White, fmt::format( "Successfully reloaded {} (ID {}).", - task_manager->GetTaskName(task_id), + TaskManager::Instance()->GetTaskName(task_id), task_id ).c_str() ); @@ -304,21 +304,12 @@ void command_task(Client *c, const Seperator *sep) return; } - if ( - CompletedTasksRepository::DeleteWhere( - database, - fmt::format( - "charid = {} AND taskid = {}", - t->CharacterID(), - task_id - ) - ) - ) { + if (t->UncompleteTask(task_id)) { c->Message( Chat::White, fmt::format( "Successfully uncompleted {} (ID {}) for {}.", - task_manager->GetTaskName(task_id), + TaskManager::Instance()->GetTaskName(task_id), task_id, c->GetTargetDescription(t) ).c_str() @@ -330,7 +321,7 @@ void command_task(Client *c, const Seperator *sep) "{} {} not completed {} (ID {}).", c->GetTargetDescription(t, TargetDescriptionType::UCYou), c == t ? "have" : "has", - task_manager->GetTaskName(task_id), + TaskManager::Instance()->GetTaskName(task_id), task_id ).c_str() ); @@ -353,7 +344,7 @@ void command_task(Client *c, const Seperator *sep) Chat::White, fmt::format( "Updating {} (ID {}), activity {} with a count of {} for {}.", - task_manager->GetTaskName(task_id), + TaskManager::Instance()->GetTaskName(task_id), task_id, activity_id, count, diff --git a/zone/gm_commands/zone.cpp b/zone/gm_commands/zone.cpp index 13601da4d..46caf373f 100644 --- a/zone/gm_commands/zone.cpp +++ b/zone/gm_commands/zone.cpp @@ -1,3 +1,4 @@ +#include "../bot.h" #include "../client.h" void command_zone(Client *c, const Seperator *sep) @@ -25,7 +26,7 @@ void command_zone(Client *c, const Seperator *sep) } else { // validate - if (!zone_store.GetZone(zone_input)) { + if (!ZoneStore::Instance()->GetZone(zone_input)) { c->Message(Chat::White, fmt::format("Could not find zone by short_name [{}]", zone_input).c_str()); return; } diff --git a/zone/gm_commands/zone_shard.cpp b/zone/gm_commands/zone_shard.cpp index 07ef0541e..9e468ba7d 100644 --- a/zone/gm_commands/zone_shard.cpp +++ b/zone/gm_commands/zone_shard.cpp @@ -31,7 +31,7 @@ void command_zone_shard(Client *c, const Seperator *sep) } else { // validate - if (!zone_store.GetZone(zone_input)) { + if (!ZoneStore::Instance()->GetZone(zone_input)) { c->Message(Chat::White, fmt::format("Could not find zone by short_name [{}]", zone_input).c_str()); return; } diff --git a/zone/guild_mgr.h b/zone/guild_mgr.h index 1c12cd669..0b59bd1f6 100644 --- a/zone/guild_mgr.h +++ b/zone/guild_mgr.h @@ -9,7 +9,6 @@ #include "../common/repositories/guild_bank_repository.h" #include "../zone/petitions.h" -extern PetitionList petition_list; //extern GuildRanks_Struct guilds[512]; //extern ZoneDatabase database; diff --git a/zone/inventory.cpp b/zone/inventory.cpp index 78fc3bef5..f2a0faaa7 100644 --- a/zone/inventory.cpp +++ b/zone/inventory.cpp @@ -688,7 +688,7 @@ void Client::DropItem(int16 slot_id, bool recurse) LogInventory("Error in InventoryProfile::CheckNoDrop() - returned 'true' for empty slot"); } else { - if (LogSys.log_settings[Logs::Inventory].is_category_enabled) { + if (EQEmuLogSys::Instance()->log_settings[Logs::Inventory].is_category_enabled) { LogInventory("DropItem() Hack detected - full item parse:"); LogInventory("depth: 0, Item: [{}] (id: [{}]), IsDroppable: [{}]", (invalid_drop->GetItem() ? invalid_drop->GetItem()->Name : "null data"), invalid_drop->GetID(), (invalid_drop->IsDroppable(false) ? "true" : "false")); @@ -720,7 +720,7 @@ void Client::DropItem(int16 slot_id, bool recurse) // Take control of item in client inventory auto* inst = m_inv.PopItem(slot_id); if (inst) { - if (LogSys.log_settings[Logs::Inventory].is_category_enabled) { + if (EQEmuLogSys::Instance()->log_settings[Logs::Inventory].is_category_enabled) { LogInventory("DropItem() Processing - full item parse:"); LogInventory( "depth: 0, Item: [{}] (id: [{}]), IsDroppable: [{}]", diff --git a/zone/loot.cpp b/zone/loot.cpp index e78c8f519..226a40a57 100644 --- a/zone/loot.cpp +++ b/zone/loot.cpp @@ -292,7 +292,7 @@ void NPC::AddLootDrop( auto item = new LootItem; - if (LogSys.log_settings[Logs::Loot].is_category_enabled == 1) { + if (EQEmuLogSys::Instance()->log_settings[Logs::Loot].is_category_enabled == 1) { EQ::SayLinkEngine linker; linker.SetLinkType(EQ::saylink::SayLinkItemData); linker.SetItemData(item2); diff --git a/zone/lua_client.cpp b/zone/lua_client.cpp index ece5d4594..b99636f19 100644 --- a/zone/lua_client.cpp +++ b/zone/lua_client.cpp @@ -3584,6 +3584,24 @@ bool Lua_Client::KeyRingRemove(uint32 item_id) return self->KeyRingRemove(item_id); } + +bool Lua_Client::CompleteTask(int task_id) +{ + Lua_Safe_Call_Bool(); + return self->CompleteTask(task_id); +} + +bool Lua_Client::UncompleteTask(int task_id) +{ + Lua_Safe_Call_Bool(); + return self->UncompleteTask(task_id); +} + +void Lua_Client::EnableTitleSet(uint32 title_set) { + Lua_Safe_Call_Void(); + self->EnableTitle(title_set); +} + luabind::scope lua_register_client() { return luabind::class_("Client") .def(luabind::constructor<>()) @@ -3663,6 +3681,7 @@ luabind::scope lua_register_client() { .def("ClearPEQZoneFlag", (void(Lua_Client::*)(uint32))&Lua_Client::ClearPEQZoneFlag) .def("ClearXTargets", (void(Lua_Client::*)(void))&Lua_Client::ClearXTargets) .def("ClearZoneFlag", (void(Lua_Client::*)(uint32))&Lua_Client::ClearZoneFlag) + .def("CompleteTask", (bool(Lua_Client::*)(int))&Lua_Client::CompleteTask) .def("Connected", (bool(Lua_Client::*)(void))&Lua_Client::Connected) .def("CountAugmentEquippedByID", (uint32(Lua_Client::*)(uint32))&Lua_Client::CountAugmentEquippedByID) .def("CountItem", (uint32(Lua_Client::*)(uint32))&Lua_Client::CountItem) @@ -3693,6 +3712,7 @@ luabind::scope lua_register_client() { .def("EnableAreaHPRegen", &Lua_Client::EnableAreaHPRegen) .def("EnableAreaManaRegen", &Lua_Client::EnableAreaManaRegen) .def("EnableAreaRegens", &Lua_Client::EnableAreaRegens) + .def("EnableTitleSet", &Lua_Client::EnableTitleSet) .def("EndSharedTask", (void(Lua_Client::*)(void))&Lua_Client::EndSharedTask) .def("EndSharedTask", (void(Lua_Client::*)(bool))&Lua_Client::EndSharedTask) .def("Escape", (void(Lua_Client::*)(void))&Lua_Client::Escape) @@ -4156,6 +4176,7 @@ luabind::scope lua_register_client() { .def("TrainDisc", (void(Lua_Client::*)(int))&Lua_Client::TrainDisc) .def("TrainDiscBySpellID", (void(Lua_Client::*)(int32))&Lua_Client::TrainDiscBySpellID) .def("UnFreeze", (void(Lua_Client::*)(void))&Lua_Client::UnFreeze) + .def("UncompleteTask", (bool(Lua_Client::*)(int))&Lua_Client::UncompleteTask) .def("Undye", (void(Lua_Client::*)(void))&Lua_Client::Undye) .def("UnmemSpell", (void(Lua_Client::*)(int))&Lua_Client::UnmemSpell) .def("UnmemSpell", (void(Lua_Client::*)(int,bool))&Lua_Client::UnmemSpell) diff --git a/zone/lua_client.h b/zone/lua_client.h index 0e197f013..04b9da273 100644 --- a/zone/lua_client.h +++ b/zone/lua_client.h @@ -297,6 +297,7 @@ public: int GetClientVersion(); uint32 GetClientVersionBit(); void SetTitleSuffix(const char *text); + void EnableTitleSet(uint32 title_set); void SetAAPoints(int points); int GetAAPoints(); int GetSpentAA(); @@ -521,6 +522,8 @@ public: bool KeyRingClear(); void KeyRingList(); bool KeyRingRemove(uint32 item_id); + bool CompleteTask(int task_id); + bool UncompleteTask(int task_id); // account data buckets void SetAccountBucket(std::string bucket_name, std::string bucket_value); diff --git a/zone/lua_general.cpp b/zone/lua_general.cpp index e076b2674..5b26dd9b0 100644 --- a/zone/lua_general.cpp +++ b/zone/lua_general.cpp @@ -722,6 +722,14 @@ void lua_fail_task(int task_id) { quest_manager.failtask(task_id); } +bool lua_complete_task(int task_id) { + return quest_manager.completetask(task_id); +} + +bool lua_uncomplete_task(int task_id) { + return quest_manager.uncompletetask(task_id); +} + int lua_task_time_left(int task_id) { return quest_manager.tasktimeleft(task_id); } @@ -4157,607 +4165,607 @@ void lua_send_player_handin_event() float lua_get_zone_safe_x(uint32 zone_id) { - return zone_store.GetZoneSafeCoordinates(zone_id).x; + return ZoneStore::Instance()->GetZoneSafeCoordinates(zone_id).x; } float lua_get_zone_safe_x(uint32 zone_id, int version) { - return zone_store.GetZoneSafeCoordinates(zone_id, version).x; + return ZoneStore::Instance()->GetZoneSafeCoordinates(zone_id, version).x; } float lua_get_zone_safe_y(uint32 zone_id) { - return zone_store.GetZoneSafeCoordinates(zone_id).y; + return ZoneStore::Instance()->GetZoneSafeCoordinates(zone_id).y; } float lua_get_zone_safe_y(uint32 zone_id, int version) { - return zone_store.GetZoneSafeCoordinates(zone_id, version).y; + return ZoneStore::Instance()->GetZoneSafeCoordinates(zone_id, version).y; } float lua_get_zone_safe_z(uint32 zone_id) { - return zone_store.GetZoneSafeCoordinates(zone_id).z; + return ZoneStore::Instance()->GetZoneSafeCoordinates(zone_id).z; } float lua_get_zone_safe_z(uint32 zone_id, int version) { - return zone_store.GetZoneSafeCoordinates(zone_id, version).z; + return ZoneStore::Instance()->GetZoneSafeCoordinates(zone_id, version).z; } float lua_get_zone_safe_heading(uint32 zone_id) { - return zone_store.GetZoneSafeCoordinates(zone_id).w; + return ZoneStore::Instance()->GetZoneSafeCoordinates(zone_id).w; } float lua_get_zone_safe_heading(uint32 zone_id, int version) { - return zone_store.GetZoneSafeCoordinates(zone_id, version).w; + return ZoneStore::Instance()->GetZoneSafeCoordinates(zone_id, version).w; } float lua_get_zone_graveyard_id(uint32 zone_id) { - return zone_store.GetZoneGraveyardID(zone_id); + return ZoneStore::Instance()->GetZoneGraveyardID(zone_id); } float lua_get_zone_graveyard_id(uint32 zone_id, int version) { - return zone_store.GetZoneGraveyardID(zone_id, version); + return ZoneStore::Instance()->GetZoneGraveyardID(zone_id, version); } uint8 lua_get_zone_minimum_level(uint32 zone_id) { - return zone_store.GetZoneMinimumLevel(zone_id); + return ZoneStore::Instance()->GetZoneMinimumLevel(zone_id); } uint8 lua_get_zone_minimum_level(uint32 zone_id, int version) { - return zone_store.GetZoneMinimumLevel(zone_id, version); + return ZoneStore::Instance()->GetZoneMinimumLevel(zone_id, version); } uint8 lua_get_zone_maximum_level(uint32 zone_id) { - return zone_store.GetZoneMaximumLevel(zone_id); + return ZoneStore::Instance()->GetZoneMaximumLevel(zone_id); } uint8 lua_get_zone_maximum_level(uint32 zone_id, int version) { - return zone_store.GetZoneMaximumLevel(zone_id, version); + return ZoneStore::Instance()->GetZoneMaximumLevel(zone_id, version); } uint8 lua_get_zone_minimum_status(uint32 zone_id) { - return zone_store.GetZoneMinimumStatus(zone_id); + return ZoneStore::Instance()->GetZoneMinimumStatus(zone_id); } uint8 lua_get_zone_minimum_status(uint32 zone_id, int version) { - return zone_store.GetZoneMinimumStatus(zone_id, version); + return ZoneStore::Instance()->GetZoneMinimumStatus(zone_id, version); } int lua_get_zone_time_zone(uint32 zone_id) { - return zone_store.GetZoneTimeZone(zone_id); + return ZoneStore::Instance()->GetZoneTimeZone(zone_id); } int lua_get_zone_time_zone(uint32 zone_id, int version) { - return zone_store.GetZoneTimeZone(zone_id, version); + return ZoneStore::Instance()->GetZoneTimeZone(zone_id, version); } int lua_get_zone_maximum_players(uint32 zone_id) { - return zone_store.GetZoneMaximumPlayers(zone_id); + return ZoneStore::Instance()->GetZoneMaximumPlayers(zone_id); } int lua_get_zone_maximum_players(uint32 zone_id, int version) { - return zone_store.GetZoneMaximumPlayers(zone_id, version); + return ZoneStore::Instance()->GetZoneMaximumPlayers(zone_id, version); } uint32 lua_get_zone_rule_set(uint32 zone_id) { - return zone_store.GetZoneRuleSet(zone_id); + return ZoneStore::Instance()->GetZoneRuleSet(zone_id); } uint32 lua_get_zone_rule_set(uint32 zone_id, int version) { - return zone_store.GetZoneRuleSet(zone_id, version); + return ZoneStore::Instance()->GetZoneRuleSet(zone_id, version); } std::string lua_get_zone_note(uint32 zone_id) { - return zone_store.GetZoneNote(zone_id); + return ZoneStore::Instance()->GetZoneNote(zone_id); } std::string lua_get_zone_note(uint32 zone_id, int version) { - return zone_store.GetZoneNote(zone_id, version); + return ZoneStore::Instance()->GetZoneNote(zone_id, version); } float lua_get_zone_underworld(uint32 zone_id) { - return zone_store.GetZoneUnderworld(zone_id); + return ZoneStore::Instance()->GetZoneUnderworld(zone_id); } float lua_get_zone_underworld(uint32 zone_id, int version) { - return zone_store.GetZoneUnderworld(zone_id, version); + return ZoneStore::Instance()->GetZoneUnderworld(zone_id, version); } float lua_get_zone_minimum_clip(uint32 zone_id) { - return zone_store.GetZoneMinimumClip(zone_id); + return ZoneStore::Instance()->GetZoneMinimumClip(zone_id); } float lua_get_zone_minimum_clip(uint32 zone_id, int version) { - return zone_store.GetZoneMinimumClip(zone_id, version); + return ZoneStore::Instance()->GetZoneMinimumClip(zone_id, version); } float lua_get_zone_maximum_clip(uint32 zone_id) { - return zone_store.GetZoneMaximumClip(zone_id); + return ZoneStore::Instance()->GetZoneMaximumClip(zone_id); } float lua_get_zone_maximum_clip(uint32 zone_id, int version) { - return zone_store.GetZoneMaximumClip(zone_id, version); + return ZoneStore::Instance()->GetZoneMaximumClip(zone_id, version); } float lua_get_zone_fog_minimum_clip(uint32 zone_id) { - return zone_store.GetZoneFogMinimumClip(zone_id); + return ZoneStore::Instance()->GetZoneFogMinimumClip(zone_id); } float lua_get_zone_fog_minimum_clip(uint32 zone_id, uint8 slot) { - return zone_store.GetZoneFogMinimumClip(zone_id, slot); + return ZoneStore::Instance()->GetZoneFogMinimumClip(zone_id, slot); } float lua_get_zone_fog_minimum_clip(uint32 zone_id, uint8 slot, int version) { - return zone_store.GetZoneFogMinimumClip(zone_id, slot); + return ZoneStore::Instance()->GetZoneFogMinimumClip(zone_id, slot); } float lua_get_zone_fog_maximum_clip(uint32 zone_id) { - return zone_store.GetZoneFogMaximumClip(zone_id); + return ZoneStore::Instance()->GetZoneFogMaximumClip(zone_id); } float lua_get_zone_fog_maximum_clip(uint32 zone_id, uint8 slot) { - return zone_store.GetZoneFogMaximumClip(zone_id, slot); + return ZoneStore::Instance()->GetZoneFogMaximumClip(zone_id, slot); } float lua_get_zone_fog_maximum_clip(uint32 zone_id, uint8 slot, int version) { - return zone_store.GetZoneFogMaximumClip(zone_id, slot, version); + return ZoneStore::Instance()->GetZoneFogMaximumClip(zone_id, slot, version); } uint8 lua_get_zone_fog_red(uint32 zone_id) { - return zone_store.GetZoneFogRed(zone_id); + return ZoneStore::Instance()->GetZoneFogRed(zone_id); } uint8 lua_get_zone_fog_red(uint32 zone_id, uint8 slot) { - return zone_store.GetZoneFogRed(zone_id, slot); + return ZoneStore::Instance()->GetZoneFogRed(zone_id, slot); } uint8 lua_get_zone_fog_red(uint32 zone_id, uint8 slot, int version) { - return zone_store.GetZoneFogRed(zone_id, slot, version); + return ZoneStore::Instance()->GetZoneFogRed(zone_id, slot, version); } uint8 lua_get_zone_fog_green(uint32 zone_id) { - return zone_store.GetZoneFogGreen(zone_id); + return ZoneStore::Instance()->GetZoneFogGreen(zone_id); } uint8 lua_get_zone_fog_green(uint32 zone_id, uint8 slot) { - return zone_store.GetZoneFogGreen(zone_id, slot); + return ZoneStore::Instance()->GetZoneFogGreen(zone_id, slot); } uint8 lua_get_zone_fog_green(uint32 zone_id, uint8 slot, int version) { - return zone_store.GetZoneFogGreen(zone_id, slot, version); + return ZoneStore::Instance()->GetZoneFogGreen(zone_id, slot, version); } uint8 lua_get_zone_fog_blue(uint32 zone_id) { - return zone_store.GetZoneFogBlue(zone_id); + return ZoneStore::Instance()->GetZoneFogBlue(zone_id); } uint8 lua_get_zone_fog_blue(uint32 zone_id, uint8 slot) { - return zone_store.GetZoneFogBlue(zone_id, slot); + return ZoneStore::Instance()->GetZoneFogBlue(zone_id, slot); } uint8 lua_get_zone_fog_blue(uint32 zone_id, uint8 slot, int version) { - return zone_store.GetZoneFogBlue(zone_id, slot, version); + return ZoneStore::Instance()->GetZoneFogBlue(zone_id, slot, version); } uint8 lua_get_zone_sky(uint32 zone_id) { - return zone_store.GetZoneSky(zone_id); + return ZoneStore::Instance()->GetZoneSky(zone_id); } uint8 lua_get_zone_sky(uint32 zone_id, int version) { - return zone_store.GetZoneSky(zone_id, version); + return ZoneStore::Instance()->GetZoneSky(zone_id, version); } uint8 lua_get_zone_ztype(uint32 zone_id) { - return zone_store.GetZoneZType(zone_id); + return ZoneStore::Instance()->GetZoneZType(zone_id); } uint8 lua_get_zone_ztype(uint32 zone_id, int version) { - return zone_store.GetZoneZType(zone_id, version); + return ZoneStore::Instance()->GetZoneZType(zone_id, version); } float lua_get_zone_experience_multiplier(uint32 zone_id) { - return zone_store.GetZoneExperienceMultiplier(zone_id); + return ZoneStore::Instance()->GetZoneExperienceMultiplier(zone_id); } float lua_get_zone_experience_multiplier(uint32 zone_id, int version) { - return zone_store.GetZoneExperienceMultiplier(zone_id, version); + return ZoneStore::Instance()->GetZoneExperienceMultiplier(zone_id, version); } float lua_get_zone_walk_speed(uint32 zone_id) { - return zone_store.GetZoneWalkSpeed(zone_id); + return ZoneStore::Instance()->GetZoneWalkSpeed(zone_id); } float lua_get_zone_walk_speed(uint32 zone_id, int version) { - return zone_store.GetZoneWalkSpeed(zone_id, version); + return ZoneStore::Instance()->GetZoneWalkSpeed(zone_id, version); } uint8 lua_get_zone_time_type(uint32 zone_id) { - return zone_store.GetZoneTimeType(zone_id); + return ZoneStore::Instance()->GetZoneTimeType(zone_id); } uint8 lua_get_zone_time_type(uint32 zone_id, int version) { - return zone_store.GetZoneTimeType(zone_id, version); + return ZoneStore::Instance()->GetZoneTimeType(zone_id, version); } float lua_get_zone_fog_density(uint32 zone_id) { - return zone_store.GetZoneFogDensity(zone_id); + return ZoneStore::Instance()->GetZoneFogDensity(zone_id); } float lua_get_zone_fog_density(uint32 zone_id, int version) { - return zone_store.GetZoneFogDensity(zone_id, version); + return ZoneStore::Instance()->GetZoneFogDensity(zone_id, version); } std::string lua_get_zone_flag_needed(uint32 zone_id) { - return zone_store.GetZoneFlagNeeded(zone_id); + return ZoneStore::Instance()->GetZoneFlagNeeded(zone_id); } std::string lua_get_zone_flag_needed(uint32 zone_id, int version) { - return zone_store.GetZoneFlagNeeded(zone_id, version); + return ZoneStore::Instance()->GetZoneFlagNeeded(zone_id, version); } int8 lua_get_zone_can_bind(uint32 zone_id) { - return zone_store.GetZoneCanBind(zone_id); + return ZoneStore::Instance()->GetZoneCanBind(zone_id); } int8 lua_get_zone_can_bind(uint32 zone_id, int version) { - return zone_store.GetZoneCanBind(zone_id, version); + return ZoneStore::Instance()->GetZoneCanBind(zone_id, version); } int8 lua_get_zone_can_combat(uint32 zone_id) { - return zone_store.GetZoneCanCombat(zone_id); + return ZoneStore::Instance()->GetZoneCanCombat(zone_id); } int8 lua_get_zone_can_combat(uint32 zone_id, int version) { - return zone_store.GetZoneCanCombat(zone_id, version); + return ZoneStore::Instance()->GetZoneCanCombat(zone_id, version); } int8 lua_get_zone_can_levitate(uint32 zone_id) { - return zone_store.GetZoneCanLevitate(zone_id); + return ZoneStore::Instance()->GetZoneCanLevitate(zone_id); } int8 lua_get_zone_can_levitate(uint32 zone_id, int version) { - return zone_store.GetZoneCanLevitate(zone_id, version); + return ZoneStore::Instance()->GetZoneCanLevitate(zone_id, version); } int8 lua_get_zone_cast_outdoor(uint32 zone_id) { - return zone_store.GetZoneCastOutdoor(zone_id); + return ZoneStore::Instance()->GetZoneCastOutdoor(zone_id); } int8 lua_get_zone_cast_outdoor(uint32 zone_id, int version) { - return zone_store.GetZoneCastOutdoor(zone_id, version); + return ZoneStore::Instance()->GetZoneCastOutdoor(zone_id, version); } uint8 lua_get_zone_hotzone(uint32 zone_id) { - return zone_store.GetZoneHotzone(zone_id); + return ZoneStore::Instance()->GetZoneHotzone(zone_id); } uint8 lua_get_zone_hotzone(uint32 zone_id, int version) { - return zone_store.GetZoneHotzone(zone_id, version); + return ZoneStore::Instance()->GetZoneHotzone(zone_id, version); } uint8 lua_get_zone_instance_type(uint32 zone_id) { - return zone_store.GetZoneInstanceType(zone_id); + return ZoneStore::Instance()->GetZoneInstanceType(zone_id); } uint8 lua_get_zone_instance_type(uint32 zone_id, int version) { - return zone_store.GetZoneInstanceType(zone_id, version); + return ZoneStore::Instance()->GetZoneInstanceType(zone_id, version); } uint64 lua_get_zone_shutdown_delay(uint32 zone_id) { - return zone_store.GetZoneShutdownDelay(zone_id); + return ZoneStore::Instance()->GetZoneShutdownDelay(zone_id); } uint64 lua_get_zone_shutdown_delay(uint32 zone_id, int version) { - return zone_store.GetZoneShutdownDelay(zone_id, version); + return ZoneStore::Instance()->GetZoneShutdownDelay(zone_id, version); } int8 lua_get_zone_peqzone(uint32 zone_id) { - return zone_store.GetZonePEQZone(zone_id); + return ZoneStore::Instance()->GetZonePEQZone(zone_id); } int8 lua_get_zone_peqzone(uint32 zone_id, int version) { - return zone_store.GetZonePEQZone(zone_id, version); + return ZoneStore::Instance()->GetZonePEQZone(zone_id, version); } int8 lua_get_zone_expansion(uint32 zone_id) { - return zone_store.GetZoneExpansion(zone_id); + return ZoneStore::Instance()->GetZoneExpansion(zone_id); } int8 lua_get_zone_expansion(uint32 zone_id, int version) { - return zone_store.GetZoneExpansion(zone_id, version); + return ZoneStore::Instance()->GetZoneExpansion(zone_id, version); } int8 lua_get_zone_bypass_expansion_check(uint32 zone_id) { - return zone_store.GetZoneBypassExpansionCheck(zone_id); + return ZoneStore::Instance()->GetZoneBypassExpansionCheck(zone_id); } int8 lua_get_zone_bypass_expansion_check(uint32 zone_id, int version) { - return zone_store.GetZoneBypassExpansionCheck(zone_id, version); + return ZoneStore::Instance()->GetZoneBypassExpansionCheck(zone_id, version); } int8 lua_get_zone_suspend_buffs(uint32 zone_id) { - return zone_store.GetZoneSuspendBuffs(zone_id); + return ZoneStore::Instance()->GetZoneSuspendBuffs(zone_id); } int8 lua_get_zone_suspend_buffs(uint32 zone_id, int version) { - return zone_store.GetZoneSuspendBuffs(zone_id, version); + return ZoneStore::Instance()->GetZoneSuspendBuffs(zone_id, version); } int lua_get_zone_rain_chance(uint32 zone_id) { - return zone_store.GetZoneRainChance(zone_id); + return ZoneStore::Instance()->GetZoneRainChance(zone_id); } int lua_get_zone_rain_chance(uint32 zone_id, int version) { - return zone_store.GetZoneRainChance(zone_id, version); + return ZoneStore::Instance()->GetZoneRainChance(zone_id, version); } int lua_get_zone_rain_duration(uint32 zone_id) { - return zone_store.GetZoneRainDuration(zone_id); + return ZoneStore::Instance()->GetZoneRainDuration(zone_id); } int lua_get_zone_rain_duration(uint32 zone_id, int version) { - return zone_store.GetZoneRainDuration(zone_id, version); + return ZoneStore::Instance()->GetZoneRainDuration(zone_id, version); } int lua_get_zone_snow_chance(uint32 zone_id) { - return zone_store.GetZoneSnowChance(zone_id); + return ZoneStore::Instance()->GetZoneSnowChance(zone_id); } int lua_get_zone_snow_chance(uint32 zone_id, int version) { - return zone_store.GetZoneSnowChance(zone_id, version); + return ZoneStore::Instance()->GetZoneSnowChance(zone_id, version); } int lua_get_zone_snow_duration(uint32 zone_id) { - return zone_store.GetZoneSnowDuration(zone_id); + return ZoneStore::Instance()->GetZoneSnowDuration(zone_id); } int lua_get_zone_snow_duration(uint32 zone_id, int version) { - return zone_store.GetZoneSnowDuration(zone_id, version); + return ZoneStore::Instance()->GetZoneSnowDuration(zone_id, version); } float lua_get_zone_gravity(uint32 zone_id) { - return zone_store.GetZoneGravity(zone_id); + return ZoneStore::Instance()->GetZoneGravity(zone_id); } float lua_get_zone_gravity(uint32 zone_id, int version) { - return zone_store.GetZoneGravity(zone_id, version); + return ZoneStore::Instance()->GetZoneGravity(zone_id, version); } int lua_get_zone_type(uint32 zone_id) { - return zone_store.GetZoneType(zone_id); + return ZoneStore::Instance()->GetZoneType(zone_id); } int lua_get_zone_type(uint32 zone_id, int version) { - return zone_store.GetZoneType(zone_id, version); + return ZoneStore::Instance()->GetZoneType(zone_id, version); } int lua_get_zone_sky_lock(uint32 zone_id) { - return zone_store.GetZoneSkyLock(zone_id); + return ZoneStore::Instance()->GetZoneSkyLock(zone_id); } int lua_get_zone_sky_lock(uint32 zone_id, int version) { - return zone_store.GetZoneSkyLock(zone_id, version); + return ZoneStore::Instance()->GetZoneSkyLock(zone_id, version); } int lua_get_zone_fast_regen_hp(uint32 zone_id) { - return zone_store.GetZoneFastRegenHP(zone_id); + return ZoneStore::Instance()->GetZoneFastRegenHP(zone_id); } int lua_get_zone_fast_regen_hp(uint32 zone_id, int version) { - return zone_store.GetZoneFastRegenHP(zone_id, version); + return ZoneStore::Instance()->GetZoneFastRegenHP(zone_id, version); } int lua_get_zone_fast_regen_mana(uint32 zone_id) { - return zone_store.GetZoneFastRegenMana(zone_id); + return ZoneStore::Instance()->GetZoneFastRegenMana(zone_id); } int lua_get_zone_fast_regen_mana(uint32 zone_id, int version) { - return zone_store.GetZoneFastRegenMana(zone_id, version); + return ZoneStore::Instance()->GetZoneFastRegenMana(zone_id, version); } int lua_get_zone_fast_regen_endurance(uint32 zone_id) { - return zone_store.GetZoneFastRegenEndurance(zone_id); + return ZoneStore::Instance()->GetZoneFastRegenEndurance(zone_id); } int lua_get_zone_fast_regen_endurance(uint32 zone_id, int version) { - return zone_store.GetZoneFastRegenEndurance(zone_id, version); + return ZoneStore::Instance()->GetZoneFastRegenEndurance(zone_id, version); } int lua_get_zone_npc_maximum_aggro_distance(uint32 zone_id) { - return zone_store.GetZoneNPCMaximumAggroDistance(zone_id); + return ZoneStore::Instance()->GetZoneNPCMaximumAggroDistance(zone_id); } int lua_get_zone_npc_maximum_aggro_distance(uint32 zone_id, int version) { - return zone_store.GetZoneNPCMaximumAggroDistance(zone_id, version); + return ZoneStore::Instance()->GetZoneNPCMaximumAggroDistance(zone_id, version); } int8 lua_get_zone_minimum_expansion(uint32 zone_id) { - return zone_store.GetZoneMinimumExpansion(zone_id); + return ZoneStore::Instance()->GetZoneMinimumExpansion(zone_id); } int8 lua_get_zone_minimum_expansion(uint32 zone_id, int version) { - return zone_store.GetZoneMinimumExpansion(zone_id, version); + return ZoneStore::Instance()->GetZoneMinimumExpansion(zone_id, version); } int8 lua_get_zone_maximum_expansion(uint32 zone_id) { - return zone_store.GetZoneMaximumExpansion(zone_id); + return ZoneStore::Instance()->GetZoneMaximumExpansion(zone_id); } int8 lua_get_zone_maximum_expansion(uint32 zone_id, int version) { - return zone_store.GetZoneMaximumExpansion(zone_id, version); + return ZoneStore::Instance()->GetZoneMaximumExpansion(zone_id, version); } std::string lua_get_zone_content_flags(uint32 zone_id) { - return zone_store.GetZoneContentFlags(zone_id); + return ZoneStore::Instance()->GetZoneContentFlags(zone_id); } std::string lua_get_zone_content_flags(uint32 zone_id, int version) { - return zone_store.GetZoneContentFlags(zone_id, version); + return ZoneStore::Instance()->GetZoneContentFlags(zone_id, version); } std::string lua_get_zone_content_flags_disabled(uint32 zone_id) { - return zone_store.GetZoneContentFlagsDisabled(zone_id); + return ZoneStore::Instance()->GetZoneContentFlagsDisabled(zone_id); } std::string lua_get_zone_content_flags_disabled(uint32 zone_id, int version) { - return zone_store.GetZoneContentFlagsDisabled(zone_id, version); + return ZoneStore::Instance()->GetZoneContentFlagsDisabled(zone_id, version); } int lua_get_zone_underworld_teleport_index(uint32 zone_id) { - return zone_store.GetZoneUnderworldTeleportIndex(zone_id); + return ZoneStore::Instance()->GetZoneUnderworldTeleportIndex(zone_id); } int lua_get_zone_underworld_teleport_index(uint32 zone_id, int version) { - return zone_store.GetZoneUnderworldTeleportIndex(zone_id, version); + return ZoneStore::Instance()->GetZoneUnderworldTeleportIndex(zone_id, version); } int lua_get_zone_lava_damage(uint32 zone_id) { - return zone_store.GetZoneLavaDamage(zone_id); + return ZoneStore::Instance()->GetZoneLavaDamage(zone_id); } int lua_get_zone_lava_damage(uint32 zone_id, int version) { - return zone_store.GetZoneLavaDamage(zone_id, version); + return ZoneStore::Instance()->GetZoneLavaDamage(zone_id, version); } int lua_get_zone_minimum_lava_damage(uint32 zone_id) { - return zone_store.GetZoneMinimumLavaDamage(zone_id); + return ZoneStore::Instance()->GetZoneMinimumLavaDamage(zone_id); } int lua_get_zone_minimum_lava_damage(uint32 zone_id, int version) { - return zone_store.GetZoneMinimumLavaDamage(zone_id, version); + return ZoneStore::Instance()->GetZoneMinimumLavaDamage(zone_id, version); } uint8 lua_get_zone_idle_when_empty(uint32 zone_id) { - return zone_store.GetZoneIdleWhenEmpty(zone_id); + return ZoneStore::Instance()->GetZoneIdleWhenEmpty(zone_id); } uint8 lua_get_zone_idle_when_empty(uint32 zone_id, int version) { - return zone_store.GetZoneIdleWhenEmpty(zone_id, version); + return ZoneStore::Instance()->GetZoneIdleWhenEmpty(zone_id, version); } uint32 lua_get_zone_seconds_before_idle(uint32 zone_id) { - return zone_store.GetZoneSecondsBeforeIdle(zone_id); + return ZoneStore::Instance()->GetZoneSecondsBeforeIdle(zone_id); } uint32 lua_get_zone_seconds_before_idle(uint32 zone_id, int version) { - return zone_store.GetZoneSecondsBeforeIdle(zone_id, version); + return ZoneStore::Instance()->GetZoneSecondsBeforeIdle(zone_id, version); } void lua_send_channel_message(uint8 channel_number, uint32 guild_id, uint8 language_id, uint8 language_skill, const char* message) @@ -5497,11 +5505,11 @@ bool lua_set_auto_login_character_name_by_account_id(uint32 account_id, std::str } uint32 lua_get_zone_id_by_long_name(std::string zone_long_name) { - return zone_store.GetZoneIDByLongName(zone_long_name); + return ZoneStore::Instance()->GetZoneIDByLongName(zone_long_name); } std::string lua_get_zone_short_name_by_long_name(std::string zone_long_name) { - return zone_store.GetZoneShortNameByLongName(zone_long_name); + return ZoneStore::Instance()->GetZoneShortNameByLongName(zone_long_name); } bool lua_send_parcel(luabind::object lua_table) @@ -5970,6 +5978,8 @@ luabind::scope lua_register_general() { luabind::def("reset_task_activity", &lua_reset_task_activity), luabind::def("assign_task", &lua_assign_task), luabind::def("fail_task", &lua_fail_task), + luabind::def("complete_task", &lua_complete_task), + luabind::def("uncomplete_task", &lua_uncomplete_task), luabind::def("task_time_left", &lua_task_time_left), luabind::def("is_task_completed", &lua_is_task_completed), luabind::def("enabled_task_count", &lua_enabled_task_count), @@ -7963,33 +7973,6 @@ luabind::scope lua_register_languages() { )]; } -luabind::scope lua_register_rules_const() { - return luabind::class_("Rule") - .enum_("constants") - [( -#define RULE_INT(cat, rule, default_value, notes) \ - luabind::value(#rule, RuleManager::Int__##rule), -#include "../common/ruletypes.h" - luabind::value("_IntRuleCount", RuleManager::_IntRuleCount), -#undef RULE_INT -#define RULE_REAL(cat, rule, default_value, notes) \ - luabind::value(#rule, RuleManager::Real__##rule), -#include "../common/ruletypes.h" - luabind::value("_RealRuleCount", RuleManager::_RealRuleCount), -#undef RULE_REAL -#define RULE_BOOL(cat, rule, default_value, notes) \ - luabind::value(#rule, RuleManager::Bool__##rule), -#include "../common/ruletypes.h" - luabind::value("_BoolRuleCount", RuleManager::_BoolRuleCount), -#undef RULE_BOOL -#define RULE_STRING(cat, rule, default_value, notes) \ - luabind::value(#rule, RuleManager::String__##rule), -#include "../common/ruletypes.h" - luabind::value("_StringRuleCount", RuleManager::_StringRuleCount) -#undef RULE_STRING - )]; -} - luabind::scope lua_register_rulei() { return luabind::namespace_("RuleI") [ diff --git a/zone/lua_parser.cpp b/zone/lua_parser.cpp index bd3544b6a..d44fb2bfa 100644 --- a/zone/lua_parser.cpp +++ b/zone/lua_parser.cpp @@ -1070,7 +1070,7 @@ void LuaParser::ReloadQuests() { std::string module_path = lua_tostring(L, -1); lua_pop(L, 1); - for (const auto& dir : path.GetLuaModulePaths()) { + for (const auto& dir : PathManager::Instance()->GetLuaModulePaths()) { module_path += fmt::format(";{}/?.lua", dir); module_path += fmt::format(";{}/?/init.lua", dir); module_path += fmt::format(";{}/share/lua/{}/?.lua", dir, lua_version); @@ -1086,7 +1086,7 @@ void LuaParser::ReloadQuests() { module_path = lua_tostring(L, -1); lua_pop(L, 1); - for (const auto& dir : path.GetLuaModulePaths()) { + for (const auto& dir : PathManager::Instance()->GetLuaModulePaths()) { module_path += fmt::format(";{}/?{}", dir, libext); module_path += fmt::format(";{}/lib/lua/{}/?{}", dir, lua_version, libext); } @@ -1098,7 +1098,7 @@ void LuaParser::ReloadQuests() { MapFunctions(L); // load init - for (auto& dir : path.GetQuestPaths()) { + for (auto& dir : PathManager::Instance()->GetQuestPaths()) { std::string filename = fmt::format("{}/{}/script_init.lua", dir, QUEST_GLOBAL_DIRECTORY); FILE* f = fopen(filename.c_str(), "r"); @@ -1114,7 +1114,7 @@ void LuaParser::ReloadQuests() { //zone init - always loads after global if (zone) { - for (auto& dir : path.GetQuestPaths()) { + for (auto& dir : PathManager::Instance()->GetQuestPaths()) { std::string zone_script = fmt::format( "{}/{}/script_init_v{}.lua", dir, @@ -1147,7 +1147,7 @@ void LuaParser::ReloadQuests() { } } - FILE *load_order = fopen(fmt::format("{}/load_order.txt", path.GetLuaModsPath()).c_str(), "r"); + FILE *load_order = fopen(fmt::format("{}/load_order.txt", PathManager::Instance()->GetLuaModsPath()).c_str(), "r"); if (load_order) { char file_name[256] = { 0 }; while (fgets(file_name, 256, load_order) != nullptr) { @@ -1159,7 +1159,7 @@ void LuaParser::ReloadQuests() { } } - LoadScript(fmt::format("{}/{}", path.GetLuaModsPath(), std::string(file_name)), file_name); + LoadScript(fmt::format("{}/{}", PathManager::Instance()->GetLuaModsPath(), std::string(file_name)), file_name); mods_.emplace_back(L, this, file_name); } @@ -1320,7 +1320,6 @@ void LuaParser::MapFunctions(lua_State *L) { lua_register_packet(), lua_register_packet_opcodes(), lua_register_stat_bonuses(), - lua_register_rules_const(), lua_register_rulei(), lua_register_ruler(), lua_register_ruleb(), diff --git a/zone/lua_zone.cpp b/zone/lua_zone.cpp index 79f4f0982..8250296ff 100644 --- a/zone/lua_zone.cpp +++ b/zone/lua_zone.cpp @@ -4,7 +4,6 @@ #include #include "../common/global_define.h" -#include "embperl.h" #include "lua_zone.h" bool Lua_Zone::BuffTimersSuspended() @@ -16,7 +15,7 @@ bool Lua_Zone::BuffTimersSuspended() bool Lua_Zone::BypassesExpansionCheck() { Lua_Safe_Call_Bool(); - return zone_store.GetZoneBypassExpansionCheck(self->GetZoneID(), self->GetInstanceVersion()); + return ZoneStore::Instance()->GetZoneBypassExpansionCheck(self->GetZoneID(), self->GetInstanceVersion()); } bool Lua_Zone::CanBind() @@ -88,25 +87,25 @@ float Lua_Zone::GetAAEXPModifierByCharacterID(uint32 character_id) std::string Lua_Zone::GetContentFlags() { Lua_Safe_Call_String(); - return zone_store.GetZoneContentFlags(self->GetZoneID(), self->GetInstanceVersion()); + return ZoneStore::Instance()->GetZoneContentFlags(self->GetZoneID(), self->GetInstanceVersion()); } std::string Lua_Zone::GetContentFlagsDisabled() { Lua_Safe_Call_String(); - return zone_store.GetZoneContentFlagsDisabled(self->GetZoneID(), self->GetInstanceVersion()); + return ZoneStore::Instance()->GetZoneContentFlagsDisabled(self->GetZoneID(), self->GetInstanceVersion()); } float Lua_Zone::GetExperienceMultiplier() { Lua_Safe_Call_Real(); - return zone_store.GetZoneExperienceMultiplier(self->GetZoneID(), self->GetInstanceVersion()); + return ZoneStore::Instance()->GetZoneExperienceMultiplier(self->GetZoneID(), self->GetInstanceVersion()); } int8 Lua_Zone::GetExpansion() { Lua_Safe_Call_Int(); - return zone_store.GetZoneExpansion(self->GetZoneID(), self->GetInstanceVersion()); + return ZoneStore::Instance()->GetZoneExpansion(self->GetZoneID(), self->GetInstanceVersion()); } float Lua_Zone::GetEXPModifier(Lua_Client c) @@ -124,19 +123,19 @@ float Lua_Zone::GetEXPModifierByCharacterID(uint32 character_id) int Lua_Zone::GetFastRegenEndurance() { Lua_Safe_Call_Int(); - return zone_store.GetZoneFastRegenEndurance(self->GetZoneID(), self->GetInstanceVersion()); + return ZoneStore::Instance()->GetZoneFastRegenEndurance(self->GetZoneID(), self->GetInstanceVersion()); } int Lua_Zone::GetFastRegenHP() { Lua_Safe_Call_Int(); - return zone_store.GetZoneFastRegenHP(self->GetZoneID(), self->GetInstanceVersion()); + return ZoneStore::Instance()->GetZoneFastRegenHP(self->GetZoneID(), self->GetInstanceVersion()); } int Lua_Zone::GetFastRegenMana() { Lua_Safe_Call_Int(); - return zone_store.GetZoneFastRegenMana(self->GetZoneID(), self->GetInstanceVersion()); + return ZoneStore::Instance()->GetZoneFastRegenMana(self->GetZoneID(), self->GetInstanceVersion()); } std::string Lua_Zone::GetFileName() @@ -148,73 +147,73 @@ std::string Lua_Zone::GetFileName() std::string Lua_Zone::GetFlagNeeded() { Lua_Safe_Call_String(); - return zone_store.GetZoneFlagNeeded(self->GetZoneID(), self->GetInstanceVersion()); + return ZoneStore::Instance()->GetZoneFlagNeeded(self->GetZoneID(), self->GetInstanceVersion()); } uint8 Lua_Zone::GetFogBlue() { Lua_Safe_Call_Int(); - return zone_store.GetZoneFogBlue(self->GetZoneID(), 0, self->GetInstanceVersion()); + return ZoneStore::Instance()->GetZoneFogBlue(self->GetZoneID(), 0, self->GetInstanceVersion()); } uint8 Lua_Zone::GetFogBlue(uint8 slot) { Lua_Safe_Call_Int(); - return zone_store.GetZoneFogBlue(self->GetZoneID(), slot, self->GetInstanceVersion()); + return ZoneStore::Instance()->GetZoneFogBlue(self->GetZoneID(), slot, self->GetInstanceVersion()); } float Lua_Zone::GetFogDensity() { Lua_Safe_Call_Real(); - return zone_store.GetZoneFogDensity(self->GetZoneID(), self->GetInstanceVersion()); + return ZoneStore::Instance()->GetZoneFogDensity(self->GetZoneID(), self->GetInstanceVersion()); } uint8 Lua_Zone::GetFogGreen() { Lua_Safe_Call_Int(); - return zone_store.GetZoneFogGreen(self->GetZoneID(), 0, self->GetInstanceVersion()); + return ZoneStore::Instance()->GetZoneFogGreen(self->GetZoneID(), 0, self->GetInstanceVersion()); } uint8 Lua_Zone::GetFogGreen(uint8 slot) { Lua_Safe_Call_Int(); - return zone_store.GetZoneFogGreen(self->GetZoneID(), slot, self->GetInstanceVersion()); + return ZoneStore::Instance()->GetZoneFogGreen(self->GetZoneID(), slot, self->GetInstanceVersion()); } float Lua_Zone::GetFogMaximumClip() { Lua_Safe_Call_Real(); - return zone_store.GetZoneFogMaximumClip(self->GetZoneID(), 0, self->GetInstanceVersion()); + return ZoneStore::Instance()->GetZoneFogMaximumClip(self->GetZoneID(), 0, self->GetInstanceVersion()); } float Lua_Zone::GetFogMaximumClip(uint8 slot) { Lua_Safe_Call_Real(); - return zone_store.GetZoneFogMaximumClip(self->GetZoneID(), slot, self->GetInstanceVersion()); + return ZoneStore::Instance()->GetZoneFogMaximumClip(self->GetZoneID(), slot, self->GetInstanceVersion()); } float Lua_Zone::GetFogMinimumClip() { Lua_Safe_Call_Real(); - return zone_store.GetZoneFogMinimumClip(self->GetZoneID(), 0, self->GetInstanceVersion()); + return ZoneStore::Instance()->GetZoneFogMinimumClip(self->GetZoneID(), 0, self->GetInstanceVersion()); } float Lua_Zone::GetFogMinimumClip(uint8 slot) { Lua_Safe_Call_Real(); - return zone_store.GetZoneFogMinimumClip(self->GetZoneID(), slot, self->GetInstanceVersion()); + return ZoneStore::Instance()->GetZoneFogMinimumClip(self->GetZoneID(), slot, self->GetInstanceVersion()); } uint8 Lua_Zone::GetFogRed() { Lua_Safe_Call_Int(); - return zone_store.GetZoneFogRed(self->GetZoneID(), 0, self->GetInstanceVersion()); + return ZoneStore::Instance()->GetZoneFogRed(self->GetZoneID(), 0, self->GetInstanceVersion()); } uint8 Lua_Zone::GetFogRed(uint8 slot) { Lua_Safe_Call_Int(); - return zone_store.GetZoneFogRed(self->GetZoneID(), slot, self->GetInstanceVersion()); + return ZoneStore::Instance()->GetZoneFogRed(self->GetZoneID(), slot, self->GetInstanceVersion()); } float Lua_Zone::GetGraveyardHeading() @@ -256,7 +255,7 @@ uint32 Lua_Zone::GetGraveyardZoneID() float Lua_Zone::GetGravity() { Lua_Safe_Call_Real(); - return zone_store.GetZoneGravity(self->GetZoneID(), self->GetInstanceVersion()); + return ZoneStore::Instance()->GetZoneGravity(self->GetZoneID(), self->GetInstanceVersion()); } uint32 Lua_Zone::GetInstanceID() @@ -268,7 +267,7 @@ uint32 Lua_Zone::GetInstanceID() uint8 Lua_Zone::GetInstanceType() { Lua_Safe_Call_Int(); - return zone_store.GetZoneInstanceType(self->GetZoneID(), self->GetInstanceVersion()); + return ZoneStore::Instance()->GetZoneInstanceType(self->GetZoneID(), self->GetInstanceVersion()); } uint16 Lua_Zone::GetInstanceVersion() @@ -286,7 +285,7 @@ uint32 Lua_Zone::GetInstanceTimeRemaining() int Lua_Zone::GetLavaDamage() { Lua_Safe_Call_Int(); - return zone_store.GetZoneLavaDamage(self->GetZoneID(), self->GetInstanceVersion()); + return ZoneStore::Instance()->GetZoneLavaDamage(self->GetZoneID(), self->GetInstanceVersion()); } std::string Lua_Zone::GetLongName() @@ -298,19 +297,19 @@ std::string Lua_Zone::GetLongName() float Lua_Zone::GetMaximumClip() { Lua_Safe_Call_Real(); - return zone_store.GetZoneMaximumClip(self->GetZoneID(), self->GetInstanceVersion()); + return ZoneStore::Instance()->GetZoneMaximumClip(self->GetZoneID(), self->GetInstanceVersion()); } int8 Lua_Zone::GetMaximumExpansion() { Lua_Safe_Call_Int(); - return zone_store.GetZoneMaximumExpansion(self->GetZoneID(), self->GetInstanceVersion()); + return ZoneStore::Instance()->GetZoneMaximumExpansion(self->GetZoneID(), self->GetInstanceVersion()); } uint8 Lua_Zone::GetMaximumLevel() { Lua_Safe_Call_Int(); - return zone_store.GetZoneMaximumLevel(self->GetZoneID(), self->GetInstanceVersion()); + return ZoneStore::Instance()->GetZoneMaximumLevel(self->GetZoneID(), self->GetInstanceVersion()); } uint32 Lua_Zone::GetMaxClients() @@ -322,79 +321,79 @@ uint32 Lua_Zone::GetMaxClients() float Lua_Zone::GetMinimumClip() { Lua_Safe_Call_Int(); - return zone_store.GetZoneMinimumClip(self->GetZoneID(), self->GetInstanceVersion()); + return ZoneStore::Instance()->GetZoneMinimumClip(self->GetZoneID(), self->GetInstanceVersion()); } int8 Lua_Zone::GetMinimumExpansion() { Lua_Safe_Call_Int(); - return zone_store.GetZoneMinimumExpansion(self->GetZoneID(), self->GetInstanceVersion()); + return ZoneStore::Instance()->GetZoneMinimumExpansion(self->GetZoneID(), self->GetInstanceVersion()); } uint8 Lua_Zone::GetMinimumLevel() { Lua_Safe_Call_Int(); - return zone_store.GetZoneMinimumLevel(self->GetZoneID(), self->GetInstanceVersion()); + return ZoneStore::Instance()->GetZoneMinimumLevel(self->GetZoneID(), self->GetInstanceVersion()); } int Lua_Zone::GetMinimumLavaDamage() { Lua_Safe_Call_Int(); - return zone_store.GetZoneMinimumLavaDamage(self->GetZoneID(), self->GetInstanceVersion()); + return ZoneStore::Instance()->GetZoneMinimumLavaDamage(self->GetZoneID(), self->GetInstanceVersion()); } uint8 Lua_Zone::GetMinimumStatus() { Lua_Safe_Call_Int(); - return zone_store.GetZoneMinimumStatus(self->GetZoneID(), self->GetInstanceVersion()); + return ZoneStore::Instance()->GetZoneMinimumStatus(self->GetZoneID(), self->GetInstanceVersion()); } std::string Lua_Zone::GetNote() { Lua_Safe_Call_String(); - return zone_store.GetZoneNote(self->GetZoneID(), self->GetInstanceVersion()); + return ZoneStore::Instance()->GetZoneNote(self->GetZoneID(), self->GetInstanceVersion()); } int Lua_Zone::GetNPCMaximumAggroDistance() { Lua_Safe_Call_Int(); - return zone_store.GetZoneNPCMaximumAggroDistance(self->GetZoneID(), self->GetInstanceVersion()); + return ZoneStore::Instance()->GetZoneNPCMaximumAggroDistance(self->GetZoneID(), self->GetInstanceVersion()); } int8 Lua_Zone::GetPEQZone() { Lua_Safe_Call_Int(); - return zone_store.GetZonePEQZone(self->GetZoneID(), self->GetInstanceVersion()); + return ZoneStore::Instance()->GetZonePEQZone(self->GetZoneID(), self->GetInstanceVersion()); } int Lua_Zone::GetRainChance() { Lua_Safe_Call_Int(); - return zone_store.GetZoneRainChance(self->GetZoneID(), 0, self->GetInstanceVersion()); + return ZoneStore::Instance()->GetZoneRainChance(self->GetZoneID(), 0, self->GetInstanceVersion()); } int Lua_Zone::GetRainChance(uint8 slot) { Lua_Safe_Call_Int(); - return zone_store.GetZoneRainChance(self->GetZoneID(), slot, self->GetInstanceVersion()); + return ZoneStore::Instance()->GetZoneRainChance(self->GetZoneID(), slot, self->GetInstanceVersion()); } int Lua_Zone::GetRainDuration() { Lua_Safe_Call_Int(); - return zone_store.GetZoneRainDuration(self->GetZoneID(), 0, self->GetInstanceVersion()); + return ZoneStore::Instance()->GetZoneRainDuration(self->GetZoneID(), 0, self->GetInstanceVersion()); } int Lua_Zone::GetRainDuration(uint8 slot) { Lua_Safe_Call_Int(); - return zone_store.GetZoneRainDuration(self->GetZoneID(), slot, self->GetInstanceVersion()); + return ZoneStore::Instance()->GetZoneRainDuration(self->GetZoneID(), slot, self->GetInstanceVersion()); } uint32 Lua_Zone::GetRuleSet() { Lua_Safe_Call_Int(); - return zone_store.GetZoneRuleSet(self->GetZoneID(), self->GetInstanceVersion()); + return ZoneStore::Instance()->GetZoneRuleSet(self->GetZoneID(), self->GetInstanceVersion()); } float Lua_Zone::GetSafeHeading() @@ -436,55 +435,55 @@ uint32 Lua_Zone::GetSecondsBeforeIdle() uint64 Lua_Zone::GetShutdownDelay() { Lua_Safe_Call_Int(); - return zone_store.GetZoneShutdownDelay(self->GetZoneID(), self->GetInstanceVersion()); + return ZoneStore::Instance()->GetZoneShutdownDelay(self->GetZoneID(), self->GetInstanceVersion()); } uint8 Lua_Zone::GetSky() { Lua_Safe_Call_Int(); - return zone_store.GetZoneSky(self->GetZoneID(), self->GetInstanceVersion()); + return ZoneStore::Instance()->GetZoneSky(self->GetZoneID(), self->GetInstanceVersion()); } int8 Lua_Zone::GetSkyLock() { Lua_Safe_Call_Int(); - return zone_store.GetZoneSkyLock(self->GetZoneID(), self->GetInstanceVersion()); + return ZoneStore::Instance()->GetZoneSkyLock(self->GetZoneID(), self->GetInstanceVersion()); } int Lua_Zone::GetSnowChance() { Lua_Safe_Call_Int(); - return zone_store.GetZoneSnowChance(self->GetZoneID(), 0, self->GetInstanceVersion()); + return ZoneStore::Instance()->GetZoneSnowChance(self->GetZoneID(), 0, self->GetInstanceVersion()); } int Lua_Zone::GetSnowChance(uint8 slot) { Lua_Safe_Call_Int(); - return zone_store.GetZoneSnowChance(self->GetZoneID(), slot, self->GetInstanceVersion()); + return ZoneStore::Instance()->GetZoneSnowChance(self->GetZoneID(), slot, self->GetInstanceVersion()); } int Lua_Zone::GetSnowDuration() { Lua_Safe_Call_Int(); - return zone_store.GetZoneSnowDuration(self->GetZoneID(), 0, self->GetInstanceVersion()); + return ZoneStore::Instance()->GetZoneSnowDuration(self->GetZoneID(), 0, self->GetInstanceVersion()); } int Lua_Zone::GetSnowDuration(uint8 slot) { Lua_Safe_Call_Int(); - return zone_store.GetZoneSnowDuration(self->GetZoneID(), slot, self->GetInstanceVersion()); + return ZoneStore::Instance()->GetZoneSnowDuration(self->GetZoneID(), slot, self->GetInstanceVersion()); } uint8 Lua_Zone::GetTimeType() { Lua_Safe_Call_Int(); - return zone_store.GetZoneTimeType(self->GetZoneID(), self->GetInstanceVersion()); + return ZoneStore::Instance()->GetZoneTimeType(self->GetZoneID(), self->GetInstanceVersion()); } int Lua_Zone::GetTimeZone() { Lua_Safe_Call_Int(); - return zone_store.GetZoneTimeZone(self->GetZoneID(), self->GetInstanceVersion()); + return ZoneStore::Instance()->GetZoneTimeZone(self->GetZoneID(), self->GetInstanceVersion()); } std::string Lua_Zone::GetZoneDescription() @@ -508,25 +507,25 @@ uint8 Lua_Zone::GetZoneType() float Lua_Zone::GetUnderworld() { Lua_Safe_Call_Real(); - return zone_store.GetZoneUnderworld(self->GetZoneID(), self->GetInstanceVersion()); + return ZoneStore::Instance()->GetZoneUnderworld(self->GetZoneID(), self->GetInstanceVersion()); } int Lua_Zone::GetUnderworldTeleportIndex() { Lua_Safe_Call_Int(); - return zone_store.GetZoneUnderworldTeleportIndex(self->GetZoneID(), self->GetInstanceVersion()); + return ZoneStore::Instance()->GetZoneUnderworldTeleportIndex(self->GetZoneID(), self->GetInstanceVersion()); } float Lua_Zone::GetWalkSpeed() { Lua_Safe_Call_Real(); - return zone_store.GetZoneWalkSpeed(self->GetZoneID(), self->GetInstanceVersion()); + return ZoneStore::Instance()->GetZoneWalkSpeed(self->GetZoneID(), self->GetInstanceVersion()); } uint8 Lua_Zone::GetZoneZType() { Lua_Safe_Call_Int(); - return zone_store.GetZoneZType(self->GetZoneID(), self->GetInstanceVersion()); + return ZoneStore::Instance()->GetZoneZType(self->GetZoneID(), self->GetInstanceVersion()); } int Lua_Zone::GetZoneTotalBlockedSpells() diff --git a/zone/main.cpp b/zone/main.cpp index 0f9abef3f..58e205609 100644 --- a/zone/main.cpp +++ b/zone/main.cpp @@ -93,7 +93,6 @@ extern volatile bool is_zone_loaded; EntityList entity_list; WorldServer worldserver; -ZoneStore zone_store; uint32 numclients = 0; char errorname[32]; extern Zone *zone; @@ -101,16 +100,11 @@ extern Zone *zone; npcDecayTimes_Struct npcCorpseDecayTimes[100]; TitleManager title_manager; QueryServ *QServ = 0; -TaskManager *task_manager = 0; NpcScaleManager *npc_scale_manager; QuestParserCollection *parse = 0; -EQEmuLogSys LogSys; ZoneEventScheduler event_scheduler; WorldContentService content_service; -PathManager path; PlayerEventLogs player_event_logs; -DatabaseUpdate database_update; -SkillCaps skill_caps; EvolvingItemsManager evolving_items_manager; const SPDat_Spell_Struct* spells; @@ -128,16 +122,16 @@ bool CheckForCompatibleQuestPlugins(); int main(int argc, char **argv) { RegisterExecutablePlatform(ExePlatformZone); - LogSys.LoadLogSettingsDefaults(); + EQEmuLogSys::Instance()->LoadLogSettingsDefaults(); set_exception_handler(); // silence logging if we ran a command if (ZoneCLI::RanConsoleCommand(argc, argv) || ZoneCLI::RanTestCommand(argc, argv)) { - LogSys.SilenceConsoleLogging(); + EQEmuLogSys::Instance()->SilenceConsoleLogging(); } - path.LoadPaths(); + PathManager::Instance()->Init(); #ifdef USE_MAP_MMFS if (argc == 3 && strcasecmp(argv[1], "convert_map") == 0) { @@ -300,27 +294,27 @@ int main(int argc, char **argv) // command handler (no sidecar or test commands) if (ZoneCLI::RanConsoleCommand(argc, argv) && !(ZoneCLI::RanSidecarCommand(argc, argv) || ZoneCLI::RanTestCommand(argc, argv))) { - LogSys.EnableConsoleLogging(); + EQEmuLogSys::Instance()->EnableConsoleLogging(); ZoneCLI::CommandHandler(argc, argv); } - LogSys.SetDatabase(&database) - ->SetLogPath(path.GetLogPath()) + EQEmuLogSys::Instance()->SetDatabase(&database) + ->SetLogPath(PathManager::Instance()->GetLogPath()) ->LoadLogDatabaseSettings(ZoneCLI::RanTestCommand(argc, argv)) ->SetGMSayHandler(&Zone::GMSayHookCallBackProcess) ->StartFileLogs(); if (ZoneCLI::RanTestCommand(argc, argv)) { - LogSys.SilenceConsoleLogging(); + EQEmuLogSys::Instance()->SilenceConsoleLogging(); } player_event_logs.SetDatabase(&database)->Init(); - skill_caps.SetContentDatabase(&content_db)->LoadSkillCaps(); + SkillCaps::Instance()->SetContentDatabase(&content_db)->LoadSkillCaps(); const auto c = EQEmuConfig::get(); if (c->auto_database_updates) { - if (database_update.SetDatabase(&database)->HasPendingUpdates()) { + if (DatabaseUpdate::Instance()->SetDatabase(&database)->HasPendingUpdates()) { LogWarning("Database is not up to date [world] needs to be ran to apply updates, shutting down in 5 seconds"); std::this_thread::sleep_for(std::chrono::milliseconds(5000)); LogInfo("Exiting due to pending database updates"); @@ -367,9 +361,9 @@ int main(int argc, char **argv) } } - zone_store.LoadZones(content_db); + ZoneStore::Instance()->LoadZones(content_db); - if (zone_store.GetZones().empty()) { + if (ZoneStore::Instance()->GetZones().empty()) { LogError("Failed to load zones data, check your schema for possible errors"); return 1; } @@ -450,8 +444,7 @@ int main(int argc, char **argv) npc_scale_manager->LoadScaleData(); if (RuleB(TaskSystem, EnableTaskSystem)) { - task_manager = new TaskManager; - task_manager->LoadTasks(); + TaskManager::Instance()->LoadTasks(); } parse = new QuestParserCollection(); @@ -495,7 +488,7 @@ int main(int argc, char **argv) // sidecar command handler if (ZoneCLI::RanConsoleCommand(argc, argv) && (ZoneCLI::RanSidecarCommand(argc, argv) || ZoneCLI::RanTestCommand(argc, argv))) { - LogSys.EnableConsoleLogging(); + EQEmuLogSys::Instance()->EnableConsoleLogging(); ZoneCLI::CommandHandler(argc, argv); } @@ -682,13 +675,12 @@ int main(int argc, char **argv) zone->Shutdown(true); } //Fix for Linux world server problem. - safe_delete(task_manager); safe_delete(npc_scale_manager); command_deinit(); bot_command_deinit(); safe_delete(parse); LogInfo("Proper zone shutdown complete."); - LogSys.CloseFileLogs(); + EQEmuLogSys::Instance()->CloseFileLogs(); safe_delete(mutex); safe_delete(QServ); @@ -700,7 +692,7 @@ void Shutdown() { zone->Shutdown(true); LogInfo("Shutting down..."); - LogSys.CloseFileLogs(); + EQEmuLogSys::Instance()->CloseFileLogs(); EQ::EventLoop::Get().Shutdown(); } @@ -752,7 +744,7 @@ bool CheckForCompatibleQuestPlugins() try { for (const auto &[directory, flag]: directories) { - std::string dir_path = path.GetServerPath() + "/" + directory; + std::string dir_path = PathManager::Instance()->GetServerPath() + "/" + directory; if (!File::Exists(dir_path)) { continue; } for (const auto &file: fs::directory_iterator(dir_path)) { diff --git a/zone/map.cpp b/zone/map.cpp index 7e3d8822c..bf6ff68ec 100644 --- a/zone/map.cpp +++ b/zone/map.cpp @@ -271,7 +271,7 @@ bool Map::DoCollisionCheck(glm::vec3 myloc, glm::vec3 oloc, glm::vec3 &outnorm, Map *Map::LoadMapFile(std::string file) { std::transform(file.begin(), file.end(), file.begin(), ::tolower); - std::string filename = fmt::format("{}/base/{}.map", path.GetMapsPath(), file); + std::string filename = fmt::format("{}/base/{}.map", PathManager::Instance()->GetMapsPath(), file); LogInfo("Attempting to load Map File [{}]", filename.c_str()); diff --git a/zone/merc.cpp b/zone/merc.cpp index c54585f9e..f19287e86 100644 --- a/zone/merc.cpp +++ b/zone/merc.cpp @@ -67,7 +67,7 @@ Merc::Merc(const NPCType* d, float x, float y, float z, float heading) int r; for (r = 0; r <= EQ::skills::HIGHEST_SKILL; r++) { - skills[r] = skill_caps.GetSkillCap(GetClass(), (EQ::skills::SkillType)r, GetLevel()).cap; + skills[r] = SkillCaps::Instance()->GetSkillCap(GetClass(), (EQ::skills::SkillType)r, GetLevel()).cap; } size = d->size; @@ -774,12 +774,12 @@ bool Merc::HasSkill(EQ::skills::SkillType skill_id) const { } bool Merc::CanHaveSkill(EQ::skills::SkillType skill_id) const { - return skill_caps.GetSkillCap(GetClass(), skill_id, RuleI(Character, MaxLevel)).cap > 0; + return SkillCaps::Instance()->GetSkillCap(GetClass(), skill_id, RuleI(Character, MaxLevel)).cap > 0; //if you don't have it by max level, then odds are you never will? } uint16 Merc::MaxSkill(EQ::skills::SkillType skillid, uint16 class_, uint16 level) const { - return skill_caps.GetSkillCap(class_, skillid, level).cap; + return SkillCaps::Instance()->GetSkillCap(class_, skillid, level).cap; } void Merc::FillSpawnStruct(NewSpawn_Struct* ns, Mob* ForWho) { diff --git a/zone/mob.h b/zone/mob.h index c963dc3fc..18541857e 100644 --- a/zone/mob.h +++ b/zone/mob.h @@ -208,6 +208,10 @@ public: Timer m_see_close_mobs_timer; Timer m_mob_check_moving_timer; + uint16 m_last_wearchange_race_id = 0; + // client_id -> slot_id -> key + std::unordered_map> m_last_seen_wearchange; + // Bot attack flag Timer bot_attack_flag_timer; diff --git a/zone/mob_appearance.cpp b/zone/mob_appearance.cpp index 4f6b2b509..430247443 100644 --- a/zone/mob_appearance.cpp +++ b/zone/mob_appearance.cpp @@ -381,10 +381,6 @@ void Mob::SendWearChange(uint8 material_slot, Client *one_client) auto packet = new EQApplicationPacket(OP_WearChange, sizeof(WearChange_Struct)); auto w = (WearChange_Struct *) packet->pBuffer; - Log(Logs::Detail, Logs::MobAppearance, "[%s]", - GetCleanName() - ); - w->spawn_id = GetID(); w->material = static_cast(GetEquipmentMaterial(material_slot)); w->elite_material = IsEliteMaterialItem(material_slot); @@ -399,10 +395,50 @@ void Mob::SendWearChange(uint8 material_slot, Client *one_client) w->wear_slot_id = material_slot; - if (!one_client) { - entity_list.QueueClients(this, packet); - } else { - one_client->QueuePacket(packet, false, Client::CLIENT_CONNECTED); + if (GetRace() != m_last_wearchange_race_id) { + m_last_seen_wearchange.clear(); + m_last_wearchange_race_id = GetRace(); + } + + // this is a hash-like key to deduplicate packets sent to clients + // it includes spawn_id, material, elite_material, hero_forge_model, wear_slot_id, and color + // we send an enormous amount of wearchange packets in brute-force fashion and this is a low cost way to deduplicate them + // we could remove all the extra wearchanges at the expense of tracing down intermittent visual bugs over a long time + auto build_key = [&](const WearChange_Struct& s) -> uint64_t { + uint64_t key = 0; + + key |= static_cast(s.material & 0xFFF) << 0; // 12 bits + key |= static_cast(s.elite_material & 0x1) << 12; // 1 bit + key |= static_cast(s.hero_forge_model & 0xFFFFF) << 13; // 20 bits + key |= static_cast(GetRace() & 0xFFFF) << 33; // 16 bits + + // Optional: Fold in color for appearance differences + uint8_t folded_color = static_cast( + (s.color.Color * 17ull) & 0xFF + ); + key |= static_cast(folded_color) << 49; + + return key; + }; + + + auto dedupe_key = build_key(*w); + auto send_if_changed = [&](Client* client) { + auto& last_key = m_last_seen_wearchange[client->GetID()][material_slot]; + if (last_key == dedupe_key) { + return; + } + last_key = dedupe_key; + client->QueuePacket(packet, true, Client::CLIENT_CONNECTED); + }; + + if (one_client) { + send_if_changed(one_client); + } + else { + for (auto& [_, client] : entity_list.GetClientList()) { + send_if_changed(client); + } } safe_delete(packet); diff --git a/zone/npc.cpp b/zone/npc.cpp index defebff94..1f02330d8 100644 --- a/zone/npc.cpp +++ b/zone/npc.cpp @@ -370,7 +370,7 @@ NPC::NPC(const NPCType *npc_type_data, Spawn2 *in_respawn, const glm::vec4 &posi //give NPCs skill values... int r; for (r = 0; r <= EQ::skills::HIGHEST_SKILL; r++) { - skills[r] = skill_caps.GetSkillCap(GetClass(), (EQ::skills::SkillType)r, moblevel).cap; + skills[r] = SkillCaps::Instance()->GetSkillCap(GetClass(), (EQ::skills::SkillType)r, moblevel).cap; } // some overrides -- really we need to be able to set skills for mobs in the DB // There are some known low level SHM/BST pets that do not follow this, which supports @@ -3726,7 +3726,7 @@ void NPC::RecalculateSkills() { int r; for (r = 0; r <= EQ::skills::HIGHEST_SKILL; r++) { - skills[r] = skill_caps.GetSkillCap(GetClass(), (EQ::skills::SkillType)r, level).cap; + skills[r] = SkillCaps::Instance()->GetSkillCap(GetClass(), (EQ::skills::SkillType)r, level).cap; } // some overrides -- really we need to be able to set skills for mobs in the DB diff --git a/zone/npc_scale_manager.cpp b/zone/npc_scale_manager.cpp index f8fef83e4..2a66b613a 100644 --- a/zone/npc_scale_manager.cpp +++ b/zone/npc_scale_manager.cpp @@ -187,7 +187,7 @@ void NpcScaleManager::ScaleNPC( npc->ModifyNPCStat("special_abilities", scale_data.special_abilities); } - if (LogSys.log_settings[Logs::NPCScaling].is_category_enabled == 1) { + if (EQEmuLogSys::Instance()->log_settings[Logs::NPCScaling].is_category_enabled == 1) { std::string scale_log; for (const auto &stat : scaling_stats) { diff --git a/zone/pathfinder_interface.cpp b/zone/pathfinder_interface.cpp index 74209703c..e6aef0cd9 100644 --- a/zone/pathfinder_interface.cpp +++ b/zone/pathfinder_interface.cpp @@ -7,7 +7,7 @@ IPathfinder *IPathfinder::Load(const std::string &zone) { struct stat statbuffer; - std::string navmesh_path = fmt::format("{}/maps/nav/{}.nav", path.GetServerPath(), zone); + std::string navmesh_path = fmt::format("{}/maps/nav/{}.nav", PathManager::Instance()->GetServerPath(), zone); if (stat(navmesh_path.c_str(), &statbuffer) == 0) { return new PathfinderNavmesh(navmesh_path); } diff --git a/zone/pch/pch.h b/zone/pch/pch.h new file mode 100644 index 000000000..a34b69021 --- /dev/null +++ b/zone/pch/pch.h @@ -0,0 +1,11 @@ +#pragma once + +#include "../merc.h" +#include "../mob.h" +#include "../npc.h" +#include "../corpse.h" +#include "../doors.h" +#include "../bot.h" +#include "../entity.h" +#include "../client.h" +#include "../zone.h" \ No newline at end of file diff --git a/zone/perl_client.cpp b/zone/perl_client.cpp index 20ff56fe3..2f853c9cb 100644 --- a/zone/perl_client.cpp +++ b/zone/perl_client.cpp @@ -3336,6 +3336,16 @@ bool Perl_Client_KeyRingRemove(Client* self, uint32 item_id) return self->KeyRingRemove(item_id); } +bool Perl_Client_CompleteTask(Client* self, int task_id) +{ + return self->CompleteTask(task_id); +} + +bool Perl_Client_UncompleteTask(Client* self, int task_id) +{ + return self->UncompleteTask(task_id); +} + void perl_register_client() { perl::interpreter perl(PERL_GET_THX); @@ -3418,6 +3428,7 @@ void perl_register_client() package.add("ClearPEQZoneFlag", &Perl_Client_ClearPEQZoneFlag); package.add("ClearXTargets", &Perl_Client_ClearXTargets); package.add("ClearZoneFlag", &Perl_Client_ClearZoneFlag); + package.add("CompleteTask", &Perl_Client_CompleteTask); package.add("Connected", &Perl_Client_Connected); package.add("CountAugmentEquippedByID", &Perl_Client_CountAugmentEquippedByID); package.add("CountItem", &Perl_Client_CountItem); @@ -3909,6 +3920,7 @@ void perl_register_client() package.add("Thirsty", &Perl_Client_Thirsty); package.add("TrainDiscBySpellID", &Perl_Client_TrainDiscBySpellID); package.add("UnFreeze", &Perl_Client_UnFreeze); + package.add("UncompleteTask", &Perl_Client_UncompleteTask); package.add("Undye", &Perl_Client_Undye); package.add("UnmemSpell", (void(*)(Client*, int))&Perl_Client_UnmemSpell); package.add("UnmemSpell", (void(*)(Client*, int, bool))&Perl_Client_UnmemSpell); diff --git a/zone/perl_zone.cpp b/zone/perl_zone.cpp index 0d9cd8ddb..6cb49f557 100644 --- a/zone/perl_zone.cpp +++ b/zone/perl_zone.cpp @@ -13,7 +13,7 @@ bool Perl_Zone_BuffTimersSuspended(Zone* self) bool Perl_Zone_BypassesExpansionCheck(Zone* self) { - return zone_store.GetZoneBypassExpansionCheck(self->GetZoneID(), self->GetInstanceVersion()); + return ZoneStore::Instance()->GetZoneBypassExpansionCheck(self->GetZoneID(), self->GetInstanceVersion()); } bool Perl_Zone_CanBind(Zone* self) @@ -73,22 +73,22 @@ float Perl_Zone_GetAAEXPModifierByCharacterID(Zone* self, uint32 character_id) std::string Perl_Zone_GetContentFlags(Zone* self) { - return zone_store.GetZoneContentFlags(self->GetZoneID(), self->GetInstanceVersion()); + return ZoneStore::Instance()->GetZoneContentFlags(self->GetZoneID(), self->GetInstanceVersion()); } std::string Perl_Zone_GetContentFlagsDisabled(Zone* self) { - return zone_store.GetZoneContentFlagsDisabled(self->GetZoneID(), self->GetInstanceVersion()); + return ZoneStore::Instance()->GetZoneContentFlagsDisabled(self->GetZoneID(), self->GetInstanceVersion()); } float Perl_Zone_GetExperienceMultiplier(Zone* self) { - return zone_store.GetZoneExperienceMultiplier(self->GetZoneID(), self->GetInstanceVersion()); + return ZoneStore::Instance()->GetZoneExperienceMultiplier(self->GetZoneID(), self->GetInstanceVersion()); } int8 Perl_Zone_GetExpansion(Zone* self) { - return zone_store.GetZoneExpansion(self->GetZoneID(), self->GetInstanceVersion()); + return ZoneStore::Instance()->GetZoneExpansion(self->GetZoneID(), self->GetInstanceVersion()); } float Perl_Zone_GetEXPModifier(Zone* self, Client* c) @@ -103,17 +103,17 @@ float Perl_Zone_GetEXPModifierByCharacterID(Zone* self, uint32 character_id) int Perl_Zone_GetFastRegenEndurance(Zone* self) { - return zone_store.GetZoneFastRegenEndurance(self->GetZoneID(), self->GetInstanceVersion()); + return ZoneStore::Instance()->GetZoneFastRegenEndurance(self->GetZoneID(), self->GetInstanceVersion()); } int Perl_Zone_GetFastRegenHP(Zone* self) { - return zone_store.GetZoneFastRegenHP(self->GetZoneID(), self->GetInstanceVersion()); + return ZoneStore::Instance()->GetZoneFastRegenHP(self->GetZoneID(), self->GetInstanceVersion()); } int Perl_Zone_GetFastRegenMana(Zone* self) { - return zone_store.GetZoneFastRegenMana(self->GetZoneID(), self->GetInstanceVersion()); + return ZoneStore::Instance()->GetZoneFastRegenMana(self->GetZoneID(), self->GetInstanceVersion()); } std::string Perl_Zone_GetFileName(Zone* self) @@ -123,37 +123,37 @@ std::string Perl_Zone_GetFileName(Zone* self) std::string Perl_Zone_GetFlagNeeded(Zone* self) { - return zone_store.GetZoneFlagNeeded(self->GetZoneID(), self->GetInstanceVersion()); + return ZoneStore::Instance()->GetZoneFlagNeeded(self->GetZoneID(), self->GetInstanceVersion()); } uint8 Perl_Zone_GetFogBlue(Zone* self, uint8 slot = 0) { - return zone_store.GetZoneFogBlue(self->GetZoneID(), slot, self->GetInstanceVersion()); + return ZoneStore::Instance()->GetZoneFogBlue(self->GetZoneID(), slot, self->GetInstanceVersion()); } float Perl_Zone_GetFogDensity(Zone* self) { - return zone_store.GetZoneFogDensity(self->GetZoneID(), self->GetInstanceVersion()); + return ZoneStore::Instance()->GetZoneFogDensity(self->GetZoneID(), self->GetInstanceVersion()); } uint8 Perl_Zone_GetFogGreen(Zone* self, uint8 slot = 0) { - return zone_store.GetZoneFogGreen(self->GetZoneID(), slot, self->GetInstanceVersion()); + return ZoneStore::Instance()->GetZoneFogGreen(self->GetZoneID(), slot, self->GetInstanceVersion()); } float Perl_Zone_GetFogMaximumClip(Zone* self, uint8 slot = 0) { - return zone_store.GetZoneFogMaximumClip(self->GetZoneID(), slot, self->GetInstanceVersion()); + return ZoneStore::Instance()->GetZoneFogMaximumClip(self->GetZoneID(), slot, self->GetInstanceVersion()); } float Perl_Zone_GetFogMinimumClip(Zone* self, uint8 slot = 0) { - return zone_store.GetZoneFogMinimumClip(self->GetZoneID(), slot, self->GetInstanceVersion()); + return ZoneStore::Instance()->GetZoneFogMinimumClip(self->GetZoneID(), slot, self->GetInstanceVersion()); } uint8 Perl_Zone_GetFogRed(Zone* self, uint8 slot = 0) { - return zone_store.GetZoneFogRed(self->GetZoneID(), slot, self->GetInstanceVersion()); + return ZoneStore::Instance()->GetZoneFogRed(self->GetZoneID(), slot, self->GetInstanceVersion()); } float Perl_Zone_GetGraveyardHeading(Zone* self) @@ -188,7 +188,7 @@ uint32 Perl_Zone_GetGraveyardZoneID(Zone* self) float Perl_Zone_GetGravity(Zone* self) { - return zone_store.GetZoneGravity(self->GetZoneID(), self->GetInstanceVersion()); + return ZoneStore::Instance()->GetZoneGravity(self->GetZoneID(), self->GetInstanceVersion()); } uint32 Perl_Zone_GetInstanceID(Zone* self) @@ -198,7 +198,7 @@ uint32 Perl_Zone_GetInstanceID(Zone* self) uint8 Perl_Zone_GetInstanceType(Zone* self) { - return zone_store.GetZoneInstanceType(self->GetZoneID(), self->GetInstanceVersion()); + return ZoneStore::Instance()->GetZoneInstanceType(self->GetZoneID(), self->GetInstanceVersion()); } uint16 Perl_Zone_GetInstanceVersion(Zone* self) @@ -213,7 +213,7 @@ uint32 Perl_Zone_GetInstanceTimeRemaining(Zone* self) int Perl_Zone_GetLavaDamage(Zone* self) { - return zone_store.GetZoneLavaDamage(self->GetZoneID(), self->GetInstanceVersion()); + return ZoneStore::Instance()->GetZoneLavaDamage(self->GetZoneID(), self->GetInstanceVersion()); } std::string Perl_Zone_GetLongName(Zone* self) @@ -223,17 +223,17 @@ std::string Perl_Zone_GetLongName(Zone* self) float Perl_Zone_GetMaximumClip(Zone* self) { - return zone_store.GetZoneMaximumClip(self->GetZoneID(), self->GetInstanceVersion()); + return ZoneStore::Instance()->GetZoneMaximumClip(self->GetZoneID(), self->GetInstanceVersion()); } int8 Perl_Zone_GetMaximumExpansion(Zone* self) { - return zone_store.GetZoneMaximumExpansion(self->GetZoneID(), self->GetInstanceVersion()); + return ZoneStore::Instance()->GetZoneMaximumExpansion(self->GetZoneID(), self->GetInstanceVersion()); } uint8 Perl_Zone_GetMaximumLevel(Zone* self) { - return zone_store.GetZoneMaximumLevel(self->GetZoneID(), self->GetInstanceVersion()); + return ZoneStore::Instance()->GetZoneMaximumLevel(self->GetZoneID(), self->GetInstanceVersion()); } uint32 Perl_Zone_GetMaxClients(Zone* self) @@ -243,57 +243,57 @@ uint32 Perl_Zone_GetMaxClients(Zone* self) float Perl_Zone_GetMinimumClip(Zone* self) { - return zone_store.GetZoneMinimumClip(self->GetZoneID(), self->GetInstanceVersion()); + return ZoneStore::Instance()->GetZoneMinimumClip(self->GetZoneID(), self->GetInstanceVersion()); } int8 Perl_Zone_GetMinimumExpansion(Zone* self) { - return zone_store.GetZoneMinimumExpansion(self->GetZoneID(), self->GetInstanceVersion()); + return ZoneStore::Instance()->GetZoneMinimumExpansion(self->GetZoneID(), self->GetInstanceVersion()); } uint8 Perl_Zone_GetMinimumLevel(Zone* self) { - return zone_store.GetZoneMinimumLevel(self->GetZoneID(), self->GetInstanceVersion()); + return ZoneStore::Instance()->GetZoneMinimumLevel(self->GetZoneID(), self->GetInstanceVersion()); } int Perl_Zone_GetMinimumLavaDamage(Zone* self) { - return zone_store.GetZoneMinimumLavaDamage(self->GetZoneID(), self->GetInstanceVersion()); + return ZoneStore::Instance()->GetZoneMinimumLavaDamage(self->GetZoneID(), self->GetInstanceVersion()); } uint8 Perl_Zone_GetMinimumStatus(Zone* self) { - return zone_store.GetZoneMinimumStatus(self->GetZoneID(), self->GetInstanceVersion()); + return ZoneStore::Instance()->GetZoneMinimumStatus(self->GetZoneID(), self->GetInstanceVersion()); } std::string Perl_Zone_GetNote(Zone* self) { - return zone_store.GetZoneNote(self->GetZoneID(), self->GetInstanceVersion()); + return ZoneStore::Instance()->GetZoneNote(self->GetZoneID(), self->GetInstanceVersion()); } int Perl_Zone_GetNPCMaximumAggroDistance(Zone* self) { - return zone_store.GetZoneNPCMaximumAggroDistance(self->GetZoneID(), self->GetInstanceVersion()); + return ZoneStore::Instance()->GetZoneNPCMaximumAggroDistance(self->GetZoneID(), self->GetInstanceVersion()); } int8 Perl_Zone_GetPEQZone(Zone* self) { - return zone_store.GetZonePEQZone(self->GetZoneID(), self->GetInstanceVersion()); + return ZoneStore::Instance()->GetZonePEQZone(self->GetZoneID(), self->GetInstanceVersion()); } int Perl_Zone_GetRainChance(Zone* self, uint8 slot = 0) { - return zone_store.GetZoneRainChance(self->GetZoneID(), slot, self->GetInstanceVersion()); + return ZoneStore::Instance()->GetZoneRainChance(self->GetZoneID(), slot, self->GetInstanceVersion()); } int Perl_Zone_GetRainDuration(Zone* self, uint8 slot = 0) { - return zone_store.GetZoneRainDuration(self->GetZoneID(), slot, self->GetInstanceVersion()); + return ZoneStore::Instance()->GetZoneRainDuration(self->GetZoneID(), slot, self->GetInstanceVersion()); } uint32 Perl_Zone_GetRuleSet(Zone* self) { - return zone_store.GetZoneRuleSet(self->GetZoneID(), self->GetInstanceVersion()); + return ZoneStore::Instance()->GetZoneRuleSet(self->GetZoneID(), self->GetInstanceVersion()); } float Perl_Zone_GetSafeHeading(Zone* self) @@ -328,37 +328,37 @@ uint32 Perl_Zone_GetSecondsBeforeIdle(Zone* self) uint64 Perl_Zone_GetShutdownDelay(Zone* self) { - return zone_store.GetZoneShutdownDelay(self->GetZoneID(), self->GetInstanceVersion()); + return ZoneStore::Instance()->GetZoneShutdownDelay(self->GetZoneID(), self->GetInstanceVersion()); } uint8 Perl_Zone_GetSky(Zone* self) { - return zone_store.GetZoneSky(self->GetZoneID(), self->GetInstanceVersion()); + return ZoneStore::Instance()->GetZoneSky(self->GetZoneID(), self->GetInstanceVersion()); } int8 Perl_Zone_GetSkyLock(Zone* self) { - return zone_store.GetZoneSkyLock(self->GetZoneID(), self->GetInstanceVersion()); + return ZoneStore::Instance()->GetZoneSkyLock(self->GetZoneID(), self->GetInstanceVersion()); } int Perl_Zone_GetSnowChance(Zone* self, uint8 slot = 0) { - return zone_store.GetZoneSnowChance(self->GetZoneID(), slot, self->GetInstanceVersion()); + return ZoneStore::Instance()->GetZoneSnowChance(self->GetZoneID(), slot, self->GetInstanceVersion()); } int Perl_Zone_GetSnowDuration(Zone* self, uint8 slot = 0) { - return zone_store.GetZoneSnowDuration(self->GetZoneID(), slot, self->GetInstanceVersion()); + return ZoneStore::Instance()->GetZoneSnowDuration(self->GetZoneID(), slot, self->GetInstanceVersion()); } uint8 Perl_Zone_GetTimeType(Zone* self) { - return zone_store.GetZoneTimeType(self->GetZoneID(), self->GetInstanceVersion()); + return ZoneStore::Instance()->GetZoneTimeType(self->GetZoneID(), self->GetInstanceVersion()); } int Perl_Zone_GetTimeZone(Zone* self) { - return zone_store.GetZoneTimeZone(self->GetZoneID(), self->GetInstanceVersion()); + return ZoneStore::Instance()->GetZoneTimeZone(self->GetZoneID(), self->GetInstanceVersion()); } std::string Perl_Zone_GetZoneDescription(Zone* self) @@ -378,22 +378,22 @@ uint8 Perl_Zone_GetZoneType(Zone* self) float Perl_Zone_GetUnderworld(Zone* self) { - return zone_store.GetZoneUnderworld(self->GetZoneID(), self->GetInstanceVersion()); + return ZoneStore::Instance()->GetZoneUnderworld(self->GetZoneID(), self->GetInstanceVersion()); } int Perl_Zone_GetUnderworldTeleportIndex(Zone* self) { - return zone_store.GetZoneUnderworldTeleportIndex(self->GetZoneID(), self->GetInstanceVersion()); + return ZoneStore::Instance()->GetZoneUnderworldTeleportIndex(self->GetZoneID(), self->GetInstanceVersion()); } float Perl_Zone_GetWalkSpeed(Zone* self) { - return zone_store.GetZoneWalkSpeed(self->GetZoneID(), self->GetInstanceVersion()); + return ZoneStore::Instance()->GetZoneWalkSpeed(self->GetZoneID(), self->GetInstanceVersion()); } uint8 Perl_Zone_GetZoneZType(Zone* self) { - return zone_store.GetZoneZType(self->GetZoneID(), self->GetInstanceVersion()); + return ZoneStore::Instance()->GetZoneZType(self->GetZoneID(), self->GetInstanceVersion()); } int Perl_Zone_GetZoneTotalBlockedSpells(Zone* self) diff --git a/zone/petitions.cpp b/zone/petitions.cpp index 1f4dd8ff7..2790a0df8 100644 --- a/zone/petitions.cpp +++ b/zone/petitions.cpp @@ -38,8 +38,6 @@ Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org) #include "petitions.h" #include "worldserver.h" -PetitionList petition_list; - extern WorldServer worldserver; void Petition::SendPetitionToPlayer(Client* clientto) { @@ -288,7 +286,7 @@ void ZoneDatabase::RefreshPetitionsFromDB() newpet->SetCheckedOut(true); else newpet->SetCheckedOut(false); - petition_list.AddPetition(newpet); + PetitionList::Instance()->AddPetition(newpet); } } diff --git a/zone/petitions.h b/zone/petitions.h index b3a0dc5fd..20ddf8137 100644 --- a/zone/petitions.h +++ b/zone/petitions.h @@ -112,6 +112,12 @@ public: bool FindPetitionByAccountName(const char* acctname); bool DeletePetitionByCharName(const char* charname); + static PetitionList* Instance() + { + static PetitionList instance; + return &instance; + } + private: LinkedList list; Mutex PList_Mutex; diff --git a/zone/position.cpp b/zone/position.cpp index 52062120e..39cb5b6d4 100644 --- a/zone/position.cpp +++ b/zone/position.cpp @@ -6,6 +6,7 @@ #include "../common/data_verification.h" #include #include "../common/types.h" +#include constexpr float position_eps = 0.0001f; diff --git a/zone/queryserv.cpp b/zone/queryserv.cpp index c94d88795..77a00b8e2 100644 --- a/zone/queryserv.cpp +++ b/zone/queryserv.cpp @@ -1,12 +1,13 @@ #include "../common/global_define.h" #include "../common/servertalk.h" #include "../common/strings.h" +#include "../common/events/player_event_logs.h" #include "queryserv.h" #include "worldserver.h" extern WorldServer worldserver; -extern QueryServ *QServ; +extern QueryServ* QServ; QueryServ::QueryServ() { @@ -20,18 +21,29 @@ void QueryServ::SendQuery(std::string Query) { auto pack = new ServerPacket(ServerOP_QSSendQuery, Query.length() + 5); pack->WriteUInt32(Query.length()); /* Pack Query String Size so it can be dynamically broken out at queryserv */ - pack->WriteString(Query.c_str()); /* Query */ + pack->WriteString(Query.c_str()); /* Query */ worldserver.SendPacket(pack); safe_delete(pack); } void QueryServ::Connect() { - m_connection = std::make_unique(Config->QSHost, Config->QSPort, false, "Zone", Config->SharedKey); + m_connection = std::make_unique( + Config->QSHost, + Config->QSPort, + false, + "Zone", + Config->SharedKey + ); m_connection->OnMessage(std::bind(&QueryServ::HandleMessage, this, std::placeholders::_1, std::placeholders::_2)); - m_connection->OnConnect([this](EQ::Net::ServertalkClient *client) { + m_connection->OnConnect([this](EQ::Net::ServertalkClient* client) + { m_is_qs_connected = true; - LogInfo("Query Server connection established to [{}] [{}]", client->Handle()->RemoteIP(), client->Handle()->RemotePort()); + LogInfo( + "Query Server connection established to [{}] [{}]", + client->Handle()->RemoteIP(), + client->Handle()->RemotePort() + ); }); LogInfo( @@ -41,7 +53,7 @@ void QueryServ::Connect() ); } -bool QueryServ::SendPacket(ServerPacket *pack) +bool QueryServ::SendPacket(ServerPacket* pack) { if (m_connection.get() == nullptr) { Connect(); @@ -59,14 +71,50 @@ bool QueryServ::SendPacket(ServerPacket *pack) return false; } -void QueryServ::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) +void QueryServ::HandleMessage(uint16 opcode, const EQ::Net::Packet& p) { ServerPacket tpack(opcode, p); - auto pack = &tpack; + auto pack = &tpack; switch (opcode) { - default: { - LogInfo("Unknown ServerOP Received [{}]", opcode); + case ServerOP_SendPlayerEventSettings: + { + if (pack->size < sizeof(ServerSendPlayerEvent_Struct)) { + LogError("ServerOP_SendPlayerEventSettings: packet too small"); + break; + } + + auto* data = reinterpret_cast(pack->pBuffer); + const uint32_t expected_size = sizeof(ServerSendPlayerEvent_Struct) + data->cereal_size; + + if (pack->size < expected_size) { + LogError( + "ServerOP_SendPlayerEventSettings: packet size mismatch, expected {}, got {}", expected_size, + pack->size + ); + break; + } + + std::vector settings; + + try { + EQ::Util::MemoryStreamReader ms(const_cast(data->cereal_data), data->cereal_size); + cereal::BinaryInputArchive ar(ms); + ar(settings); + } + catch (const std::exception& ex) { + LogError("Failed to deserialize PlayerEventLogSettings: {}", ex.what()); + break; + } + + player_event_logs.LoadPlayerEventSettingsFromQS(settings); + LogInfo("Loaded {} PlayerEventLogSettings from queryserv", settings.size()); + break; + } + + default: + { + LogInfo("Unknown ServerOP Received [{}]", opcode); break; } } diff --git a/zone/quest_parser_collection.cpp b/zone/quest_parser_collection.cpp index 18022b570..2ab537c64 100644 --- a/zone/quest_parser_collection.cpp +++ b/zone/quest_parser_collection.cpp @@ -939,7 +939,7 @@ QuestInterface* QuestParserCollection::GetQIByNPCQuest(uint32 npc_id, std::strin Strings::FindReplace(npc_name, "`", "-"); - for (auto & dir : path.GetQuestPaths()) { + for (auto & dir : PathManager::Instance()->GetQuestPaths()) { const std::string& npc_id_and_name = fmt::format( "{}_{}", npc_name, @@ -1007,7 +1007,7 @@ QuestInterface* QuestParserCollection::GetQIByPlayerQuest(std::string& filename) return nullptr; } - for (auto & dir : path.GetQuestPaths()) { + for (auto & dir : PathManager::Instance()->GetQuestPaths()) { const std::string& global_path = fmt::format( "{}/{}", dir, @@ -1062,7 +1062,7 @@ QuestInterface* QuestParserCollection::GetQIByGlobalNPCQuest(std::string& filena std::string file_name; - for (auto & dir : path.GetQuestPaths()) { + for (auto & dir : PathManager::Instance()->GetQuestPaths()) { for (auto* e: _load_precedence) { file_name = fmt::format( "{}/{}/global_npc.{}", @@ -1088,7 +1088,7 @@ QuestInterface* QuestParserCollection::GetQIByGlobalPlayerQuest(std::string& fil } std::string file_name; - for (auto & dir : path.GetQuestPaths()) { + for (auto & dir : PathManager::Instance()->GetQuestPaths()) { for (auto* e: _load_precedence) { file_name = fmt::format( "{}/{}/global_player.{}", @@ -1113,7 +1113,7 @@ QuestInterface* QuestParserCollection::GetQIBySpellQuest(uint32 spell_id, std::s return nullptr; } - for (auto & dir : path.GetQuestPaths()) { + for (auto & dir : PathManager::Instance()->GetQuestPaths()) { const std::string& global_path = fmt::format( "{}/{}/spells", dir, @@ -1167,7 +1167,7 @@ QuestInterface* QuestParserCollection::GetQIByItemQuest(std::string item_script, return nullptr; } - for (auto & dir : path.GetQuestPaths()) { + for (auto & dir : PathManager::Instance()->GetQuestPaths()) { const std::string& global_path = fmt::format( "{}/{}/items", dir, @@ -1221,7 +1221,7 @@ QuestInterface* QuestParserCollection::GetQIByEncounterQuest(std::string encount return nullptr; } - for (auto & dir : path.GetQuestPaths()) { + for (auto & dir : PathManager::Instance()->GetQuestPaths()) { const std::string& global_path = fmt::format( "{}/{}/encounters", dir, @@ -1273,7 +1273,7 @@ QuestInterface* QuestParserCollection::GetQIByBotQuest(std::string& filename) return nullptr; } - for (auto & dir : path.GetQuestPaths()) { + for (auto & dir : PathManager::Instance()->GetQuestPaths()) { const std::string& global_path = fmt::format( "{}/{}", dir, @@ -1327,7 +1327,7 @@ QuestInterface* QuestParserCollection::GetQIByGlobalBotQuest(std::string& filena } std::string file_name; - for (auto & dir : path.GetQuestPaths()) { + for (auto & dir : PathManager::Instance()->GetQuestPaths()) { for (auto* e: _load_precedence) { file_name = fmt::format( "{}/{}/global_bot.{}", @@ -1352,7 +1352,7 @@ QuestInterface* QuestParserCollection::GetQIByMercQuest(std::string& filename) return nullptr; } - for (auto & dir : path.GetQuestPaths()) { + for (auto & dir : PathManager::Instance()->GetQuestPaths()) { const std::string& global_path = fmt::format( "{}/{}", dir, @@ -1406,7 +1406,7 @@ QuestInterface* QuestParserCollection::GetQIByGlobalMercQuest(std::string& filen } std::string file_name; - for (auto & dir : path.GetQuestPaths()) { + for (auto & dir : PathManager::Instance()->GetQuestPaths()) { for (auto* e: _load_precedence) { file_name = fmt::format( "{}/{}/global_merc.{}", diff --git a/zone/questmgr.cpp b/zone/questmgr.cpp index b9807703e..ac17e68d3 100644 --- a/zone/questmgr.cpp +++ b/zone/questmgr.cpp @@ -40,6 +40,7 @@ #include "dialogue_window.h" #include "../common/repositories/account_repository.h" +#include "../common/repositories/completed_tasks_repository.h" #include "../common/repositories/tradeskill_recipe_repository.h" #include "../common/repositories/instance_list_repository.h" #include "../common/repositories/grid_entries_repository.h" @@ -200,7 +201,7 @@ void QuestManager::summonitem(uint32 itemid, int16 charges) { void QuestManager::write(const char *file, const char *str) { FILE * pFile; - pFile = fopen (fmt::format("{}/{}", path.GetServerPath(), file).c_str(), "a"); + pFile = fopen (fmt::format("{}/{}", PathManager::Instance()->GetServerPath(), file).c_str(), "a"); if(!pFile) return; fprintf(pFile, "%s\n", str); @@ -2868,27 +2869,27 @@ bool QuestManager::createBot(const char *name, const char *lastname, uint8 level void QuestManager::taskselector(const std::vector& tasks, bool ignore_cooldown) { QuestManagerCurrentQuestVars(); - if(RuleB(TaskSystem, EnableTaskSystem) && initiator && owner && task_manager) + if(RuleB(TaskSystem, EnableTaskSystem) && initiator && owner) initiator->TaskQuestSetSelector(owner, tasks, ignore_cooldown); } void QuestManager::enabletask(int taskcount, int *tasks) { QuestManagerCurrentQuestVars(); - if(RuleB(TaskSystem, EnableTaskSystem) && initiator && task_manager) + if(RuleB(TaskSystem, EnableTaskSystem) && initiator) initiator->EnableTask(taskcount, tasks); } void QuestManager::disabletask(int taskcount, int *tasks) { QuestManagerCurrentQuestVars(); - if(RuleB(TaskSystem, EnableTaskSystem) && initiator && task_manager) + if(RuleB(TaskSystem, EnableTaskSystem) && initiator) initiator->DisableTask(taskcount, tasks); } bool QuestManager::istaskenabled(int taskid) { QuestManagerCurrentQuestVars(); - if(RuleB(TaskSystem, EnableTaskSystem) && initiator && task_manager) + if(RuleB(TaskSystem, EnableTaskSystem) && initiator) return initiator->IsTaskEnabled(taskid); return false; @@ -2897,7 +2898,7 @@ bool QuestManager::istaskenabled(int taskid) { void QuestManager::tasksetselector(int tasksetid, bool ignore_cooldown) { QuestManagerCurrentQuestVars(); Log(Logs::General, Logs::Tasks, "[UPDATE] TaskSetSelector called for task set %i", tasksetid); - if(RuleB(TaskSystem, EnableTaskSystem) && initiator && owner && task_manager) + if(RuleB(TaskSystem, EnableTaskSystem) && initiator && owner) initiator->TaskSetSelector(owner, tasksetid, ignore_cooldown); } @@ -2958,6 +2959,27 @@ void QuestManager::failtask(int taskid) { initiator->FailTask(taskid); } +bool QuestManager::completetask(int task_id) { + QuestManagerCurrentQuestVars(); + + if (!RuleB(TaskSystem, EnableTaskSystem) || !initiator) { + return false; + + } + + return initiator->CompleteTask(task_id); +} + +bool QuestManager::uncompletetask(int task_id) { + QuestManagerCurrentQuestVars(); + + if (!RuleB(TaskSystem, EnableTaskSystem) || !initiator) { + return false; + } + + return initiator->UncompleteTask(task_id); +} + int QuestManager::tasktimeleft(int taskid) { QuestManagerCurrentQuestVars(); @@ -2979,8 +3001,8 @@ int QuestManager::enabledtaskcount(int taskset) { int QuestManager::firsttaskinset(int taskset) { QuestManagerCurrentQuestVars(); - if(RuleB(TaskSystem, EnableTaskSystem) && task_manager) - return task_manager->FirstTaskInSet(taskset); + if(RuleB(TaskSystem, EnableTaskSystem)) + return TaskManager::Instance()->FirstTaskInSet(taskset); return -1; } @@ -2988,8 +3010,8 @@ int QuestManager::firsttaskinset(int taskset) { int QuestManager::lasttaskinset(int taskset) { QuestManagerCurrentQuestVars(); - if(RuleB(TaskSystem, EnableTaskSystem) && task_manager) - return task_manager->LastTaskInSet(taskset); + if(RuleB(TaskSystem, EnableTaskSystem)) + return TaskManager::Instance()->LastTaskInSet(taskset); return -1; } @@ -2997,8 +3019,8 @@ int QuestManager::lasttaskinset(int taskset) { int QuestManager::nexttaskinset(int taskset, int taskid) { QuestManagerCurrentQuestVars(); - if(RuleB(TaskSystem, EnableTaskSystem) && task_manager) - return task_manager->NextTaskInSet(taskset, taskid); + if(RuleB(TaskSystem, EnableTaskSystem)) + return TaskManager::Instance()->NextTaskInSet(taskset, taskid); return -1; } @@ -3063,8 +3085,8 @@ int QuestManager::completedtasksinset(int taskset) { bool QuestManager::istaskappropriate(int task) { QuestManagerCurrentQuestVars(); - if(RuleB(TaskSystem, EnableTaskSystem) && initiator && task_manager) - return task_manager->ValidateLevel(task, initiator->GetLevel()); + if(RuleB(TaskSystem, EnableTaskSystem) && initiator) + return TaskManager::Instance()->ValidateLevel(task, initiator->GetLevel()); return false; } @@ -3073,7 +3095,7 @@ std::string QuestManager::gettaskname(uint32 task_id) { QuestManagerCurrentQuestVars(); if (RuleB(TaskSystem, EnableTaskSystem)) { - return task_manager->GetTaskName(task_id); + return TaskManager::Instance()->GetTaskName(task_id); } return std::string(); @@ -3082,8 +3104,8 @@ std::string QuestManager::gettaskname(uint32 task_id) { int QuestManager::GetCurrentDzTaskID() { QuestManagerCurrentQuestVars(); - if (RuleB(TaskSystem, EnableTaskSystem) && zone && task_manager) { - return task_manager->GetCurrentDzTaskID(); + if (RuleB(TaskSystem, EnableTaskSystem) && zone) { + return TaskManager::Instance()->GetCurrentDzTaskID(); } return 0; @@ -3092,8 +3114,8 @@ int QuestManager::GetCurrentDzTaskID() { void QuestManager::EndCurrentDzTask(bool send_fail) { QuestManagerCurrentQuestVars(); - if (RuleB(TaskSystem, EnableTaskSystem) && zone && task_manager) { - task_manager->EndCurrentDzTask(send_fail); + if (RuleB(TaskSystem, EnableTaskSystem) && zone) { + TaskManager::Instance()->EndCurrentDzTask(send_fail); } } diff --git a/zone/questmgr.h b/zone/questmgr.h index 5148b44f5..0e3cd4a4f 100644 --- a/zone/questmgr.h +++ b/zone/questmgr.h @@ -224,6 +224,8 @@ public: void resettaskactivity(int task, int activity); void assigntask(int taskid, bool enforce_level_requirement = false); void failtask(int taskid); + bool completetask(int task_id); + bool uncompletetask(int task_id); int tasktimeleft(int taskid); bool istaskcompleted(int task_id); bool aretaskscompleted(const std::vector& task_ids); diff --git a/zone/shared_task_zone_messaging.cpp b/zone/shared_task_zone_messaging.cpp index eac3a783a..f3cbe0983 100644 --- a/zone/shared_task_zone_messaging.cpp +++ b/zone/shared_task_zone_messaging.cpp @@ -157,7 +157,7 @@ void SharedTaskZoneMessaging::HandleWorldMessage(ServerPacket *pack) for (auto &client: entity_list.GetClientList()) { Client *c = client.second; - task_manager->SyncClientSharedTaskState(c, c->GetTaskState()); + TaskManager::Instance()->SyncClientSharedTaskState(c, c->GetTaskState()); c->RemoveClientTaskState(); c->LoadClientTaskState(); } diff --git a/zone/sidecar_api/loot_simulator_controller.cpp b/zone/sidecar_api/loot_simulator_controller.cpp index 1a91ab3fd..ad61157ef 100644 --- a/zone/sidecar_api/loot_simulator_controller.cpp +++ b/zone/sidecar_api/loot_simulator_controller.cpp @@ -11,7 +11,7 @@ void SidecarApi::LootSimulatorController(const httplib::Request &req, httplib::R auto iterations = 100; auto log_enabled = false; - LogSys.log_settings[Logs::Loot].log_to_console = 0; + EQEmuLogSys::Instance()->log_settings[Logs::Loot].log_to_console = 0; nlohmann::json j; diff --git a/zone/task_client_state.cpp b/zone/task_client_state.cpp index 1bd633ddf..42d504ec5 100644 --- a/zone/task_client_state.cpp +++ b/zone/task_client_state.cpp @@ -66,7 +66,7 @@ void ClientTaskState::SendTaskHistory(Client *client, int task_index) return; } - const auto task_data = task_manager->GetTaskData(task_id); + const auto task_data = TaskManager::Instance()->GetTaskData(task_id); if (!task_data) { return; } @@ -252,16 +252,16 @@ int ClientTaskState::EnabledTaskCount(int task_set_id) if ((task_set_id <= 0) || (task_set_id >= MAXTASKSETS)) { return -1; } while ((enabled_task_index < m_enabled_tasks.size()) && - (task_set_index < task_manager->m_task_sets[task_set_id].size())) { + (task_set_index < TaskManager::Instance()->m_task_sets[task_set_id].size())) { - if (m_enabled_tasks[enabled_task_index] == task_manager->m_task_sets[task_set_id][task_set_index]) { + if (m_enabled_tasks[enabled_task_index] == TaskManager::Instance()->m_task_sets[task_set_id][task_set_index]) { enabled_task_count++; enabled_task_index++; task_set_index++; continue; } - if (m_enabled_tasks[enabled_task_index] < task_manager->m_task_sets[task_set_id][task_set_index]) { + if (m_enabled_tasks[enabled_task_index] < TaskManager::Instance()->m_task_sets[task_set_id][task_set_index]) { enabled_task_index++; } else { @@ -281,7 +281,7 @@ int ClientTaskState::ActiveTasksInSet(int task_set_id) int active_task_in_set_count = 0; - for (int task_id : task_manager->m_task_sets[task_set_id]) { + for (int task_id : TaskManager::Instance()->m_task_sets[task_set_id]) { if (IsTaskActive(task_id)) { active_task_in_set_count++; } @@ -298,7 +298,7 @@ int ClientTaskState::CompletedTasksInSet(int task_set_id) int completed_tasks_count = 0; - for (int i : task_manager->m_task_sets[task_set_id]) { + for (int i : TaskManager::Instance()->m_task_sets[task_set_id]) { if (IsTaskCompleted(i)) { completed_tasks_count++; } @@ -362,7 +362,7 @@ bool ClientTaskState::UnlockActivities(Client* client, ClientTaskInformation& ta task_info.updated ); - const auto task = task_manager->GetTaskData(task_info.task_id); + const auto task = TaskManager::Instance()->GetTaskData(task_info.task_id); if (!task) { return true; @@ -453,7 +453,7 @@ const TaskInformation* ClientTaskState::GetTaskData(const ClientTaskInformation& return nullptr; } - return task_manager->GetTaskData(client_task.task_id); + return TaskManager::Instance()->GetTaskData(client_task.task_id); } bool ClientTaskState::CanUpdate(Client* client, const TaskUpdateFilter& filter, int task_id, @@ -521,11 +521,6 @@ bool ClientTaskState::CanUpdate(Client* client, const TaskUpdateFilter& filter, int ClientTaskState::UpdateTasks(Client* client, const TaskUpdateFilter& filter, int count) { - if (!task_manager) - { - return 0; - } - int max_updated = 0; for (const auto& client_task : m_active_tasks) @@ -593,11 +588,6 @@ int ClientTaskState::UpdateTasks(Client* client, const TaskUpdateFilter& filter, std::pair ClientTaskState::FindTask(Client* client, const TaskUpdateFilter& filter) const { - if (!task_manager) - { - return std::make_pair(0, 0); - } - for (const auto& client_task : m_active_tasks) { const auto task = GetTaskData(client_task); @@ -901,7 +891,7 @@ int ClientTaskState::IncrementDoneCount( // and by the 'Task Stage Completed' message client->SendTaskActivityComplete(info->task_id, activity_id, task_index, task_data->type); // Send the updated task/activity_information list to the client - task_manager->SendSingleActiveTaskToClient(client, *info, task_complete, false); + TaskManager::Instance()->SendSingleActiveTaskToClient(client, *info, task_complete, false); if (!ignore_quest_update) { if (parse->PlayerHasQuestSub(EVENT_TASK_STAGE_COMPLETE)) { @@ -929,7 +919,7 @@ int ClientTaskState::IncrementDoneCount( if (player_event_logs.IsEventEnabled(PlayerEvent::TASK_COMPLETE)) { auto e = PlayerEvent::TaskCompleteEvent{ .task_id = static_cast(info->task_id), - .task_name = task_manager->GetTaskName(static_cast(info->task_id)), + .task_name = TaskManager::Instance()->GetTaskName(static_cast(info->task_id)), .activity_id = static_cast(info->activity[activity_id].activity_id), .done_count = static_cast(info->activity[activity_id].done_count) }; @@ -948,7 +938,7 @@ int ClientTaskState::IncrementDoneCount( // shared tasks linger at the completion step and do not get removed from the task window unlike quests/task if (task_data->type != TaskType::Shared) { - task_manager->SendCompletedTasksToClient(client, this); + TaskManager::Instance()->SendCompletedTasksToClient(client, this); client->CancelTask(task_index, task_data->type); } @@ -958,7 +948,7 @@ int ClientTaskState::IncrementDoneCount( } else { // Send an updated packet for this single activity_information - task_manager->SendTaskActivityLong( + TaskManager::Instance()->SendTaskActivityLong( client, info->task_id, activity_id, @@ -968,7 +958,7 @@ int ClientTaskState::IncrementDoneCount( if (player_event_logs.IsEventEnabled(PlayerEvent::TASK_UPDATE)) { auto e = PlayerEvent::TaskUpdateEvent{ .task_id = static_cast(info->task_id), - .task_name = task_manager->GetTaskName(static_cast(info->task_id)), + .task_name = TaskManager::Instance()->GetTaskName(static_cast(info->task_id)), .activity_id = static_cast(info->activity[activity_id].activity_id), .done_count = static_cast(info->activity[activity_id].done_count) }; @@ -976,7 +966,7 @@ int ClientTaskState::IncrementDoneCount( } } - task_manager->SaveClientState(client, this); + TaskManager::Instance()->SaveClientState(client, this); return count; } @@ -1149,7 +1139,7 @@ void ClientTaskState::FailTask(Client *client, int task_id) // type: Shared Task (failed via world for all members) if (m_active_shared_task.task_id == task_id) { - task_manager->EndSharedTask(*client, task_id, true); + TaskManager::Instance()->EndSharedTask(*client, task_id, true); return; } @@ -1211,7 +1201,7 @@ bool ClientTaskState::IsTaskActivityActive(int task_id, int activity_id) return false; } - const auto task_data = task_manager->GetTaskData(info->task_id); + const auto task_data = TaskManager::Instance()->GetTaskData(info->task_id); if (!task_data) { return false; } @@ -1282,7 +1272,7 @@ void ClientTaskState::UpdateTaskActivity( return; } - const auto task_data = task_manager->GetTaskData(info->task_id); + const auto task_data = TaskManager::Instance()->GetTaskData(info->task_id); if (!task_data) { return; } @@ -1352,7 +1342,7 @@ void ClientTaskState::ResetTaskActivity(Client *client, int task_id, int activit return; } - const auto task_data = task_manager->GetTaskData(info->task_id); + const auto task_data = TaskManager::Instance()->GetTaskData(info->task_id); if (!task_data) { return; } @@ -1386,14 +1376,14 @@ void ClientTaskState::ResetTaskActivity(Client *client, int task_id, int activit bool ClientTaskState::CompleteTask(Client *c, uint32 task_id) { - const auto task_data = task_manager->GetTaskData(task_id); + const auto task_data = TaskManager::Instance()->GetTaskData(task_id); if (!task_data) { return false; } for ( int activity_id = 0; - activity_id < task_manager->GetActivityCount(task_id); + activity_id < TaskManager::Instance()->GetActivityCount(task_id); activity_id++ ) { c->UpdateTaskActivity( @@ -1406,9 +1396,19 @@ bool ClientTaskState::CompleteTask(Client *c, uint32 task_id) return true; } +bool ClientTaskState::UncompleteTask(int task_id) +{ + return std::erase_if( + m_completed_tasks, + [&](const CompletedTaskInformation& task) { + return task.task_id == task_id; + } + ); +} + void ClientTaskState::ShowClientTaskInfoMessage(ClientTaskInformation *task, Client *c) { - const auto task_data = task_manager->GetTaskData(task->task_id); + const auto task_data = TaskManager::Instance()->GetTaskData(task->task_id); c->Message(Chat::White, "------------------------------------------------"); c->Message( @@ -1430,7 +1430,7 @@ void ClientTaskState::ShowClientTaskInfoMessage(ClientTaskInformation *task, Cli ).c_str() ); - for (int activity_id = 0; activity_id < task_manager->GetActivityCount(task->task_id); activity_id++) { + for (int activity_id = 0; activity_id < TaskManager::Instance()->GetActivityCount(task->task_id); activity_id++) { std::vector update_increments = { "1", "5", "10", "20", "50" }; std::vector update_saylinks; @@ -1501,7 +1501,7 @@ int ClientTaskState::TaskTimeLeft(int task_id) if (m_active_task.task_id == task_id) { int time_now = time(nullptr); - const auto task_data = task_manager->GetTaskData(task_id); + const auto task_data = TaskManager::Instance()->GetTaskData(task_id); if (!task_data) { return -1; } @@ -1519,7 +1519,7 @@ int ClientTaskState::TaskTimeLeft(int task_id) if (m_active_shared_task.task_id == task_id) { int time_now = time(nullptr); - const auto task_data = task_manager->GetTaskData(task_id); + const auto task_data = TaskManager::Instance()->GetTaskData(task_id); if (!task_data) { return -1; } @@ -1544,7 +1544,7 @@ int ClientTaskState::TaskTimeLeft(int task_id) int time_now = time(nullptr); - const auto task_data = task_manager->GetTaskData(active_quest.task_id); + const auto task_data = TaskManager::Instance()->GetTaskData(active_quest.task_id); if (!task_data) { return -1; } @@ -1616,7 +1616,7 @@ bool ClientTaskState::TaskOutOfTime(TaskType task_type, int index) } int time_now = time(nullptr); - const auto task_data = task_manager->GetTaskData(info->task_id); + const auto task_data = TaskManager::Instance()->GetTaskData(info->task_id); if (!task_data) { return false; } @@ -1936,7 +1936,7 @@ void ClientTaskState::RemoveTask(Client *client, int sequence_number, TaskType t void ClientTaskState::RemoveTaskByTaskID(Client *client, uint32 task_id) { - switch (task_manager->GetTaskType(task_id)) { + switch (TaskManager::Instance()->GetTaskType(task_id)) { case TaskType::Task: { if (m_active_task.task_id == task_id) { LogTasks("RemoveTaskByTaskID found Task [{}]", task_id); @@ -1973,12 +1973,12 @@ void ClientTaskState::AcceptNewTask( bool enforce_level_requirement ) { - if (!task_manager || task_id < 0) { + if (task_id < 0) { client->Message(Chat::Red, "Task system not functioning, or task_id %i out of range.", task_id); return; } - const auto task = task_manager->GetTaskData(task_id); + const auto task = TaskManager::Instance()->GetTaskData(task_id); if (!task) { client->Message(Chat::Red, "Invalid task_id %i", task_id); return; @@ -2048,12 +2048,12 @@ void ClientTaskState::AcceptNewTask( } } - if (enforce_level_requirement && !task_manager->ValidateLevel(task_id, client->GetLevel())) { + if (enforce_level_requirement && !TaskManager::Instance()->ValidateLevel(task_id, client->GetLevel())) { client->MessageString(Chat::Yellow, TASK_NOT_RIGHT_LEVEL); return; } - if (!task_manager->IsTaskRepeatable(task_id) && IsTaskCompleted(task_id)) { + if (!TaskManager::Instance()->IsTaskRepeatable(task_id) && IsTaskCompleted(task_id)) { return; } @@ -2184,11 +2184,11 @@ void ClientTaskState::AcceptNewTask( } } - task_manager->SendSingleActiveTaskToClient(client, *active_slot, false, true); + TaskManager::Instance()->SendSingleActiveTaskToClient(client, *active_slot, false, true); client->StartTaskRequestCooldownTimer(); client->MessageString(Chat::DefaultText, YOU_ASSIGNED_TASK, task->title.c_str()); - task_manager->SaveClientState(client, this); + TaskManager::Instance()->SaveClientState(client, this); NPC *npc = entity_list.GetNPCByID(npc_entity_id); if (npc) { @@ -2197,7 +2197,7 @@ void ClientTaskState::AcceptNewTask( .npc_id = npc->GetNPCTypeID(), .npc_name = npc->GetCleanName(), .task_id = static_cast(task_id), - .task_name = task_manager->GetTaskName(static_cast(task_id)), + .task_name = TaskManager::Instance()->GetTaskName(static_cast(task_id)), }; RecordPlayerEventLogWithClient(client, PlayerEvent::TASK_ACCEPT, e); } @@ -2211,7 +2211,7 @@ void ClientTaskState::AcceptNewTask( .npc_id = 0, .npc_name = "No NPC", .task_id = static_cast(task_id), - .task_name = task_manager->GetTaskName(static_cast(task_id)), + .task_name = TaskManager::Instance()->GetTaskName(static_cast(task_id)), }; RecordPlayerEventLogWithClient(client, PlayerEvent::TASK_ACCEPT, e); } @@ -2247,7 +2247,7 @@ void ClientTaskState::SharedTaskIncrementDoneCount( bool ignore_quest_update ) { - const auto t = task_manager->GetTaskData(task_id); + const auto t = TaskManager::Instance()->GetTaskData(task_id); auto info = GetClientTaskInfo(t->type, TASKSLOTSHAREDTASK); if (info == nullptr) { @@ -2286,14 +2286,14 @@ bool ClientTaskState::HasActiveSharedTask() void ClientTaskState::CreateTaskDynamicZone(Client* client, int task_id, DynamicZone& dz_request) { - const auto task = task_manager->GetTaskData(task_id); + const auto task = TaskManager::Instance()->GetTaskData(task_id); if (!task) { return; } // dz should be named the version-based zone name (used in choose zone window and dz window on live) - auto zone_info = zone_store.GetZoneWithFallback(dz_request.GetZoneID(), dz_request.GetZoneVersion()); + auto zone_info = ZoneStore::Instance()->GetZoneWithFallback(dz_request.GetZoneID(), dz_request.GetZoneVersion()); dz_request.SetName(zone_info && !zone_info->long_name.empty() ? zone_info->long_name : task->title); dz_request.SetMinPlayers(task->min_players); dz_request.SetMaxPlayers(task->max_players); @@ -2349,7 +2349,7 @@ void ClientTaskState::ListTaskTimers(Client* client) for (const auto& task_timer : character_task_timers) { - const auto task = task_manager->GetTaskData(task_timer.task_id); + const auto task = TaskManager::Instance()->GetTaskData(task_timer.task_id); if (task) { auto timer_type = static_cast(task_timer.timer_type); @@ -2455,10 +2455,6 @@ void ClientTaskState::SyncSharedTaskZoneClientDoneCountState( bool ClientTaskState::HasActiveTasks() { - if (!task_manager) { - return false; - } - if (m_active_task.task_id != TASKSLOTEMPTY) { return true; } @@ -2495,9 +2491,9 @@ void ClientTaskState::LockSharedTask(Client* client, bool lock) void ClientTaskState::EndSharedTask(Client* client, bool send_fail) { - if (task_manager && m_active_shared_task.task_id != TASKSLOTEMPTY) + if (m_active_shared_task.task_id != TASKSLOTEMPTY) { - task_manager->EndSharedTask(*client, m_active_shared_task.task_id, send_fail); + TaskManager::Instance()->EndSharedTask(*client, m_active_shared_task.task_id, send_fail); } } bool ClientTaskState::CanAcceptNewTask(Client* client, int task_id, int npc_entity_id) const diff --git a/zone/task_client_state.h b/zone/task_client_state.h index c43329734..30c5dd69c 100644 --- a/zone/task_client_state.h +++ b/zone/task_client_state.h @@ -86,6 +86,7 @@ public: bool HasExploreTask(Client* client) const; void EndSharedTask(Client* client, bool send_fail); bool CompleteTask(Client *c, uint32 task_id); + bool UncompleteTask(int task_id); inline bool HasFreeTaskSlot() { return m_active_task.task_id == TASKSLOTEMPTY; } diff --git a/zone/task_manager.h b/zone/task_manager.h index e1f1a1154..abd1255a4 100644 --- a/zone/task_manager.h +++ b/zone/task_manager.h @@ -70,6 +70,12 @@ public: return it != m_task_data.end() ? &it->second : nullptr; } + static TaskManager* Instance() + { + static TaskManager instance; + return &instance; + } + private: std::vector m_task_sets[MAXTASKSETS]; std::unordered_map m_task_data; diff --git a/zone/tasks.cpp b/zone/tasks.cpp index 33c5150a6..708a43e84 100644 --- a/zone/tasks.cpp +++ b/zone/tasks.cpp @@ -14,17 +14,17 @@ extern QueryServ *QServ; void Client::LoadClientTaskState() { - if (RuleB(TaskSystem, EnableTaskSystem) && task_manager) { + if (RuleB(TaskSystem, EnableTaskSystem)) { LoadClientSharedCompletedTasks(); safe_delete(task_state); task_state = new ClientTaskState(); - if (!task_manager->LoadClientState(this, task_state)) { + if (!TaskManager::Instance()->LoadClientState(this, task_state)) { safe_delete(task_state); } else { - task_manager->SendActiveTasksToClient(this); - task_manager->SendCompletedTasksToClient(this, task_state); + TaskManager::Instance()->SendActiveTasksToClient(this); + TaskManager::Instance()->SendCompletedTasksToClient(this, task_state); } } } diff --git a/zone/water_map.cpp b/zone/water_map.cpp index 27289abd6..e31bb0c75 100644 --- a/zone/water_map.cpp +++ b/zone/water_map.cpp @@ -17,7 +17,7 @@ WaterMap* WaterMap::LoadWaterMapfile(std::string zone_name) { std::transform(zone_name.begin(), zone_name.end(), zone_name.begin(), ::tolower); - std::string file_path = fmt::format("{}/water/{}.wtr", path.GetMapsPath(), zone_name); + std::string file_path = fmt::format("{}/water/{}.wtr", PathManager::Instance()->GetMapsPath(), zone_name); LogDebug("Attempting to load water map with path [{}]", file_path.c_str()); FILE *f = fopen(file_path.c_str(), "rb"); if(f) { diff --git a/zone/worldserver.cpp b/zone/worldserver.cpp index 209ff87db..4115ecc5b 100644 --- a/zone/worldserver.cpp +++ b/zone/worldserver.cpp @@ -68,7 +68,6 @@ extern Zone *zone; extern volatile bool is_zone_loaded; extern void Shutdown(); extern WorldServer worldserver; -extern PetitionList petition_list; extern uint32 numclients; extern volatile bool RunLoops; extern QuestParserCollection *parse; @@ -230,7 +229,7 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) LogInfo("World assigned Port [{}] for this zone", sci->port); ZoneConfig::SetZonePort(sci->port); - LogSys.SetDiscordHandler(&Zone::DiscordWebhookMessageHandler); + EQEmuLogSys::Instance()->SetDiscordHandler(&Zone::DiscordWebhookMessageHandler); } break; } @@ -911,8 +910,8 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) std::cout << "Got Server Requested Petition List Refresh" << std::endl; ServerPetitionUpdate_Struct* sus = (ServerPetitionUpdate_Struct*)pack->pBuffer; // this was typoed to = instead of ==, not that it acts any different now though.. - if (sus->status == 0) petition_list.ReadDatabase(); - else if (sus->status == 1) petition_list.ReadDatabase(); // Until I fix this to be better.... + if (sus->status == 0) PetitionList::Instance()->ReadDatabase(); + else if (sus->status == 1) PetitionList::Instance()->ReadDatabase(); // Until I fix this to be better.... break; } case ServerOP_RezzPlayer: { @@ -3140,7 +3139,6 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) case ServerOP_WWMarquee: { auto s = (WWMarquee_Struct*) pack->pBuffer; - for (const auto& c : entity_list.GetClientList()) { if ( c.second->Admin() >= s->min_status && @@ -4591,8 +4589,12 @@ void WorldServer::ProcessReload(const ServerReload::Request& request) break; case ServerReload::Type::Logs: - LogSys.LoadLogDatabaseSettings(); + EQEmuLogSys::Instance()->LoadLogDatabaseSettings(); player_event_logs.ReloadSettings(); + // if QS process is enabled, we get settings from QS + if (!RuleB(Logging, PlayerEventsQSProcess)) { + player_event_logs.ReloadSettings(); + } break; case ServerReload::Type::Loot: @@ -4627,7 +4629,7 @@ void WorldServer::ProcessReload(const ServerReload::Request& request) break; case ServerReload::Type::SkillCaps: - skill_caps.ReloadSkillCaps(); + SkillCaps::Instance()->ReloadSkillCaps(); break; case ServerReload::Type::DataBucketsCache: @@ -4644,11 +4646,9 @@ void WorldServer::ProcessReload(const ServerReload::Request& request) case ServerReload::Type::Tasks: if (RuleB(Tasks, EnableTaskSystem)) { entity_list.SaveAllClientsTaskState(); - safe_delete(task_manager); - task_manager = new TaskManager; - task_manager->LoadTasks(); + TaskManager::Instance()->LoadTasks(); entity_list.ReloadAllClientsTaskState(); - task_manager->LoadTaskSets(); + TaskManager::Instance()->LoadTaskSets(); } break; @@ -4700,7 +4700,7 @@ void WorldServer::ProcessReload(const ServerReload::Request& request) break; case ServerReload::Type::ZoneData: - zone_store.LoadZones(content_db); + ZoneStore::Instance()->LoadZones(content_db); zone->LoadZoneCFG(zone->GetShortName(), zone->GetInstanceVersion()); break; diff --git a/zone/zone.cpp b/zone/zone.cpp index 6f00f805e..4a9efc60a 100644 --- a/zone/zone.cpp +++ b/zone/zone.cpp @@ -81,15 +81,12 @@ #endif extern bool staticzone; -extern PetitionList petition_list; extern QuestParserCollection* parse; extern uint32 numclients; extern WorldServer worldserver; extern Zone* zone; extern NpcScaleManager* npc_scale_manager; -Mutex MZoneShutdown; - volatile bool is_zone_loaded = false; Zone* zone = 0; @@ -178,7 +175,7 @@ bool Zone::Bootup(uint32 iZoneID, uint32 iInstanceID, bool is_static) { /* * Set Logging */ - LogSys.StartFileLogs(StringFormat("%s_version_%u_inst_id_%u_port_%u", zone->GetShortName(), zone->GetInstanceVersion(), zone->GetInstanceID(), ZoneConfig::get()->ZonePort)); + EQEmuLogSys::Instance()->StartFileLogs(StringFormat("%s_version_%u_inst_id_%u_port_%u", zone->GetShortName(), zone->GetInstanceVersion(), zone->GetInstanceID(), ZoneConfig::get()->ZonePort)); return true; } @@ -926,7 +923,7 @@ void Zone::Shutdown(bool quiet) GetInstanceVersion(), GetInstanceID() ); - petition_list.ClearPetitions(); + PetitionList::Instance()->ClearPetitions(); SetZoneHasCurrentTime(false); if (!quiet) { LogInfo( @@ -946,7 +943,7 @@ void Zone::Shutdown(bool quiet) parse->ReloadQuests(true); UpdateWindowTitle(nullptr); - LogSys.CloseFileLogs(); + EQEmuLogSys::Instance()->CloseFileLogs(); if (RuleB(Zone, KillProcessOnDynamicShutdown)) { LogInfo("Shutting down"); @@ -1236,17 +1233,17 @@ bool Zone::Init(bool is_static) { LoadMercenarySpells(); } - petition_list.ClearPetitions(); - petition_list.ReadDatabase(); + PetitionList::Instance()->ClearPetitions(); + PetitionList::Instance()->ReadDatabase(); guild_mgr.LoadGuilds(); LogInfo("Zone booted successfully zone_id [{}] time_offset [{}]", zoneid, zone_time.getEQTimeZone()); // logging origination information - LogSys.origination_info.zone_short_name = zone->short_name; - LogSys.origination_info.zone_long_name = zone->long_name; - LogSys.origination_info.instance_id = zone->instanceid; + EQEmuLogSys::Instance()->origination_info.zone_short_name = zone->short_name; + EQEmuLogSys::Instance()->origination_info.zone_long_name = zone->long_name; + EQEmuLogSys::Instance()->origination_info.instance_id = zone->instanceid; return true; } @@ -1302,7 +1299,7 @@ void Zone::ReloadStaticData() { bool Zone::LoadZoneCFG(const char* filename, uint16 instance_version) { - auto z = zone_store.GetZoneWithFallback(ZoneID(filename), instance_version); + auto z = ZoneStore::Instance()->GetZoneWithFallback(ZoneID(filename), instance_version); if (!z) { LogError("Failed to load zone data for [{}] instance_version [{}]", filename, instance_version); @@ -2253,7 +2250,7 @@ void Zone::LoadZoneBlockedSpells() if (!content_db.LoadBlockedSpells(zone_total_blocked_spells, blocked_spells, GetZoneID())) { LogError( "Failed to load blocked spells for {} ({}).", - zone_store.GetZoneName(GetZoneID(), true), + ZoneStore::Instance()->GetZoneName(GetZoneID(), true), GetZoneID() ); ClearBlockedSpells(); @@ -2263,7 +2260,7 @@ void Zone::LoadZoneBlockedSpells() LogInfo( "Loaded [{}] blocked spells(s) for {} ({}).", Strings::Commify(zone_total_blocked_spells), - zone_store.GetZoneName(GetZoneID(), true), + ZoneStore::Instance()->GetZoneName(GetZoneID(), true), GetZoneID() ); } @@ -2868,7 +2865,7 @@ void Zone::SendDiscordMessage(const std::string& webhook_name, const std::string bool not_found = true; for (int i= 0; i < MAX_DISCORD_WEBHOOK_ID; i++) { - auto &w = LogSys.GetDiscordWebhooks()[i]; + auto &w = EQEmuLogSys::Instance()->GetDiscordWebhooks()[i]; if (w.webhook_name == webhook_name) { SendDiscordMessage(w.id, message + "\n"); not_found = false; diff --git a/zone/zone.h b/zone/zone.h index 29a2980fd..237c7fdb0 100755 --- a/zone/zone.h +++ b/zone/zone.h @@ -387,7 +387,7 @@ public: entity_list.MessageStatus( 0, AccountStatus::QuestTroupe, - LogSys.GetGMSayColorFromCategory(log_category), + EQEmuLogSys::Instance()->GetGMSayColorFromCategory(log_category), message_split[0].c_str() ); @@ -395,7 +395,7 @@ public: entity_list.MessageStatus( 0, AccountStatus::QuestTroupe, - LogSys.GetGMSayColorFromCategory(log_category), + EQEmuLogSys::Instance()->GetGMSayColorFromCategory(log_category), fmt::format( "--- {}", message_split[iter] @@ -407,7 +407,7 @@ public: entity_list.MessageStatus( 0, AccountStatus::QuestTroupe, - LogSys.GetGMSayColorFromCategory(log_category), + EQEmuLogSys::Instance()->GetGMSayColorFromCategory(log_category), fmt::format("[{}] [{}] {}", Logs::LogCategoryName[log_category], func, message).c_str() ); } @@ -418,11 +418,11 @@ public: static void DiscordWebhookMessageHandler(uint16 log_category, int webhook_id, const std::string &message) { std::string message_prefix; - if (!LogSys.origination_info.zone_short_name.empty()) { + if (!EQEmuLogSys::Instance()->origination_info.zone_short_name.empty()) { message_prefix = fmt::format( "[**{}**] **Zone** [**{}**] ", Logs::LogCategoryName[log_category], - LogSys.origination_info.zone_short_name + EQEmuLogSys::Instance()->origination_info.zone_short_name ); } diff --git a/zone/zonedb.cpp b/zone/zonedb.cpp index d85d9cf63..7cd66a836 100644 --- a/zone/zonedb.cpp +++ b/zone/zonedb.cpp @@ -2639,7 +2639,7 @@ int64 ZoneDatabase::GetBlockedSpellsCount(uint32 zone_id) bool ZoneDatabase::LoadBlockedSpells(int64 blocked_spells_count, ZoneSpellsBlocked* into, uint32 zone_id) { - LogInfo("Loading Blocked Spells from database for {} ({}).", zone_store.GetZoneName(zone_id, true), zone_id); + LogInfo("Loading Blocked Spells from database for {} ({}).", ZoneStore::Instance()->GetZoneName(zone_id, true), zone_id); const auto& l = BlockedSpellsRepository::GetWhere( *this, @@ -2661,7 +2661,7 @@ bool ZoneDatabase::LoadBlockedSpells(int64 blocked_spells_count, ZoneSpellsBlock LogError( "Blocked spells count of {} exceeded for {} ({}).", blocked_spells_count, - zone_store.GetZoneName(zone_id, true), + ZoneStore::Instance()->GetZoneName(zone_id, true), zone_id ); break; diff --git a/zone/zoning.cpp b/zone/zoning.cpp index 1f84ff6e3..dad889251 100644 --- a/zone/zoning.cpp +++ b/zone/zoning.cpp @@ -352,7 +352,7 @@ void Client::Handle_OP_ZoneChange(const EQApplicationPacket *app) { if (content_service.GetCurrentExpansion() >= Expansion::Classic && !GetGM()) { bool meets_zone_expansion_check = false; - auto z = zone_store.GetZoneWithFallback(ZoneID(target_zone_name), 0); + auto z = ZoneStore::Instance()->GetZoneWithFallback(ZoneID(target_zone_name), 0); if (z->expansion <= content_service.GetCurrentExpansion() || z->bypass_expansion_check) { meets_zone_expansion_check = true; }