Let world shutdown dz early for empty expeditions

Since world now tracks empty expeditions it can determine when to
shutdown dynamic zone instances when the rule is enabled rather than
letting zones do it.
This commit is contained in:
hg
2020-05-27 23:26:47 -04:00
parent 4699a303c0
commit ca2c1171a1
11 changed files with 93 additions and 67 deletions
+11 -18
View File
@@ -477,15 +477,10 @@ bool Expedition::AddMember(const std::string& add_char_name, uint32_t add_char_i
return true;
}
void Expedition::RemoveAllMembers(bool enable_removal_timers, bool update_dz_expire_time)
void Expedition::RemoveAllMembers(bool enable_removal_timers)
{
m_dynamiczone.RemoveAllCharacters(enable_removal_timers);
if (update_dz_expire_time && RuleB(Expedition, EmptyDzShutdownEnabled))
{
m_dynamiczone.UpdateExpireTime(RuleI(Expedition, EmptyDzShutdownDelaySeconds));
}
ExpeditionDatabase::UpdateAllMembersRemoved(m_id);
SendUpdatesToZoneMembers(true);
@@ -512,18 +507,6 @@ bool Expedition::RemoveMember(const std::string& remove_char_name)
ChooseNewLeader();
}
// we can't check for empty member count via cache because if other zones
// remove members at the same time then we race. cache member count won't
// be accurate until the world messages from other zones are processed
uint32_t member_count = ExpeditionDatabase::GetExpeditionMemberCount(m_id);
if (member_count == 0)
{
if (RuleB(Expedition, EmptyDzShutdownEnabled))
{
m_dynamiczone.UpdateExpireTime(RuleI(Expedition, EmptyDzShutdownDelaySeconds));
}
}
return true;
}
@@ -1813,6 +1796,16 @@ void Expedition::HandleWorldMessage(ServerPacket* pack)
}
break;
}
case ServerOP_ExpeditionDzDuration:
{
auto buf = reinterpret_cast<ServerExpeditionUpdateDuration_Struct*>(pack->pBuffer);
auto expedition = Expedition::FindCachedExpeditionByID(buf->expedition_id);
if (expedition)
{
expedition->SetDzDuration(buf->new_duration_seconds);
}
break;
}
}
}