mirror of
https://github.com/EQEmu/Server.git
synced 2026-09-04 18:46:37 +00:00
[Expeditions] Create common dz abstract class (#1312)
This creates an abstract class in common so zone and world can share most of the implementation. World now has access to the same dz data and api as zone. Rename CharacterChange to AddRemoveCharacter for clarity Rename GetRemainingDuration to GetDurationRemaining for consistency Move dynamic zone queries to custom repository methods
This commit is contained in:
+12
-19
@@ -1,9 +1,9 @@
|
||||
#ifndef WORLD_DYNAMIC_ZONE_H
|
||||
#define WORLD_DYNAMIC_ZONE_H
|
||||
|
||||
#include "../common/eq_constants.h"
|
||||
#include <chrono>
|
||||
#include "../common/dynamic_zone_base.h"
|
||||
|
||||
class Database;
|
||||
class ServerPacket;
|
||||
|
||||
enum class DynamicZoneStatus
|
||||
@@ -14,9 +14,11 @@ enum class DynamicZoneStatus
|
||||
ExpiredEmpty,
|
||||
};
|
||||
|
||||
class DynamicZone
|
||||
class DynamicZone : public DynamicZoneBase
|
||||
{
|
||||
public:
|
||||
using DynamicZoneBase::DynamicZoneBase; // inherit base constructors
|
||||
|
||||
DynamicZone() = default;
|
||||
DynamicZone(uint32_t id, uint32_t zone_id, uint32_t instance_id, uint32_t zone_version,
|
||||
uint32_t start_time, uint32_t duration, DynamicZoneType type);
|
||||
@@ -24,29 +26,20 @@ public:
|
||||
static DynamicZone* FindDynamicZoneByID(uint32_t dz_id);
|
||||
static void HandleZoneMessage(ServerPacket* pack);
|
||||
|
||||
uint32_t GetID() const { return m_id; }
|
||||
uint16_t GetInstanceID() const { return static_cast<uint16_t>(m_instance_id); }
|
||||
uint16_t GetZoneID() const { return static_cast<uint16_t>(m_zone_id); }
|
||||
uint32_t GetZoneVersion() const { return m_zone_version; }
|
||||
std::chrono::system_clock::duration GetRemainingDuration() const {
|
||||
return m_expire_time - std::chrono::system_clock::now(); }
|
||||
void SetSecondsRemaining(uint32_t seconds_remaining) override;
|
||||
|
||||
DynamicZoneStatus Process(bool force_expire);
|
||||
bool IsExpired() const { return m_expire_time < std::chrono::system_clock::now(); }
|
||||
void SetSecondsRemaining(uint32_t seconds_remaining);
|
||||
|
||||
protected:
|
||||
Database& GetDatabase() override;
|
||||
void SendInstanceAddRemoveCharacter(uint32_t character_id, bool remove) override;
|
||||
void SendInstanceRemoveAllCharacters() override;
|
||||
void SendGlobalLocationChange(uint16_t server_opcode, const DynamicZoneLocation& location) override;
|
||||
|
||||
private:
|
||||
void SendZonesDurationUpdate();
|
||||
|
||||
uint32_t m_id = 0;
|
||||
uint32_t m_instance_id = 0;
|
||||
uint32_t m_zone_id = 0;
|
||||
uint32_t m_zone_version = 0;
|
||||
bool m_is_pending_early_shutdown = false;
|
||||
DynamicZoneType m_type{ DynamicZoneType::None };
|
||||
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_expire_time;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user