mirror of
https://github.com/EQEmu/Server.git
synced 2026-06-10 10:50:24 +00:00
Only update dz expire time if reducing
Add optional UpdateExpireTime parameter This is currently only used when an expedition becomes empty to make dynamic zone instances shutdown earlier. For that it should only update if new time is less than remaining time
This commit is contained in:
@@ -437,21 +437,19 @@ void DynamicZone::SendInstanceCharacterChange(uint32_t character_id, bool remove
|
||||
}
|
||||
}
|
||||
|
||||
void DynamicZone::UpdateExpireTime(uint32_t seconds)
|
||||
void DynamicZone::UpdateExpireTime(uint32_t seconds, bool reduce_only)
|
||||
{
|
||||
if (GetInstanceID() == 0)
|
||||
if (GetInstanceID() == 0 || (reduce_only && GetSecondsRemaining() < seconds))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_duration = seconds;
|
||||
m_expire_time = std::chrono::system_clock::now() + std::chrono::seconds(seconds);
|
||||
|
||||
auto new_duration = std::chrono::system_clock::to_time_t(m_expire_time) - m_start_time;
|
||||
m_duration = std::chrono::system_clock::to_time_t(m_expire_time) - m_start_time;
|
||||
|
||||
std::string query = fmt::format(SQL(
|
||||
UPDATE instance_list SET duration = {} WHERE id = {};
|
||||
), new_duration, GetInstanceID());
|
||||
), m_duration, GetInstanceID());
|
||||
|
||||
auto results = database.QueryDatabase(query);
|
||||
if (results.Success())
|
||||
|
||||
Reference in New Issue
Block a user