[Expeditions] Move expedition code into DynamicZone (#4672)

This removes the separate Expedition class and moves lockout code and
/dz command handlers into DynamicZone classes. It also refactors some
code to reduce bloat and some database usage.

This completes the effort of moving everything to DynamicZone that
started when implementing shared tasks. It also makes sense to do this
since expeditions are just dynamic zones internally despite dzs being
used for other types. Expedition specific things are just handled with
dz type checks.

Functionally nothing should change. This is mainly internal refactoring
and moving code around along with some bug fixes and reduced database
usage.

Main changes:

 - The `expeditions` database table has been removed

 - Expeditions no longer use a separate id, the expedition id is just the dz id

 - Expedition lock state and replay timer option were moved to the
   `dynamic_zones` table

 - Expeditions no longer have a separate cache from dynamic zones

 - Expedition creation no longer has every zone query the database to cache it

 - Expedition internal lockouts are now stored on DynamicZone

 - The `expedition_lockouts` table has been renamed to `dynamic_zone_lockouts`

 - Fixed a small bug with the UpdateLockoutDuration api where the
   internal lockout would get the time added twice in memory in the
   initiating zone (this api is likely rarely used)

 - Fixed an issue where use of the group/raid DoesAnyMemberHaveExpeditionLockout
   api would query once for every out of zone character.

   - This api now checks all members in the current zone first and only
     performs a single bulk query for out of zone members if that check
     is exhausted

 - Deprecated the max_check_count param of DoesAnyMemberHaveExpeditionLockout,
   the quest api still exists to avoid api break but a passed arg has no effect
This commit is contained in:
hg
2025-02-15 19:40:35 -05:00
committed by GitHub
parent ab4e1191ef
commit 55155ff800
78 changed files with 2889 additions and 4778 deletions
+20 -20
View File
@@ -1944,12 +1944,12 @@ Lua_Expedition Lua_Client::CreateExpedition(luabind::object expedition_table) {
Lua_Expedition Lua_Client::CreateExpedition(std::string zone_name, uint32 version, uint32 duration, std::string expedition_name, uint32 min_players, uint32 max_players) {
Lua_Safe_Call_Class(Lua_Expedition);
return self->CreateExpedition(zone_name, version, duration, expedition_name, min_players, max_players);
return self->CreateExpedition(ZoneID(zone_name), version, duration, expedition_name, min_players, max_players);
}
Lua_Expedition Lua_Client::CreateExpedition(std::string zone_name, uint32 version, uint32 duration, std::string expedition_name, uint32 min_players, uint32 max_players, bool disable_messages) {
Lua_Safe_Call_Class(Lua_Expedition);
return self->CreateExpedition(zone_name, version, duration, expedition_name, min_players, max_players, disable_messages);
return self->CreateExpedition(ZoneID(zone_name), version, duration, expedition_name, min_players, max_players, disable_messages);
}
Lua_Expedition Lua_Client::CreateExpeditionFromTemplate(uint32_t dz_template_id) {
@@ -1968,16 +1968,15 @@ luabind::object Lua_Client::GetExpeditionLockouts(lua_State* L)
if (d_)
{
auto self = reinterpret_cast<NativeType*>(d_);
auto lockouts = self->GetExpeditionLockouts();
const auto& lockouts = self->GetDzLockouts();
for (const auto& lockout : lockouts)
{
auto lockout_table = lua_table[lockout.GetExpeditionName()];
auto lockout_table = lua_table[lockout.DzName()];
if (luabind::type(lockout_table) != LUA_TTABLE)
{
lockout_table = luabind::newtable(L);
}
lockout_table[lockout.GetEventName()] = lockout.GetSecondsRemaining();
lockout_table[lockout.Event()] = lockout.GetSecondsRemaining();
}
}
return lua_table;
@@ -1989,13 +1988,12 @@ luabind::object Lua_Client::GetExpeditionLockouts(lua_State* L, std::string expe
if (d_)
{
auto self = reinterpret_cast<NativeType*>(d_);
auto lockouts = self->GetExpeditionLockouts();
const auto& lockouts = self->GetDzLockouts();
for (const auto& lockout : lockouts)
{
if (lockout.GetExpeditionName() == expedition_name)
if (lockout.DzName() == expedition_name)
{
lua_table[lockout.GetEventName()] = lockout.GetSecondsRemaining();
lua_table[lockout.Event()] = lockout.GetSecondsRemaining();
}
}
}
@@ -2005,52 +2003,54 @@ luabind::object Lua_Client::GetExpeditionLockouts(lua_State* L, std::string expe
std::string Lua_Client::GetLockoutExpeditionUUID(std::string expedition_name, std::string event_name) {
Lua_Safe_Call_String();
std::string uuid;
auto lockout = self->GetExpeditionLockout(expedition_name, event_name);
auto lockout = self->GetDzLockout(expedition_name, event_name);
if (lockout)
{
uuid = lockout->GetExpeditionUUID();
uuid = lockout->UUID();
}
return uuid;
}
void Lua_Client::AddExpeditionLockout(std::string expedition_name, std::string event_name, uint32 seconds) {
Lua_Safe_Call_Void();
self->AddNewExpeditionLockout(expedition_name, event_name, seconds);
self->AddDzLockout(expedition_name, event_name, seconds);
}
void Lua_Client::AddExpeditionLockout(std::string expedition_name, std::string event_name, uint32 seconds, std::string uuid) {
Lua_Safe_Call_Void();
self->AddNewExpeditionLockout(expedition_name, event_name, seconds, uuid);
self->AddDzLockout(expedition_name, event_name, seconds, uuid);
}
void Lua_Client::AddExpeditionLockoutDuration(std::string expedition_name, std::string event_name, int seconds) {
Lua_Safe_Call_Void();
self->AddExpeditionLockoutDuration(expedition_name, event_name, seconds, {}, true);
auto lockout = DzLockout::Create(expedition_name, event_name, seconds);
self->AddDzLockoutDuration(lockout, seconds, {}, true);
}
void Lua_Client::AddExpeditionLockoutDuration(std::string expedition_name, std::string event_name, int seconds, std::string uuid) {
Lua_Safe_Call_Void();
self->AddExpeditionLockoutDuration(expedition_name, event_name, seconds, uuid, true);
auto lockout = DzLockout::Create(expedition_name, event_name, seconds, uuid);
self->AddDzLockoutDuration(lockout, seconds, uuid, true);
}
void Lua_Client::RemoveAllExpeditionLockouts() {
Lua_Safe_Call_Void();
self->RemoveAllExpeditionLockouts({}, true);
self->RemoveDzLockouts({}, true);
}
void Lua_Client::RemoveAllExpeditionLockouts(std::string expedition_name) {
Lua_Safe_Call_Void();
self->RemoveAllExpeditionLockouts(expedition_name, true);
self->RemoveDzLockouts(expedition_name, true);
}
void Lua_Client::RemoveExpeditionLockout(std::string expedition_name, std::string event_name) {
Lua_Safe_Call_Void();
self->RemoveExpeditionLockout(expedition_name, event_name, true);
self->RemoveDzLockout(expedition_name, event_name, true);
}
bool Lua_Client::HasExpeditionLockout(std::string expedition_name, std::string event_name) {
Lua_Safe_Call_Bool();
return self->HasExpeditionLockout(expedition_name, event_name);
return self->HasDzLockout(expedition_name, event_name);
}
void Lua_Client::MovePCDynamicZone(uint32 zone_id) {