mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-12 05:21:29 +00:00
Let world dispatch expedition expire warnings
This depends on C++14 remaining enabled for chrono literals
This commit is contained in:
parent
da5d4b9830
commit
ca113cdd85
@ -43,6 +43,7 @@ Expedition::Expedition(
|
|||||||
m_duration(duration)
|
m_duration(duration)
|
||||||
{
|
{
|
||||||
m_expire_time = m_start_time + m_duration;
|
m_expire_time = m_start_time + m_duration;
|
||||||
|
m_warning_cooldown_timer.Enable();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Expedition::SendZonesExpeditionDeleted()
|
void Expedition::SendZonesExpeditionDeleted()
|
||||||
@ -64,6 +65,16 @@ void Expedition::SendZonesDurationUpdate()
|
|||||||
zoneserver_list.SendPacket(pack.get());
|
zoneserver_list.SendPacket(pack.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Expedition::SendZonesExpireWarning(uint32_t minutes_remaining)
|
||||||
|
{
|
||||||
|
uint32_t pack_size = sizeof(ServerExpeditionExpireWarning_Struct);
|
||||||
|
auto pack = std::unique_ptr<ServerPacket>(new ServerPacket(ServerOP_ExpeditionExpireWarning, pack_size));
|
||||||
|
auto buf = reinterpret_cast<ServerExpeditionExpireWarning_Struct*>(pack->pBuffer);
|
||||||
|
buf->expedition_id = GetID();
|
||||||
|
buf->minutes_remaining = minutes_remaining;
|
||||||
|
zoneserver_list.SendPacket(pack.get());
|
||||||
|
}
|
||||||
|
|
||||||
void Expedition::UpdateDzSecondsRemaining(uint32_t seconds_remaining)
|
void Expedition::UpdateDzSecondsRemaining(uint32_t seconds_remaining)
|
||||||
{
|
{
|
||||||
auto now = std::chrono::system_clock::now();
|
auto now = std::chrono::system_clock::now();
|
||||||
@ -88,6 +99,28 @@ void Expedition::UpdateDzSecondsRemaining(uint32_t seconds_remaining)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::chrono::system_clock::duration Expedition::GetRemainingDuration() const
|
||||||
|
{
|
||||||
|
return m_expire_time - std::chrono::system_clock::now();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Expedition::CheckExpireWarning()
|
||||||
|
{
|
||||||
|
if (m_warning_cooldown_timer.Check(false))
|
||||||
|
{
|
||||||
|
using namespace std::chrono_literals;
|
||||||
|
auto remaining = GetRemainingDuration();
|
||||||
|
if ((remaining > 14min && remaining < 15min) ||
|
||||||
|
(remaining > 4min && remaining < 5min) ||
|
||||||
|
(remaining > 0min && remaining < 1min))
|
||||||
|
{
|
||||||
|
int minutes = std::chrono::duration_cast<std::chrono::minutes>(remaining).count() + 1;
|
||||||
|
SendZonesExpireWarning(minutes);
|
||||||
|
m_warning_cooldown_timer.Start(70000); // 1 minute 10 seconds
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ExpeditionCache::LoadActiveExpeditions()
|
void ExpeditionCache::LoadActiveExpeditions()
|
||||||
{
|
{
|
||||||
BenchTimer benchmark;
|
BenchTimer benchmark;
|
||||||
@ -205,6 +238,10 @@ void ExpeditionCache::Process()
|
|||||||
|
|
||||||
it->SetPendingDelete(true);
|
it->SetPendingDelete(true);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
it->CheckExpireWarning();
|
||||||
|
}
|
||||||
|
|
||||||
it = is_deleted ? m_expeditions.erase(it) : it + 1;
|
it = is_deleted ? m_expeditions.erase(it) : it + 1;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -79,6 +79,7 @@ public:
|
|||||||
void AddMember(uint32_t character_id) { m_member_ids.emplace(character_id); }
|
void AddMember(uint32_t character_id) { m_member_ids.emplace(character_id); }
|
||||||
void RemoveMember(uint32_t character_id) { m_member_ids.erase(character_id); }
|
void RemoveMember(uint32_t character_id) { m_member_ids.erase(character_id); }
|
||||||
void RemoveAllMembers() { m_member_ids.clear(); }
|
void RemoveAllMembers() { m_member_ids.clear(); }
|
||||||
|
void CheckExpireWarning();
|
||||||
uint32_t GetID() const { return m_expedition_id; }
|
uint32_t GetID() const { return m_expedition_id; }
|
||||||
uint16_t GetInstanceID() const { return static_cast<uint16_t>(m_dz_instance_id); }
|
uint16_t GetInstanceID() const { return static_cast<uint16_t>(m_dz_instance_id); }
|
||||||
uint16_t GetZoneID() const { return static_cast<uint16_t>(m_dz_zone_id); }
|
uint16_t GetZoneID() const { return static_cast<uint16_t>(m_dz_zone_id); }
|
||||||
@ -87,14 +88,17 @@ public:
|
|||||||
bool IsPendingDelete() const { return m_pending_delete; }
|
bool IsPendingDelete() const { return m_pending_delete; }
|
||||||
void SendZonesDurationUpdate();
|
void SendZonesDurationUpdate();
|
||||||
void SendZonesExpeditionDeleted();
|
void SendZonesExpeditionDeleted();
|
||||||
|
void SendZonesExpireWarning(uint32_t minutes_remaining);
|
||||||
void SetPendingDelete(bool pending) { m_pending_delete = pending; }
|
void SetPendingDelete(bool pending) { m_pending_delete = pending; }
|
||||||
void UpdateDzSecondsRemaining(uint32_t seconds_remaining);
|
void UpdateDzSecondsRemaining(uint32_t seconds_remaining);
|
||||||
|
std::chrono::system_clock::duration GetRemainingDuration() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint32_t m_expedition_id = 0;
|
uint32_t m_expedition_id = 0;
|
||||||
uint32_t m_dz_instance_id = 0;
|
uint32_t m_dz_instance_id = 0;
|
||||||
uint32_t m_dz_zone_id = 0;
|
uint32_t m_dz_zone_id = 0;
|
||||||
bool m_pending_delete = false;
|
bool m_pending_delete = false;
|
||||||
|
Timer m_warning_cooldown_timer;
|
||||||
std::unordered_set<uint32_t> m_member_ids;
|
std::unordered_set<uint32_t> m_member_ids;
|
||||||
std::chrono::seconds m_duration;
|
std::chrono::seconds m_duration;
|
||||||
std::chrono::time_point<std::chrono::system_clock> m_start_time;
|
std::chrono::time_point<std::chrono::system_clock> m_start_time;
|
||||||
|
|||||||
@ -1742,16 +1742,6 @@ void Expedition::SendWorldSetSecondsRemaining(uint32_t seconds_remaining)
|
|||||||
worldserver.SendPacket(pack.get());
|
worldserver.SendPacket(pack.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Expedition::SendWorldExpireWarning(uint32_t minutes_remaining)
|
|
||||||
{
|
|
||||||
uint32_t pack_size = sizeof(ServerExpeditionExpireWarning_Struct);
|
|
||||||
auto pack = std::unique_ptr<ServerPacket>(new ServerPacket(ServerOP_ExpeditionExpireWarning, pack_size));
|
|
||||||
auto buf = reinterpret_cast<ServerExpeditionExpireWarning_Struct*>(pack->pBuffer);
|
|
||||||
buf->expedition_id = GetID();
|
|
||||||
buf->minutes_remaining = minutes_remaining;
|
|
||||||
worldserver.SendPacket(pack.get());
|
|
||||||
}
|
|
||||||
|
|
||||||
void Expedition::AddLockoutByCharacterID(
|
void Expedition::AddLockoutByCharacterID(
|
||||||
uint32_t character_id, const std::string& expedition_name, const std::string& event_name,
|
uint32_t character_id, const std::string& expedition_name, const std::string& event_name,
|
||||||
uint32_t seconds, const std::string& uuid)
|
uint32_t seconds, const std::string& uuid)
|
||||||
|
|||||||
@ -142,7 +142,6 @@ public:
|
|||||||
void SetLootEventBySpawnID(uint32_t spawn_id, const std::string& event_name);
|
void SetLootEventBySpawnID(uint32_t spawn_id, const std::string& event_name);
|
||||||
|
|
||||||
void SendClientExpeditionInfo(Client* client);
|
void SendClientExpeditionInfo(Client* client);
|
||||||
void SendWorldExpireWarning(uint32_t minutes);
|
|
||||||
void SendWorldPendingInvite(const ExpeditionInvite& invite, const std::string& add_name);
|
void SendWorldPendingInvite(const ExpeditionInvite& invite, const std::string& add_name);
|
||||||
|
|
||||||
void DzAddPlayer(Client* requester, const std::string& add_char_name, const std::string& swap_remove_name = {});
|
void DzAddPlayer(Client* requester, const std::string& add_char_name, const std::string& swap_remove_name = {});
|
||||||
|
|||||||
@ -1524,18 +1524,15 @@ bool Zone::Process() {
|
|||||||
|
|
||||||
if (minutes_warning > 0)
|
if (minutes_warning > 0)
|
||||||
{
|
{
|
||||||
|
// expedition expire warnings are handled by world
|
||||||
auto expedition = Expedition::FindCachedExpeditionByZoneInstance(GetZoneID(), GetInstanceID());
|
auto expedition = Expedition::FindCachedExpeditionByZoneInstance(GetZoneID(), GetInstanceID());
|
||||||
if (expedition)
|
if (!expedition)
|
||||||
{
|
|
||||||
expedition->SendWorldExpireWarning(minutes_warning);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
entity_list.ExpeditionWarning(minutes_warning);
|
entity_list.ExpeditionWarning(minutes_warning);
|
||||||
}
|
|
||||||
Instance_Warning_timer = new Timer(10000);
|
Instance_Warning_timer = new Timer(10000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if(Instance_Warning_timer->Check())
|
else if(Instance_Warning_timer->Check())
|
||||||
{
|
{
|
||||||
safe_delete(Instance_Warning_timer);
|
safe_delete(Instance_Warning_timer);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user