[Expeditions] Let dz process its expired state (#1310)

Move early empty shutdown and process rate rules to DynamicZone scope

This decouples the expired status check from expeditions into an
internal dz method that can be called by its owning system
This commit is contained in:
hg authored and GitHub committed 2021-03-28 20:43:09 -05:00
1 parent 97c11a1199
commit f5cf566fca
7 files changed
+60 -39

No files matched your search

+24
View File
@@ -35,6 +35,30 @@ DynamicZone* DynamicZone::FindDynamicZoneByID(uint32_t dz_id)
return nullptr;
}
DynamicZoneStatus DynamicZone::Process(bool force_expire)
{
DynamicZoneStatus status = DynamicZoneStatus::Normal;
if (force_expire || IsExpired())
{
status = DynamicZoneStatus::Expired;
auto dz_zoneserver = zoneserver_list.FindByInstanceID(GetInstanceID());
if (!dz_zoneserver || dz_zoneserver->NumPlayers() == 0) // no clients inside dz
{
status = DynamicZoneStatus::ExpiredEmpty;
if (force_expire && !m_is_pending_early_shutdown && RuleB(DynamicZone, EmptyShutdownEnabled))
{
SetSecondsRemaining(RuleI(DynamicZone, EmptyShutdownDelaySeconds));
m_is_pending_early_shutdown = true;
}
}
}
return status;
}
void DynamicZone::SetSecondsRemaining(uint32_t seconds_remaining)
{
auto now = std::chrono::system_clock::now();