[Expeditions] Refactor expedition caching (#1315)

Add common expedition base class

Use repository for zone and world expedition caching

World now stores members and leader as Member objects instead of ids

This improves readability of the caching methods and lets world cache
expedition dzs and members like zone. World also now caches expeditions
as unique_ptr which will be necessary for future dz callback lambdas
that capture 'this' so addresses don't change on cache vector resizes.
This commit is contained in:
hg
2021-04-07 02:20:35 -04:00
committed by GitHub
parent 0534a2c6be
commit dadc1b2843
27 changed files with 580 additions and 559 deletions
+6 -15
View File
@@ -22,43 +22,34 @@
#define WORLD_EXPEDITION_H
#include "dynamic_zone.h"
#include "../common/expedition_base.h"
#include "../common/timer.h"
#include <chrono>
#include <cstdint>
#include <vector>
class Expedition
class Expedition : public ExpeditionBase
{
public:
Expedition() = default;
Expedition(uint32_t expedition_id, const DynamicZone& dz, uint32_t leader_id);
Expedition();
void AddMember(uint32_t character_id);
void RemoveMember(uint32_t character_id);
void RemoveAllMembers() { m_member_ids.clear(); }
void CheckExpireWarning();
void CheckLeader();
void ChooseNewLeader();
DynamicZone& GetDynamicZone() { return m_dynamic_zone; }
uint32_t GetID() const { return m_expedition_id; }
bool HasMember(uint32_t character_id);
bool IsEmpty() const { return m_member_ids.empty(); }
bool IsValid() const { return m_expedition_id != 0; }
bool Process();
void SendZonesExpeditionDeleted();
void SendZonesExpireWarning(uint32_t minutes_remaining);
bool SetNewLeader(uint32_t new_leader_id);
void SetDynamicZone(DynamicZone&& dz);
bool SetNewLeader(const ExpeditionMember& member);
private:
void SendZonesLeaderChanged();
uint32_t m_expedition_id = 0;
uint32_t m_leader_id = 0;
bool m_choose_leader_needed = false;
Timer m_choose_leader_cooldown_timer;
Timer m_warning_cooldown_timer;
DynamicZone m_dynamic_zone;
std::vector<uint32_t> m_member_ids;
};
#endif