[Performance] Server Reload Overhaul (#4689)

* [Performance] Server Reload Overhaul

* Client::SendReloadCommandMessages

* Remove global buffs
This commit is contained in:
Chris Miles
2025-02-18 00:54:37 -06:00
committed by GitHub
parent 49cf97ae9c
commit 1bd281c8f2
24 changed files with 607 additions and 1258 deletions
+14 -102
View File
@@ -5,6 +5,7 @@
#include "zoneserver.h"
#include "zonelist.h"
#include "../common/database_schema.h"
#include "../common/server_reload_types.h"
#include "../common/zone_store.h"
#include "worlddb.h"
#include "wguild_mgr.h"
@@ -113,136 +114,47 @@ void callGetClientList(Json::Value &response)
client_list.GetClientList(response);
}
struct Reload {
std::string command{};
uint16 opcode;
std::string desc{};
};
std::vector<Reload> reload_types = {
Reload{.command = "aa", .opcode = ServerOP_ReloadAAData, .desc = "Alternate Advancement"},
Reload{.command = "alternate_currencies", .opcode = ServerOP_ReloadAlternateCurrencies, .desc = "Alternate Currencies"},
Reload{.command = "base_data", .opcode = ServerOP_ReloadBaseData, .desc = "Base Data"},
Reload{.command = "blocked_spells", .opcode = ServerOP_ReloadBlockedSpells, .desc = "Blocked Spells"},
Reload{.command = "commands", .opcode = ServerOP_ReloadCommands, .desc = "Commands"},
Reload{.command = "content_flags", .opcode = ServerOP_ReloadContentFlags, .desc = "Content Flags"},
Reload{.command = "data_buckets_cache", .opcode = ServerOP_ReloadDataBucketsCache, .desc = "Data Buckets Cache"},
Reload{.command = "doors", .opcode = ServerOP_ReloadDoors, .desc = "Doors"},
Reload{.command = "dztemplates", .opcode = ServerOP_ReloadDzTemplates, .desc = "Dynamic Zone Templates"},
Reload{.command = "ground_spawns", .opcode = ServerOP_ReloadGroundSpawns, .desc = "Ground Spawns"},
Reload{.command = "level_mods", .opcode = ServerOP_ReloadLevelEXPMods, .desc = "Level Mods"},
Reload{.command = "logs", .opcode = ServerOP_ReloadLogs, .desc = "Log Settings"},
Reload{.command = "loot", .opcode = ServerOP_ReloadLoot, .desc = "Loot"},
Reload{.command = "merchants", .opcode = ServerOP_ReloadMerchants, .desc = "Merchants"},
Reload{.command = "npc_emotes", .opcode = ServerOP_ReloadNPCEmotes, .desc = "NPC Emotes"},
Reload{.command = "npc_spells", .opcode = ServerOP_ReloadNPCSpells, .desc = "NPC Spells"},
Reload{.command = "objects", .opcode = ServerOP_ReloadObjects, .desc = "Objects"},
Reload{.command = "opcodes", .opcode = ServerOP_ReloadOpcodes, .desc = "Opcodes"},
Reload{.command = "perl_export", .opcode = ServerOP_ReloadPerlExportSettings, .desc = "Perl Event Export Settings"},
Reload{.command = "rules", .opcode = ServerOP_ReloadRules, .desc = "Rules"},
Reload{.command = "skill_caps", .opcode = ServerOP_ReloadSkillCaps, .desc = "Skill Caps"},
Reload{.command = "static", .opcode = ServerOP_ReloadStaticZoneData, .desc = "Static Zone Data"},
Reload{.command = "tasks", .opcode = ServerOP_ReloadTasks, .desc = "Tasks"},
Reload{.command = "titles", .opcode = ServerOP_ReloadTitles, .desc = "Titles"},
Reload{.command = "traps", .opcode = ServerOP_ReloadTraps, .desc = "Traps"},
Reload{.command = "variables", .opcode = ServerOP_ReloadVariables, .desc = "Variables"},
Reload{.command = "veteran_rewards", .opcode = ServerOP_ReloadVeteranRewards, .desc = "Veteran Rewards"},
Reload{.command = "world", .opcode = ServerOP_ReloadWorld, .desc = "World"},
Reload{.command = "zone_points", .opcode = ServerOP_ReloadZonePoints, .desc = "Zone Points"},
};
void getReloadTypes(Json::Value &response)
{
for (auto &c: reload_types) {
for (auto &t: ServerReload::GetTypes()) {
Json::Value v;
v["command"] = c.command;
v["opcode"] = c.opcode;
v["description"] = c.desc;
v["command"] = std::to_string(t);
v["description"] = ServerReload::GetName(t);
response.append(v);
}
}
void EQEmuApiWorldDataService::reload(Json::Value &r, const std::vector<std::string> &args)
{
std::vector<std::string> commands{};
commands.reserve(reload_types.size());
for (auto &c: reload_types) {
commands.emplace_back(c.command);
commands.reserve(ServerReload::GetTypes().size());
for (auto &c: ServerReload::GetTypes()) {
commands.emplace_back(std::to_string(c));
}
std::string command = !args[1].empty() ? args[1] : "";
if (command.empty()) {
message(r, fmt::format("Need to provide a type to reload. Example(s) [{}]", Strings::Implode("|", commands)));
message(r, fmt::format("Need to provide a type ID to reload. Example(s) [{}]", Strings::Implode("|", commands)));
return;
}
ServerPacket *pack = nullptr;
bool found_command = false;
for (auto &c: reload_types) {
if (command == c.command) {
if (c.command == "world") {
uint8 global_repop = ReloadWorld::NoRepop;
bool found_command = false;
if (Strings::IsNumber(args[2])) {
global_repop = static_cast<uint8>(Strings::ToUnsignedInt(args[2]));
if (global_repop > ReloadWorld::ForceRepop) {
global_repop = ReloadWorld::ForceRepop;
}
}
message(
r,
fmt::format(
"Attempting to reload Quests {}worldwide.",
(
global_repop ?
(
global_repop == ReloadWorld::Repop ?
"and repop NPCs " :
"and forcefully repop NPCs "
) :
""
)
)
);
pack = new ServerPacket(ServerOP_ReloadWorld, sizeof(ReloadWorld_Struct));
auto RW = (ReloadWorld_Struct *) pack->pBuffer;
RW->global_repop = global_repop;
}
else {
pack = new ServerPacket(c.opcode, 0);
message(r, fmt::format("Reloading [{}] globally", c.desc));
if (c.opcode == ServerOP_ReloadLogs) {
LogSys.LoadLogDatabaseSettings();
QSLink.SendPacket(pack);
UCSLink.SendPacket(pack);
}
else if (c.opcode == ServerOP_ReloadRules) {
RuleManager::Instance()->LoadRules(&database, RuleManager::Instance()->GetActiveRuleset(), true);
}
}
found_command = true;
for (auto &t: ServerReload::GetTypes()) {
if (std::to_string(t) == command || Strings::ToLower(ServerReload::GetName(t)) == command) {
message(r, fmt::format("Reloading [{}] globally", ServerReload::GetName(t)));
zoneserver_list.SendServerReload(t, nullptr);
}
found_command = true;
}
if (!found_command) {
message(r, fmt::format("Need to provide a type to reload. Example(s) [{}]", Strings::Implode("|", commands)));
return;
}
if (pack) {
zoneserver_list.SendPacket(pack);
}
safe_delete(pack);
}
void EQEmuApiWorldDataService::message(Json::Value &r, const std::string &message)