mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-12 09:31:30 +00:00
This removes the separate Expedition class and moves lockout code and
/dz command handlers into DynamicZone classes. It also refactors some
code to reduce bloat and some database usage.
This completes the effort of moving everything to DynamicZone that
started when implementing shared tasks. It also makes sense to do this
since expeditions are just dynamic zones internally despite dzs being
used for other types. Expedition specific things are just handled with
dz type checks.
Functionally nothing should change. This is mainly internal refactoring
and moving code around along with some bug fixes and reduced database
usage.
Main changes:
- The `expeditions` database table has been removed
- Expeditions no longer use a separate id, the expedition id is just the dz id
- Expedition lock state and replay timer option were moved to the
`dynamic_zones` table
- Expeditions no longer have a separate cache from dynamic zones
- Expedition creation no longer has every zone query the database to cache it
- Expedition internal lockouts are now stored on DynamicZone
- The `expedition_lockouts` table has been renamed to `dynamic_zone_lockouts`
- Fixed a small bug with the UpdateLockoutDuration api where the
internal lockout would get the time added twice in memory in the
initiating zone (this api is likely rarely used)
- Fixed an issue where use of the group/raid DoesAnyMemberHaveExpeditionLockout
api would query once for every out of zone character.
- This api now checks all members in the current zone first and only
performs a single bulk query for out of zone members if that check
is exhausted
- Deprecated the max_check_count param of DoesAnyMemberHaveExpeditionLockout,
the quest api still exists to avoid api break but a passed arg has no effect
125 lines
5.4 KiB
C++
Executable File
125 lines
5.4 KiB
C++
Executable File
#include "../client.h"
|
|
#include "../dynamic_zone.h"
|
|
|
|
void command_dz(Client *c, const Seperator *sep)
|
|
{
|
|
if (!c || !zone) {
|
|
return;
|
|
}
|
|
|
|
if (strcasecmp(sep->arg[1], "cache") == 0) {
|
|
if (strcasecmp(sep->arg[2], "reload") == 0) {
|
|
DynamicZone::CacheAllFromDatabase();
|
|
c->Message(Chat::White, fmt::format("Reloaded [{}] dynamic zone(s) from database", zone->dynamic_zone_cache.size()).c_str());
|
|
}
|
|
}
|
|
else if (strcasecmp(sep->arg[1], "destroy") == 0 && sep->IsNumber(2)) {
|
|
auto dz_id = std::strtoul(sep->arg[2], nullptr, 10);
|
|
if (auto dz = DynamicZone::FindDynamicZoneByID(dz_id)) {
|
|
c->Message(Chat::White, fmt::format("Destroying dz [{}] ({})", dz_id, dz->GetName()).c_str());
|
|
dz->RemoveAllMembers();
|
|
}
|
|
else {
|
|
c->Message(Chat::Red, fmt::format("Failed to destroy dz [{}]", sep->arg[3]).c_str());
|
|
}
|
|
}
|
|
else if (strcasecmp(sep->arg[1], "list") == 0) {
|
|
std::vector<DynamicZone*> dynamic_zones;
|
|
for (const auto& it : zone->dynamic_zone_cache) {
|
|
dynamic_zones.push_back(it.second.get());
|
|
}
|
|
|
|
std::ranges::sort(dynamic_zones, {}, &DynamicZone::GetID);
|
|
c->Message(Chat::White, fmt::format("Total Dynamic Zones (cache): [{}]", dynamic_zones.size()).c_str());
|
|
for (const DynamicZone* dz : dynamic_zones) {
|
|
uint32_t seconds = dz->GetSecondsRemaining();
|
|
c->Message(Chat::White, fmt::format(
|
|
"id: [{}] - [{}] - {}: [{}:{}:{}] members: [{}] expires: [{:02}:{:02}:{:02}] leader: [{}]",
|
|
dz->GetID(),
|
|
DynamicZone::GetDynamicZoneTypeName(dz->GetType()),
|
|
Saylink::Silent(fmt::format("#zoneinstance {}", dz->GetInstanceID()), "zone"),
|
|
dz->GetZoneID(),
|
|
dz->GetInstanceID(),
|
|
dz->GetZoneVersion(),
|
|
dz->GetMemberCount(),
|
|
seconds / 3600, // hours
|
|
seconds / 60 % 60, // minutes
|
|
seconds % 60, // seconds
|
|
Saylink::Silent(fmt::format("#goto {}", dz->GetLeaderName()), dz->GetLeaderName())
|
|
).c_str());
|
|
}
|
|
}
|
|
else if (strcasecmp(sep->arg[1], "listdb") == 0) {
|
|
auto dz_list = DynamicZonesRepository::AllDzInstancePlayerCounts(database);
|
|
c->Message(Chat::White, fmt::format("Total Dynamic Zones (database): [{}]", dz_list.size()).c_str());
|
|
|
|
auto now = std::chrono::system_clock::now();
|
|
|
|
for (const auto& dz : dz_list) {
|
|
auto expire_time = std::chrono::system_clock::from_time_t(static_cast<time_t>(dz.start_time) + dz.duration);
|
|
bool is_expired = now > expire_time;
|
|
|
|
if (!is_expired || strcasecmp(sep->arg[2], "all") == 0) {
|
|
auto seconds = std::max(0, static_cast<int>(std::chrono::duration_cast<std::chrono::seconds>(expire_time - now).count()));
|
|
c->Message(Chat::White, fmt::format(
|
|
"id: [{}] - [{}] - {}: [{}:{}:{}] members: [{}] expires: [{:02}:{:02}:{:02}]",
|
|
dz.id,
|
|
DynamicZone::GetDynamicZoneTypeName(static_cast<DynamicZoneType>(dz.type)),
|
|
is_expired ? "zone" : Saylink::Silent(fmt::format("#zoneinstance {}", dz.instance), "zone"),
|
|
dz.zone,
|
|
dz.instance,
|
|
dz.version,
|
|
dz.member_count,
|
|
seconds / 3600, // hours
|
|
seconds / 60 % 60, // minutes
|
|
seconds % 60 // seconds
|
|
).c_str());
|
|
}
|
|
}
|
|
}
|
|
else if (strcasecmp(sep->arg[1], "lockouts") == 0) {
|
|
if (strcasecmp(sep->arg[2], "remove") == 0 && sep->arg[3][0] != '\0') {
|
|
if (sep->arg[5][0] == '\0') {
|
|
c->Message(Chat::White, fmt::format("Removing [{}] lockouts on [{}].", sep->arg[4][0] ? sep->arg[4] : "all", sep->arg[3]).c_str());
|
|
}
|
|
else {
|
|
c->Message(Chat::White, fmt::format("Removing [{}]:[{}] lockout on [{}].", sep->arg[4], sep->arg[5], sep->arg[3]).c_str());
|
|
}
|
|
DynamicZone::RemoveCharacterLockouts(sep->arg[3], sep->arg[4], sep->arg[5]);
|
|
}
|
|
}
|
|
else if (strcasecmp(sep->arg[1], "makeleader") == 0 && sep->IsNumber(2) && sep->arg[3][0] != '\0') {
|
|
uint32_t dz_id = std::strtoul(sep->arg[2], nullptr, 10);
|
|
if (auto dz = DynamicZone::FindDynamicZoneByID(dz_id)) {
|
|
std::string name = FormatName(sep->arg[3]);
|
|
c->Message(Chat::White, fmt::format("Setting expedition [{}] leader to [{}]", dz_id, name).c_str());
|
|
dz->SendWorldMakeLeaderRequest(c->CharacterID(), name);
|
|
}
|
|
else {
|
|
c->Message(Chat::Red, fmt::format("Failed to find expedition [{}]", dz_id).c_str());
|
|
}
|
|
}
|
|
else if (strcasecmp(sep->arg[1], "unlock") == 0 && sep->IsNumber(2)) {
|
|
uint32_t dz_id = std::strtoul(sep->arg[2], nullptr, 10);
|
|
if (auto dz = DynamicZone::FindDynamicZoneByID(dz_id)) {
|
|
c->Message(Chat::White, fmt::format("Unlocking expedition dz [{}]", dz_id).c_str());
|
|
dz->SetLocked(false, true);
|
|
}
|
|
else {
|
|
c->Message(Chat::Red, fmt::format("Failed to find dz [{}]", sep->arg[2]).c_str());
|
|
}
|
|
}
|
|
else {
|
|
c->Message(Chat::White, "#dz usage:");
|
|
c->Message(Chat::White, "#dz cache reload - reload current zone cache from db (also reloads expedition cache)");
|
|
c->Message(Chat::White, "#dz destroy <dz_id> - destroy dz globally (must be in cache)");
|
|
c->Message(Chat::White, "#dz list - list dynamic zones in current zone cache");
|
|
c->Message(Chat::White, "#dz listdb [all] - list dynamic zones in database -- 'all' includes expired");
|
|
c->Message(Chat::White, "#dz lockouts remove <char_name> - delete all of character's expedition lockouts");
|
|
c->Message(Chat::White, "#dz lockouts remove <char_name> \"<expedition_name>\" - delete lockouts by expedition");
|
|
c->Message(Chat::White, "#dz lockouts remove <char_name> \"<expedition_name>\" \"<event_name>\" - delete expedition event lockout");
|
|
c->Message(Chat::White, "#dz makeleader <dz_id> <character_name> - set new expedition leader");
|
|
c->Message(Chat::White, "#dz unlock <dz_id> - unlock expedition");
|
|
}
|
|
}
|