Send all members expedition expire warnings

All expedition members are notified not just those in dz

This will only work if the dz is running. It might make more sense to
move this to client or world processing so members are notified even if
the zone instance isn't running
This commit is contained in:
hg
2020-10-04 20:17:50 -04:00
parent 79287fc507
commit da5d4b9830
6 changed files with 73 additions and 5 deletions
+45
View File
@@ -1436,6 +1436,15 @@ void Expedition::SendWorldPendingInvite(const ExpeditionInvite& invite, const st
SendWorldAddPlayerInvite(invite.inviter_name, invite.swap_remove_name, add_name, true);
}
std::unique_ptr<EQApplicationPacket> Expedition::CreateExpireWarningPacket(uint32_t minutes_remaining)
{
uint32_t outsize = sizeof(ExpeditionExpireWarning);
auto outapp = std::unique_ptr<EQApplicationPacket>(new EQApplicationPacket(OP_DzExpeditionEndsWarning, outsize));
auto buf = reinterpret_cast<ExpeditionExpireWarning*>(outapp->pBuffer);
buf->minutes_remaining = minutes_remaining;
return outapp;
}
std::unique_ptr<EQApplicationPacket> Expedition::CreateInfoPacket(bool clear)
{
uint32_t outsize = sizeof(ExpeditionInfo_Struct);
@@ -1733,6 +1742,16 @@ void Expedition::SendWorldSetSecondsRemaining(uint32_t seconds_remaining)
worldserver.SendPacket(pack.get());
}
void Expedition::SendWorldExpireWarning(uint32_t minutes_remaining)
{
uint32_t pack_size = sizeof(ServerExpeditionExpireWarning_Struct);
auto pack = std::unique_ptr<ServerPacket>(new ServerPacket(ServerOP_ExpeditionExpireWarning, pack_size));
auto buf = reinterpret_cast<ServerExpeditionExpireWarning_Struct*>(pack->pBuffer);
buf->expedition_id = GetID();
buf->minutes_remaining = minutes_remaining;
worldserver.SendPacket(pack.get());
}
void Expedition::AddLockoutByCharacterID(
uint32_t character_id, const std::string& expedition_name, const std::string& event_name,
uint32_t seconds, const std::string& uuid)
@@ -2075,6 +2094,16 @@ void Expedition::HandleWorldMessage(ServerPacket* pack)
}
break;
}
case ServerOP_ExpeditionExpireWarning:
{
auto buf = reinterpret_cast<ServerExpeditionExpireWarning_Struct*>(pack->pBuffer);
auto expedition = Expedition::FindCachedExpeditionByID(buf->expedition_id);
if (expedition)
{
expedition->SendMembersExpireWarning(buf->minutes_remaining);
}
break;
}
}
}
@@ -2238,3 +2267,19 @@ std::vector<ExpeditionLockoutTimer> Expedition::GetExpeditionLockoutsByCharacter
return lockouts;
}
void Expedition::SendMembersExpireWarning(uint32_t minutes_remaining)
{
// expeditions warn members in all zones not just the dz
auto outapp = CreateExpireWarningPacket(minutes_remaining);
for (const auto& member : m_members)
{
Client* member_client = entity_list.GetClientByCharID(member.char_id);
if (member_client)
{
member_client->QueuePacket(outapp.get());
member_client->MessageString(Chat::Yellow, EXPEDITION_MIN_REMAIN,
fmt::format_int(minutes_remaining).c_str());
}
}
}