mirror of
https://github.com/EQEmu/Server.git
synced 2026-09-05 15:36:38 +00:00
Store expeditions with dz id not instance id
This exposes dynamic zone ids for any future changes and will make it easier to preserve historic dz and expedition data. This also cleans up some dynamic zone creation for expedition requests When purging instances the expedition table is no longer updated since dynamic zone ids are not re-used like instance ids are Update #dz list commands to show dz id Add GetDynamicZoneID and get_expedition_by_dz_id quest apis
This commit is contained in:
@@ -26,12 +26,12 @@
|
||||
|
||||
extern ZSList zoneserver_list;
|
||||
|
||||
Expedition::Expedition(
|
||||
uint32_t expedition_id, uint32_t instance_id, uint32_t dz_zone_id,
|
||||
uint32_t start_time, uint32_t duration
|
||||
Expedition::Expedition(uint32_t expedition_id, uint32_t dz_id, uint32_t dz_instance_id,
|
||||
uint32_t dz_zone_id, uint32_t start_time, uint32_t duration
|
||||
) :
|
||||
m_expedition_id(expedition_id),
|
||||
m_dz_instance_id(instance_id),
|
||||
m_dz_id(dz_id),
|
||||
m_dz_instance_id(dz_instance_id),
|
||||
m_dz_zone_id(dz_zone_id),
|
||||
m_start_time(std::chrono::system_clock::from_time_t(start_time)),
|
||||
m_duration(duration)
|
||||
|
||||
+4
-2
@@ -30,8 +30,8 @@ class Expedition
|
||||
{
|
||||
public:
|
||||
Expedition() = default;
|
||||
Expedition(uint32_t expedition_id, uint32_t instance_id, uint32_t dz_zone_id,
|
||||
uint32_t expire_time, uint32_t duration);
|
||||
Expedition(uint32_t expedition_id, uint32_t dz_id, uint32_t dz_instance_id,
|
||||
uint32_t dz_zone_id, uint32_t expire_time, uint32_t duration);
|
||||
|
||||
void AddMember(uint32_t character_id) { m_member_ids.emplace(character_id); }
|
||||
void RemoveMember(uint32_t character_id) { m_member_ids.erase(character_id); }
|
||||
@@ -43,6 +43,7 @@ public:
|
||||
bool IsEmpty() const { return m_member_ids.empty(); }
|
||||
bool IsExpired() const { return m_expire_time < std::chrono::system_clock::now(); }
|
||||
bool IsPendingDelete() const { return m_pending_delete; }
|
||||
bool IsValid() const { return m_expedition_id != 0; }
|
||||
void SendZonesDurationUpdate();
|
||||
void SendZonesExpeditionDeleted();
|
||||
void SendZonesExpireWarning(uint32_t minutes_remaining);
|
||||
@@ -52,6 +53,7 @@ public:
|
||||
|
||||
private:
|
||||
uint32_t m_expedition_id = 0;
|
||||
uint32_t m_dz_id = 0;
|
||||
uint32_t m_dz_instance_id = 0;
|
||||
uint32_t m_dz_zone_id = 0;
|
||||
bool m_pending_delete = false;
|
||||
|
||||
@@ -28,7 +28,8 @@ void ExpeditionDatabase::PurgeExpiredExpeditions()
|
||||
SELECT
|
||||
expeditions.id
|
||||
FROM expeditions
|
||||
LEFT JOIN instance_list ON expeditions.instance_id = instance_list.id
|
||||
LEFT JOIN dynamic_zones ON expeditions.dynamic_zone_id = dynamic_zones.id
|
||||
LEFT JOIN instance_list ON dynamic_zones.instance_id = instance_list.id
|
||||
LEFT JOIN
|
||||
(
|
||||
SELECT expedition_id, COUNT(*) member_count
|
||||
@@ -64,24 +65,34 @@ void ExpeditionDatabase::PurgeExpiredCharacterLockouts()
|
||||
database.QueryDatabase(query);
|
||||
}
|
||||
|
||||
std::vector<Expedition> ExpeditionDatabase::LoadExpeditions()
|
||||
std::vector<Expedition> ExpeditionDatabase::LoadExpeditions(uint32_t select_expedition_id)
|
||||
{
|
||||
std::vector<Expedition> expeditions;
|
||||
|
||||
std::string query = SQL(
|
||||
SELECT
|
||||
expeditions.id,
|
||||
expeditions.instance_id,
|
||||
expeditions.dynamic_zone_id,
|
||||
instance_list.id,
|
||||
instance_list.zone,
|
||||
instance_list.start_time,
|
||||
instance_list.duration,
|
||||
expedition_members.character_id
|
||||
FROM expeditions
|
||||
INNER JOIN instance_list ON expeditions.instance_id = instance_list.id
|
||||
INNER JOIN dynamic_zones ON expeditions.dynamic_zone_id = dynamic_zones.id
|
||||
INNER JOIN instance_list ON dynamic_zones.instance_id = instance_list.id
|
||||
INNER JOIN expedition_members ON expedition_members.expedition_id = expeditions.id
|
||||
ORDER BY expeditions.id;
|
||||
);
|
||||
|
||||
if (select_expedition_id != 0)
|
||||
{
|
||||
query.append(fmt::format(" WHERE expeditions.id = {};", select_expedition_id));
|
||||
}
|
||||
else
|
||||
{
|
||||
query.append(" ORDER BY expeditions.id;");
|
||||
}
|
||||
|
||||
auto results = database.QueryDatabase(query);
|
||||
if (results.Success())
|
||||
{
|
||||
@@ -95,16 +106,17 @@ std::vector<Expedition> ExpeditionDatabase::LoadExpeditions()
|
||||
{
|
||||
expeditions.emplace_back(
|
||||
static_cast<uint32_t>(strtoul(row[0], nullptr, 10)), // expedition_id
|
||||
static_cast<uint32_t>(strtoul(row[1], nullptr, 10)), // dz_instance_id
|
||||
static_cast<uint32_t>(strtoul(row[2], nullptr, 10)), // dz_zone_id
|
||||
static_cast<uint32_t>(strtoul(row[3], nullptr, 10)), // start_time
|
||||
static_cast<uint32_t>(strtoul(row[4], nullptr, 10)) // duration
|
||||
static_cast<uint32_t>(strtoul(row[1], nullptr, 10)), // dz_id
|
||||
static_cast<uint32_t>(strtoul(row[2], nullptr, 10)), // dz_instance_id
|
||||
static_cast<uint32_t>(strtoul(row[3], nullptr, 10)), // dz_zone_id
|
||||
static_cast<uint32_t>(strtoul(row[4], nullptr, 10)), // start_time
|
||||
static_cast<uint32_t>(strtoul(row[5], nullptr, 10)) // duration
|
||||
);
|
||||
}
|
||||
|
||||
last_expedition_id = expedition_id;
|
||||
|
||||
uint32_t member_id = static_cast<uint32_t>(strtoul(row[5], nullptr, 10));
|
||||
uint32_t member_id = static_cast<uint32_t>(strtoul(row[6], nullptr, 10));
|
||||
expeditions.back().AddMember(member_id);
|
||||
}
|
||||
}
|
||||
@@ -118,41 +130,10 @@ Expedition ExpeditionDatabase::LoadExpedition(uint32_t expedition_id)
|
||||
|
||||
Expedition expedition;
|
||||
|
||||
std::string query = fmt::format(SQL(
|
||||
SELECT
|
||||
expeditions.id,
|
||||
expeditions.instance_id,
|
||||
instance_list.zone,
|
||||
instance_list.start_time,
|
||||
instance_list.duration,
|
||||
expedition_members.character_id
|
||||
FROM expeditions
|
||||
INNER JOIN instance_list ON expeditions.instance_id = instance_list.id
|
||||
INNER JOIN expedition_members ON expedition_members.expedition_id = expeditions.id
|
||||
WHERE expeditions.id = {};
|
||||
), expedition_id);
|
||||
|
||||
auto results = database.QueryDatabase(query);
|
||||
if (results.Success())
|
||||
auto expeditions = LoadExpeditions(expedition_id);
|
||||
if (!expeditions.empty())
|
||||
{
|
||||
bool created = false;
|
||||
for (auto row = results.begin(); row != results.end(); ++row)
|
||||
{
|
||||
if (!created)
|
||||
{
|
||||
expedition = Expedition{
|
||||
static_cast<uint32_t>(strtoul(row[0], nullptr, 10)), // expedition_id
|
||||
static_cast<uint32_t>(strtoul(row[1], nullptr, 10)), // dz_instance_id
|
||||
static_cast<uint32_t>(strtoul(row[2], nullptr, 10)), // dz_zone_id
|
||||
static_cast<uint32_t>(strtoul(row[3], nullptr, 10)), // start_time
|
||||
static_cast<uint32_t>(strtoul(row[4], nullptr, 10)) // duration
|
||||
};
|
||||
created = true;
|
||||
}
|
||||
|
||||
auto member_id = static_cast<uint32_t>(strtoul(row[5], nullptr, 10));
|
||||
expedition.AddMember(member_id);
|
||||
}
|
||||
expedition = expeditions.front();
|
||||
}
|
||||
|
||||
return expedition;
|
||||
|
||||
@@ -29,7 +29,7 @@ class Expedition;
|
||||
namespace ExpeditionDatabase
|
||||
{
|
||||
void DeleteExpeditions(const std::vector<uint32_t>& expedition_ids);
|
||||
std::vector<Expedition> LoadExpeditions();
|
||||
std::vector<Expedition> LoadExpeditions(uint32_t select_expedition_id = 0);
|
||||
Expedition LoadExpedition(uint32_t expedition_id);
|
||||
void PurgeExpiredExpeditions();
|
||||
void PurgeExpiredCharacterLockouts();
|
||||
|
||||
@@ -49,7 +49,7 @@ void ExpeditionState::AddExpedition(uint32_t expedition_id)
|
||||
|
||||
auto expedition = ExpeditionDatabase::LoadExpedition(expedition_id);
|
||||
|
||||
if (expedition.GetID() == expedition_id)
|
||||
if (expedition.IsValid())
|
||||
{
|
||||
auto it = std::find_if(m_expeditions.begin(), m_expeditions.end(), [&](const Expedition& expedition) {
|
||||
return expedition.GetID() == expedition_id;
|
||||
|
||||
Reference in New Issue
Block a user