Only delete empty expeditions when the dz is empty

Zones are no longer able to delete expeditions. World now tracks empty
expeditions in cache and only deletes them when it detects an
expedition's dynamic zone instance has no more clients inside.

This fixes an exploit where lockouts couldn't be applied to expeditions
after all members were removed because zones were deleting the expedition
immediately. Clients still inside the dz were able to complete events
before being kicked from the instance while not having an expedition.

Expeditions are no longer purged from database in the world purge
instance timer to avoid a possible race with this new system
This commit is contained in:
hg
2020-05-26 22:32:08 -04:00
parent 2a0ae8160e
commit 4699a303c0
10 changed files with 167 additions and 101 deletions
+12 -27
View File
@@ -320,18 +320,6 @@ void ExpeditionDatabase::DeletePendingLockouts(uint32_t character_id)
database.QueryDatabase(query);
}
void ExpeditionDatabase::DeleteExpedition(uint32_t expedition_id)
{
LogExpeditionsDetail("Deleting expedition [{}]", expedition_id);
auto query = fmt::format("DELETE FROM expedition_details WHERE id = {}", expedition_id);
auto results = database.QueryDatabase(query);
if (!results.Success())
{
LogExpeditions("Failed to delete expedition [{}]", expedition_id);
}
}
void ExpeditionDatabase::DeleteLockout(uint32_t expedition_id, const std::string& event_name)
{
LogExpeditionsDetail("Deleting expedition [{}] lockout event [{}]", expedition_id, event_name);
@@ -348,21 +336,6 @@ void ExpeditionDatabase::DeleteLockout(uint32_t expedition_id, const std::string
}
}
void ExpeditionDatabase::DeleteAllMembers(uint32_t expedition_id)
{
LogExpeditionsDetail("Deleting all members of expedition [{}]", expedition_id);
auto query = fmt::format(SQL(
DELETE FROM expedition_members WHERE expedition_id = {};
), expedition_id);
auto results = database.QueryDatabase(query);
if (!results.Success())
{
LogExpeditions("Failed to delete all members of expedition [{}]", expedition_id);
}
}
uint32_t ExpeditionDatabase::GetExpeditionIDFromCharacterID(uint32_t character_id)
{
LogExpeditionsDetail("Getting expedition id for character [{}]", character_id);
@@ -675,6 +648,18 @@ void ExpeditionDatabase::UpdateMemberRemoved(uint32_t expedition_id, uint32_t ch
}
}
void ExpeditionDatabase::UpdateAllMembersRemoved(uint32_t expedition_id)
{
LogExpeditionsDetail("Updating all members of expedition [{}] as removed", expedition_id);
auto query = fmt::format(SQL(
UPDATE expedition_members SET is_current_member = FALSE
WHERE expedition_id = {};
), expedition_id);
database.QueryDatabase(query);
}
void ExpeditionDatabase::UpdateReplayLockoutOnJoin(uint32_t expedition_id, bool add_on_join)
{
LogExpeditionsDetail("Updating replay lockout on join [{}] for expedition [{}]", add_on_join, expedition_id);