mirror of
https://github.com/EQEmu/Server.git
synced 2026-02-19 07:32:25 +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:
parent
89c6d1e258
commit
528b74109e
@ -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())
|
||||
|
||||
@ -89,7 +89,7 @@ public:
|
||||
void SetCompass(const DynamicZoneLocation& location, bool update_db = false);
|
||||
void SetSafeReturn(const DynamicZoneLocation& location, bool update_db = false);
|
||||
void SetZoneInLocation(const DynamicZoneLocation& location, bool update_db = false);
|
||||
void UpdateExpireTime(uint32_t seconds);
|
||||
void UpdateExpireTime(uint32_t seconds, bool reduce_only = true);
|
||||
|
||||
void LoadFromDatabase(uint32_t instance_id);
|
||||
uint32_t SaveToDatabase();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user