Add api to add lockout to all clients in zone

This commit is contained in:
hg 2020-09-21 20:15:08 -04:00
parent c45840173e
commit 3db23e402c
3 changed files with 30 additions and 16 deletions

View File

@ -1318,27 +1318,28 @@ void Expedition::ProcessLockoutDuration(
if (m_dynamiczone.IsCurrentZoneDzInstance()) if (m_dynamiczone.IsCurrentZoneDzInstance())
{ {
AddLockoutDurationNonMembers(lockout, seconds); AddLockoutDurationClients(lockout, seconds, GetID());
} }
} }
void Expedition::AddLockoutDurationNonMembers(const ExpeditionLockoutTimer& lockout, int seconds) void Expedition::AddLockoutDurationClients(
const ExpeditionLockoutTimer& lockout, int seconds, uint32_t exclude_id)
{ {
std::vector<ExpeditionMember> non_members; std::vector<ExpeditionMember> lockout_clients;
for (const auto& client_iter : entity_list.GetClientList()) for (const auto& client_iter : entity_list.GetClientList())
{ {
Client* client = client_iter.second; Client* client = client_iter.second;
if (client && client->GetExpeditionID() != GetID()) if (client && (exclude_id == 0 || client->GetExpeditionID() != exclude_id))
{ {
non_members.emplace_back(client->CharacterID(), client->GetName()); lockout_clients.emplace_back(client->CharacterID(), client->GetName());
client->AddExpeditionLockoutDuration(m_expedition_name, client->AddExpeditionLockoutDuration(m_expedition_name,
lockout.GetEventName(), seconds, m_uuid); lockout.GetEventName(), seconds, m_uuid);
} }
} }
if (!non_members.empty()) if (!lockout_clients.empty())
{ {
ExpeditionDatabase::AddLockoutDuration(non_members, lockout, seconds); ExpeditionDatabase::AddLockoutDuration(lockout_clients, lockout, seconds);
} }
} }
@ -1378,26 +1379,27 @@ void Expedition::ProcessLockoutUpdate(
// members leave the expedition but haven't been kicked from zone yet // members leave the expedition but haven't been kicked from zone yet
if (!remove && m_dynamiczone.IsCurrentZoneDzInstance()) if (!remove && m_dynamiczone.IsCurrentZoneDzInstance())
{ {
AddLockoutNonMembers(lockout); AddLockoutClients(lockout, GetID());
} }
} }
void Expedition::AddLockoutNonMembers(const ExpeditionLockoutTimer& lockout) void Expedition::AddLockoutClients(
const ExpeditionLockoutTimer& lockout, uint32_t exclude_expedition_id)
{ {
std::vector<ExpeditionMember> non_members; std::vector<ExpeditionMember> lockout_clients;
for (const auto& client_iter : entity_list.GetClientList()) for (const auto& client_iter : entity_list.GetClientList())
{ {
Client* client = client_iter.second; Client* client = client_iter.second;
if (client && client->GetExpeditionID() != GetID()) if (client && (exclude_expedition_id == 0 || client->GetExpeditionID() != exclude_expedition_id))
{ {
non_members.emplace_back(client->CharacterID(), client->GetName()); lockout_clients.emplace_back(client->CharacterID(), client->GetName());
client->AddExpeditionLockout(lockout); client->AddExpeditionLockout(lockout);
} }
} }
if (!non_members.empty()) if (!lockout_clients.empty())
{ {
ExpeditionDatabase::InsertMembersLockout(non_members, lockout); ExpeditionDatabase::InsertMembersLockout(lockout_clients, lockout);
} }
} }

View File

@ -100,6 +100,7 @@ public:
const std::string& expedition_name = {}, const std::string& event_name = {}); const std::string& expedition_name = {}, const std::string& event_name = {});
static void RemoveLockoutsByCharacterName(const std::string& character_name, static void RemoveLockoutsByCharacterName(const std::string& character_name,
const std::string& expedition_name = {}, const std::string& event_name = {}); const std::string& expedition_name = {}, const std::string& event_name = {});
static void AddLockoutClients(const ExpeditionLockoutTimer& lockout, uint32_t exclude_id = 0);
uint32_t GetID() const { return m_id; } uint32_t GetID() const { return m_id; }
uint16_t GetInstanceID() const { return m_dynamiczone.GetInstanceID(); } uint16_t GetInstanceID() const { return m_dynamiczone.GetInstanceID(); }
@ -169,8 +170,7 @@ private:
static void SendWorldCharacterLockout(uint32_t character_id, const ExpeditionLockoutTimer& lockout, bool remove); static void SendWorldCharacterLockout(uint32_t character_id, const ExpeditionLockoutTimer& lockout, bool remove);
void AddLockout(const ExpeditionLockoutTimer& lockout, bool members_only = false); void AddLockout(const ExpeditionLockoutTimer& lockout, bool members_only = false);
void AddLockoutDurationNonMembers(const ExpeditionLockoutTimer& lockout, int seconds); void AddLockoutDurationClients(const ExpeditionLockoutTimer& lockout, int seconds, uint32_t exclude_id = 0);
void AddLockoutNonMembers(const ExpeditionLockoutTimer& lockout);
void AddInternalMember(const std::string& char_name, uint32_t char_id, ExpeditionMemberStatus status); void AddInternalMember(const std::string& char_name, uint32_t char_id, ExpeditionMemberStatus status);
bool ChooseNewLeader(); bool ChooseNewLeader();
bool ConfirmLeaderCommand(Client* requester); bool ConfirmLeaderCommand(Client* requester);

View File

@ -2258,6 +2258,16 @@ luabind::object lua_get_expedition_lockouts_by_char_id(lua_State* L, uint32 char
return lua_table; return lua_table;
} }
void lua_add_expedition_lockout_all_clients(std::string expedition_name, std::string event_name, uint32 seconds) {
auto lockout = ExpeditionLockoutTimer::CreateLockout(expedition_name, event_name, seconds);
Expedition::AddLockoutClients(lockout);
}
void lua_add_expedition_lockout_all_clients(std::string expedition_name, std::string event_name, uint32 seconds, std::string uuid) {
auto lockout = ExpeditionLockoutTimer::CreateLockout(expedition_name, event_name, seconds, uuid);
Expedition::AddLockoutClients(lockout);
}
void lua_add_expedition_lockout_by_char_id(uint32 char_id, std::string expedition_name, std::string event_name, uint32 seconds) { void lua_add_expedition_lockout_by_char_id(uint32 char_id, std::string expedition_name, std::string event_name, uint32 seconds) {
Expedition::AddLockoutByCharacterID(char_id, expedition_name, event_name, seconds); Expedition::AddLockoutByCharacterID(char_id, expedition_name, event_name, seconds);
} }
@ -2883,6 +2893,8 @@ luabind::scope lua_register_general() {
luabind::def("get_expedition_lockout_by_char_id", &lua_get_expedition_lockout_by_char_id), luabind::def("get_expedition_lockout_by_char_id", &lua_get_expedition_lockout_by_char_id),
luabind::def("get_expedition_lockouts_by_char_id", (luabind::object(*)(lua_State*, uint32))&lua_get_expedition_lockouts_by_char_id), luabind::def("get_expedition_lockouts_by_char_id", (luabind::object(*)(lua_State*, uint32))&lua_get_expedition_lockouts_by_char_id),
luabind::def("get_expedition_lockouts_by_char_id", (luabind::object(*)(lua_State*, uint32, std::string))&lua_get_expedition_lockouts_by_char_id), luabind::def("get_expedition_lockouts_by_char_id", (luabind::object(*)(lua_State*, uint32, std::string))&lua_get_expedition_lockouts_by_char_id),
luabind::def("add_expedition_lockout_all_clients", (void(*)(std::string, std::string, uint32))&lua_add_expedition_lockout_all_clients),
luabind::def("add_expedition_lockout_all_clients", (void(*)(std::string, std::string, uint32, std::string))&lua_add_expedition_lockout_all_clients),
luabind::def("add_expedition_lockout_by_char_id", (void(*)(uint32, std::string, std::string, uint32))&lua_add_expedition_lockout_by_char_id), luabind::def("add_expedition_lockout_by_char_id", (void(*)(uint32, std::string, std::string, uint32))&lua_add_expedition_lockout_by_char_id),
luabind::def("add_expedition_lockout_by_char_id", (void(*)(uint32, std::string, std::string, uint32, std::string))&lua_add_expedition_lockout_by_char_id), luabind::def("add_expedition_lockout_by_char_id", (void(*)(uint32, std::string, std::string, uint32, std::string))&lua_add_expedition_lockout_by_char_id),
luabind::def("remove_expedition_lockout_by_char_id", &lua_remove_expedition_lockout_by_char_id), luabind::def("remove_expedition_lockout_by_char_id", &lua_remove_expedition_lockout_by_char_id),